|
84 | 84 |
|
85 | 85 | import android.app.ActivityManager; |
86 | 86 | import android.app.ActivityManagerInternal; |
| 87 | +import android.app.AlarmManager; |
87 | 88 | import android.app.AppOpsManager; |
88 | 89 | import android.app.AutomaticZenRule; |
89 | 90 | import android.app.IActivityManager; |
|
171 | 172 | import com.android.server.lights.LogicalLight; |
172 | 173 | import com.android.server.notification.NotificationManagerService.NotificationAssistants; |
173 | 174 | import com.android.server.notification.NotificationManagerService.NotificationListeners; |
| 175 | +import com.android.server.pm.PackageManagerService; |
174 | 176 | import com.android.server.statusbar.StatusBarManagerInternal; |
175 | 177 | import com.android.server.uri.UriGrantsManagerInternal; |
176 | 178 | import com.android.server.wm.ActivityTaskManagerInternal; |
@@ -282,6 +284,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { |
282 | 284 | NotificationHistoryManager mHistoryManager; |
283 | 285 | @Mock |
284 | 286 | StatsManager mStatsManager; |
| 287 | + @Mock |
| 288 | + AlarmManager mAlarmManager; |
285 | 289 | NotificationRecordLoggerFake mNotificationRecordLogger = new NotificationRecordLoggerFake(); |
286 | 290 | private InstanceIdSequence mNotificationInstanceIdSequence = new InstanceIdSequenceFake( |
287 | 291 | 1 << 30); |
@@ -423,6 +427,8 @@ public void setUp() throws Exception { |
423 | 427 | LocalServices.addService(DeviceIdleInternal.class, deviceIdleInternal); |
424 | 428 | LocalServices.removeServiceForTest(ActivityManagerInternal.class); |
425 | 429 | LocalServices.addService(ActivityManagerInternal.class, activityManagerInternal); |
| 430 | + mContext.addMockSystemService(Context.ALARM_SERVICE, mAlarmManager); |
| 431 | + |
426 | 432 |
|
427 | 433 | doNothing().when(mContext).sendBroadcastAsUser(any(), any(), any()); |
428 | 434 |
|
@@ -831,6 +837,26 @@ private NotificationRecord addGroupWithBubblesAndValidateAdded(boolean summaryAu |
831 | 837 | return nrSummary; |
832 | 838 | } |
833 | 839 |
|
| 840 | + @Test |
| 841 | + public void testLimitTimeOutBroadcast() { |
| 842 | + NotificationChannel channel = new NotificationChannel("id", "name", |
| 843 | + NotificationManager.IMPORTANCE_HIGH); |
| 844 | + Notification.Builder nb = new Notification.Builder(mContext, channel.getId()) |
| 845 | + .setContentTitle("foo") |
| 846 | + .setSmallIcon(android.R.drawable.sym_def_app_icon) |
| 847 | + .setTimeoutAfter(1); |
| 848 | + |
| 849 | + StatusBarNotification sbn = new StatusBarNotification(PKG, PKG, 8, "tag", mUid, 0, |
| 850 | + nb.build(), UserHandle.getUserHandleForUid(mUid), null, 0); |
| 851 | + NotificationRecord r = new NotificationRecord(mContext, sbn, channel); |
| 852 | + |
| 853 | + mService.scheduleTimeoutLocked(r); |
| 854 | + ArgumentCaptor<PendingIntent> captor = ArgumentCaptor.forClass(PendingIntent.class); |
| 855 | + verify(mAlarmManager).setExactAndAllowWhileIdle(anyInt(), anyLong(), captor.capture()); |
| 856 | + assertEquals(PackageManagerService.PLATFORM_PACKAGE_NAME, |
| 857 | + captor.getValue().getIntent().getPackage()); |
| 858 | + } |
| 859 | + |
834 | 860 | @Test |
835 | 861 | public void testDefaultAssistant_overrideDefault() { |
836 | 862 | final int userId = 0; |
|
0 commit comments