Loading services/core/java/com/android/server/notification/NotificationManagerService.java +2 −0 Original line number Diff line number Diff line Loading @@ -3236,6 +3236,8 @@ public class NotificationManagerService extends SystemService { final String noChannelStr = "No Channel found for " + "pkg=" + pkg + ", channelId=" + channelId + ", id=" + id + ", tag=" + tag + ", opPkg=" + opPkg + ", callingUid=" + callingUid + ", userId=" + userId Loading services/core/java/com/android/server/notification/RankingHelper.java +1 −0 Original line number Diff line number Diff line Loading @@ -1115,6 +1115,7 @@ public class RankingHelper implements RankingConfig { Record fullRecord = getRecord(pkg, mPm.getPackageUidAsUser(pkg, changeUserId)); if (fullRecord != null) { createDefaultChannelIfNeeded(fullRecord); deleteDefaultChannelIfNeeded(fullRecord); } } catch (NameNotFoundException e) {} Loading services/tests/notification/src/com/android/server/notification/RankingHelperTest.java +19 −0 Original line number Diff line number Diff line Loading @@ -123,6 +123,7 @@ public class RankingHelperTest extends NotificationTestCase { when(mPm.getApplicationInfoAsUser(eq(PKG), anyInt(), anyInt())).thenReturn(legacy); when(mPm.getApplicationInfoAsUser(eq(UPDATED_PKG), anyInt(), anyInt())).thenReturn(upgrade); when(mPm.getPackageUidAsUser(eq(PKG), anyInt())).thenReturn(UID); when(mPm.getPackageUidAsUser(eq(UPDATED_PKG), anyInt())).thenReturn(UID2); when(mContext.getResources()).thenReturn( InstrumentationRegistry.getContext().getResources()); when(mContext.getPackageManager()).thenReturn(mPm); Loading Loading @@ -1045,6 +1046,24 @@ public class RankingHelperTest extends NotificationTestCase { assertEquals(0, mHelper.getNotificationChannelGroups(PKG, UID, true).getList().size()); } @Test public void testOnPackageChange_downgradeTargetSdk() throws Exception { // create channel as api 26 mHelper.createNotificationChannel(UPDATED_PKG, UID2, getChannel(), true); // install new app version targeting 25 final ApplicationInfo legacy = new ApplicationInfo(); legacy.targetSdkVersion = Build.VERSION_CODES.N_MR1; when(mPm.getApplicationInfoAsUser(eq(UPDATED_PKG), anyInt(), anyInt())).thenReturn(legacy); mHelper.onPackagesChanged( false, UserHandle.USER_SYSTEM, new String[]{UPDATED_PKG}, new int[]{UID2}); // make sure the default channel was readded //assertEquals(2, mHelper.getNotificationChannels(UPDATED_PKG, UID2, false).getList().size()); assertNotNull(mHelper.getNotificationChannel( UPDATED_PKG, UID2, NotificationChannel.DEFAULT_CHANNEL_ID, false)); } @Test public void testRecordDefaults() throws Exception { assertEquals(NotificationManager.IMPORTANCE_UNSPECIFIED, mHelper.getImportance(PKG, UID)); Loading Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +2 −0 Original line number Diff line number Diff line Loading @@ -3236,6 +3236,8 @@ public class NotificationManagerService extends SystemService { final String noChannelStr = "No Channel found for " + "pkg=" + pkg + ", channelId=" + channelId + ", id=" + id + ", tag=" + tag + ", opPkg=" + opPkg + ", callingUid=" + callingUid + ", userId=" + userId Loading
services/core/java/com/android/server/notification/RankingHelper.java +1 −0 Original line number Diff line number Diff line Loading @@ -1115,6 +1115,7 @@ public class RankingHelper implements RankingConfig { Record fullRecord = getRecord(pkg, mPm.getPackageUidAsUser(pkg, changeUserId)); if (fullRecord != null) { createDefaultChannelIfNeeded(fullRecord); deleteDefaultChannelIfNeeded(fullRecord); } } catch (NameNotFoundException e) {} Loading
services/tests/notification/src/com/android/server/notification/RankingHelperTest.java +19 −0 Original line number Diff line number Diff line Loading @@ -123,6 +123,7 @@ public class RankingHelperTest extends NotificationTestCase { when(mPm.getApplicationInfoAsUser(eq(PKG), anyInt(), anyInt())).thenReturn(legacy); when(mPm.getApplicationInfoAsUser(eq(UPDATED_PKG), anyInt(), anyInt())).thenReturn(upgrade); when(mPm.getPackageUidAsUser(eq(PKG), anyInt())).thenReturn(UID); when(mPm.getPackageUidAsUser(eq(UPDATED_PKG), anyInt())).thenReturn(UID2); when(mContext.getResources()).thenReturn( InstrumentationRegistry.getContext().getResources()); when(mContext.getPackageManager()).thenReturn(mPm); Loading Loading @@ -1045,6 +1046,24 @@ public class RankingHelperTest extends NotificationTestCase { assertEquals(0, mHelper.getNotificationChannelGroups(PKG, UID, true).getList().size()); } @Test public void testOnPackageChange_downgradeTargetSdk() throws Exception { // create channel as api 26 mHelper.createNotificationChannel(UPDATED_PKG, UID2, getChannel(), true); // install new app version targeting 25 final ApplicationInfo legacy = new ApplicationInfo(); legacy.targetSdkVersion = Build.VERSION_CODES.N_MR1; when(mPm.getApplicationInfoAsUser(eq(UPDATED_PKG), anyInt(), anyInt())).thenReturn(legacy); mHelper.onPackagesChanged( false, UserHandle.USER_SYSTEM, new String[]{UPDATED_PKG}, new int[]{UID2}); // make sure the default channel was readded //assertEquals(2, mHelper.getNotificationChannels(UPDATED_PKG, UID2, false).getList().size()); assertNotNull(mHelper.getNotificationChannel( UPDATED_PKG, UID2, NotificationChannel.DEFAULT_CHANNEL_ID, false)); } @Test public void testRecordDefaults() throws Exception { assertEquals(NotificationManager.IMPORTANCE_UNSPECIFIED, mHelper.getImportance(PKG, UID)); Loading