diff options
| author | 2022-04-12 02:07:31 +0000 | |
|---|---|---|
| committer | 2022-04-12 02:11:13 +0000 | |
| commit | 745698b4dad2bbf679bdaae35bba8bdd5a4f8ca5 (patch) | |
| tree | ff0271a2fc68602d9e08704a997c54641e5cf0b7 | |
| parent | 1c5f21f070bc1b468f178ba6f1bc2d71d730ef9d (diff) | |
Inform the app to wait only if procstate has affect on ntwk access.
Bug: 226299593
Test: atest tests/cts/hostside/src/com/android/cts/net/HostsideRestrictBackgroundNetworkTests.java
Change-Id: Iad41fa423844dee975c5063c03784e44a68bbfcd
| -rw-r--r-- | services/core/java/com/android/server/am/ActivityManagerService.java | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index efde2a52f4dc..e29f11a42c18 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -49,6 +49,12 @@ import static android.content.pm.PackageManager.MATCH_DIRECT_BOOT_UNAWARE; import static android.content.pm.PackageManager.MATCH_SYSTEM_ONLY; import static android.content.pm.PackageManager.MATCH_UNINSTALLED_PACKAGES; import static android.content.pm.PackageManager.PERMISSION_GRANTED; +import static android.net.ConnectivityManager.BLOCKED_METERED_REASON_DATA_SAVER; +import static android.net.ConnectivityManager.BLOCKED_METERED_REASON_USER_RESTRICTED; +import static android.net.ConnectivityManager.BLOCKED_REASON_APP_STANDBY; +import static android.net.ConnectivityManager.BLOCKED_REASON_BATTERY_SAVER; +import static android.net.ConnectivityManager.BLOCKED_REASON_DOZE; +import static android.net.ConnectivityManager.BLOCKED_REASON_LOW_POWER_STANDBY; import static android.net.ConnectivityManager.BLOCKED_REASON_NONE; import static android.os.FactoryTest.FACTORY_TEST_OFF; import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_CRITICAL; @@ -17306,8 +17312,22 @@ public class ActivityManagerService extends IActivityManager.Stub // TODO: We can reuse this data in // ProcessList#incrementProcStateSeqAndNotifyAppsLOSP instead of calling into // NetworkManagementService. - return mUidNetworkBlockedReasons.get(uid, BLOCKED_REASON_NONE) - != BLOCKED_REASON_NONE; + final int uidBlockedReasons = mUidNetworkBlockedReasons.get( + uid, BLOCKED_REASON_NONE); + if (uidBlockedReasons == BLOCKED_REASON_NONE) { + return false; + } + final int topExemptedBlockedReasons = BLOCKED_REASON_BATTERY_SAVER + | BLOCKED_REASON_DOZE + | BLOCKED_REASON_APP_STANDBY + | BLOCKED_REASON_LOW_POWER_STANDBY + | BLOCKED_METERED_REASON_DATA_SAVER + | BLOCKED_METERED_REASON_USER_RESTRICTED; + final int effectiveBlockedReasons = + uidBlockedReasons & ~topExemptedBlockedReasons; + // Only consider it as blocked if it is not blocked by a reason + // that is not exempted by app being in the top state. + return effectiveBlockedReasons == BLOCKED_REASON_NONE; } } |