Loading services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java +3 −5 Original line number Original line Diff line number Diff line Loading @@ -685,8 +685,7 @@ public class CompanionDeviceManagerService extends SystemService { public PendingIntent requestNotificationAccess(ComponentName component, int userId) public PendingIntent requestNotificationAccess(ComponentName component, int userId) throws RemoteException { throws RemoteException { String callingPackage = component.getPackageName(); String callingPackage = component.getPackageName(); checkCanCallNotificationApi(callingPackage); checkCanCallNotificationApi(callingPackage, userId); // TODO: check userId. if (component.flattenToString().length() > MAX_CN_LENGTH) { if (component.flattenToString().length() > MAX_CN_LENGTH) { throw new IllegalArgumentException("Component name is too long."); throw new IllegalArgumentException("Component name is too long."); } } Loading @@ -712,7 +711,7 @@ public class CompanionDeviceManagerService extends SystemService { @Deprecated @Deprecated @Override @Override public boolean hasNotificationAccess(ComponentName component) throws RemoteException { public boolean hasNotificationAccess(ComponentName component) throws RemoteException { checkCanCallNotificationApi(component.getPackageName()); checkCanCallNotificationApi(component.getPackageName(), getCallingUserId()); NotificationManager nm = getContext().getSystemService(NotificationManager.class); NotificationManager nm = getContext().getSystemService(NotificationManager.class); return nm.isNotificationListenerAccessGranted(component); return nm.isNotificationListenerAccessGranted(component); } } Loading Loading @@ -908,8 +907,7 @@ public class CompanionDeviceManagerService extends SystemService { createNewAssociation(userId, packageName, macAddressObj, null, null, false); createNewAssociation(userId, packageName, macAddressObj, null, null, false); } } private void checkCanCallNotificationApi(String callingPackage) { private void checkCanCallNotificationApi(String callingPackage, int userId) { final int userId = getCallingUserId(); enforceCallerIsSystemOr(userId, callingPackage); enforceCallerIsSystemOr(userId, callingPackage); if (getCallingUid() == SYSTEM_UID) return; if (getCallingUid() == SYSTEM_UID) return; Loading Loading
services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java +3 −5 Original line number Original line Diff line number Diff line Loading @@ -685,8 +685,7 @@ public class CompanionDeviceManagerService extends SystemService { public PendingIntent requestNotificationAccess(ComponentName component, int userId) public PendingIntent requestNotificationAccess(ComponentName component, int userId) throws RemoteException { throws RemoteException { String callingPackage = component.getPackageName(); String callingPackage = component.getPackageName(); checkCanCallNotificationApi(callingPackage); checkCanCallNotificationApi(callingPackage, userId); // TODO: check userId. if (component.flattenToString().length() > MAX_CN_LENGTH) { if (component.flattenToString().length() > MAX_CN_LENGTH) { throw new IllegalArgumentException("Component name is too long."); throw new IllegalArgumentException("Component name is too long."); } } Loading @@ -712,7 +711,7 @@ public class CompanionDeviceManagerService extends SystemService { @Deprecated @Deprecated @Override @Override public boolean hasNotificationAccess(ComponentName component) throws RemoteException { public boolean hasNotificationAccess(ComponentName component) throws RemoteException { checkCanCallNotificationApi(component.getPackageName()); checkCanCallNotificationApi(component.getPackageName(), getCallingUserId()); NotificationManager nm = getContext().getSystemService(NotificationManager.class); NotificationManager nm = getContext().getSystemService(NotificationManager.class); return nm.isNotificationListenerAccessGranted(component); return nm.isNotificationListenerAccessGranted(component); } } Loading Loading @@ -908,8 +907,7 @@ public class CompanionDeviceManagerService extends SystemService { createNewAssociation(userId, packageName, macAddressObj, null, null, false); createNewAssociation(userId, packageName, macAddressObj, null, null, false); } } private void checkCanCallNotificationApi(String callingPackage) { private void checkCanCallNotificationApi(String callingPackage, int userId) { final int userId = getCallingUserId(); enforceCallerIsSystemOr(userId, callingPackage); enforceCallerIsSystemOr(userId, callingPackage); if (getCallingUid() == SYSTEM_UID) return; if (getCallingUid() == SYSTEM_UID) return; Loading