Merge "Simply ignore invalid keys" into sc-qpr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
362b31f106
@@ -4363,8 +4363,7 @@ public class NotificationManagerService extends SystemService {
|
|||||||
final int userId = r.getSbn().getUserId();
|
final int userId = r.getSbn().getUserId();
|
||||||
if (userId != info.userid && userId != UserHandle.USER_ALL &&
|
if (userId != info.userid && userId != UserHandle.USER_ALL &&
|
||||||
!mUserProfiles.isCurrentProfile(userId)) {
|
!mUserProfiles.isCurrentProfile(userId)) {
|
||||||
throw new SecurityException("Disallowed call from listener: "
|
continue;
|
||||||
+ info.service);
|
|
||||||
}
|
}
|
||||||
cancelNotificationFromListenerLocked(info, callingUid, callingPid,
|
cancelNotificationFromListenerLocked(info, callingUid, callingPid,
|
||||||
r.getSbn().getPackageName(), r.getSbn().getTag(),
|
r.getSbn().getPackageName(), r.getSbn().getTag(),
|
||||||
@@ -4431,8 +4430,7 @@ public class NotificationManagerService extends SystemService {
|
|||||||
final int userId = r.getSbn().getUserId();
|
final int userId = r.getSbn().getUserId();
|
||||||
if (userId != info.userid && userId != UserHandle.USER_ALL
|
if (userId != info.userid && userId != UserHandle.USER_ALL
|
||||||
&& !mUserProfiles.isCurrentProfile(userId)) {
|
&& !mUserProfiles.isCurrentProfile(userId)) {
|
||||||
throw new SecurityException("Disallowed call from listener: "
|
continue;
|
||||||
+ info.service);
|
|
||||||
}
|
}
|
||||||
seen.add(r);
|
seen.add(r);
|
||||||
if (!r.isSeen()) {
|
if (!r.isSeen()) {
|
||||||
|
|||||||
@@ -4792,6 +4792,52 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
|
|||||||
verify(mAppUsageStats).reportInterruptiveNotification(anyString(), anyString(), anyInt());
|
verify(mAppUsageStats).reportInterruptiveNotification(anyString(), anyString(), anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSetNotificationsShownFromListener_protectsCrossUserInformation()
|
||||||
|
throws RemoteException {
|
||||||
|
Notification.Builder nb = new Notification.Builder(
|
||||||
|
mContext, mTestNotificationChannel.getId())
|
||||||
|
.setContentTitle("foo")
|
||||||
|
.setSmallIcon(android.R.drawable.sym_def_app_icon);
|
||||||
|
StatusBarNotification sbn = new StatusBarNotification(PKG, PKG, 1,
|
||||||
|
"tag" + System.currentTimeMillis(), UserHandle.PER_USER_RANGE, 0,
|
||||||
|
nb.build(), UserHandle.getUserHandleForUid(mUid + UserHandle.PER_USER_RANGE),
|
||||||
|
null, 0);
|
||||||
|
final NotificationRecord r =
|
||||||
|
new NotificationRecord(mContext, sbn, mTestNotificationChannel);
|
||||||
|
r.setTextChanged(true);
|
||||||
|
mService.addNotification(r);
|
||||||
|
|
||||||
|
// no security exception!
|
||||||
|
mBinderService.setNotificationsShownFromListener(null, new String[] {r.getKey()});
|
||||||
|
|
||||||
|
verify(mAppUsageStats, never()).reportInterruptiveNotification(
|
||||||
|
anyString(), anyString(), anyInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCancelNotificationsFromListener_protectsCrossUserInformation()
|
||||||
|
throws RemoteException {
|
||||||
|
Notification.Builder nb = new Notification.Builder(
|
||||||
|
mContext, mTestNotificationChannel.getId())
|
||||||
|
.setContentTitle("foo")
|
||||||
|
.setSmallIcon(android.R.drawable.sym_def_app_icon);
|
||||||
|
StatusBarNotification sbn = new StatusBarNotification(PKG, PKG, 1,
|
||||||
|
"tag" + System.currentTimeMillis(), UserHandle.PER_USER_RANGE, 0,
|
||||||
|
nb.build(), UserHandle.getUserHandleForUid(mUid + UserHandle.PER_USER_RANGE),
|
||||||
|
null, 0);
|
||||||
|
final NotificationRecord r =
|
||||||
|
new NotificationRecord(mContext, sbn, mTestNotificationChannel);
|
||||||
|
r.setTextChanged(true);
|
||||||
|
mService.addNotification(r);
|
||||||
|
|
||||||
|
// no security exception!
|
||||||
|
mBinderService.cancelNotificationsFromListener(null, new String[] {r.getKey()});
|
||||||
|
|
||||||
|
waitForIdle();
|
||||||
|
assertEquals(1, mService.getNotificationRecordCount());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMaybeRecordInterruptionLocked_doesNotRecordTwice()
|
public void testMaybeRecordInterruptionLocked_doesNotRecordTwice()
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
|
|||||||
Reference in New Issue
Block a user