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

Commit a16038a1 authored by Hongguang Chen's avatar Hongguang Chen Committed by Android (Google) Code Review
Browse files

Merge "Fix NPE in NotificationManagerService"

parents b9fde865 413c1dbd
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -579,9 +579,6 @@ public class NotificationManagerService extends SystemService {
    private float mInCallNotificationVolume;
    private Binder mCallNotificationToken = null;
    @VisibleForTesting
    protected boolean mSystemExemptFromDismissal = false;
    private SystemUiSystemPropertiesFlags.FlagResolver mFlagResolver;
    // used as a mutex for access to all active notifications & listeners
@@ -648,6 +645,7 @@ public class NotificationManagerService extends SystemService {
    private NotificationUsageStats mUsageStats;
    private boolean mLockScreenAllowSecureNotifications = true;
    boolean mAllowFgsDismissal = false;
    boolean mSystemExemptFromDismissal = false;
    private static final int MY_UID = Process.myUid();
    private static final int MY_PID = Process.myPid();
@@ -2603,8 +2601,10 @@ public class NotificationManagerService extends SystemService {
        mAllowFgsDismissal = DeviceConfig.getBoolean(
                DeviceConfig.NAMESPACE_SYSTEMUI,
                SystemUiDeviceConfigFlags.TASK_MANAGER_ENABLED, true);
        mSystemExemptFromDismissal =
                mDpm.isApplicationExemptionsFlagEnabled();
        mSystemExemptFromDismissal = DeviceConfig.getBoolean(
                DeviceConfig.NAMESPACE_DEVICE_POLICY_MANAGER,
                /* name= */ "application_exemptions",
                /* defaultValue= */ true);
        DeviceConfig.addOnPropertiesChangedListener(
                DeviceConfig.NAMESPACE_SYSTEMUI,
                new HandlerExecutor(mHandler),
+12 −4
Original line number Diff line number Diff line
@@ -10305,7 +10305,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        // Given: a notification has the flag FLAG_ONGOING_EVENT set
        // feature flag: ALLOW_DISMISS_ONGOING is on
        mTestFlagResolver.setFlagOverride(ALLOW_DISMISS_ONGOING, true);
        mService.setSystemExemptFromDismissal(false);
        setSystemExemptFromDismissal(false);
        Notification n = new Notification.Builder(mContext, "test")
                .setOngoing(true)
                .build();
@@ -10326,7 +10326,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        // Given: a notification has the flag FLAG_ONGOING_EVENT set
        // feature flag: ALLOW_DISMISS_ONGOING is on
        mTestFlagResolver.setFlagOverride(ALLOW_DISMISS_ONGOING, true);
        mService.setSystemExemptFromDismissal(true);
        setSystemExemptFromDismissal(true);
        Notification n = new Notification.Builder(mContext, "test")
                .setOngoing(true)
                .build();
@@ -10337,7 +10337,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        // Then: the notification's flag FLAG_NO_DISMISS should be set
        assertNotSame(0, n.flags & Notification.FLAG_NO_DISMISS);

        mService.setSystemExemptFromDismissal(false);
        setSystemExemptFromDismissal(false);
    }

    @Test
@@ -10349,7 +10349,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        // Given: a notification has the flag FLAG_ONGOING_EVENT set
        // feature flag: ALLOW_DISMISS_ONGOING is on
        mTestFlagResolver.setFlagOverride(ALLOW_DISMISS_ONGOING, true);
        mService.setSystemExemptFromDismissal(false);
        setSystemExemptFromDismissal(false);
        Notification n = new Notification.Builder(mContext, "test")
                .setOngoing(true)
                .build();
@@ -10360,4 +10360,12 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        // Then: the notification's flag FLAG_NO_DISMISS should not be set
        assertEquals(0, n.flags & Notification.FLAG_NO_DISMISS);
    }

    private void setSystemExemptFromDismissal(boolean isOn) {
        DeviceConfig.setProperty(
                DeviceConfig.NAMESPACE_DEVICE_POLICY_MANAGER,
                /* name= */ "application_exemptions",
                String.valueOf(isOn),
                /* makeDefault= */ false);
    }
}
+0 −4
Original line number Diff line number Diff line
@@ -159,8 +159,4 @@ public class TestableNotificationManagerService extends NotificationManagerServi
            return mGetStrongAuthForUserReturnValue;
        }
    }

    protected void setSystemExemptFromDismissal(boolean isOn) {
        mSystemExemptFromDismissal = isOn;
    }
}