Loading app/src/main/aidl/foundation/e/apps/IAppLoungeIntegrityService.aidl +3 −1 Original line number Diff line number Diff line package foundation.e.apps; import foundation.e.apps.IAppLoungeIntegrityServiceCallback; interface IAppLoungeIntegrityService { void checkIntegrity(String packageName, String nonce); void checkIntegrity(String packageName, String nonce, IAppLoungeIntegrityServiceCallback callback); } No newline at end of file app/src/main/aidl/foundation/e/apps/IAppLoungeIntegrityServiceCallback.aidl 0 → 100644 +6 −0 Original line number Diff line number Diff line package foundation.e.apps; interface IAppLoungeIntegrityServiceCallback { void onSuccess(String token); void onError(int errorCode); } No newline at end of file app/src/main/java/foundation/e/apps/api/gplay/GPlayAPIImpl.kt +7 −9 Original line number Diff line number Diff line Loading @@ -195,11 +195,11 @@ class GPlayAPIImpl @Inject constructor(private val gPlayHttpClient: GPlayHttpCli packageName: String, nonce: String, droidGuardToken: String ) { ): String? { val integrityApiKey = "AIzaSyAjf_GZN-B3oyEKTqug3eEcch_4qK3M2Hg" withContext(Dispatchers.IO) { return withContext(Dispatchers.IO) { Log.i("jklee", "checking integrity with token $droidGuardToken") val integrityHelper = IntegrityHelper(authData, integrityApiKey).using(gPlayHttpClient) Loading @@ -207,13 +207,11 @@ class GPlayAPIImpl @Inject constructor(private val gPlayHttpClient: GPlayHttpCli Log.i("jklee", "checkIntegrity reponse ${response.code}") Log.i("jklee", "checkIntegrity successful ${response.isSuccessful}") val token = IntegrityAnswer.parseFrom(response.responseBytes).tokenWrapper.token.value Log.i("jklee", "token $token"); response = integrityHelper.checkToken(token) Log.i("jklee", "checkToken response ${response.code}") Log.i("jklee", "checkToken successful ${response.isSuccessful}") Log.i("jklee", "checkToken response ${String(response.responseBytes)}") if (!response.isSuccessful) { null } else { IntegrityAnswer.parseFrom(response.responseBytes).tokenWrapper.token.value } } } Loading app/src/main/java/foundation/e/apps/api/gplay/GPlayAPIRepository.kt +1 −3 Original line number Diff line number Diff line Loading @@ -116,7 +116,5 @@ class GPlayAPIRepository @Inject constructor(private val gPlayAPIImpl: GPlayAPII packageName: String, nonce: String, droidGuardToken: String ) { gPlayAPIImpl.checkIntegrityService(authData, packageName, nonce, droidGuardToken) } ) = gPlayAPIImpl.checkIntegrityService(authData, packageName, nonce, droidGuardToken) } app/src/main/java/foundation/e/apps/integrity/IntegrityBinder.kt +9 −4 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ import com.google.android.gms.droidguard.DroidGuard import com.google.android.gms.droidguard.DroidGuardClient import com.google.android.gms.droidguard.internal.DroidGuardResultsRequest import foundation.e.apps.IAppLoungeIntegrityService import foundation.e.apps.IAppLoungeIntegrityServiceCallback import foundation.e.apps.api.gplay.GPlayAPIRepository import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch Loading @@ -37,13 +38,14 @@ class IntegrityBinder( companion object { const val TAG = "IntegrityBinder" const val INTEGRITY_ERROR_NETWORK_ERROR = -3 } override fun checkIntegrity(packageName: String, nonce: String) { requestDroidGuardToken(packageName, nonce) override fun checkIntegrity(packageName: String, nonce: String, callback: IAppLoungeIntegrityServiceCallback) { requestDroidGuardToken(packageName, nonce, callback) } private fun requestDroidGuardToken(packageName: String, nonce: String) { private fun requestDroidGuardToken(packageName: String, nonce: String, callback: IAppLoungeIntegrityServiceCallback) { val integrityPackage = IntegrityPackage.newBuilder().setPackageName(packageName) val versionCode = PackageVersionCode.newBuilder().setVersion(10) val timestamp = System.currentTimeMillis().asProtoTimestamp() Loading Loading @@ -72,7 +74,10 @@ class IntegrityBinder( request.bundle.putString("thirdPartyCallerAppPackageName", packageName) client.getResults("pia_attest", map, request).addOnSuccessListener { lifecycleCoroutineScope.launch { gPlayAPIRepository.checkIntegrity(authData, packageName, nonce, it) gPlayAPIRepository.checkIntegrity(authData, packageName, nonce, it).let { if (it == null) callback.onError(INTEGRITY_ERROR_NETWORK_ERROR) else callback.onSuccess(it) } } } } Loading Loading
app/src/main/aidl/foundation/e/apps/IAppLoungeIntegrityService.aidl +3 −1 Original line number Diff line number Diff line package foundation.e.apps; import foundation.e.apps.IAppLoungeIntegrityServiceCallback; interface IAppLoungeIntegrityService { void checkIntegrity(String packageName, String nonce); void checkIntegrity(String packageName, String nonce, IAppLoungeIntegrityServiceCallback callback); } No newline at end of file
app/src/main/aidl/foundation/e/apps/IAppLoungeIntegrityServiceCallback.aidl 0 → 100644 +6 −0 Original line number Diff line number Diff line package foundation.e.apps; interface IAppLoungeIntegrityServiceCallback { void onSuccess(String token); void onError(int errorCode); } No newline at end of file
app/src/main/java/foundation/e/apps/api/gplay/GPlayAPIImpl.kt +7 −9 Original line number Diff line number Diff line Loading @@ -195,11 +195,11 @@ class GPlayAPIImpl @Inject constructor(private val gPlayHttpClient: GPlayHttpCli packageName: String, nonce: String, droidGuardToken: String ) { ): String? { val integrityApiKey = "AIzaSyAjf_GZN-B3oyEKTqug3eEcch_4qK3M2Hg" withContext(Dispatchers.IO) { return withContext(Dispatchers.IO) { Log.i("jklee", "checking integrity with token $droidGuardToken") val integrityHelper = IntegrityHelper(authData, integrityApiKey).using(gPlayHttpClient) Loading @@ -207,13 +207,11 @@ class GPlayAPIImpl @Inject constructor(private val gPlayHttpClient: GPlayHttpCli Log.i("jklee", "checkIntegrity reponse ${response.code}") Log.i("jklee", "checkIntegrity successful ${response.isSuccessful}") val token = IntegrityAnswer.parseFrom(response.responseBytes).tokenWrapper.token.value Log.i("jklee", "token $token"); response = integrityHelper.checkToken(token) Log.i("jklee", "checkToken response ${response.code}") Log.i("jklee", "checkToken successful ${response.isSuccessful}") Log.i("jklee", "checkToken response ${String(response.responseBytes)}") if (!response.isSuccessful) { null } else { IntegrityAnswer.parseFrom(response.responseBytes).tokenWrapper.token.value } } } Loading
app/src/main/java/foundation/e/apps/api/gplay/GPlayAPIRepository.kt +1 −3 Original line number Diff line number Diff line Loading @@ -116,7 +116,5 @@ class GPlayAPIRepository @Inject constructor(private val gPlayAPIImpl: GPlayAPII packageName: String, nonce: String, droidGuardToken: String ) { gPlayAPIImpl.checkIntegrityService(authData, packageName, nonce, droidGuardToken) } ) = gPlayAPIImpl.checkIntegrityService(authData, packageName, nonce, droidGuardToken) }
app/src/main/java/foundation/e/apps/integrity/IntegrityBinder.kt +9 −4 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ import com.google.android.gms.droidguard.DroidGuard import com.google.android.gms.droidguard.DroidGuardClient import com.google.android.gms.droidguard.internal.DroidGuardResultsRequest import foundation.e.apps.IAppLoungeIntegrityService import foundation.e.apps.IAppLoungeIntegrityServiceCallback import foundation.e.apps.api.gplay.GPlayAPIRepository import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch Loading @@ -37,13 +38,14 @@ class IntegrityBinder( companion object { const val TAG = "IntegrityBinder" const val INTEGRITY_ERROR_NETWORK_ERROR = -3 } override fun checkIntegrity(packageName: String, nonce: String) { requestDroidGuardToken(packageName, nonce) override fun checkIntegrity(packageName: String, nonce: String, callback: IAppLoungeIntegrityServiceCallback) { requestDroidGuardToken(packageName, nonce, callback) } private fun requestDroidGuardToken(packageName: String, nonce: String) { private fun requestDroidGuardToken(packageName: String, nonce: String, callback: IAppLoungeIntegrityServiceCallback) { val integrityPackage = IntegrityPackage.newBuilder().setPackageName(packageName) val versionCode = PackageVersionCode.newBuilder().setVersion(10) val timestamp = System.currentTimeMillis().asProtoTimestamp() Loading Loading @@ -72,7 +74,10 @@ class IntegrityBinder( request.bundle.putString("thirdPartyCallerAppPackageName", packageName) client.getResults("pia_attest", map, request).addOnSuccessListener { lifecycleCoroutineScope.launch { gPlayAPIRepository.checkIntegrity(authData, packageName, nonce, it) gPlayAPIRepository.checkIntegrity(authData, packageName, nonce, it).let { if (it == null) callback.onError(INTEGRITY_ERROR_NETWORK_ERROR) else callback.onSuccess(it) } } } } Loading