Loading services/core/java/com/android/server/notification/NotificationManagerService.java +1 −0 Original line number Diff line number Diff line Loading @@ -7120,6 +7120,7 @@ public class NotificationManagerService extends SystemService { final PendingIntent pi = PendingIntent.getBroadcast(getContext(), REQUEST_CODE_TIMEOUT, new Intent(ACTION_NOTIFICATION_TIMEOUT) .setPackage(PackageManagerService.PLATFORM_PACKAGE_NAME) .setData(new Uri.Builder().scheme(SCHEME_TIMEOUT) .appendPath(record.getKey()).build()) .addFlags(Intent.FLAG_RECEIVER_FOREGROUND) Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +25 −0 Original line number Diff line number Diff line Loading @@ -93,6 +93,7 @@ import static org.mockito.Mockito.when; import android.app.ActivityManager; import android.app.ActivityManagerInternal; import android.app.AlarmManager; import android.app.AppOpsManager; import android.app.AutomaticZenRule; import android.app.IActivityManager; Loading Loading @@ -187,6 +188,7 @@ import com.android.server.lights.LightsManager; import com.android.server.lights.LogicalLight; import com.android.server.notification.NotificationManagerService.NotificationAssistants; import com.android.server.notification.NotificationManagerService.NotificationListeners; import com.android.server.pm.PackageManagerService; import com.android.server.statusbar.StatusBarManagerInternal; import com.android.server.uri.UriGrantsManagerInternal; import com.android.server.utils.quota.MultiRateLimiter; Loading Loading @@ -307,6 +309,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Mock StatsManager mStatsManager; @Mock AlarmManager mAlarmManager; @Mock MultiRateLimiter mToastRateLimiter; BroadcastReceiver mPackageIntentReceiver; NotificationRecordLoggerFake mNotificationRecordLogger = new NotificationRecordLoggerFake(); Loading Loading @@ -428,6 +432,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { LocalServices.addService(DeviceIdleInternal.class, deviceIdleInternal); LocalServices.removeServiceForTest(ActivityManagerInternal.class); LocalServices.addService(ActivityManagerInternal.class, mAmi); mContext.addMockSystemService(Context.ALARM_SERVICE, mAlarmManager); doNothing().when(mContext).sendBroadcastAsUser(any(), any(), any()); Loading Loading @@ -904,6 +909,26 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { return nrSummary; } @Test public void testLimitTimeOutBroadcast() { NotificationChannel channel = new NotificationChannel("id", "name", NotificationManager.IMPORTANCE_HIGH); Notification.Builder nb = new Notification.Builder(mContext, channel.getId()) .setContentTitle("foo") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setTimeoutAfter(1); StatusBarNotification sbn = new StatusBarNotification(PKG, PKG, 8, "tag", mUid, 0, nb.build(), UserHandle.getUserHandleForUid(mUid), null, 0); NotificationRecord r = new NotificationRecord(mContext, sbn, channel); mService.scheduleTimeoutLocked(r); ArgumentCaptor<PendingIntent> captor = ArgumentCaptor.forClass(PendingIntent.class); verify(mAlarmManager).setExactAndAllowWhileIdle(anyInt(), anyLong(), captor.capture()); assertEquals(PackageManagerService.PLATFORM_PACKAGE_NAME, captor.getValue().getIntent().getPackage()); } @Test public void testDefaultAssistant_overrideDefault() { final int userId = mContext.getUserId(); Loading Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +1 −0 Original line number Diff line number Diff line Loading @@ -7120,6 +7120,7 @@ public class NotificationManagerService extends SystemService { final PendingIntent pi = PendingIntent.getBroadcast(getContext(), REQUEST_CODE_TIMEOUT, new Intent(ACTION_NOTIFICATION_TIMEOUT) .setPackage(PackageManagerService.PLATFORM_PACKAGE_NAME) .setData(new Uri.Builder().scheme(SCHEME_TIMEOUT) .appendPath(record.getKey()).build()) .addFlags(Intent.FLAG_RECEIVER_FOREGROUND) Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +25 −0 Original line number Diff line number Diff line Loading @@ -93,6 +93,7 @@ import static org.mockito.Mockito.when; import android.app.ActivityManager; import android.app.ActivityManagerInternal; import android.app.AlarmManager; import android.app.AppOpsManager; import android.app.AutomaticZenRule; import android.app.IActivityManager; Loading Loading @@ -187,6 +188,7 @@ import com.android.server.lights.LightsManager; import com.android.server.lights.LogicalLight; import com.android.server.notification.NotificationManagerService.NotificationAssistants; import com.android.server.notification.NotificationManagerService.NotificationListeners; import com.android.server.pm.PackageManagerService; import com.android.server.statusbar.StatusBarManagerInternal; import com.android.server.uri.UriGrantsManagerInternal; import com.android.server.utils.quota.MultiRateLimiter; Loading Loading @@ -307,6 +309,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Mock StatsManager mStatsManager; @Mock AlarmManager mAlarmManager; @Mock MultiRateLimiter mToastRateLimiter; BroadcastReceiver mPackageIntentReceiver; NotificationRecordLoggerFake mNotificationRecordLogger = new NotificationRecordLoggerFake(); Loading Loading @@ -428,6 +432,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { LocalServices.addService(DeviceIdleInternal.class, deviceIdleInternal); LocalServices.removeServiceForTest(ActivityManagerInternal.class); LocalServices.addService(ActivityManagerInternal.class, mAmi); mContext.addMockSystemService(Context.ALARM_SERVICE, mAlarmManager); doNothing().when(mContext).sendBroadcastAsUser(any(), any(), any()); Loading Loading @@ -904,6 +909,26 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { return nrSummary; } @Test public void testLimitTimeOutBroadcast() { NotificationChannel channel = new NotificationChannel("id", "name", NotificationManager.IMPORTANCE_HIGH); Notification.Builder nb = new Notification.Builder(mContext, channel.getId()) .setContentTitle("foo") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setTimeoutAfter(1); StatusBarNotification sbn = new StatusBarNotification(PKG, PKG, 8, "tag", mUid, 0, nb.build(), UserHandle.getUserHandleForUid(mUid), null, 0); NotificationRecord r = new NotificationRecord(mContext, sbn, channel); mService.scheduleTimeoutLocked(r); ArgumentCaptor<PendingIntent> captor = ArgumentCaptor.forClass(PendingIntent.class); verify(mAlarmManager).setExactAndAllowWhileIdle(anyInt(), anyLong(), captor.capture()); assertEquals(PackageManagerService.PLATFORM_PACKAGE_NAME, captor.getValue().getIntent().getPackage()); } @Test public void testDefaultAssistant_overrideDefault() { final int userId = mContext.getUserId(); Loading