Loading core/java/android/app/notification.aconfig +8 −1 Original line number Diff line number Diff line Loading @@ -167,3 +167,10 @@ flag { description: "[Minimal HUN] Enables the compact heads up notification reply capability for Conversation Notifications" bug: "336229954" } flag { name: "remove_remote_views" namespace: "systemui" description: "Removes all custom views" bug: "342602960" } services/core/java/com/android/server/notification/NotificationManagerService.java +32 −12 Original line number Diff line number Diff line Loading @@ -7774,6 +7774,25 @@ public class NotificationManagerService extends SystemService { } private void checkRemoteViews(String pkg, String tag, int id, Notification notification) { if (android.app.Flags.removeRemoteViews()) { if (notification.contentView != null || notification.bigContentView != null || notification.headsUpContentView != null || (notification.publicVersion != null && (notification.publicVersion.contentView != null || notification.publicVersion.bigContentView != null || notification.publicVersion.headsUpContentView != null))) { Slog.i(TAG, "Removed customViews for " + pkg); mUsageStats.registerImageRemoved(pkg); } notification.contentView = null; notification.bigContentView = null; notification.headsUpContentView = null; if (notification.publicVersion != null) { notification.publicVersion.contentView = null; notification.publicVersion.bigContentView = null; notification.publicVersion.headsUpContentView = null; } } else { if (removeRemoteView(pkg, tag, id, notification.contentView)) { notification.contentView = null; } Loading @@ -7795,6 +7814,7 @@ public class NotificationManagerService extends SystemService { } } } } private boolean removeRemoteView(String pkg, String tag, int id, RemoteViews contentView) { if (contentView == null) { Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +41 −0 Original line number Diff line number Diff line Loading @@ -10696,6 +10696,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { } @Test @DisableFlags(android.app.Flags.FLAG_REMOVE_REMOTE_VIEWS) public void testRemoveLargeRemoteViews() throws Exception { int removeSize = mContext.getResources().getInteger( com.android.internal.R.integer.config_notificationStripRemoteViewSizeBytes); Loading Loading @@ -10757,6 +10758,46 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { verify(mUsageStats, times(5)).registerImageRemoved(mPkg); } @Test @EnableFlags(android.app.Flags.FLAG_REMOVE_REMOTE_VIEWS) public void testRemoveRemoteViews() throws Exception { Notification np = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setContentText("test") .setCustomContentView(mock(RemoteViews.class)) .setCustomBigContentView(mock(RemoteViews.class)) .setCustomHeadsUpContentView(mock(RemoteViews.class)) .build(); Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setContentText("test") .setCustomContentView(mock(RemoteViews.class)) .setCustomBigContentView(mock(RemoteViews.class)) .setCustomHeadsUpContentView(mock(RemoteViews.class)) .setPublicVersion(np) .build(); assertNotNull(n.contentView); assertNotNull(n.bigContentView); assertNotNull(n.headsUpContentView); assertTrue(np.extras.containsKey(Notification.EXTRA_CONTAINS_CUSTOM_VIEW)); assertNotNull(np.contentView); assertNotNull(np.bigContentView); assertNotNull(np.headsUpContentView); mService.fixNotification(n, mPkg, "tag", 9, 0, mUid, NOT_FOREGROUND_SERVICE, true); assertNull(n.contentView); assertNull(n.bigContentView); assertNull(n.headsUpContentView); assertNull(n.publicVersion.contentView); assertNull(n.publicVersion.bigContentView); assertNull(n.publicVersion.headsUpContentView); verify(mUsageStats, times(1)).registerImageRemoved(mPkg); } @Test public void testNotificationBubbles_flagAutoExpandForeground_fails_notForeground() throws Exception { Loading Loading
core/java/android/app/notification.aconfig +8 −1 Original line number Diff line number Diff line Loading @@ -167,3 +167,10 @@ flag { description: "[Minimal HUN] Enables the compact heads up notification reply capability for Conversation Notifications" bug: "336229954" } flag { name: "remove_remote_views" namespace: "systemui" description: "Removes all custom views" bug: "342602960" }
services/core/java/com/android/server/notification/NotificationManagerService.java +32 −12 Original line number Diff line number Diff line Loading @@ -7774,6 +7774,25 @@ public class NotificationManagerService extends SystemService { } private void checkRemoteViews(String pkg, String tag, int id, Notification notification) { if (android.app.Flags.removeRemoteViews()) { if (notification.contentView != null || notification.bigContentView != null || notification.headsUpContentView != null || (notification.publicVersion != null && (notification.publicVersion.contentView != null || notification.publicVersion.bigContentView != null || notification.publicVersion.headsUpContentView != null))) { Slog.i(TAG, "Removed customViews for " + pkg); mUsageStats.registerImageRemoved(pkg); } notification.contentView = null; notification.bigContentView = null; notification.headsUpContentView = null; if (notification.publicVersion != null) { notification.publicVersion.contentView = null; notification.publicVersion.bigContentView = null; notification.publicVersion.headsUpContentView = null; } } else { if (removeRemoteView(pkg, tag, id, notification.contentView)) { notification.contentView = null; } Loading @@ -7795,6 +7814,7 @@ public class NotificationManagerService extends SystemService { } } } } private boolean removeRemoteView(String pkg, String tag, int id, RemoteViews contentView) { if (contentView == null) { Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +41 −0 Original line number Diff line number Diff line Loading @@ -10696,6 +10696,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { } @Test @DisableFlags(android.app.Flags.FLAG_REMOVE_REMOTE_VIEWS) public void testRemoveLargeRemoteViews() throws Exception { int removeSize = mContext.getResources().getInteger( com.android.internal.R.integer.config_notificationStripRemoteViewSizeBytes); Loading Loading @@ -10757,6 +10758,46 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { verify(mUsageStats, times(5)).registerImageRemoved(mPkg); } @Test @EnableFlags(android.app.Flags.FLAG_REMOVE_REMOTE_VIEWS) public void testRemoveRemoteViews() throws Exception { Notification np = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setContentText("test") .setCustomContentView(mock(RemoteViews.class)) .setCustomBigContentView(mock(RemoteViews.class)) .setCustomHeadsUpContentView(mock(RemoteViews.class)) .build(); Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setContentText("test") .setCustomContentView(mock(RemoteViews.class)) .setCustomBigContentView(mock(RemoteViews.class)) .setCustomHeadsUpContentView(mock(RemoteViews.class)) .setPublicVersion(np) .build(); assertNotNull(n.contentView); assertNotNull(n.bigContentView); assertNotNull(n.headsUpContentView); assertTrue(np.extras.containsKey(Notification.EXTRA_CONTAINS_CUSTOM_VIEW)); assertNotNull(np.contentView); assertNotNull(np.bigContentView); assertNotNull(np.headsUpContentView); mService.fixNotification(n, mPkg, "tag", 9, 0, mUid, NOT_FOREGROUND_SERVICE, true); assertNull(n.contentView); assertNull(n.bigContentView); assertNull(n.headsUpContentView); assertNull(n.publicVersion.contentView); assertNull(n.publicVersion.bigContentView); assertNull(n.publicVersion.headsUpContentView); verify(mUsageStats, times(1)).registerImageRemoved(mPkg); } @Test public void testNotificationBubbles_flagAutoExpandForeground_fails_notForeground() throws Exception { Loading