我正在尝试添加额外的检查来检测应用程序是否被克隆。
到目前为止一切顺利,我正在测试包名称是否相同、点数是否相同以及某些应用程序(例如 Dualspace)创建用户 999。
但是有些应用程序(例如“Island”)会将应用程序沙箱化并将其隔离。
我的问题是,有什么方法可以检测应用程序是否在沙盒环境中克隆? 我在互联网上搜索,但找不到有关此主题的太多信息。
最佳答案
对于这种情况我有两种解决方案:
解决方案 1:检查权限
大多数沙盒克隆应用程序都使用工作配置文件,因此它们需要特定的权限,我只需要检查它们是否被授予:
注意:如果您的应用也需要这些权限,这将不起作用
ActivityCompat.checkSelfPermission(Main2Activity.this, Manifest.permission. GET_ACCOUNTS) = PackageManager.PERMISSION_GRANTED
ActivityCompat.checkSelfPermission(Main2Activity.this, Manifest.permission. MANAGE_ACCOUNTS) = PackageManager.PERMISSION_GRANTED
解决方案 2:使用 installreferrer
我发现当我尝试访问 Google Play installreferrer 时,克隆的应用程序会抛出错误代码 FEATURE_NOT_SUPPORTED
我的代码:
import com.android.installreferrer.api.InstallReferrerClient
import com.android.installreferrer.api.InstallReferrerStateListener
...
suspend fun getInstallReferrer(): Result<String?> {
val referrerClient = InstallReferrerClient.newBuilder(context).build()
return withContext(Dispatchers.IO) {
referrerClient.startConnection(object : InstallReferrerStateListener {
override fun onInstallReferrerSetupFinished(responseCode: Int) {
when (responseCode) {
InstallReferrerClient.InstallReferrerResponse.OK -> {
// Connection established and response received
try {
val response = referrerClient.installReferrer
installReferrer.append(response.installReferrer)
} catch (e: RemoteException) {
return@withContext Result.Error(e)
}
return@withContext Result.Success(installReferrer.toString()) // ==> Default App will go here
}
InstallReferrerClient.InstallReferrerResponse.FEATURE_NOT_SUPPORTED -> // ==> Cloned App will go here
return@withContext Result.Error(Exception("FEATURE_NOT_SUPPORTED")
InstallReferrerClient.InstallReferrerResponse.SERVICE_UNAVAILABLE ->
return@withContext Result.Error(Exception("SERVICE_UNAVAILABLE")
else -> return@withContext Result.Error(Exception("ERR_APPLICATION_INSTALL_REFERRER")
}
referrerClient.endConnection()
}
override fun onInstallReferrerServiceDisconnected() {
return@withContext Result.Error(Exception("ERR_APPLICATION_INSTALL_REFERRER_SERVICE_DISCONNECTED")
}
})
}
}
关于android - 有没有办法检测我的应用程序是否在沙盒模式下克隆?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74888415/