summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulia Reynolds <juliacr@google.com>2021-02-22 15:58:57 -0500
committerAnis Assi <anisassi@google.com>2021-03-31 12:19:35 -0700
commit67fae877f918a31ac9286972b97ae7667dd1eb1d (patch)
tree070489ce1ab58184d66ccdd383c1c8aab84e0894
parent6708fff83f72ca426546d1bf0bab436180813b77 (diff)
downloadbase-android-security-9.0.0_r68.tar.gz
Add pkg target to snoozing alarmandroid-security-9.0.0_r68
Test: SnoozeHelperTest Bug: 174493336 Change-Id: I6aaf80a11dcae2eca41d4647411126ed41587027 (cherry picked from commit 6b5813b1f10181f3949386201c4a8f5e6ed4d00f) Merged-In: I6aaf80a11dcae2eca41d4647411126ed41587027 (cherry picked from commit b341523840ed04c01542e476da71c02d1dd5fa8d)
-rw-r--r--services/core/java/com/android/server/notification/SnoozeHelper.java1
-rw-r--r--services/tests/uiservicestests/src/com/android/server/notification/SnoozeHelperTest.java11
2 files changed, 12 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/notification/SnoozeHelper.java b/services/core/java/com/android/server/notification/SnoozeHelper.java
index a178a525cede..732a58774b78 100644
--- a/services/core/java/com/android/server/notification/SnoozeHelper.java
+++ b/services/core/java/com/android/server/notification/SnoozeHelper.java
@@ -309,6 +309,7 @@ public class SnoozeHelper {
return PendingIntent.getBroadcast(mContext,
REQUEST_CODE_REPOST,
new Intent(REPOST_ACTION)
+ .setPackage("android")
.setData(new Uri.Builder().scheme(REPOST_SCHEME).appendPath(key).build())
.addFlags(Intent.FLAG_RECEIVER_FOREGROUND)
.putExtra(EXTRA_KEY, key)
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/SnoozeHelperTest.java b/services/tests/uiservicestests/src/com/android/server/notification/SnoozeHelperTest.java
index 88c6fcf138cf..7adfbd3cb777 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/SnoozeHelperTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/SnoozeHelperTest.java
@@ -46,6 +46,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.android.server.UiServiceTestCase;
+import com.android.server.pm.PackageManagerService;
@SmallTest
@@ -81,6 +82,16 @@ public class SnoozeHelperTest extends UiServiceTestCase {
}
@Test
+ public void testSnoozeSentToAndroid() throws Exception {
+ NotificationRecord r = getNotificationRecord("pkg", 1, "one", UserHandle.SYSTEM);
+ mSnoozeHelper.snooze(r, 1000);
+ ArgumentCaptor<PendingIntent> captor = ArgumentCaptor.forClass(PendingIntent.class);
+ verify(mAm, times(1)).setExactAndAllowWhileIdle(
+ anyInt(), anyLong(), captor.capture());
+ assertEquals("android", captor.getValue().getIntent().getPackage());
+ }
+
+ @Test
public void testSnooze() throws Exception {
NotificationRecord r = getNotificationRecord("pkg", 1, "one", UserHandle.SYSTEM);
mSnoozeHelper.snooze(r);