Add signature to crash reporter info
This commit is contained in:
parent
a686ffd04d
commit
78593e0391
@ -11,6 +11,8 @@ import android.util.Log;
|
||||
import java.util.TimeZone;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.balsikandar.crashreporter.utils.AppUtilsKt.getAppSignature;
|
||||
|
||||
/**
|
||||
* Created by bali on 12/08/17.
|
||||
*/
|
||||
@ -37,6 +39,7 @@ public class AppUtils {
|
||||
|
||||
return "APP.VERSION : " + getAppVersion(context)
|
||||
+ "\nAPP.VERSIONCODE : " + getAppVersionCode(context)
|
||||
+ "\nAPP.SIGNATURE : " + getAppSignature(context)
|
||||
+ "\nLAUNCHER.APP : " + getCurrentLauncherApp(context)
|
||||
+ "\nTIMEZONE : " + timeZone()
|
||||
+ "\nVERSION.RELEASE : " + Build.VERSION.RELEASE
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
package com.balsikandar.crashreporter.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import android.util.Base64
|
||||
import java.security.MessageDigest
|
||||
|
||||
internal fun getAppSignature(context: Context): String {
|
||||
val signature = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
val pi = context.packageManager.getPackageInfo(
|
||||
context.packageName,
|
||||
PackageManager.GET_SIGNING_CERTIFICATES
|
||||
)
|
||||
pi.signingInfo.apkContentsSigners.firstOrNull()
|
||||
} else {
|
||||
val pi = context.packageManager.getPackageInfo(
|
||||
context.packageName,
|
||||
PackageManager.GET_SIGNATURES
|
||||
)
|
||||
pi.signatures.firstOrNull()
|
||||
}
|
||||
return if (signature != null) {
|
||||
val digest = MessageDigest.getInstance("SHA")
|
||||
digest.update(signature.toByteArray())
|
||||
Base64.encodeToString(digest.digest(), Base64.NO_WRAP)
|
||||
} else "null"
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user