Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cd969f4c authored by Jaewan Kim's avatar Jaewan Kim Committed by Automerger Merge Worker
Browse files

[DO NOT MERGE] Verify package name and UID for trusted app check am: 0b998c2a

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16001113

Change-Id: Ie96a566eccd547f696ab96f626b558cf9c89b71f
parents b8bd7cbc 0b998c2a
Loading
Loading
Loading
Loading
+17 −0
Original line number Original line Diff line number Diff line
@@ -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))) {