[DO NOT MERGE] Verify package name and UID for trusted app check
Bug: 179783181 Test: Run CTS Change-Id: I19e52fef310762dc1d4193901cfc6c23370115b6
This commit is contained in:
@@ -2128,6 +2128,23 @@ public class MediaSessionService extends SystemService implements Monitor {
|
|||||||
// Enabled notification listener only works within the same user.
|
// Enabled notification listener only works within the same user.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// Verify whether package name and controller UID.
|
||||||
|
// It will indirectly check whether the caller has obtained the package name and UID
|
||||||
|
// via ControllerInfo or with the valid package name visibility.
|
||||||
|
try {
|
||||||
|
int actualControllerUid = mContext.getPackageManager().getPackageUidAsUser(
|
||||||
|
controllerPackageName,
|
||||||
|
UserHandle.getUserId(controllerUid));
|
||||||
|
if (controllerUid != actualControllerUid) {
|
||||||
|
Log.w(TAG, "Failed to check enabled notification listener. Package name and"
|
||||||
|
+ " UID doesn't match");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
Log.w(TAG, "Failed to check enabled notification listener. Package name doesn't"
|
||||||
|
+ " exist");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (mNotificationManager.hasEnabledNotificationListener(controllerPackageName,
|
if (mNotificationManager.hasEnabledNotificationListener(controllerPackageName,
|
||||||
UserHandle.getUserHandleForUid(controllerUid))) {
|
UserHandle.getUserHandleForUid(controllerUid))) {
|
||||||
|
|||||||
Reference in New Issue
Block a user