Loading services/core/java/com/android/server/notification/NotificationManagerService.java +5 −3 Original line number Diff line number Diff line Loading @@ -1952,10 +1952,12 @@ public class NotificationManagerService extends SystemService { */ @GuardedBy("mNotificationLock") protected void reportSeen(NotificationRecord r) { if (!r.isProxied()) { mAppUsageStats.reportEvent(r.sbn.getPackageName(), getRealUserId(r.sbn.getUserId()), UsageEvents.Event.NOTIFICATION_SEEN); } } protected int calculateSuppressedVisualEffects(Policy incomingPolicy, Policy currPolicy, int targetSdkVersion) { Loading services/core/java/com/android/server/notification/NotificationRecord.java +7 −1 Original line number Diff line number Diff line Loading @@ -151,7 +151,6 @@ public final class NotificationRecord { private int mSuppressedVisualEffects = 0; private String mUserExplanation; private String mPeopleExplanation; private boolean mPreChannelsNotification = true; private Uri mSound; private long[] mVibration; Loading Loading @@ -1190,6 +1189,13 @@ public final class NotificationRecord { return mSmartReplies; } /** * Returns whether this notification was posted by a secondary app */ public boolean isProxied() { return !Objects.equals(sbn.getPackageName(), sbn.getOpPkg()); } /** * @return all {@link Uri} that should have permission granted to whoever * will be rendering it. This list has already been vetted to only Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +24 −6 Original line number Diff line number Diff line Loading @@ -231,11 +231,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { return null; } @Override protected void reportSeen(NotificationRecord r) { return; } @Override protected void reportUserInteraction(NotificationRecord r) { return; Loading Loading @@ -3831,4 +3826,27 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { assertEquals(0, mService.countLogSmartSuggestionsVisible); } public void testReportSeen_delegated() { Notification.Builder nb = new Notification.Builder(mContext, mTestNotificationChannel.getId()) .setContentTitle("foo") .setSmallIcon(android.R.drawable.sym_def_app_icon); StatusBarNotification sbn = new StatusBarNotification(PKG, "opPkg", 0, "tag", mUid, 0, nb.build(), new UserHandle(mUid), null, 0); NotificationRecord r = new NotificationRecord(mContext, sbn, mTestNotificationChannel); mService.reportSeen(r); verify(mAppUsageStats, never()).reportEvent(anyString(), anyInt(), anyInt()); } @Test public void testReportSeen_notDelegated() { NotificationRecord r = generateNotificationRecord(mTestNotificationChannel); mService.reportSeen(r); verify(mAppUsageStats, times(1)).reportEvent(anyString(), anyInt(), anyInt()); } } Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +5 −3 Original line number Diff line number Diff line Loading @@ -1952,10 +1952,12 @@ public class NotificationManagerService extends SystemService { */ @GuardedBy("mNotificationLock") protected void reportSeen(NotificationRecord r) { if (!r.isProxied()) { mAppUsageStats.reportEvent(r.sbn.getPackageName(), getRealUserId(r.sbn.getUserId()), UsageEvents.Event.NOTIFICATION_SEEN); } } protected int calculateSuppressedVisualEffects(Policy incomingPolicy, Policy currPolicy, int targetSdkVersion) { Loading
services/core/java/com/android/server/notification/NotificationRecord.java +7 −1 Original line number Diff line number Diff line Loading @@ -151,7 +151,6 @@ public final class NotificationRecord { private int mSuppressedVisualEffects = 0; private String mUserExplanation; private String mPeopleExplanation; private boolean mPreChannelsNotification = true; private Uri mSound; private long[] mVibration; Loading Loading @@ -1190,6 +1189,13 @@ public final class NotificationRecord { return mSmartReplies; } /** * Returns whether this notification was posted by a secondary app */ public boolean isProxied() { return !Objects.equals(sbn.getPackageName(), sbn.getOpPkg()); } /** * @return all {@link Uri} that should have permission granted to whoever * will be rendering it. This list has already been vetted to only Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +24 −6 Original line number Diff line number Diff line Loading @@ -231,11 +231,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { return null; } @Override protected void reportSeen(NotificationRecord r) { return; } @Override protected void reportUserInteraction(NotificationRecord r) { return; Loading Loading @@ -3831,4 +3826,27 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { assertEquals(0, mService.countLogSmartSuggestionsVisible); } public void testReportSeen_delegated() { Notification.Builder nb = new Notification.Builder(mContext, mTestNotificationChannel.getId()) .setContentTitle("foo") .setSmallIcon(android.R.drawable.sym_def_app_icon); StatusBarNotification sbn = new StatusBarNotification(PKG, "opPkg", 0, "tag", mUid, 0, nb.build(), new UserHandle(mUid), null, 0); NotificationRecord r = new NotificationRecord(mContext, sbn, mTestNotificationChannel); mService.reportSeen(r); verify(mAppUsageStats, never()).reportEvent(anyString(), anyInt(), anyInt()); } @Test public void testReportSeen_notDelegated() { NotificationRecord r = generateNotificationRecord(mTestNotificationChannel); mService.reportSeen(r); verify(mAppUsageStats, times(1)).reportEvent(anyString(), anyInt(), anyInt()); } }