Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 95f6280b authored by Felipe Leme's avatar Felipe Leme Committed by Android (Google) Code Review
Browse files

Merge "Propagate changes when uids are added or removed to the restricted background whitelist."

parents 1ad24fe2 3f52cd5f
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -1689,6 +1689,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
            }
            writePolicy = true;
        }
        updateRulesForGlobalChangeLocked(true);

        // Remove associated UID policies
        int[] uids = new int[0];
@@ -1862,8 +1863,8 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
        Slog.i(TAG, "adding uid " + uid + " to restrict background whitelist");
        synchronized (mRulesLock) {
            mRestrictBackgroundWhitelistUids.append(uid, true);
            updateRulesForGlobalChangeLocked(true);
            writePolicyLocked();
            // TODO: call other update methods like updateNetworkRulesLocked?
        }
        mHandler.obtainMessage(MSG_RESTRICT_BACKGROUND_WHITELIST_CHANGED, uid, 0).sendToTarget();
    }
@@ -1878,9 +1879,10 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
        mHandler.obtainMessage(MSG_RESTRICT_BACKGROUND_WHITELIST_CHANGED, uid, 0).sendToTarget();
    }

    private void removeRestrictBackgroundWhitelistedUidLocked(int uid, boolean writePolicy) {
    private void removeRestrictBackgroundWhitelistedUidLocked(int uid, boolean updateNow) {
        mRestrictBackgroundWhitelistUids.delete(uid);
        if (writePolicy) {
        if (updateNow) {
            updateRulesForGlobalChangeLocked(true);
            writePolicyLocked();
        }
    }
+12 −2
Original line number Diff line number Diff line
@@ -215,7 +215,12 @@ class NetworkPolicyManagerShellCommand extends ShellCommand {
      if (uid < 0) {
          return uid;
      }
      final long token = Binder.clearCallingIdentity();
      try {
          mInterface.addRestrictBackgroundWhitelistedUid(uid);
      } finally {
          Binder.restoreCallingIdentity(token);
      }
      return 0;
    }

@@ -224,7 +229,12 @@ class NetworkPolicyManagerShellCommand extends ShellCommand {
        if (uid < 0) {
            return uid;
        }
        final long token = Binder.clearCallingIdentity();
        try {
            mInterface.removeRestrictBackgroundWhitelistedUid(uid);
        } finally {
            Binder.restoreCallingIdentity(token);
        }
        return 0;
    }