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

Commit e5c680f4 authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Clear calling identity

... after checking the caller. For hostside tests.

Fixes: 65245599
Test: cts-tradefed run singleCommand cts-dev -m CtsHostsideNetworkTests -t \
          com.android.cts.net.HostsideRestrictBackgroundNetworkTests

Change-Id: I094e38dbaf7818b9f645c55288bddffc879c6a0d
parent 13f31bd0
Loading
Loading
Loading
Loading
+49 −33
Original line number Diff line number Diff line
@@ -2747,6 +2747,8 @@ public class NotificationManagerService extends SystemService {
        public void setNotificationPolicyAccessGranted(String pkg, boolean granted)
                throws RemoteException {
            checkCallerIsSystemOrShell();
            final long identity = Binder.clearCallingIdentity();
            try {
                if (!mActivityManager.isLowRamDevice()) {
                    mConditionProviders.setPackageOrComponentEnabled(
                            pkg, getCallingUserHandle().getIdentifier(), true, granted);
@@ -2759,6 +2761,9 @@ public class NotificationManagerService extends SystemService {

                    savePolicyFile();
                }
            } finally {
                Binder.restoreCallingIdentity(identity);
            }
        }

        @Override
@@ -2839,6 +2844,8 @@ public class NotificationManagerService extends SystemService {
                boolean granted) throws RemoteException {
            Preconditions.checkNotNull(listener);
            checkCallerIsSystemOrShell();
            final long identity = Binder.clearCallingIdentity();
            try {
                if (!mActivityManager.isLowRamDevice()) {
                    mConditionProviders.setPackageOrComponentEnabled(listener.flattenToString(),
                            userId, false, granted);
@@ -2847,12 +2854,16 @@ public class NotificationManagerService extends SystemService {

                    getContext().sendBroadcastAsUser(new Intent(
                                    NotificationManager.ACTION_NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED)

                                    .setPackage(listener.getPackageName())
                                    .addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY),
                            getCallingUserHandle(), null);

                    savePolicyFile();
                }
            } finally {
                Binder.restoreCallingIdentity(identity);
            }
        }

        @Override
@@ -2860,6 +2871,8 @@ public class NotificationManagerService extends SystemService {
                int userId, boolean granted) throws RemoteException {
            Preconditions.checkNotNull(assistant);
            checkCallerIsSystemOrShell();
            final long identity = Binder.clearCallingIdentity();
            try {
                if (!mActivityManager.isLowRamDevice()) {
                    mConditionProviders.setPackageOrComponentEnabled(assistant.flattenToString(),
                            userId, false, granted);
@@ -2874,6 +2887,9 @@ public class NotificationManagerService extends SystemService {

                    savePolicyFile();
                }
            } finally {
                Binder.restoreCallingIdentity(identity);
            }
        }

        @Override