Loading services/core/java/com/android/server/notification/NotificationManagerService.java +1 −43 Original line number Diff line number Diff line Loading @@ -266,7 +266,6 @@ import android.os.UserHandle; import android.os.UserManager; import android.os.WorkSource; import android.permission.PermissionManager; import android.provider.DeviceConfig; import android.provider.Settings; import android.provider.Settings.Secure; import android.service.notification.Adjustment; Loading Loading @@ -313,7 +312,6 @@ import com.android.internal.R; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.compat.IPlatformCompat; import com.android.internal.config.sysui.SystemUiDeviceConfigFlags; import com.android.internal.config.sysui.SystemUiSystemPropertiesFlags; import com.android.internal.config.sysui.SystemUiSystemPropertiesFlags.NotificationFlags; import com.android.internal.logging.InstanceId; Loading Loading @@ -704,7 +702,6 @@ public class NotificationManagerService extends SystemService { private ConditionProviders mConditionProviders; private NotificationUsageStats mUsageStats; private boolean mLockScreenAllowSecureNotifications = true; boolean mSystemExemptFromDismissal = false; final ArrayMap<String, ArrayMap<Integer, RemoteCallbackList<ICallNotificationEventCallback>>> mCallNotificationEventCallbacks = new ArrayMap<>(); Loading @@ -722,7 +719,6 @@ public class NotificationManagerService extends SystemService { private GroupHelper mGroupHelper; private int mAutoGroupAtCount; private boolean mIsTelevision; private DeviceConfig.OnPropertiesChangedListener mDeviceConfigChangedListener; protected NotificationAttentionHelper mAttentionHelper; private int mWarnRemoteViewsSizeBytes; Loading Loading @@ -973,18 +969,6 @@ public class NotificationManagerService extends SystemService { } protected void setDefaultAssistantForUser(int userId) { String overrideDefaultAssistantString = DeviceConfig.getProperty( DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.NAS_DEFAULT_SERVICE); if (overrideDefaultAssistantString != null) { ArraySet<ComponentName> approved = mAssistants.queryPackageForServices( overrideDefaultAssistantString, MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE, userId); for (int i = 0; i < approved.size(); i++) { if (allowAssistant(userId, approved.valueAt(i))) return; } } ArraySet<ComponentName> defaults = mAssistants.getDefaultComponents(); // We should have only one default assistant by default // allowAssistant should execute once in practice Loading Loading @@ -2670,10 +2654,6 @@ public class NotificationManagerService extends SystemService { mStatsManager.clearPullAtomCallback(DND_MODE_RULE); mAppOps.stopWatchingMode(mAppOpsListener); mAlarmManager.cancelAll(); if (mDeviceConfigChangedListener != null) { DeviceConfig.removeOnPropertiesChangedListener(mDeviceConfigChangedListener); } } protected String[] getStringArrayResource(int key) { Loading Loading @@ -2744,27 +2724,6 @@ public class NotificationManagerService extends SystemService { publishLocalService(NotificationManagerInternal.class, mInternalService); } void registerDeviceConfigChange() { mDeviceConfigChangedListener = properties -> { if (!DeviceConfig.NAMESPACE_SYSTEMUI.equals(properties.getNamespace())) { return; } for (String name : properties.getKeyset()) { if (SystemUiDeviceConfigFlags.NAS_DEFAULT_SERVICE.equals(name)) { mAssistants.resetDefaultAssistantsIfNecessary(); } } }; mSystemExemptFromDismissal = DeviceConfig.getBoolean( DeviceConfig.NAMESPACE_DEVICE_POLICY_MANAGER, /* name= */ "application_exemptions", /* defaultValue= */ true); DeviceConfig.addOnPropertiesChangedListener( DeviceConfig.NAMESPACE_SYSTEMUI, new HandlerExecutor(mHandler), mDeviceConfigChangedListener); } private void registerNotificationPreferencesPullers() { mPullAtomCallback = new StatsPullAtomCallbackImpl(); mStatsManager.setPullAtomCallback( Loading Loading @@ -2938,7 +2897,6 @@ public class NotificationManagerService extends SystemService { mAssistants.onBootPhaseAppsCanStart(); mConditionProviders.onBootPhaseAppsCanStart(); mHistoryManager.onBootPhaseAppsCanStart(); registerDeviceConfigChange(); migrateDefaultNAS(); maybeShowInitialReviewPermissionsNotification(); Loading Loading @@ -7738,7 +7696,7 @@ public class NotificationManagerService extends SystemService { return true; } // Check if an app has been given system exemption return mSystemExemptFromDismissal && mAppOps.checkOpNoThrow( return mAppOps.checkOpNoThrow( AppOpsManager.OP_SYSTEM_EXEMPT_FROM_DISMISSIBLE_NOTIFICATIONS, ai.uid, ai.packageName) == MODE_ALLOWED; } Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +6 −78 Original line number Diff line number Diff line Loading @@ -243,7 +243,6 @@ import android.platform.test.annotations.EnableFlags; import android.platform.test.flag.junit.FlagsParameterization; import android.platform.test.flag.junit.SetFlagsRule; import android.platform.test.rule.LimitDevicesRule; import android.provider.DeviceConfig; import android.provider.MediaStore; import android.provider.Settings; import android.service.notification.Adjustment; Loading Loading @@ -280,7 +279,6 @@ import androidx.test.InstrumentationRegistry; import androidx.test.filters.SmallTest; import com.android.internal.R; import com.android.internal.config.sysui.SystemUiDeviceConfigFlags; import com.android.internal.config.sysui.TestableFlagResolver; import com.android.internal.logging.InstanceIdSequence; import com.android.internal.logging.InstanceIdSequenceFake; Loading Loading @@ -602,7 +600,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { when(mContext.getContentResolver()).thenReturn(cr); doNothing().when(cr).registerContentObserver(any(), anyBoolean(), any(), anyInt()); setDpmAppOppsExemptFromDismissal(false); when(mAppOpsManager.checkOpNoThrow( AppOpsManager.OP_SYSTEM_EXEMPT_FROM_DISMISSIBLE_NOTIFICATIONS, mUid, mPkg)).thenReturn(AppOpsManager.MODE_IGNORED); // Use this testable looper. mTestableLooper = TestableLooper.get(this); Loading Loading @@ -900,7 +900,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @After public void tearDown() throws Exception { if (mFile != null) mFile.delete(); clearDeviceConfig(); if (mActivityIntent != null) { mActivityIntent.cancel(); Loading Loading @@ -1200,19 +1199,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { return answers; } private void clearDeviceConfig() { DeviceConfig.resetToDefaults( Settings.RESET_MODE_PACKAGE_DEFAULTS, DeviceConfig.NAMESPACE_SYSTEMUI); } private void setDefaultAssistantInDeviceConfig(String componentName) { DeviceConfig.setProperty( DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.NAS_DEFAULT_SERVICE, componentName, false); } private Notification.Builder getMessageStyleNotifBuilder(boolean addBubbleMetadata, String groupKey, boolean isSummary, boolean mutable) { // Give it a person Loading Loading @@ -9092,7 +9078,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void setDefaultAssistantForUser_fromConfigXml() { clearDeviceConfig(); ComponentName xmlConfig = new ComponentName("config", "xml"); ArraySet<ComponentName> components = new ArraySet<>(Arrays.asList(xmlConfig)); when(mResources Loading @@ -9114,51 +9099,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { .onGranted(eq(xmlConfig), eq(0), eq(true), eq(false)); } @Test public void setDefaultAssistantForUser_fromDeviceConfig() { ComponentName xmlConfig = new ComponentName("xml", "config"); ComponentName deviceConfig = new ComponentName("device", "config"); setDefaultAssistantInDeviceConfig(deviceConfig.flattenToString()); when(mResources .getString(com.android.internal.R.string.config_defaultAssistantAccessComponent)) .thenReturn(xmlConfig.flattenToString()); when(mContext.getResources()).thenReturn(mResources); when(mAssistants.queryPackageForServices(eq(null), anyInt(), anyInt())) .thenReturn(new ArraySet<>(Arrays.asList(xmlConfig, deviceConfig))); when(mAssistants.getDefaultComponents()) .thenReturn(new ArraySet<>(Arrays.asList(deviceConfig))); mService.setNotificationAssistantAccessGrantedCallback( mNotificationAssistantAccessGrantedCallback); mService.setDefaultAssistantForUser(0); verify(mNotificationAssistantAccessGrantedCallback) .onGranted(eq(deviceConfig), eq(0), eq(true), eq(false)); } @Test public void setDefaultAssistantForUser_deviceConfigInvalid() { ComponentName xmlConfig = new ComponentName("xml", "config"); ComponentName deviceConfig = new ComponentName("device", "config"); setDefaultAssistantInDeviceConfig(deviceConfig.flattenToString()); when(mResources .getString(com.android.internal.R.string.config_defaultAssistantAccessComponent)) .thenReturn(xmlConfig.flattenToString()); when(mContext.getResources()).thenReturn(mResources); // Only xmlConfig is valid, deviceConfig is not. when(mAssistants.queryPackageForServices(eq(null), anyInt(), eq(0))) .thenReturn(new ArraySet<>(Collections.singleton(xmlConfig))); when(mAssistants.getDefaultComponents()) .thenReturn(new ArraySet<>(Arrays.asList(xmlConfig, deviceConfig))); mService.setNotificationAssistantAccessGrantedCallback( mNotificationAssistantAccessGrantedCallback); mService.setDefaultAssistantForUser(0); verify(mNotificationAssistantAccessGrantedCallback) .onGranted(eq(xmlConfig), eq(0), eq(true), eq(false)); } @Test public void clearMultipleDefaultAssistantPackagesShouldEnableOnlyOne() throws RemoteException { ArrayMap<Boolean, ArrayList<ComponentName>> changedListeners = Loading Loading @@ -11006,7 +10946,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { tr.addOverride(com.android.internal.R.string.config_defaultListenerAccessPackages, ""); tr.addOverride(com.android.internal.R.string.config_defaultDndAccessPackages, ""); tr.addOverride(com.android.internal.R.string.config_defaultAssistantAccessComponent, ""); setDefaultAssistantInDeviceConfig(""); mService.loadDefaultApprovedServices(USER_SYSTEM); Loading Loading @@ -13425,7 +13364,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { throws Exception { when(mDevicePolicyManager.isActiveDeviceOwner(mUid)).thenReturn(true); // Given: a notification has the flag FLAG_ONGOING_EVENT set setDpmAppOppsExemptFromDismissal(false); Notification n = new Notification.Builder(mContext, "test") .setOngoing(true) .build(); Loading @@ -13451,7 +13389,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { AppOpsManager.OP_SYSTEM_EXEMPT_FROM_DISMISSIBLE_NOTIFICATIONS, mUid, mPkg)).thenReturn(AppOpsManager.MODE_ALLOWED); // Given: a notification has the flag FLAG_ONGOING_EVENT set setDpmAppOppsExemptFromDismissal(true); Notification n = new Notification.Builder(mContext, "test") .setOngoing(true) .build(); Loading @@ -13459,8 +13396,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { // When: fix the notification with NotificationManagerService mService.fixNotification(n, mPkg, "tag", 9, 0, mUid, NOT_FOREGROUND_SERVICE, true); // Then: the notification's flag FLAG_NO_DISMISS should be cleared assertEquals(0, n.flags & Notification.FLAG_NO_DISMISS); // Then: the notification's flag FLAG_NO_DISMISS should be set assertNotSame(0, n.flags & Notification.FLAG_NO_DISMISS); } @Test Loading @@ -13468,9 +13405,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { throws Exception { when(mAppOpsManager.checkOpNoThrow( AppOpsManager.OP_SYSTEM_EXEMPT_FROM_DISMISSIBLE_NOTIFICATIONS, mUid, mPkg)).thenReturn(AppOpsManager.MODE_ALLOWED); mPkg)).thenReturn(AppOpsManager.MODE_IGNORED); // Given: a notification has the flag FLAG_ONGOING_EVENT set setDpmAppOppsExemptFromDismissal(false); Notification n = new Notification.Builder(mContext, "test") .setOngoing(true) .build(); Loading Loading @@ -15551,14 +15487,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { PendingIntent.FLAG_MUTABLE); } private void setDpmAppOppsExemptFromDismissal(boolean isOn) { DeviceConfig.setProperty( DeviceConfig.NAMESPACE_DEVICE_POLICY_MANAGER, /* name= */ "application_exemptions", String.valueOf(isOn), /* makeDefault= */ false); } private void allowTestPackageToToast() throws Exception { assertWithMessage("toast queue").that(mService.mToastQueue).isEmpty(); mService.isSystemUid = false; Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +1 −43 Original line number Diff line number Diff line Loading @@ -266,7 +266,6 @@ import android.os.UserHandle; import android.os.UserManager; import android.os.WorkSource; import android.permission.PermissionManager; import android.provider.DeviceConfig; import android.provider.Settings; import android.provider.Settings.Secure; import android.service.notification.Adjustment; Loading Loading @@ -313,7 +312,6 @@ import com.android.internal.R; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.compat.IPlatformCompat; import com.android.internal.config.sysui.SystemUiDeviceConfigFlags; import com.android.internal.config.sysui.SystemUiSystemPropertiesFlags; import com.android.internal.config.sysui.SystemUiSystemPropertiesFlags.NotificationFlags; import com.android.internal.logging.InstanceId; Loading Loading @@ -704,7 +702,6 @@ public class NotificationManagerService extends SystemService { private ConditionProviders mConditionProviders; private NotificationUsageStats mUsageStats; private boolean mLockScreenAllowSecureNotifications = true; boolean mSystemExemptFromDismissal = false; final ArrayMap<String, ArrayMap<Integer, RemoteCallbackList<ICallNotificationEventCallback>>> mCallNotificationEventCallbacks = new ArrayMap<>(); Loading @@ -722,7 +719,6 @@ public class NotificationManagerService extends SystemService { private GroupHelper mGroupHelper; private int mAutoGroupAtCount; private boolean mIsTelevision; private DeviceConfig.OnPropertiesChangedListener mDeviceConfigChangedListener; protected NotificationAttentionHelper mAttentionHelper; private int mWarnRemoteViewsSizeBytes; Loading Loading @@ -973,18 +969,6 @@ public class NotificationManagerService extends SystemService { } protected void setDefaultAssistantForUser(int userId) { String overrideDefaultAssistantString = DeviceConfig.getProperty( DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.NAS_DEFAULT_SERVICE); if (overrideDefaultAssistantString != null) { ArraySet<ComponentName> approved = mAssistants.queryPackageForServices( overrideDefaultAssistantString, MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE, userId); for (int i = 0; i < approved.size(); i++) { if (allowAssistant(userId, approved.valueAt(i))) return; } } ArraySet<ComponentName> defaults = mAssistants.getDefaultComponents(); // We should have only one default assistant by default // allowAssistant should execute once in practice Loading Loading @@ -2670,10 +2654,6 @@ public class NotificationManagerService extends SystemService { mStatsManager.clearPullAtomCallback(DND_MODE_RULE); mAppOps.stopWatchingMode(mAppOpsListener); mAlarmManager.cancelAll(); if (mDeviceConfigChangedListener != null) { DeviceConfig.removeOnPropertiesChangedListener(mDeviceConfigChangedListener); } } protected String[] getStringArrayResource(int key) { Loading Loading @@ -2744,27 +2724,6 @@ public class NotificationManagerService extends SystemService { publishLocalService(NotificationManagerInternal.class, mInternalService); } void registerDeviceConfigChange() { mDeviceConfigChangedListener = properties -> { if (!DeviceConfig.NAMESPACE_SYSTEMUI.equals(properties.getNamespace())) { return; } for (String name : properties.getKeyset()) { if (SystemUiDeviceConfigFlags.NAS_DEFAULT_SERVICE.equals(name)) { mAssistants.resetDefaultAssistantsIfNecessary(); } } }; mSystemExemptFromDismissal = DeviceConfig.getBoolean( DeviceConfig.NAMESPACE_DEVICE_POLICY_MANAGER, /* name= */ "application_exemptions", /* defaultValue= */ true); DeviceConfig.addOnPropertiesChangedListener( DeviceConfig.NAMESPACE_SYSTEMUI, new HandlerExecutor(mHandler), mDeviceConfigChangedListener); } private void registerNotificationPreferencesPullers() { mPullAtomCallback = new StatsPullAtomCallbackImpl(); mStatsManager.setPullAtomCallback( Loading Loading @@ -2938,7 +2897,6 @@ public class NotificationManagerService extends SystemService { mAssistants.onBootPhaseAppsCanStart(); mConditionProviders.onBootPhaseAppsCanStart(); mHistoryManager.onBootPhaseAppsCanStart(); registerDeviceConfigChange(); migrateDefaultNAS(); maybeShowInitialReviewPermissionsNotification(); Loading Loading @@ -7738,7 +7696,7 @@ public class NotificationManagerService extends SystemService { return true; } // Check if an app has been given system exemption return mSystemExemptFromDismissal && mAppOps.checkOpNoThrow( return mAppOps.checkOpNoThrow( AppOpsManager.OP_SYSTEM_EXEMPT_FROM_DISMISSIBLE_NOTIFICATIONS, ai.uid, ai.packageName) == MODE_ALLOWED; } Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +6 −78 Original line number Diff line number Diff line Loading @@ -243,7 +243,6 @@ import android.platform.test.annotations.EnableFlags; import android.platform.test.flag.junit.FlagsParameterization; import android.platform.test.flag.junit.SetFlagsRule; import android.platform.test.rule.LimitDevicesRule; import android.provider.DeviceConfig; import android.provider.MediaStore; import android.provider.Settings; import android.service.notification.Adjustment; Loading Loading @@ -280,7 +279,6 @@ import androidx.test.InstrumentationRegistry; import androidx.test.filters.SmallTest; import com.android.internal.R; import com.android.internal.config.sysui.SystemUiDeviceConfigFlags; import com.android.internal.config.sysui.TestableFlagResolver; import com.android.internal.logging.InstanceIdSequence; import com.android.internal.logging.InstanceIdSequenceFake; Loading Loading @@ -602,7 +600,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { when(mContext.getContentResolver()).thenReturn(cr); doNothing().when(cr).registerContentObserver(any(), anyBoolean(), any(), anyInt()); setDpmAppOppsExemptFromDismissal(false); when(mAppOpsManager.checkOpNoThrow( AppOpsManager.OP_SYSTEM_EXEMPT_FROM_DISMISSIBLE_NOTIFICATIONS, mUid, mPkg)).thenReturn(AppOpsManager.MODE_IGNORED); // Use this testable looper. mTestableLooper = TestableLooper.get(this); Loading Loading @@ -900,7 +900,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @After public void tearDown() throws Exception { if (mFile != null) mFile.delete(); clearDeviceConfig(); if (mActivityIntent != null) { mActivityIntent.cancel(); Loading Loading @@ -1200,19 +1199,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { return answers; } private void clearDeviceConfig() { DeviceConfig.resetToDefaults( Settings.RESET_MODE_PACKAGE_DEFAULTS, DeviceConfig.NAMESPACE_SYSTEMUI); } private void setDefaultAssistantInDeviceConfig(String componentName) { DeviceConfig.setProperty( DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.NAS_DEFAULT_SERVICE, componentName, false); } private Notification.Builder getMessageStyleNotifBuilder(boolean addBubbleMetadata, String groupKey, boolean isSummary, boolean mutable) { // Give it a person Loading Loading @@ -9092,7 +9078,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void setDefaultAssistantForUser_fromConfigXml() { clearDeviceConfig(); ComponentName xmlConfig = new ComponentName("config", "xml"); ArraySet<ComponentName> components = new ArraySet<>(Arrays.asList(xmlConfig)); when(mResources Loading @@ -9114,51 +9099,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { .onGranted(eq(xmlConfig), eq(0), eq(true), eq(false)); } @Test public void setDefaultAssistantForUser_fromDeviceConfig() { ComponentName xmlConfig = new ComponentName("xml", "config"); ComponentName deviceConfig = new ComponentName("device", "config"); setDefaultAssistantInDeviceConfig(deviceConfig.flattenToString()); when(mResources .getString(com.android.internal.R.string.config_defaultAssistantAccessComponent)) .thenReturn(xmlConfig.flattenToString()); when(mContext.getResources()).thenReturn(mResources); when(mAssistants.queryPackageForServices(eq(null), anyInt(), anyInt())) .thenReturn(new ArraySet<>(Arrays.asList(xmlConfig, deviceConfig))); when(mAssistants.getDefaultComponents()) .thenReturn(new ArraySet<>(Arrays.asList(deviceConfig))); mService.setNotificationAssistantAccessGrantedCallback( mNotificationAssistantAccessGrantedCallback); mService.setDefaultAssistantForUser(0); verify(mNotificationAssistantAccessGrantedCallback) .onGranted(eq(deviceConfig), eq(0), eq(true), eq(false)); } @Test public void setDefaultAssistantForUser_deviceConfigInvalid() { ComponentName xmlConfig = new ComponentName("xml", "config"); ComponentName deviceConfig = new ComponentName("device", "config"); setDefaultAssistantInDeviceConfig(deviceConfig.flattenToString()); when(mResources .getString(com.android.internal.R.string.config_defaultAssistantAccessComponent)) .thenReturn(xmlConfig.flattenToString()); when(mContext.getResources()).thenReturn(mResources); // Only xmlConfig is valid, deviceConfig is not. when(mAssistants.queryPackageForServices(eq(null), anyInt(), eq(0))) .thenReturn(new ArraySet<>(Collections.singleton(xmlConfig))); when(mAssistants.getDefaultComponents()) .thenReturn(new ArraySet<>(Arrays.asList(xmlConfig, deviceConfig))); mService.setNotificationAssistantAccessGrantedCallback( mNotificationAssistantAccessGrantedCallback); mService.setDefaultAssistantForUser(0); verify(mNotificationAssistantAccessGrantedCallback) .onGranted(eq(xmlConfig), eq(0), eq(true), eq(false)); } @Test public void clearMultipleDefaultAssistantPackagesShouldEnableOnlyOne() throws RemoteException { ArrayMap<Boolean, ArrayList<ComponentName>> changedListeners = Loading Loading @@ -11006,7 +10946,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { tr.addOverride(com.android.internal.R.string.config_defaultListenerAccessPackages, ""); tr.addOverride(com.android.internal.R.string.config_defaultDndAccessPackages, ""); tr.addOverride(com.android.internal.R.string.config_defaultAssistantAccessComponent, ""); setDefaultAssistantInDeviceConfig(""); mService.loadDefaultApprovedServices(USER_SYSTEM); Loading Loading @@ -13425,7 +13364,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { throws Exception { when(mDevicePolicyManager.isActiveDeviceOwner(mUid)).thenReturn(true); // Given: a notification has the flag FLAG_ONGOING_EVENT set setDpmAppOppsExemptFromDismissal(false); Notification n = new Notification.Builder(mContext, "test") .setOngoing(true) .build(); Loading @@ -13451,7 +13389,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { AppOpsManager.OP_SYSTEM_EXEMPT_FROM_DISMISSIBLE_NOTIFICATIONS, mUid, mPkg)).thenReturn(AppOpsManager.MODE_ALLOWED); // Given: a notification has the flag FLAG_ONGOING_EVENT set setDpmAppOppsExemptFromDismissal(true); Notification n = new Notification.Builder(mContext, "test") .setOngoing(true) .build(); Loading @@ -13459,8 +13396,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { // When: fix the notification with NotificationManagerService mService.fixNotification(n, mPkg, "tag", 9, 0, mUid, NOT_FOREGROUND_SERVICE, true); // Then: the notification's flag FLAG_NO_DISMISS should be cleared assertEquals(0, n.flags & Notification.FLAG_NO_DISMISS); // Then: the notification's flag FLAG_NO_DISMISS should be set assertNotSame(0, n.flags & Notification.FLAG_NO_DISMISS); } @Test Loading @@ -13468,9 +13405,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { throws Exception { when(mAppOpsManager.checkOpNoThrow( AppOpsManager.OP_SYSTEM_EXEMPT_FROM_DISMISSIBLE_NOTIFICATIONS, mUid, mPkg)).thenReturn(AppOpsManager.MODE_ALLOWED); mPkg)).thenReturn(AppOpsManager.MODE_IGNORED); // Given: a notification has the flag FLAG_ONGOING_EVENT set setDpmAppOppsExemptFromDismissal(false); Notification n = new Notification.Builder(mContext, "test") .setOngoing(true) .build(); Loading Loading @@ -15551,14 +15487,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { PendingIntent.FLAG_MUTABLE); } private void setDpmAppOppsExemptFromDismissal(boolean isOn) { DeviceConfig.setProperty( DeviceConfig.NAMESPACE_DEVICE_POLICY_MANAGER, /* name= */ "application_exemptions", String.valueOf(isOn), /* makeDefault= */ false); } private void allowTestPackageToToast() throws Exception { assertWithMessage("toast queue").that(mService.mToastQueue).isEmpty(); mService.isSystemUid = false;