Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network Error (-3) When Switching Networks: Play Integrity API Issue #1628

Open
play-akira-kawakami opened this issue Jan 23, 2025 · 1 comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@play-akira-kawakami
Copy link

Environment Details

Feature: Play Integrity API
OS Type and Version: Android
Java Version: 1.8
Library Version(s):

Steps to Reproduce

On the Google Play Console, configure the "Unable to check device integrity" test response.
Connect to WiFi1 and launch the app. Integrity check is performed.
Switch to WiFi2 and launch the app. Integrity check is not performed.
Switch back to WiFi1 and launch the app. Integrity check is performed again.

Additional Notes:

If the app is force-stopped (via the Android TV home settings) after switching to WiFi2, the integrity check is performed upon the next app launch.

Code Example

val integrityManager = IntegrityManagerFactory.create(activity)

val request = IntegrityTokenRequest.builder()
    .setNonce(nonce)
    .build()

integrityManager.requestIntegrityToken(request)
    .addOnSuccessListener { integrityTokenResponse: IntegrityTokenResponse ->
        val token = integrityTokenResponse.token()
        emitter.onSuccess(token)
    }
    .addOnFailureListener { exception ->
        emitter.onError(exception)
    }

Stack Trace

throwable = com.google.android.play.core.integrity.IntegrityServiceException: -3: Integrity API error (-3): Network error: unable to obtain integrity details.
Ask the user to check for a connection.
(https://developer.android.com/google/play/integrity/reference/com/google/android/play/core/integrity/model/IntegrityErrorCode.html#NETWORK_ERROR)

Investigation

I checked whether the integrityManager instance remains the same when the integrity check is performed vs. when it is not.

  • When integrity check is performed:
    integrityManager: com.google.android.play.core.integrity.aa@8fe6d4

  • When integrity check is not performed:
    integrityManager: com.google.android.play.core.integrity.aa@8fe6d4

  • After reinstalling the app:
    integrityManager: com.google.android.play.core.integrity.aa@8f5a6e6

Since the integrityManager instance appears to be a singleton, it is recreated only after reinstalling the app. However, the API does not seem to provide a method to reset the integrityManager.

Workarounds Attempted

Currently, the only workaround I found is to restart the app process using the following method:

android.os.Process.killProcess(android.os.Process.myPid())
Other methods, such as the following, did not resolve the issue:

activity.finish()
activity.finishAffinity()
activity.finishAndRemoveTask()

Request

Is there a recommended approach to handle this issue during network changes? Specifically, is there a way to reset the integrityManager without restarting the app process?

@lqiu96 lqiu96 added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Jan 24, 2025
@lqiu96
Copy link
Contributor

lqiu96 commented Jan 24, 2025

Hi, @play-akira-kawakami.

I'm not entirely sure this is an Auth related issue. I'm not entirely familiar with IntegrityManagerFactory (Is this an Android SDK class?).

If you have a support contract with Google, please create an issue in the support console. I think they would be able to help direct you for better support with Android related issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

2 participants