Loading core/java/android/app/ActivityManagerInternal.java +6 −0 Original line number Diff line number Diff line Loading @@ -238,6 +238,12 @@ public abstract class ActivityManagerInternal { */ public abstract void notifyNetworkPolicyRulesUpdated(int uid, long procStateSeq); /** * Inform ActivityManagerService about the latest {@code blockedReasons} for an uid, which * can be used to understand whether the {@code uid} is allowed to access network or not. */ public abstract void onUidBlockedReasonsChanged(int uid, int blockedReasons); /** * @return true if runtime was restarted, false if it's normal boot */ Loading services/core/java/com/android/server/am/ActivityManagerService.java +15 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ 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_REASON_NONE; import static android.os.FactoryTest.FACTORY_TEST_OFF; import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_CRITICAL; import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_HIGH; Loading Loading @@ -1477,6 +1478,9 @@ public class ActivityManagerService extends IActivityManager.Stub final UidObserverController mUidObserverController; private volatile IUidObserver mNetworkPolicyUidObserver; @GuardedBy("mUidNetworkBlockedReasons") private final SparseIntArray mUidNetworkBlockedReasons = new SparseIntArray(); final AppRestrictionController mAppRestrictionController; private final class AppDeathRecipient implements IBinder.DeathRecipient { Loading Loading @@ -16535,6 +16539,17 @@ public class ActivityManagerService extends IActivityManager.Stub } } @Override public void onUidBlockedReasonsChanged(int uid, int blockedReasons) { synchronized (mUidNetworkBlockedReasons) { if (blockedReasons == BLOCKED_REASON_NONE) { mUidNetworkBlockedReasons.delete(uid); } else { mUidNetworkBlockedReasons.put(uid, blockedReasons); } } } @Override public boolean isRuntimeRestarted() { return mSystemServiceManager.isRuntimeRestarted(); services/core/java/com/android/server/net/NetworkPolicyManagerService.java +14 −4 Original line number Diff line number Diff line Loading @@ -926,6 +926,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { mUsageStats = LocalServices.getService(UsageStatsManagerInternal.class); mAppStandby = LocalServices.getService(AppStandbyInternal.class); mActivityManagerInternal = LocalServices.getService(ActivityManagerInternal.class); synchronized (mUidRulesFirstLock) { synchronized (mNetworkPoliciesSecondLock) { Loading Loading @@ -1003,7 +1004,6 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { } } mActivityManagerInternal = LocalServices.getService(ActivityManagerInternal.class); try { final int changes = ActivityManager.UID_OBSERVER_PROCSTATE | ActivityManager.UID_OBSERVER_GONE Loading Loading @@ -4225,7 +4225,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { : uidBlockedState.deriveUidRules(); } if (oldEffectiveBlockedReasons != newEffectiveBlockedReasons) { postBlockedReasonsChangedMsg(uid, handleBlockedReasonsChanged(uid, newEffectiveBlockedReasons, oldEffectiveBlockedReasons); postUidRulesChangedMsg(uid, uidRules); Loading Loading @@ -4587,6 +4587,9 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { someArgs.argi2 = uidBlockedState.effectiveBlockedReasons; someArgs.argi3 = uidBlockedState.deriveUidRules(); uidStateUpdates.append(uid, someArgs); // TODO: Update the state for all changed uids together. mActivityManagerInternal.onUidBlockedReasonsChanged(uid, uidBlockedState.effectiveBlockedReasons); } } } Loading Loading @@ -4810,6 +4813,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { mUidBlockedState.delete(uid); } mUidState.delete(uid); mActivityManagerInternal.onUidBlockedReasonsChanged(uid, BLOCKED_REASON_NONE); mUidPolicy.delete(uid); mUidFirewallStandbyRules.delete(uid); mUidFirewallDozableRules.delete(uid); Loading Loading @@ -4972,7 +4976,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { } } if (oldEffectiveBlockedReasons != newEffectiveBlockedReasons) { postBlockedReasonsChangedMsg(uid, handleBlockedReasonsChanged(uid, newEffectiveBlockedReasons, oldEffectiveBlockedReasons); postUidRulesChangedMsg(uid, uidRules); Loading Loading @@ -5115,7 +5119,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { : uidBlockedState.deriveUidRules(); } if (oldEffectiveBlockedReasons != newEffectiveBlockedReasons) { postBlockedReasonsChangedMsg(uid, handleBlockedReasonsChanged(uid, newEffectiveBlockedReasons, oldEffectiveBlockedReasons); Loading Loading @@ -5148,6 +5152,12 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { } } private void handleBlockedReasonsChanged(int uid, int newEffectiveBlockedReasons, int oldEffectiveBlockedReasons) { mActivityManagerInternal.onUidBlockedReasonsChanged(uid, newEffectiveBlockedReasons); postBlockedReasonsChangedMsg(uid, newEffectiveBlockedReasons, oldEffectiveBlockedReasons); } private void postBlockedReasonsChangedMsg(int uid, int newEffectiveBlockedReasons, int oldEffectiveBlockedReasons) { mHandler.obtainMessage(MSG_UID_BLOCKED_REASON_CHANGED, uid, Loading Loading
core/java/android/app/ActivityManagerInternal.java +6 −0 Original line number Diff line number Diff line Loading @@ -238,6 +238,12 @@ public abstract class ActivityManagerInternal { */ public abstract void notifyNetworkPolicyRulesUpdated(int uid, long procStateSeq); /** * Inform ActivityManagerService about the latest {@code blockedReasons} for an uid, which * can be used to understand whether the {@code uid} is allowed to access network or not. */ public abstract void onUidBlockedReasonsChanged(int uid, int blockedReasons); /** * @return true if runtime was restarted, false if it's normal boot */ Loading
services/core/java/com/android/server/am/ActivityManagerService.java +15 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ 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_REASON_NONE; import static android.os.FactoryTest.FACTORY_TEST_OFF; import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_CRITICAL; import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_HIGH; Loading Loading @@ -1477,6 +1478,9 @@ public class ActivityManagerService extends IActivityManager.Stub final UidObserverController mUidObserverController; private volatile IUidObserver mNetworkPolicyUidObserver; @GuardedBy("mUidNetworkBlockedReasons") private final SparseIntArray mUidNetworkBlockedReasons = new SparseIntArray(); final AppRestrictionController mAppRestrictionController; private final class AppDeathRecipient implements IBinder.DeathRecipient { Loading Loading @@ -16535,6 +16539,17 @@ public class ActivityManagerService extends IActivityManager.Stub } } @Override public void onUidBlockedReasonsChanged(int uid, int blockedReasons) { synchronized (mUidNetworkBlockedReasons) { if (blockedReasons == BLOCKED_REASON_NONE) { mUidNetworkBlockedReasons.delete(uid); } else { mUidNetworkBlockedReasons.put(uid, blockedReasons); } } } @Override public boolean isRuntimeRestarted() { return mSystemServiceManager.isRuntimeRestarted();
services/core/java/com/android/server/net/NetworkPolicyManagerService.java +14 −4 Original line number Diff line number Diff line Loading @@ -926,6 +926,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { mUsageStats = LocalServices.getService(UsageStatsManagerInternal.class); mAppStandby = LocalServices.getService(AppStandbyInternal.class); mActivityManagerInternal = LocalServices.getService(ActivityManagerInternal.class); synchronized (mUidRulesFirstLock) { synchronized (mNetworkPoliciesSecondLock) { Loading Loading @@ -1003,7 +1004,6 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { } } mActivityManagerInternal = LocalServices.getService(ActivityManagerInternal.class); try { final int changes = ActivityManager.UID_OBSERVER_PROCSTATE | ActivityManager.UID_OBSERVER_GONE Loading Loading @@ -4225,7 +4225,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { : uidBlockedState.deriveUidRules(); } if (oldEffectiveBlockedReasons != newEffectiveBlockedReasons) { postBlockedReasonsChangedMsg(uid, handleBlockedReasonsChanged(uid, newEffectiveBlockedReasons, oldEffectiveBlockedReasons); postUidRulesChangedMsg(uid, uidRules); Loading Loading @@ -4587,6 +4587,9 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { someArgs.argi2 = uidBlockedState.effectiveBlockedReasons; someArgs.argi3 = uidBlockedState.deriveUidRules(); uidStateUpdates.append(uid, someArgs); // TODO: Update the state for all changed uids together. mActivityManagerInternal.onUidBlockedReasonsChanged(uid, uidBlockedState.effectiveBlockedReasons); } } } Loading Loading @@ -4810,6 +4813,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { mUidBlockedState.delete(uid); } mUidState.delete(uid); mActivityManagerInternal.onUidBlockedReasonsChanged(uid, BLOCKED_REASON_NONE); mUidPolicy.delete(uid); mUidFirewallStandbyRules.delete(uid); mUidFirewallDozableRules.delete(uid); Loading Loading @@ -4972,7 +4976,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { } } if (oldEffectiveBlockedReasons != newEffectiveBlockedReasons) { postBlockedReasonsChangedMsg(uid, handleBlockedReasonsChanged(uid, newEffectiveBlockedReasons, oldEffectiveBlockedReasons); postUidRulesChangedMsg(uid, uidRules); Loading Loading @@ -5115,7 +5119,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { : uidBlockedState.deriveUidRules(); } if (oldEffectiveBlockedReasons != newEffectiveBlockedReasons) { postBlockedReasonsChangedMsg(uid, handleBlockedReasonsChanged(uid, newEffectiveBlockedReasons, oldEffectiveBlockedReasons); Loading Loading @@ -5148,6 +5152,12 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { } } private void handleBlockedReasonsChanged(int uid, int newEffectiveBlockedReasons, int oldEffectiveBlockedReasons) { mActivityManagerInternal.onUidBlockedReasonsChanged(uid, newEffectiveBlockedReasons); postBlockedReasonsChangedMsg(uid, newEffectiveBlockedReasons, oldEffectiveBlockedReasons); } private void postBlockedReasonsChangedMsg(int uid, int newEffectiveBlockedReasons, int oldEffectiveBlockedReasons) { mHandler.obtainMessage(MSG_UID_BLOCKED_REASON_CHANGED, uid, Loading