Skip to content
Snippets Groups Projects
Commit 38e1e9fb authored by Evan Chen's avatar Evan Chen
Browse files

Do not allow setting notification access across users.

For mutil user case, make sure the calling userid
matching the passing userid

Test: test it on sample app
Bug: 298635078
Change-Id: I6c478ebcc1d981faf2d125a4b41909c3b6a30a2a
parent d14c585e
No related branches found
No related tags found
No related merge requests found
......@@ -756,8 +756,7 @@ public class CompanionDeviceManagerService extends SystemService {
public PendingIntent requestNotificationAccess(ComponentName component, int userId)
throws RemoteException {
String callingPackage = component.getPackageName();
checkCanCallNotificationApi(callingPackage);
// TODO: check userId.
checkCanCallNotificationApi(callingPackage, userId);
if (component.flattenToString().length() > MAX_CN_LENGTH) {
throw new IllegalArgumentException("Component name is too long.");
}
......@@ -783,7 +782,7 @@ public class CompanionDeviceManagerService extends SystemService {
@Deprecated
@Override
public boolean hasNotificationAccess(ComponentName component) throws RemoteException {
checkCanCallNotificationApi(component.getPackageName());
checkCanCallNotificationApi(component.getPackageName(), getCallingUserId());
NotificationManager nm = getContext().getSystemService(NotificationManager.class);
return nm.isNotificationListenerAccessGranted(component);
}
......@@ -1017,8 +1016,7 @@ public class CompanionDeviceManagerService extends SystemService {
createNewAssociation(userId, packageName, macAddressObj, null, null, false);
}
private void checkCanCallNotificationApi(String callingPackage) {
final int userId = getCallingUserId();
private void checkCanCallNotificationApi(String callingPackage, int userId) {
enforceCallerIsSystemOr(userId, callingPackage);
if (getCallingUid() == SYSTEM_UID) return;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment