Loading services/core/java/com/android/server/notification/NotificationManagerService.java +36 −16 Original line number Diff line number Diff line Loading @@ -107,7 +107,6 @@ import android.annotation.CallbackExecutor; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.RequiresPermission; import android.annotation.UserIdInt; import android.annotation.WorkerThread; import android.app.ActivityManager; import android.app.ActivityManagerInternal; Loading Loading @@ -155,6 +154,7 @@ import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.PackageManagerInternal; import android.content.pm.ParceledListSlice; import android.content.pm.ShortcutInfo; import android.content.pm.UserInfo; import android.content.res.Resources; import android.database.ContentObserver; Loading Loading @@ -1729,6 +1729,11 @@ public class NotificationManagerService extends SystemService { return mShortcutHelper; } @VisibleForTesting void setShortcutHelper(ShortcutHelper helper) { mShortcutHelper = helper; } @VisibleForTesting void setHints(int hints) { mListenerHints = hints; Loading Loading @@ -3459,11 +3464,15 @@ public class NotificationManagerService extends SystemService { ArrayList<ConversationChannelWrapper> conversations = mPreferencesHelper.getConversations(onlyImportant); for (ConversationChannelWrapper conversation : conversations) { if (mShortcutHelper == null) { conversation.setShortcutInfo(null); } else { conversation.setShortcutInfo(mShortcutHelper.getValidShortcutInfo( conversation.getNotificationChannel().getConversationId(), conversation.getPkg(), UserHandle.of(UserHandle.getUserId(conversation.getUid())))); } } return new ParceledListSlice<>(conversations); } Loading @@ -3482,11 +3491,15 @@ public class NotificationManagerService extends SystemService { ArrayList<ConversationChannelWrapper> conversations = mPreferencesHelper.getConversations(pkg, uid); for (ConversationChannelWrapper conversation : conversations) { if (mShortcutHelper == null) { conversation.setShortcutInfo(null); } else { conversation.setShortcutInfo(mShortcutHelper.getValidShortcutInfo( conversation.getNotificationChannel().getConversationId(), pkg, UserHandle.of(UserHandle.getUserId(uid)))); } } return new ParceledListSlice<>(conversations); } Loading Loading @@ -5680,8 +5693,10 @@ public class NotificationManagerService extends SystemService { } } r.setShortcutInfo(mShortcutHelper.getValidShortcutInfo( notification.getShortcutId(), pkg, user)); ShortcutInfo info = mShortcutHelper != null ? mShortcutHelper.getValidShortcutInfo(notification.getShortcutId(), pkg, user) : null; r.setShortcutInfo(info); if (!checkDisqualifyingFeatures(userId, notificationUid, id, tag, r, r.getSbn().getOverrideGroupKey() != null)) { Loading Loading @@ -6214,8 +6229,11 @@ public class NotificationManagerService extends SystemService { cancelGroupChildrenLocked(r, mCallingUid, mCallingPid, listenerName, mSendDelete, childrenFlagChecker); updateLightsLocked(); mShortcutHelper.maybeListenForShortcutChangesForBubbles(r, true /* isRemoved */, if (mShortcutHelper != null) { mShortcutHelper.maybeListenForShortcutChangesForBubbles(r, true /* isRemoved */, mHandler); } } else { // No notification was found, assume that it is snoozed and cancel it. if (mReason != REASON_SNOOZED) { Loading Loading @@ -6453,9 +6471,11 @@ public class NotificationManagerService extends SystemService { + n.getPackageName()); } if (mShortcutHelper != null) { mShortcutHelper.maybeListenForShortcutChangesForBubbles(r, false /* isRemoved */, mHandler); } maybeRecordInterruptionLocked(r); Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +15 −0 Original line number Diff line number Diff line Loading @@ -6504,4 +6504,19 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { assertNull(conversations.get(0).getShortcutInfo()); assertNull(conversations.get(1).getShortcutInfo()); } @Test public void testShortcutHelperNull_doesntCrashEnqueue() throws RemoteException { mService.setShortcutHelper(null); NotificationRecord nr = generateMessageBubbleNotifRecord(mTestNotificationChannel, "testShortcutHelperNull_doesntCrashEnqueue"); try { mBinderService.enqueueNotificationWithTag(PKG, PKG, nr.getSbn().getTag(), nr.getSbn().getId(), nr.getSbn().getNotification(), nr.getSbn().getUserId()); waitForIdle(); } catch (Exception e) { fail(e.getMessage()); } } } Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +36 −16 Original line number Diff line number Diff line Loading @@ -107,7 +107,6 @@ import android.annotation.CallbackExecutor; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.RequiresPermission; import android.annotation.UserIdInt; import android.annotation.WorkerThread; import android.app.ActivityManager; import android.app.ActivityManagerInternal; Loading Loading @@ -155,6 +154,7 @@ import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.PackageManagerInternal; import android.content.pm.ParceledListSlice; import android.content.pm.ShortcutInfo; import android.content.pm.UserInfo; import android.content.res.Resources; import android.database.ContentObserver; Loading Loading @@ -1729,6 +1729,11 @@ public class NotificationManagerService extends SystemService { return mShortcutHelper; } @VisibleForTesting void setShortcutHelper(ShortcutHelper helper) { mShortcutHelper = helper; } @VisibleForTesting void setHints(int hints) { mListenerHints = hints; Loading Loading @@ -3459,11 +3464,15 @@ public class NotificationManagerService extends SystemService { ArrayList<ConversationChannelWrapper> conversations = mPreferencesHelper.getConversations(onlyImportant); for (ConversationChannelWrapper conversation : conversations) { if (mShortcutHelper == null) { conversation.setShortcutInfo(null); } else { conversation.setShortcutInfo(mShortcutHelper.getValidShortcutInfo( conversation.getNotificationChannel().getConversationId(), conversation.getPkg(), UserHandle.of(UserHandle.getUserId(conversation.getUid())))); } } return new ParceledListSlice<>(conversations); } Loading @@ -3482,11 +3491,15 @@ public class NotificationManagerService extends SystemService { ArrayList<ConversationChannelWrapper> conversations = mPreferencesHelper.getConversations(pkg, uid); for (ConversationChannelWrapper conversation : conversations) { if (mShortcutHelper == null) { conversation.setShortcutInfo(null); } else { conversation.setShortcutInfo(mShortcutHelper.getValidShortcutInfo( conversation.getNotificationChannel().getConversationId(), pkg, UserHandle.of(UserHandle.getUserId(uid)))); } } return new ParceledListSlice<>(conversations); } Loading Loading @@ -5680,8 +5693,10 @@ public class NotificationManagerService extends SystemService { } } r.setShortcutInfo(mShortcutHelper.getValidShortcutInfo( notification.getShortcutId(), pkg, user)); ShortcutInfo info = mShortcutHelper != null ? mShortcutHelper.getValidShortcutInfo(notification.getShortcutId(), pkg, user) : null; r.setShortcutInfo(info); if (!checkDisqualifyingFeatures(userId, notificationUid, id, tag, r, r.getSbn().getOverrideGroupKey() != null)) { Loading Loading @@ -6214,8 +6229,11 @@ public class NotificationManagerService extends SystemService { cancelGroupChildrenLocked(r, mCallingUid, mCallingPid, listenerName, mSendDelete, childrenFlagChecker); updateLightsLocked(); mShortcutHelper.maybeListenForShortcutChangesForBubbles(r, true /* isRemoved */, if (mShortcutHelper != null) { mShortcutHelper.maybeListenForShortcutChangesForBubbles(r, true /* isRemoved */, mHandler); } } else { // No notification was found, assume that it is snoozed and cancel it. if (mReason != REASON_SNOOZED) { Loading Loading @@ -6453,9 +6471,11 @@ public class NotificationManagerService extends SystemService { + n.getPackageName()); } if (mShortcutHelper != null) { mShortcutHelper.maybeListenForShortcutChangesForBubbles(r, false /* isRemoved */, mHandler); } maybeRecordInterruptionLocked(r); Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +15 −0 Original line number Diff line number Diff line Loading @@ -6504,4 +6504,19 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { assertNull(conversations.get(0).getShortcutInfo()); assertNull(conversations.get(1).getShortcutInfo()); } @Test public void testShortcutHelperNull_doesntCrashEnqueue() throws RemoteException { mService.setShortcutHelper(null); NotificationRecord nr = generateMessageBubbleNotifRecord(mTestNotificationChannel, "testShortcutHelperNull_doesntCrashEnqueue"); try { mBinderService.enqueueNotificationWithTag(PKG, PKG, nr.getSbn().getTag(), nr.getSbn().getId(), nr.getSbn().getNotification(), nr.getSbn().getUserId()); waitForIdle(); } catch (Exception e) { fail(e.getMessage()); } } }