Loading services/core/java/com/android/server/media/quality/MediaQualityService.java +20 −14 Original line number Diff line number Diff line Loading @@ -1006,7 +1006,7 @@ public class MediaQualityService extends SystemService { int callingPid = Binder.getCallingPid(); mHandler.post(() -> { Long dbId = mSoundProfileTempIdMap.getKey(id); if (!hasPermissionToUpdateSoundProfile(dbId, sp, callingUid)) { if (!hasPermissionToUpdateSoundProfile(dbId, sp, callingUid, callingPid)) { mMqManagerNotifier.notifyOnSoundProfileError( id, SoundProfile.ERROR_NO_PERMISSION, callingUid, callingPid); Slog.e(TAG, "updateSoundProfile: no permission to update sound profile"); Loading @@ -1027,12 +1027,16 @@ public class MediaQualityService extends SystemService { }); } private boolean hasPermissionToUpdateSoundProfile(Long dbId, SoundProfile sp, int uid) { private boolean hasPermissionToUpdateSoundProfile( Long dbId, SoundProfile toUpdate, int uid, int pid) { SoundProfile fromDb = mMqDatabaseUtils.getSoundProfile(dbId); return fromDb.getProfileType() == sp.getProfileType() && fromDb.getPackageName().equals(sp.getPackageName()) && fromDb.getName().equals(sp.getName()) && fromDb.getPackageName().equals(getPackageOfUid(uid)); boolean isPackageOwner = fromDb.getPackageName().equals(getPackageOfUid(uid)); boolean isSystemAppWithPermission = hasGlobalSoundQualityServicePermission(uid, pid) && fromDb.getProfileType() == PictureProfile.TYPE_SYSTEM; return fromDb.getProfileType() == toUpdate.getProfileType() && fromDb.getName().equals(toUpdate.getName()) && fromDb.getPackageName().equals(toUpdate.getPackageName()) && (isPackageOwner || isSystemAppWithPermission); } @GuardedBy("mSoundProfileLock") Loading Loading @@ -1257,13 +1261,6 @@ public class MediaQualityService extends SystemService { return incomingPackage.equalsIgnoreCase(getPackageOfUid(uid)); } private boolean hasGlobalSoundQualityServicePermission(int uid, int pid) { return mContext.checkPermission( android.Manifest.permission.MANAGE_GLOBAL_SOUND_QUALITY_SERVICE, pid, uid) == PackageManager.PERMISSION_GRANTED; } private boolean hasReadColorZonesPermission(int uid, int pid) { return mContext.checkPermission(android.Manifest.permission.READ_COLOR_ZONES, pid, uid) == PackageManager.PERMISSION_GRANTED; Loading Loading @@ -2128,7 +2125,10 @@ public class MediaQualityService extends SystemService { Pair<Integer, Integer> pidUid = userState.mSoundProfileCallbackPidUidMap .get(callback); if (pidUid.first == pid && pidUid.second == uid) { if ((pidUid.first == pid && pidUid.second == uid) || (hasGlobalSoundQualityServicePermission(pidUid.second, pidUid.first) && profile != null && profile.getProfileType() == PictureProfile.TYPE_SYSTEM)) { if (mode == ProfileModes.ADD) { userState.mSoundProfileCallbacks.getBroadcastItem(i) .onSoundProfileAdded(profileId, profile); Loading Loading @@ -2882,6 +2882,12 @@ public class MediaQualityService extends SystemService { == PackageManager.PERMISSION_GRANTED; } private boolean hasGlobalSoundQualityServicePermission(int uid, int pid) { return mContext.checkPermission( android.Manifest.permission.MANAGE_GLOBAL_SOUND_QUALITY_SERVICE, pid, uid) == PackageManager.PERMISSION_GRANTED; } private PictureProfile getSdrPictureProfile(String profileName, PictureProfile previous) { Log.d(TAG, "getSdrPictureProfile: profileName = " + profileName + " previous profile name = " + previous.getName()); Loading Loading
services/core/java/com/android/server/media/quality/MediaQualityService.java +20 −14 Original line number Diff line number Diff line Loading @@ -1006,7 +1006,7 @@ public class MediaQualityService extends SystemService { int callingPid = Binder.getCallingPid(); mHandler.post(() -> { Long dbId = mSoundProfileTempIdMap.getKey(id); if (!hasPermissionToUpdateSoundProfile(dbId, sp, callingUid)) { if (!hasPermissionToUpdateSoundProfile(dbId, sp, callingUid, callingPid)) { mMqManagerNotifier.notifyOnSoundProfileError( id, SoundProfile.ERROR_NO_PERMISSION, callingUid, callingPid); Slog.e(TAG, "updateSoundProfile: no permission to update sound profile"); Loading @@ -1027,12 +1027,16 @@ public class MediaQualityService extends SystemService { }); } private boolean hasPermissionToUpdateSoundProfile(Long dbId, SoundProfile sp, int uid) { private boolean hasPermissionToUpdateSoundProfile( Long dbId, SoundProfile toUpdate, int uid, int pid) { SoundProfile fromDb = mMqDatabaseUtils.getSoundProfile(dbId); return fromDb.getProfileType() == sp.getProfileType() && fromDb.getPackageName().equals(sp.getPackageName()) && fromDb.getName().equals(sp.getName()) && fromDb.getPackageName().equals(getPackageOfUid(uid)); boolean isPackageOwner = fromDb.getPackageName().equals(getPackageOfUid(uid)); boolean isSystemAppWithPermission = hasGlobalSoundQualityServicePermission(uid, pid) && fromDb.getProfileType() == PictureProfile.TYPE_SYSTEM; return fromDb.getProfileType() == toUpdate.getProfileType() && fromDb.getName().equals(toUpdate.getName()) && fromDb.getPackageName().equals(toUpdate.getPackageName()) && (isPackageOwner || isSystemAppWithPermission); } @GuardedBy("mSoundProfileLock") Loading Loading @@ -1257,13 +1261,6 @@ public class MediaQualityService extends SystemService { return incomingPackage.equalsIgnoreCase(getPackageOfUid(uid)); } private boolean hasGlobalSoundQualityServicePermission(int uid, int pid) { return mContext.checkPermission( android.Manifest.permission.MANAGE_GLOBAL_SOUND_QUALITY_SERVICE, pid, uid) == PackageManager.PERMISSION_GRANTED; } private boolean hasReadColorZonesPermission(int uid, int pid) { return mContext.checkPermission(android.Manifest.permission.READ_COLOR_ZONES, pid, uid) == PackageManager.PERMISSION_GRANTED; Loading Loading @@ -2128,7 +2125,10 @@ public class MediaQualityService extends SystemService { Pair<Integer, Integer> pidUid = userState.mSoundProfileCallbackPidUidMap .get(callback); if (pidUid.first == pid && pidUid.second == uid) { if ((pidUid.first == pid && pidUid.second == uid) || (hasGlobalSoundQualityServicePermission(pidUid.second, pidUid.first) && profile != null && profile.getProfileType() == PictureProfile.TYPE_SYSTEM)) { if (mode == ProfileModes.ADD) { userState.mSoundProfileCallbacks.getBroadcastItem(i) .onSoundProfileAdded(profileId, profile); Loading Loading @@ -2882,6 +2882,12 @@ public class MediaQualityService extends SystemService { == PackageManager.PERMISSION_GRANTED; } private boolean hasGlobalSoundQualityServicePermission(int uid, int pid) { return mContext.checkPermission( android.Manifest.permission.MANAGE_GLOBAL_SOUND_QUALITY_SERVICE, pid, uid) == PackageManager.PERMISSION_GRANTED; } private PictureProfile getSdrPictureProfile(String profileName, PictureProfile previous) { Log.d(TAG, "getSdrPictureProfile: profileName = " + profileName + " previous profile name = " + previous.getName()); Loading