Loading services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java +1 −1 Original line number Diff line number Diff line Loading @@ -313,7 +313,7 @@ class MediaRouter2ServiceImpl { if (linkedItemLandingComponent != null) { int callingUid = Binder.getCallingUid(); MediaServerUtils.enforcePackageName( linkedItemLandingComponent.getPackageName(), callingUid); mContext, linkedItemLandingComponent.getPackageName(), callingUid); if (!MediaServerUtils.isValidActivityComponentName( mContext, linkedItemLandingComponent, Loading services/core/java/com/android/server/media/MediaServerUtils.java +8 −2 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.text.TextUtils; import com.android.server.LocalServices; import java.io.PrintWriter; import java.util.Arrays; import java.util.List; /** Util class for media server. */ Loading Loading @@ -63,7 +64,8 @@ import java.util.List; * @throws IllegalArgumentException If the given {@code packageName} does not correspond to the * given {@code uid}, and {@code uid} is not the root uid, or the shell uid. */ public static void enforcePackageName(String packageName, int uid) { public static void enforcePackageName( @NonNull Context context, @NonNull String packageName, int uid) { if (uid == Process.ROOT_UID || uid == Process.SHELL_UID) { return; } Loading @@ -76,12 +78,16 @@ import java.util.List; packageManagerInternal.getPackageUid( packageName, 0 /* flags */, UserHandle.getUserId(uid)); if (!UserHandle.isSameApp(uid, actualUid)) { String[] uidPackages = context.getPackageManager().getPackagesForUid(uid); throw new IllegalArgumentException( "packageName does not belong to the calling uid; " + "pkg=" + packageName + ", uid=" + uid); + uid + " (" + Arrays.toString(uidPackages) + ")"); } } Loading services/core/java/com/android/server/media/MediaSessionService.java +6 −6 Original line number Diff line number Diff line Loading @@ -542,7 +542,7 @@ public class MediaSessionService extends SystemService implements Monitor { int callingPid, int callingUid, String callingPackage, String reason) { final long token = Binder.clearCallingIdentity(); try { MediaServerUtils.enforcePackageName(callingPackage, callingUid); MediaServerUtils.enforcePackageName(mContext, callingPackage, callingUid); if (targetUid != callingUid) { boolean canAllowWhileInUse = mActivityManagerLocal .canAllowWhileInUsePermissionInFgs(callingPid, callingUid, callingPackage); Loading Loading @@ -1187,7 +1187,7 @@ public class MediaSessionService extends SystemService implements Monitor { final int uid = Binder.getCallingUid(); final long token = Binder.clearCallingIdentity(); try { MediaServerUtils.enforcePackageName(packageName, uid); MediaServerUtils.enforcePackageName(mContext, packageName, uid); int resolvedUserId = handleIncomingUser(pid, uid, userId, packageName); if (cb == null) { throw new IllegalArgumentException("Controller callback cannot be null"); Loading Loading @@ -1239,7 +1239,7 @@ public class MediaSessionService extends SystemService implements Monitor { final int userId = userHandle.getIdentifier(); final long token = Binder.clearCallingIdentity(); try { MediaServerUtils.enforcePackageName(packageName, uid); MediaServerUtils.enforcePackageName(mContext, packageName, uid); enforceMediaPermissions(packageName, pid, uid, userId); MediaSessionRecordImpl record; Loading Loading @@ -1270,7 +1270,7 @@ public class MediaSessionService extends SystemService implements Monitor { final int userId = userHandle.getIdentifier(); final long token = Binder.clearCallingIdentity(); try { MediaServerUtils.enforcePackageName(packageName, uid); MediaServerUtils.enforcePackageName(mContext, packageName, uid); enforceMediaPermissions(packageName, pid, uid, userId); MediaSessionRecordImpl record; Loading Loading @@ -1596,7 +1596,7 @@ public class MediaSessionService extends SystemService implements Monitor { final int userId = userHandle.getIdentifier(); final long token = Binder.clearCallingIdentity(); try { MediaServerUtils.enforcePackageName(packageName, uid); MediaServerUtils.enforcePackageName(mContext, packageName, uid); enforceMediaPermissions(packageName, pid, uid, userId); synchronized (mLock) { Loading Loading @@ -2110,7 +2110,7 @@ public class MediaSessionService extends SystemService implements Monitor { // If they gave us a component name verify they own the // package packageName = componentName.getPackageName(); MediaServerUtils.enforcePackageName(packageName, uid); MediaServerUtils.enforcePackageName(mContext, packageName, uid); } // Check that they can make calls on behalf of the user and get the final user id int resolvedUserId = handleIncomingUser(pid, uid, userId, packageName); Loading Loading
services/core/java/com/android/server/media/MediaRouter2ServiceImpl.java +1 −1 Original line number Diff line number Diff line Loading @@ -313,7 +313,7 @@ class MediaRouter2ServiceImpl { if (linkedItemLandingComponent != null) { int callingUid = Binder.getCallingUid(); MediaServerUtils.enforcePackageName( linkedItemLandingComponent.getPackageName(), callingUid); mContext, linkedItemLandingComponent.getPackageName(), callingUid); if (!MediaServerUtils.isValidActivityComponentName( mContext, linkedItemLandingComponent, Loading
services/core/java/com/android/server/media/MediaServerUtils.java +8 −2 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.text.TextUtils; import com.android.server.LocalServices; import java.io.PrintWriter; import java.util.Arrays; import java.util.List; /** Util class for media server. */ Loading Loading @@ -63,7 +64,8 @@ import java.util.List; * @throws IllegalArgumentException If the given {@code packageName} does not correspond to the * given {@code uid}, and {@code uid} is not the root uid, or the shell uid. */ public static void enforcePackageName(String packageName, int uid) { public static void enforcePackageName( @NonNull Context context, @NonNull String packageName, int uid) { if (uid == Process.ROOT_UID || uid == Process.SHELL_UID) { return; } Loading @@ -76,12 +78,16 @@ import java.util.List; packageManagerInternal.getPackageUid( packageName, 0 /* flags */, UserHandle.getUserId(uid)); if (!UserHandle.isSameApp(uid, actualUid)) { String[] uidPackages = context.getPackageManager().getPackagesForUid(uid); throw new IllegalArgumentException( "packageName does not belong to the calling uid; " + "pkg=" + packageName + ", uid=" + uid); + uid + " (" + Arrays.toString(uidPackages) + ")"); } } Loading
services/core/java/com/android/server/media/MediaSessionService.java +6 −6 Original line number Diff line number Diff line Loading @@ -542,7 +542,7 @@ public class MediaSessionService extends SystemService implements Monitor { int callingPid, int callingUid, String callingPackage, String reason) { final long token = Binder.clearCallingIdentity(); try { MediaServerUtils.enforcePackageName(callingPackage, callingUid); MediaServerUtils.enforcePackageName(mContext, callingPackage, callingUid); if (targetUid != callingUid) { boolean canAllowWhileInUse = mActivityManagerLocal .canAllowWhileInUsePermissionInFgs(callingPid, callingUid, callingPackage); Loading Loading @@ -1187,7 +1187,7 @@ public class MediaSessionService extends SystemService implements Monitor { final int uid = Binder.getCallingUid(); final long token = Binder.clearCallingIdentity(); try { MediaServerUtils.enforcePackageName(packageName, uid); MediaServerUtils.enforcePackageName(mContext, packageName, uid); int resolvedUserId = handleIncomingUser(pid, uid, userId, packageName); if (cb == null) { throw new IllegalArgumentException("Controller callback cannot be null"); Loading Loading @@ -1239,7 +1239,7 @@ public class MediaSessionService extends SystemService implements Monitor { final int userId = userHandle.getIdentifier(); final long token = Binder.clearCallingIdentity(); try { MediaServerUtils.enforcePackageName(packageName, uid); MediaServerUtils.enforcePackageName(mContext, packageName, uid); enforceMediaPermissions(packageName, pid, uid, userId); MediaSessionRecordImpl record; Loading Loading @@ -1270,7 +1270,7 @@ public class MediaSessionService extends SystemService implements Monitor { final int userId = userHandle.getIdentifier(); final long token = Binder.clearCallingIdentity(); try { MediaServerUtils.enforcePackageName(packageName, uid); MediaServerUtils.enforcePackageName(mContext, packageName, uid); enforceMediaPermissions(packageName, pid, uid, userId); MediaSessionRecordImpl record; Loading Loading @@ -1596,7 +1596,7 @@ public class MediaSessionService extends SystemService implements Monitor { final int userId = userHandle.getIdentifier(); final long token = Binder.clearCallingIdentity(); try { MediaServerUtils.enforcePackageName(packageName, uid); MediaServerUtils.enforcePackageName(mContext, packageName, uid); enforceMediaPermissions(packageName, pid, uid, userId); synchronized (mLock) { Loading Loading @@ -2110,7 +2110,7 @@ public class MediaSessionService extends SystemService implements Monitor { // If they gave us a component name verify they own the // package packageName = componentName.getPackageName(); MediaServerUtils.enforcePackageName(packageName, uid); MediaServerUtils.enforcePackageName(mContext, packageName, uid); } // Check that they can make calls on behalf of the user and get the final user id int resolvedUserId = handleIncomingUser(pid, uid, userId, packageName); Loading