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

Commit 6a05eee2 authored by Felipe Leme's avatar Felipe Leme
Browse files

Fixed permissions so Shell can call netpolicy methods.

BUG: 27127112
Change-Id: I5548aba70a1c25be139462fbabe9a854fa96d2a6
parent 4b69da8c
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
    <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
    <uses-permission android:name="android.permission.MANAGE_NETWORK_POLICY" />
    <!-- System tool permissions granted to the shell. -->
    <uses-permission android:name="android.permission.REAL_GET_TASKS" />
    <uses-permission android:name="android.permission.CHANGE_CONFIGURATION" />
@@ -109,6 +110,7 @@
    <uses-permission android:name="android.permission.GET_APP_OPS_STATS" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.MANAGE_ACTIVITY_STACKS" />
    <uses-permission android:name="android.permission.CONNECTIVITY_INTERNAL" />

    <application android:label="@string/app_label"
                 android:forceDeviceEncrypted="true"
+23 −13
Original line number Diff line number Diff line
@@ -1742,6 +1742,8 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
    public void setNetworkPolicies(NetworkPolicy[] policies) {
        mContext.enforceCallingOrSelfPermission(MANAGE_NETWORK_POLICY, TAG);

        final long token = Binder.clearCallingIdentity();
        try {
            maybeRefreshTrustedTime();
            synchronized (mRulesLock) {
                normalizePoliciesLocked(policies);
@@ -1750,6 +1752,9 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
                updateNotificationsLocked();
                writePolicyLocked();
            }
        } finally {
            Binder.restoreCallingIdentity(token);
        }
    }

    void addNetworkPolicyLocked(NetworkPolicy policy) {
@@ -1851,7 +1856,8 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
    @Override
    public void setRestrictBackground(boolean restrictBackground) {
        mContext.enforceCallingOrSelfPermission(MANAGE_NETWORK_POLICY, TAG);

        final long token = Binder.clearCallingIdentity();
        try {
            maybeRefreshTrustedTime();
            synchronized (mRulesLock) {
                mRestrictBackground = restrictBackground;
@@ -1860,6 +1866,10 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
                writePolicyLocked();
            }

        } finally {
            Binder.restoreCallingIdentity(token);
        }

        mHandler.obtainMessage(MSG_RESTRICT_BACKGROUND_CHANGED, restrictBackground ? 1 : 0, 0)
                .sendToTarget();
    }
+3 −18
Original line number Diff line number Diff line
@@ -211,12 +211,7 @@ class NetworkPolicyManagerShellCommand extends ShellCommand {
        if (enabled < 0) {
            return enabled;
        }
        final long token = Binder.clearCallingIdentity();
        try {
        mInterface.setRestrictBackground(enabled > 0);
        } finally {
            Binder.restoreCallingIdentity(token);
        }
        return 0;
    }

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

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