From b49b99d85cd6356e7cd21b98a7b22114b7a006b6 Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Wed, 30 Jun 2021 10:54:00 -0400 Subject: [PATCH] Disable NAS migration notification The notification is being sent too frequently and isn't easy to understand Test: atest Fixes: 188932418 Change-Id: I74fef84f564afe93214657f012c1a9eabf8687a0 --- .../NotificationManagerService.java | 5 +-- .../NotificationManagerServiceTest.java | 36 +++++++++++-------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index d78fbdb53d8d3..addcd0f1c8370 100755 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -773,12 +773,13 @@ public class NotificationManagerService extends SystemService { mAssistants.resetDefaultFromConfig(); continue; } + // TODO(b/192450820): re-enable when "user set" isn't over triggering //User selected different NAS, need onboarding - enqueueNotificationInternal(getContext().getPackageName(), + /*enqueueNotificationInternal(getContext().getPackageName(), getContext().getOpPackageName(), Binder.getCallingUid(), Binder.getCallingPid(), TAG, SystemMessageProto.SystemMessage.NOTE_NAS_UPGRADE, - createNASUpgradeNotification(userId), userId); + createNASUpgradeNotification(userId), userId);*/ } } } diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java index 3c6f62a0a42d1..f57c416e4a97a 100755 --- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java @@ -4855,6 +4855,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testAreBubblesEnabled() throws Exception { + Settings.Secure.putInt(mContext.getContentResolver(), + Settings.Secure.NOTIFICATION_BUBBLES, 1); + mService.mPreferencesHelper.updateBubblesEnabled(); assertTrue(mBinderService.areBubblesEnabled(UserHandle.getUserHandleForUid(mUid))); } @@ -5907,7 +5910,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { service.migrateDefaultNASShowNotificationIfNecessary(); assertFalse(service.isNASMigrationDone(userId)); - verify(service, times(1)).createNASUpgradeNotification(eq(userId)); + //TODO(b/192450820) + //verify(service, times(1)).createNASUpgradeNotification(eq(userId)); verify(mAssistants, times(0)).resetDefaultFromConfig(); //Test user clear data before enable/disable from onboarding notification @@ -5926,7 +5930,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { //The notification should be still there assertFalse(service.isNASMigrationDone(userId)); - verify(service, times(2)).createNASUpgradeNotification(eq(userId)); + //TODO(b/192450820) + //verify(service, times(2)).createNASUpgradeNotification(eq(userId)); verify(mAssistants, times(0)).resetDefaultFromConfig(); assertEquals(oldDefaultComponent, service.getApprovedAssistant(userId)); } @@ -5962,7 +5967,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { assertFalse(service.isNASMigrationDone(userId1)); assertTrue(service.isNASMigrationDone(userId2)); - verify(service, times(1)).createNASUpgradeNotification(any(Integer.class)); + //TODO(b/192450820) + //verify(service, times(1)).createNASUpgradeNotification(any(Integer.class)); // only user2's default get updated verify(mAssistants, times(1)).resetDefaultFromConfig(); } @@ -5997,9 +6003,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { assertFalse(service.isNASMigrationDone(userId1)); assertFalse(service.isNASMigrationDone(userId2)); - // only user1 get notification - verify(service, times(1)).createNASUpgradeNotification(eq(userId1)); - verify(service, times(0)).createNASUpgradeNotification(eq(userId2)); + // TODO(b/192450820): only user1 get notification + //verify(service, times(1)).createNASUpgradeNotification(eq(userId1)); + //verify(service, times(0)).createNASUpgradeNotification(eq(userId2)); } @@ -6029,8 +6035,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { //Test migrate flow again service.migrateDefaultNASShowNotificationIfNecessary(); - //The notification should not appear again - verify(service, times(0)).createNASUpgradeNotification(eq(userId)); + //TODO(b/192450820): The notification should not appear again + //verify(service, times(0)).createNASUpgradeNotification(eq(userId)); verify(mAssistants, times(0)).resetDefaultFromConfig(); } @@ -6055,9 +6061,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { verify(mAssistants, times(1)).clearDefaults(); verify(mAssistants, times(0)).resetDefaultFromConfig(); - //No more notification after disabled - service.migrateDefaultNASShowNotificationIfNecessary(); - verify(service, times(0)).createNASUpgradeNotification(anyInt()); + //TODO(b/192450820):No more notification after disabled + //service.migrateDefaultNASShowNotificationIfNecessary(); + //verify(service, times(0)).createNASUpgradeNotification(anyInt()); } @Test @@ -6077,8 +6083,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { assertFalse(service.isNASMigrationDone(userId2)); verify(mAssistants, times(1)).resetDefaultFromConfig(); - service.migrateDefaultNASShowNotificationIfNecessary(); - verify(service, times(0)).createNASUpgradeNotification(eq(userId1)); + //TODO(b/192450820) + //service.migrateDefaultNASShowNotificationIfNecessary(); + //verify(service, times(0)).createNASUpgradeNotification(eq(userId1)); } @Test @@ -6093,7 +6100,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { verify(mContext, times(1)).startActivity(any(Intent.class)); assertFalse(service.isNASMigrationDone(userId)); - verify(service, times(0)).createNASUpgradeNotification(eq(userId)); + //TODO(b/192450820) + //verify(service, times(0)).createNASUpgradeNotification(eq(userId)); verify(mAssistants, times(0)).resetDefaultFromConfig(); }