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

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

Merge "[MediaQuality] Add thread to createPictureProfile API" into main

parents 3ed5f498 8a76ab0d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ import android.media.quality.SoundProfile;
 */
interface IMediaQualityManager {
    // TODO: use UserHandle
    PictureProfile createPictureProfile(in PictureProfile pp, int userId);
    void createPictureProfile(in PictureProfile pp, int userId);
    void updatePictureProfile(in String id, in PictureProfile pp, int userId);
    void removePictureProfile(in String id, int userId);
    boolean setDefaultPictureProfile(in String id, int userId);
+36 −29
Original line number Diff line number Diff line
@@ -57,7 +57,9 @@ import android.media.quality.SoundProfileHandle;
import android.os.Binder;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.Parcel;
import android.os.PersistableBundle;
import android.os.RemoteCallbackList;
@@ -116,6 +118,7 @@ public class MediaQualityService extends SystemService {
    private HalNotifier mHalNotifier;
    private MqManagerNotifier mMqManagerNotifier;
    private MqDatabaseUtils mMqDatabaseUtils;
    private Handler mHandler;

    // A global lock for picture profile objects.
    private final Object mPictureProfileLock = new Object();
@@ -141,6 +144,7 @@ public class MediaQualityService extends SystemService {
        mHalNotifier = new HalNotifier();
        mPictureProfileAdjListener = new PictureProfileAdjustmentListenerImpl();
        mSoundProfileAdjListener = new SoundProfileAdjustmentListenerImpl();
        mHandler = new Handler(Looper.getMainLooper());

        // The package info in the context isn't initialized in the way it is for normal apps,
        // so the standard, name-based context.getSharedPreferences doesn't work. Instead, we
@@ -188,7 +192,9 @@ public class MediaQualityService extends SystemService {

        @GuardedBy("mPictureProfileLock")
        @Override
        public PictureProfile createPictureProfile(PictureProfile pp, int userId) {
        public void createPictureProfile(PictureProfile pp, int userId) {
            mHandler.post(
                    () -> {
                        if ((pp.getPackageName() != null && !pp.getPackageName().isEmpty()
                                && !incomingPackageEqualsCallingUidPackage(pp.getPackageName()))
                                && !hasGlobalPictureQualityServicePermission()) {
@@ -214,10 +220,11 @@ public class MediaQualityService extends SystemService {
                            MediaQualityUtils.populateTempIdMap(mPictureProfileTempIdMap, id);
                            String value = mPictureProfileTempIdMap.getValue(id);
                            pp.setProfileId(value);
                mMqManagerNotifier.notifyOnPictureProfileAdded(value, pp, Binder.getCallingUid(),
                        Binder.getCallingPid());
                return pp;
                            mMqManagerNotifier.notifyOnPictureProfileAdded(value, pp,
                                    Binder.getCallingUid(), Binder.getCallingPid());
                        }
                    }
            );
        }

        @GuardedBy("mPictureProfileLock")