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

Commit 3f52cd5f authored by Felipe Leme's avatar Felipe Leme
Browse files

Propagate changes when uids are added or removed to the restricted

background whitelist.

BUG: 26451391
Change-Id: I21eb4959d9f60e83ef96d8d7d1c92e38ddeb2b78
parent 45a55116
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
@@ -196,7 +196,12 @@ public class NetworkPolicyManagerShellCommand extends ShellCommand {
      if (uid < 0) {
          return uid;
      }
      final long token = Binder.clearCallingIdentity();
      try {
          mInterface.addRestrictBackgroundWhitelistedUid(uid);
      } finally {
          Binder.restoreCallingIdentity(token);
      }
      return 0;
    }

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