OSDN Git Service
(root)
/
android-x86
/
frameworks-base.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[RESTRICT_AUTOMERGE]: Add cross user permission check - areNotificationsEnabledForPackage
[android-x86/frameworks-base.git]
/
services
/
core
/
java
/
com
/
android
/
server
/
notification
/
NotificationManagerService.java
diff --git
a/services/core/java/com/android/server/notification/NotificationManagerService.java
b/services/core/java/com/android/server/notification/NotificationManagerService.java
index
842ee91
..
4baec05
100644
(file)
--- a/
services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/
services/core/java/com/android/server/notification/NotificationManagerService.java
@@
-1196,7
+1196,6
@@
public class NotificationManagerService extends SystemService {
mAccessibilityManager = am;
}
mAccessibilityManager = am;
}
-
// TODO: All tests should use this init instead of the one-off setters above.
@VisibleForTesting
void init(Looper looper, IPackageManager packageManager,
// TODO: All tests should use this init instead of the one-off setters above.
@VisibleForTesting
void init(Looper looper, IPackageManager packageManager,
@@
-1768,6
+1767,11
@@
public class NotificationManagerService extends SystemService {
@Override
public boolean areNotificationsEnabledForPackage(String pkg, int uid) {
checkCallerIsSystemOrSameApp(pkg);
@Override
public boolean areNotificationsEnabledForPackage(String pkg, int uid) {
checkCallerIsSystemOrSameApp(pkg);
+ if (UserHandle.getCallingUserId() != UserHandle.getUserId(uid)) {
+ getContext().enforceCallingPermission(
+ android.Manifest.permission.INTERACT_ACROSS_USERS,
+ "canNotifyAsPackage for uid " + uid);
+ }
return mRankingHelper.getImportance(pkg, uid) != IMPORTANCE_NONE;
}
return mRankingHelper.getImportance(pkg, uid) != IMPORTANCE_NONE;
}
@@
-2764,19
+2768,25
@@
public class NotificationManagerService extends SystemService {
@Override
public void setNotificationPolicyAccessGranted(String pkg, boolean granted)
throws RemoteException {
@Override
public void setNotificationPolicyAccessGranted(String pkg, boolean granted)
throws RemoteException {
+ setNotificationPolicyAccessGrantedForUser(
+ pkg, getCallingUserHandle().getIdentifier(), granted);
+ }
+
+ @Override
+ public void setNotificationPolicyAccessGrantedForUser(
+ String pkg, int userId, boolean granted) {
checkCallerIsSystemOrShell();
final long identity = Binder.clearCallingIdentity();
try {
if (!mActivityManager.isLowRamDevice()) {
mConditionProviders.setPackageOrComponentEnabled(
checkCallerIsSystemOrShell();
final long identity = Binder.clearCallingIdentity();
try {
if (!mActivityManager.isLowRamDevice()) {
mConditionProviders.setPackageOrComponentEnabled(
- pkg,
getCallingUserHandle().getIdentifier()
, true, granted);
+ pkg,
userId
, true, granted);
getContext().sendBroadcastAsUser(new Intent(
NotificationManager.ACTION_NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED)
.setPackage(pkg)
.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY),
getContext().sendBroadcastAsUser(new Intent(
NotificationManager.ACTION_NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED)
.setPackage(pkg)
.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY),
- getCallingUserHandle(), null);
-
+ UserHandle.of(userId), null);
savePolicyFile();
}
} finally {
savePolicyFile();
}
} finally {
@@
-2871,11
+2881,10
@@
public class NotificationManagerService extends SystemService {
userId, true, granted);
getContext().sendBroadcastAsUser(new Intent(
userId, true, granted);
getContext().sendBroadcastAsUser(new Intent(
- NotificationManager.ACTION_NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED)
-
+ NotificationManager.ACTION_NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED)
.setPackage(listener.getPackageName())
.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY),
.setPackage(listener.getPackageName())
.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY),
-
getCallingUserHandle(
), null);
+
UserHandle.of(userId
), null);
savePolicyFile();
}
savePolicyFile();
}
@@
-2901,7
+2910,7
@@
public class NotificationManagerService extends SystemService {
NotificationManager.ACTION_NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED)
.setPackage(assistant.getPackageName())
.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY),
NotificationManager.ACTION_NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED)
.setPackage(assistant.getPackageName())
.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY),
-
getCallingUserHandle(
), null);
+
UserHandle.of(userId
), null);
savePolicyFile();
}
savePolicyFile();
}