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

Commit 6a0fb0d9 authored by Preethi Kandhalu's avatar Preethi Kandhalu Committed by Android (Google) Code Review
Browse files

Merge "[MediaQuality] Adding thread support for APIs that return void" into main

parents 84b998c8 15f758fc
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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);
+180 −157
Original line number Diff line number Diff line
@@ -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,
@@ -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) {
@@ -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);

@@ -287,6 +291,7 @@ public class MediaQualityService extends SystemService {
                        }
                    }
                }
            });
        }

        private boolean hasPermissionToRemovePictureProfile(PictureProfile toDelete) {
@@ -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()) {
@@ -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());
                }

@@ -498,6 +506,7 @@ public class MediaQualityService extends SystemService {

                    updateDatabaseOnSoundProfileAndNotifyManagerAndHal(values, sp.getParameters());
                }
            });
        }

        private boolean hasPermissionToUpdateSoundProfile(Long dbId, SoundProfile sp) {
@@ -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);
@@ -539,6 +549,7 @@ public class MediaQualityService extends SystemService {
                        }
                    }
                }
            });
        }

        private boolean hasPermissionToRemoveSoundProfile(SoundProfile toDelete) {
@@ -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,
@@ -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")
@@ -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
@@ -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,
@@ -910,6 +927,7 @@ public class MediaQualityService extends SystemService {
                        Slog.e(TAG, "Failed to set auto picture quality", e);
                    }
                }
            });
        }

        @GuardedBy("mPictureProfileLock")
@@ -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,
@@ -948,6 +967,7 @@ public class MediaQualityService extends SystemService {
                        Slog.e(TAG, "Failed to set super resolution", e);
                    }
                }
            });
        }

        @GuardedBy("mPictureProfileLock")
@@ -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());
                }

@@ -986,6 +1008,7 @@ public class MediaQualityService extends SystemService {
                        Slog.e(TAG, "Failed to set auto sound quality", e);
                    }
                }
            });
        }

        @GuardedBy("mSoundProfileLock")