mirror of
https://github.com/geode-sdk/android-launcher.git
synced 2026-10-22 16:42:38 +00:00
add method to validate gd's certificate
unused for now
This commit is contained in:
1 file changed
+23
@@ -8,6 +8,7 @@ import android.content.pm.PackageManager
|
|||||||
import android.content.res.AssetManager
|
import android.content.res.AssetManager
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import okio.ByteString.Companion.toByteString
|
||||||
|
|
||||||
object GamePackageUtils {
|
object GamePackageUtils {
|
||||||
fun isGameInstalled(packageManager: PackageManager): Boolean {
|
fun isGameInstalled(packageManager: PackageManager): Boolean {
|
||||||
@@ -95,4 +96,26 @@ object GamePackageUtils {
|
|||||||
aspMethod.invoke(assetManager, it)
|
aspMethod.invoke(assetManager, it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private const val GAME_CERTIFICATE_HASH = "f5e7d8284d72c461a5f022d0cf755df101c3bb1e69cbe241bc1aef2cc5610a43"
|
||||||
|
|
||||||
|
private fun validateCertificate(certificate: ByteArray): Boolean =
|
||||||
|
certificate.toByteString().sha256().hex() == GAME_CERTIFICATE_HASH
|
||||||
|
|
||||||
|
fun identifyGameLegitimacy(packageManager: PackageManager): Boolean {
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
val certificates = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
|
val game = packageManager.getPackageInfo(Constants.PACKAGE_NAME, PackageManager.GET_SIGNING_CERTIFICATES)
|
||||||
|
val signingInfo = game.signingInfo
|
||||||
|
|
||||||
|
signingInfo.signingCertificateHistory
|
||||||
|
} else {
|
||||||
|
val game = packageManager.getPackageInfo(Constants.PACKAGE_NAME, PackageManager.GET_SIGNATURES)
|
||||||
|
game.signatures
|
||||||
|
}
|
||||||
|
|
||||||
|
return certificates.any {
|
||||||
|
validateCertificate(it.toByteArray())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user