集成openinstall拉起app

This commit is contained in:
level 2025-04-24 11:31:44 +08:00
parent f9a87d3553
commit c2e2ad9fd5
5 changed files with 67 additions and 12 deletions

View File

@ -14,6 +14,7 @@ plugins {
dependencies {
implementation(fileTree(mapOf("dir" to "src/main/libs", "include" to listOf("*.aar"))))
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
implementation(files("src\\main\\libs\\OpenInstall_v2.8.5.jar"))
// implementation("com.google.firebase:firebase-crashlytics-buildtools:3.0.2")
// implementation(files("src/main/libs/openinstall.jar"))
@ -121,6 +122,8 @@ dependencies {
api ("com.huawei.hms:ads-identifier:3.4.62.300")
// 荣耀的最新版本广告标识服务SDK参阅 https://developer.hihonor.com/cn/kitdoc?kitId=11030&navigation=guides&docId=intergrate.md
api ("com.hihonor.mcs:ads-identifier:1.0.2.301")
implementation("com.android.installreferrer:installreferrer:2.2")// 使用最新版本
}
tasks.getByName("clean", type = Delete::class) {

View File

@ -56,6 +56,14 @@
android:name="releaseCode"
android:value="@integer/release_code" />
<meta-data
android:name="com.openinstall.APP_KEY"
android:value="ltbqy7"/>
<!-- 使用广告推广-->
<meta-data
android:name="com.openinstall.AD_TRACK"
android:value="true"/>
<activity
android:name=".act.SplashActivity"
android:exported="true"
@ -71,6 +79,14 @@
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE_PREFERENCES" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="ltbqy7"/>
</intent-filter>
</activity>
<activity
android:name=".act.AgreementAndPrivacyActivity"
@ -188,9 +204,9 @@
<meta-data
android:name="android.webkit.WebView.EnableSafeBrowsing"
android:value="false" />
<meta-data
android:name="com.openinstall.APP_KEY"
android:value="vsiquu" />
<!-- <meta-data-->
<!-- android:name="com.openinstall.APP_KEY"-->
<!-- android:value="vsiquu" />-->
<!-- <meta-data-->
<!-- android:name="com.openinstall.AD_TRACK"-->
<!-- android:value="true"/>-->

View File

@ -23,11 +23,18 @@ import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.core.content.FileProvider
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.customview.customView
import com.bumptech.glide.Glide
import com.bumptech.glide.request.target.SimpleTarget
import com.bumptech.glide.request.transition.Transition
import com.cncat.vpn.service.ClashManager
import com.cncat.vpn.service.remote.IClashManager
import com.cncat.vpn.service.remote.wrap
import com.fm.openinstall.OpenInstall
import com.fm.openinstall.listener.AppWakeUpAdapter
import com.fm.openinstall.model.AppData
import com.google.gson.JsonObject
import com.orhanobut.logger.Logger
import com.tencent.mmkv.MMKV
@ -42,31 +49,27 @@ import com.yingmao.clash.conf.BZYConstants.Companion.MMKV_KEY_NOTE_DEFAULT_PSW
import com.yingmao.clash.conf.BZYConstants.Companion.MMKV_KEY_REMEMBER_PASSWORD
import com.yingmao.clash.conf.BZYConstants.Companion.MMKV_KEY_REMEMBER_USERNAME
import com.yingmao.clash.entity.CheckLoginRsp
import com.yingmao.clash.listener.AsyncCallback
import com.yingmao.clash.listener.DownLoadListener
import com.yingmao.clash.net.http.HttpReqType
import com.yingmao.clash.net.http.HttpStatus
import com.yingmao.clash.net.http.entity.AppVersionCheckRsp
import com.yingmao.clash.net.http.entity.LoginRsp
import com.yingmao.clash.net.http.entity.RegisterRsp
import com.cncat.vpn.service.ClashManager
import com.cncat.vpn.service.remote.IClashManager
import com.cncat.vpn.service.remote.wrap
import com.yingmao.clash.listener.DownLoadListener
import com.yingmao.clash.net.http.entity.AppVersionCheckRsp
import com.yingmao.clash.net.http.entity.StartingBeans
import com.yingmao.clash.util.AESUtil
import com.yingmao.clash.util.Utils
import com.yingmao.clash.view.RxToast
import com.yingmao.clash.view.dialog.DialogAppVersion
import com.yingmao.clash.view.dialog.DialogBandChoose
import com.yingmao.clash.view.dialog.DialogDoMainChoose
import com.yingmao.clash.view.dialog.RxDialogSureCancel
import com.yingmao.clash.vm.SplashAtyVM
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.async
import kotlinx.coroutines.launch
import java.io.File
import java.util.Locale
import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.async
class SplashActivity : BaseActivity() {
private val deniedPermissions = hashSetOf<String>()
@ -249,8 +252,38 @@ class SplashActivity : BaseActivity() {
// val Sgtr= AESUtil.Registerdecrypt("CCBF308D702235C8F810876987A43AB02B84EBB47DBFF1B915D5FBB29FF2DBAE90DB72D58351D09D223D49E44A2A073D9156E84D6B7EB89D7493A3F0A7240EE076ADC83B5A12AC37616CEDED00643AD1E6851AFECA82E373CB4E518DF2190708F5191AE195758E8EA41A5242A6C94216B64FF8715B35C54CB894113FC93361F32FDA86CF34093DF924230DEBE27A69293C761A9A797A652A1C35C95C27FB5EB4"
// ,registerKey,registerIV2)
// println("Sgtr==>$Sgtr")
OpenInstall.getWakeUp(intent, wakeUpAdapter)
OpenInstall.getInstall { appData, error ->
var appData = appData
if (error != null && error.shouldRetry()) {
// 获取数据异常,可以尝试重新获取
} else {
if (appData == null) appData = AppData()
val channelCode = appData.getChannel() // 获取渠道编号参数
val bindData = appData.getData() // 获取自定义参数
Log.d("OpenInstall", "getInstall : channelCode = $channelCode"+"bindData::"+bindData)
}
}
}
private var wakeUpAdapter: AppWakeUpAdapter = object : AppWakeUpAdapter() {
override fun onWakeUp(appData: AppData) {
// 打印数据便于调试
Log.d("OpenInstall", "getWakeUp : wakeupData = $appData")
// 获取渠道编号参数
val channelCode = appData.getChannel()
// 获取自定义参数
val bindData = appData.getData()
Log.d("OpenInstall", "channelCode : bindData = $channelCode"+"bindData::"+bindData)
}
}
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
// 此处要调用否则App在后台运行时会无法获取
OpenInstall.getWakeUp(intent, wakeUpAdapter)
}
private fun setLocalLanguage() {
var defLan = ""
if (BuildConfig.is_tz) {

View File

@ -13,6 +13,7 @@ import androidx.core.content.getSystemService
import com.cncat.vpn.common.Global
import com.cncat.vpn.common.compat.currentProcessName
import com.cncat.vpn.common.log.Log
import com.fm.openinstall.OpenInstall
import com.github.gzuliyujiang.oaid.DeviceID
import com.github.gzuliyujiang.oaid.DeviceIdentifier
import com.github.gzuliyujiang.oaid.IGetter
@ -110,6 +111,8 @@ class MainApplication : Application() {
applicationContext,
"pk_live_51Nkl6vLWP3xWXY4LfXtdMtXzHazv6pav2rH1p1BfICeh5meGGjglExiw4GgmSzWO7NptEM1c549Fe11zRy9nCfxs009zEwLpXP"
)
OpenInstall.preInit(applicationContext)
OpenInstall.init(applicationContext)
}
fun updateActivity(language: String, locale: Locale) {

Binary file not shown.