Loading media/java/android/media/quality/aidl/android/media/quality/IMediaQualityManager.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -47,7 +47,7 @@ interface IMediaQualityManager { void setPictureProfileAllowList(in List<String> packages, int userId); List<PictureProfileHandle> getPictureProfileHandle(in String[] id, int userId); SoundProfile createSoundProfile(in SoundProfile pp, int userId); void createSoundProfile(in SoundProfile pp, int userId); void updateSoundProfile(in String id, in SoundProfile pp, int userId); void removeSoundProfile(in String id, int userId); boolean setDefaultSoundProfile(in String id, int userId); Loading services/core/java/com/android/server/media/quality/MediaQualityService.java +180 −157 Original line number Diff line number Diff line Loading @@ -230,6 +230,7 @@ public class MediaQualityService extends SystemService { @GuardedBy("mPictureProfileLock") @Override public void updatePictureProfile(String id, PictureProfile pp, int userId) { mHandler.post(() -> { Long dbId = mPictureProfileTempIdMap.getKey(id); if (!hasPermissionToUpdatePictureProfile(dbId, pp)) { mMqManagerNotifier.notifyOnPictureProfileError(id, Loading @@ -243,8 +244,10 @@ public class MediaQualityService extends SystemService { pp.getPackageName(), pp.getInputId(), pp.getParameters()); updateDatabaseOnPictureProfileAndNotifyManagerAndHal(values, pp.getParameters()); updateDatabaseOnPictureProfileAndNotifyManagerAndHal(values, pp.getParameters()); } }); } private boolean hasPermissionToUpdatePictureProfile(Long dbId, PictureProfile toUpdate) { Loading @@ -258,6 +261,7 @@ public class MediaQualityService extends SystemService { @GuardedBy("mPictureProfileLock") @Override public void removePictureProfile(String id, int userId) { mHandler.post(() -> { synchronized (mPictureProfileLock) { Long dbId = mPictureProfileTempIdMap.getKey(id); Loading Loading @@ -287,6 +291,7 @@ public class MediaQualityService extends SystemService { } } } }); } private boolean hasPermissionToRemovePictureProfile(PictureProfile toDelete) { Loading Loading @@ -448,7 +453,8 @@ public class MediaQualityService extends SystemService { @GuardedBy("mSoundProfileLock") @Override public SoundProfile createSoundProfile(SoundProfile sp, int userId) { public void createSoundProfile(SoundProfile sp, int userId) { mHandler.post(() -> { if ((sp.getPackageName() != null && !sp.getPackageName().isEmpty() && !incomingPackageEqualsCallingUidPackage(sp.getPackageName())) && !hasGlobalSoundQualityServicePermission()) { Loading @@ -475,16 +481,18 @@ public class MediaQualityService extends SystemService { sp.setProfileId(value); mMqManagerNotifier.notifyOnSoundProfileAdded(value, sp, Binder.getCallingUid(), Binder.getCallingPid()); return sp; } }); } @GuardedBy("mSoundProfileLock") @Override public void updateSoundProfile(String id, SoundProfile sp, int userId) { mHandler.post(() -> { Long dbId = mSoundProfileTempIdMap.getKey(id); if (!hasPermissionToUpdateSoundProfile(dbId, sp)) { mMqManagerNotifier.notifyOnSoundProfileError(id, SoundProfile.ERROR_NO_PERMISSION, mMqManagerNotifier.notifyOnSoundProfileError(id, SoundProfile.ERROR_NO_PERMISSION, Binder.getCallingUid(), Binder.getCallingPid()); } Loading @@ -498,6 +506,7 @@ public class MediaQualityService extends SystemService { updateDatabaseOnSoundProfileAndNotifyManagerAndHal(values, sp.getParameters()); } }); } private boolean hasPermissionToUpdateSoundProfile(Long dbId, SoundProfile sp) { Loading @@ -511,6 +520,7 @@ public class MediaQualityService extends SystemService { @GuardedBy("mSoundProfileLock") @Override public void removeSoundProfile(String id, int userId) { mHandler.post(() -> { synchronized (mSoundProfileLock) { Long dbId = mSoundProfileTempIdMap.getKey(id); SoundProfile toDelete = mMqDatabaseUtils.getSoundProfile(dbId); Loading Loading @@ -539,6 +549,7 @@ public class MediaQualityService extends SystemService { } } } }); } private boolean hasPermissionToRemoveSoundProfile(SoundProfile toDelete) { Loading Loading @@ -849,6 +860,7 @@ public class MediaQualityService extends SystemService { @GuardedBy("mPictureProfileLock") @Override public void setPictureProfileAllowList(List<String> packages, int userId) { mHandler.post(() -> { if (!hasGlobalPictureQualityServicePermission()) { mMqManagerNotifier.notifyOnPictureProfileError(null, PictureProfile.ERROR_NO_PERMISSION, Loading @@ -857,6 +869,7 @@ public class MediaQualityService extends SystemService { SharedPreferences.Editor editor = mPictureProfileSharedPreference.edit(); editor.putString(ALLOWLIST, String.join(COMMA_DELIMITER, packages)); editor.commit(); }); } @GuardedBy("mSoundProfileLock") Loading @@ -877,13 +890,16 @@ public class MediaQualityService extends SystemService { @GuardedBy("mSoundProfileLock") @Override public void setSoundProfileAllowList(List<String> packages, int userId) { mHandler.post(() -> { if (!hasGlobalSoundQualityServicePermission()) { mMqManagerNotifier.notifyOnSoundProfileError(null, SoundProfile.ERROR_NO_PERMISSION, mMqManagerNotifier.notifyOnSoundProfileError(null, SoundProfile.ERROR_NO_PERMISSION, Binder.getCallingUid(), Binder.getCallingPid()); } SharedPreferences.Editor editor = mSoundProfileSharedPreference.edit(); editor.putString(ALLOWLIST, String.join(COMMA_DELIMITER, packages)); editor.commit(); }); } @Override Loading @@ -894,6 +910,7 @@ public class MediaQualityService extends SystemService { @GuardedBy("mPictureProfileLock") @Override public void setAutoPictureQualityEnabled(boolean enabled, int userId) { mHandler.post(() -> { if (!hasGlobalPictureQualityServicePermission()) { mMqManagerNotifier.notifyOnPictureProfileError(null, PictureProfile.ERROR_NO_PERMISSION, Loading @@ -910,6 +927,7 @@ public class MediaQualityService extends SystemService { Slog.e(TAG, "Failed to set auto picture quality", e); } } }); } @GuardedBy("mPictureProfileLock") Loading @@ -932,6 +950,7 @@ public class MediaQualityService extends SystemService { @GuardedBy("mPictureProfileLock") @Override public void setSuperResolutionEnabled(boolean enabled, int userId) { mHandler.post(() -> { if (!hasGlobalPictureQualityServicePermission()) { mMqManagerNotifier.notifyOnPictureProfileError(null, PictureProfile.ERROR_NO_PERMISSION, Loading @@ -948,6 +967,7 @@ public class MediaQualityService extends SystemService { Slog.e(TAG, "Failed to set super resolution", e); } } }); } @GuardedBy("mPictureProfileLock") Loading @@ -970,8 +990,10 @@ public class MediaQualityService extends SystemService { @GuardedBy("mSoundProfileLock") @Override public void setAutoSoundQualityEnabled(boolean enabled, int userId) { mHandler.post(() -> { if (!hasGlobalSoundQualityServicePermission()) { mMqManagerNotifier.notifyOnSoundProfileError(null, SoundProfile.ERROR_NO_PERMISSION, mMqManagerNotifier.notifyOnSoundProfileError(null, SoundProfile.ERROR_NO_PERMISSION, Binder.getCallingUid(), Binder.getCallingPid()); } Loading @@ -986,6 +1008,7 @@ public class MediaQualityService extends SystemService { Slog.e(TAG, "Failed to set auto sound quality", e); } } }); } @GuardedBy("mSoundProfileLock") Loading Loading
media/java/android/media/quality/aidl/android/media/quality/IMediaQualityManager.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -47,7 +47,7 @@ interface IMediaQualityManager { void setPictureProfileAllowList(in List<String> packages, int userId); List<PictureProfileHandle> getPictureProfileHandle(in String[] id, int userId); SoundProfile createSoundProfile(in SoundProfile pp, int userId); void createSoundProfile(in SoundProfile pp, int userId); void updateSoundProfile(in String id, in SoundProfile pp, int userId); void removeSoundProfile(in String id, int userId); boolean setDefaultSoundProfile(in String id, int userId); Loading
services/core/java/com/android/server/media/quality/MediaQualityService.java +180 −157 Original line number Diff line number Diff line Loading @@ -230,6 +230,7 @@ public class MediaQualityService extends SystemService { @GuardedBy("mPictureProfileLock") @Override public void updatePictureProfile(String id, PictureProfile pp, int userId) { mHandler.post(() -> { Long dbId = mPictureProfileTempIdMap.getKey(id); if (!hasPermissionToUpdatePictureProfile(dbId, pp)) { mMqManagerNotifier.notifyOnPictureProfileError(id, Loading @@ -243,8 +244,10 @@ public class MediaQualityService extends SystemService { pp.getPackageName(), pp.getInputId(), pp.getParameters()); updateDatabaseOnPictureProfileAndNotifyManagerAndHal(values, pp.getParameters()); updateDatabaseOnPictureProfileAndNotifyManagerAndHal(values, pp.getParameters()); } }); } private boolean hasPermissionToUpdatePictureProfile(Long dbId, PictureProfile toUpdate) { Loading @@ -258,6 +261,7 @@ public class MediaQualityService extends SystemService { @GuardedBy("mPictureProfileLock") @Override public void removePictureProfile(String id, int userId) { mHandler.post(() -> { synchronized (mPictureProfileLock) { Long dbId = mPictureProfileTempIdMap.getKey(id); Loading Loading @@ -287,6 +291,7 @@ public class MediaQualityService extends SystemService { } } } }); } private boolean hasPermissionToRemovePictureProfile(PictureProfile toDelete) { Loading Loading @@ -448,7 +453,8 @@ public class MediaQualityService extends SystemService { @GuardedBy("mSoundProfileLock") @Override public SoundProfile createSoundProfile(SoundProfile sp, int userId) { public void createSoundProfile(SoundProfile sp, int userId) { mHandler.post(() -> { if ((sp.getPackageName() != null && !sp.getPackageName().isEmpty() && !incomingPackageEqualsCallingUidPackage(sp.getPackageName())) && !hasGlobalSoundQualityServicePermission()) { Loading @@ -475,16 +481,18 @@ public class MediaQualityService extends SystemService { sp.setProfileId(value); mMqManagerNotifier.notifyOnSoundProfileAdded(value, sp, Binder.getCallingUid(), Binder.getCallingPid()); return sp; } }); } @GuardedBy("mSoundProfileLock") @Override public void updateSoundProfile(String id, SoundProfile sp, int userId) { mHandler.post(() -> { Long dbId = mSoundProfileTempIdMap.getKey(id); if (!hasPermissionToUpdateSoundProfile(dbId, sp)) { mMqManagerNotifier.notifyOnSoundProfileError(id, SoundProfile.ERROR_NO_PERMISSION, mMqManagerNotifier.notifyOnSoundProfileError(id, SoundProfile.ERROR_NO_PERMISSION, Binder.getCallingUid(), Binder.getCallingPid()); } Loading @@ -498,6 +506,7 @@ public class MediaQualityService extends SystemService { updateDatabaseOnSoundProfileAndNotifyManagerAndHal(values, sp.getParameters()); } }); } private boolean hasPermissionToUpdateSoundProfile(Long dbId, SoundProfile sp) { Loading @@ -511,6 +520,7 @@ public class MediaQualityService extends SystemService { @GuardedBy("mSoundProfileLock") @Override public void removeSoundProfile(String id, int userId) { mHandler.post(() -> { synchronized (mSoundProfileLock) { Long dbId = mSoundProfileTempIdMap.getKey(id); SoundProfile toDelete = mMqDatabaseUtils.getSoundProfile(dbId); Loading Loading @@ -539,6 +549,7 @@ public class MediaQualityService extends SystemService { } } } }); } private boolean hasPermissionToRemoveSoundProfile(SoundProfile toDelete) { Loading Loading @@ -849,6 +860,7 @@ public class MediaQualityService extends SystemService { @GuardedBy("mPictureProfileLock") @Override public void setPictureProfileAllowList(List<String> packages, int userId) { mHandler.post(() -> { if (!hasGlobalPictureQualityServicePermission()) { mMqManagerNotifier.notifyOnPictureProfileError(null, PictureProfile.ERROR_NO_PERMISSION, Loading @@ -857,6 +869,7 @@ public class MediaQualityService extends SystemService { SharedPreferences.Editor editor = mPictureProfileSharedPreference.edit(); editor.putString(ALLOWLIST, String.join(COMMA_DELIMITER, packages)); editor.commit(); }); } @GuardedBy("mSoundProfileLock") Loading @@ -877,13 +890,16 @@ public class MediaQualityService extends SystemService { @GuardedBy("mSoundProfileLock") @Override public void setSoundProfileAllowList(List<String> packages, int userId) { mHandler.post(() -> { if (!hasGlobalSoundQualityServicePermission()) { mMqManagerNotifier.notifyOnSoundProfileError(null, SoundProfile.ERROR_NO_PERMISSION, mMqManagerNotifier.notifyOnSoundProfileError(null, SoundProfile.ERROR_NO_PERMISSION, Binder.getCallingUid(), Binder.getCallingPid()); } SharedPreferences.Editor editor = mSoundProfileSharedPreference.edit(); editor.putString(ALLOWLIST, String.join(COMMA_DELIMITER, packages)); editor.commit(); }); } @Override Loading @@ -894,6 +910,7 @@ public class MediaQualityService extends SystemService { @GuardedBy("mPictureProfileLock") @Override public void setAutoPictureQualityEnabled(boolean enabled, int userId) { mHandler.post(() -> { if (!hasGlobalPictureQualityServicePermission()) { mMqManagerNotifier.notifyOnPictureProfileError(null, PictureProfile.ERROR_NO_PERMISSION, Loading @@ -910,6 +927,7 @@ public class MediaQualityService extends SystemService { Slog.e(TAG, "Failed to set auto picture quality", e); } } }); } @GuardedBy("mPictureProfileLock") Loading @@ -932,6 +950,7 @@ public class MediaQualityService extends SystemService { @GuardedBy("mPictureProfileLock") @Override public void setSuperResolutionEnabled(boolean enabled, int userId) { mHandler.post(() -> { if (!hasGlobalPictureQualityServicePermission()) { mMqManagerNotifier.notifyOnPictureProfileError(null, PictureProfile.ERROR_NO_PERMISSION, Loading @@ -948,6 +967,7 @@ public class MediaQualityService extends SystemService { Slog.e(TAG, "Failed to set super resolution", e); } } }); } @GuardedBy("mPictureProfileLock") Loading @@ -970,8 +990,10 @@ public class MediaQualityService extends SystemService { @GuardedBy("mSoundProfileLock") @Override public void setAutoSoundQualityEnabled(boolean enabled, int userId) { mHandler.post(() -> { if (!hasGlobalSoundQualityServicePermission()) { mMqManagerNotifier.notifyOnSoundProfileError(null, SoundProfile.ERROR_NO_PERMISSION, mMqManagerNotifier.notifyOnSoundProfileError(null, SoundProfile.ERROR_NO_PERMISSION, Binder.getCallingUid(), Binder.getCallingPid()); } Loading @@ -986,6 +1008,7 @@ public class MediaQualityService extends SystemService { Slog.e(TAG, "Failed to set auto sound quality", e); } } }); } @GuardedBy("mSoundProfileLock") Loading