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

Commit 28745639 authored by Haofan Wang's avatar Haofan Wang Committed by Android (Google) Code Review
Browse files

Merge "[MQ] Add profile handles and getters" into main

parents 4822f8a0 f1999243
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.media.quality.ISoundProfileCallback;
import android.media.quality.ParamCapability;
import android.media.quality.PictureProfileHandle;
import android.media.quality.PictureProfile;
import android.media.quality.SoundProfileHandle;
import android.media.quality.SoundProfile;

/**
@@ -40,7 +41,7 @@ interface IMediaQualityManager {
    List<String> getPictureProfilePackageNames(int userId);
    List<String> getPictureProfileAllowList(int userId);
    void setPictureProfileAllowList(in List<String> packages, int userId);
    PictureProfileHandle getPictureProfileHandle(in String id, int userId);
    List<PictureProfileHandle> getPictureProfileHandle(in String[] id, int userId);

    SoundProfile createSoundProfile(in SoundProfile pp, int userId);
    void updateSoundProfile(in String id, in SoundProfile pp, int userId);
@@ -52,6 +53,7 @@ interface IMediaQualityManager {
    List<String> getSoundProfilePackageNames(int userId);
    List<String> getSoundProfileAllowList(int userId);
    void setSoundProfileAllowList(in List<String> packages, int userId);
    List<SoundProfileHandle> getSoundProfileHandle(in String[] id, int userId);

    void registerPictureProfileCallback(in IPictureProfileCallback cb);
    void registerSoundProfileCallback(in ISoundProfileCallback cb);
+13 −1
Original line number Diff line number Diff line
@@ -295,7 +295,7 @@ public final class MediaQualityManager {
     * Gets picture profile handle by profile ID.
     * @hide
     */
    public PictureProfileHandle getPictureProfileHandle(String id) {
    public List<PictureProfileHandle> getPictureProfileHandle(String[] id) {
        try {
            return mService.getPictureProfileHandle(id, mUserId);
        } catch (RemoteException e) {
@@ -303,6 +303,18 @@ public final class MediaQualityManager {
        }
    }

    /**
     * Gets sound profile handle by profile ID.
     * @hide
     */
    public List<SoundProfileHandle> getSoundProfileHandle(String[] id) {
        try {
            return mService.getSoundProfileHandle(id, mUserId);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Creates a picture profile and store it in the system.
     *
+29 −2
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ public final class PictureProfile implements Parcelable {
    private final String mPackageName;
    @NonNull
    private final PersistableBundle mParams;
    private final PictureProfileHandle mHandle;

    /** @hide */
    @Retention(RetentionPolicy.SOURCE)
@@ -121,6 +122,7 @@ public final class PictureProfile implements Parcelable {
        mInputId = in.readString();
        mPackageName = in.readString();
        mParams = in.readPersistableBundle();
        mHandle = in.readParcelable(PictureProfileHandle.class.getClassLoader());
    }

    @Override
@@ -131,6 +133,7 @@ public final class PictureProfile implements Parcelable {
        dest.writeString(mInputId);
        dest.writeString(mPackageName);
        dest.writePersistableBundle(mParams);
        dest.writeParcelable(mHandle, flags);
    }

    @Override
@@ -163,13 +166,15 @@ public final class PictureProfile implements Parcelable {
            @NonNull String name,
            @Nullable String inputId,
            @NonNull String packageName,
            @NonNull PersistableBundle params) {
            @NonNull PersistableBundle params,
            @NonNull PictureProfileHandle handle) {
        this.mId = id;
        this.mType = type;
        this.mName = name;
        this.mInputId = inputId;
        this.mPackageName = packageName;
        this.mParams = params;
        this.mHandle = handle;
    }

    /**
@@ -250,6 +255,15 @@ public final class PictureProfile implements Parcelable {
        return new PersistableBundle(mParams);
    }

    /**
     * Gets profile handle
     * @hide
     */
    @NonNull
    public PictureProfileHandle getHandle() {
        return mHandle;
    }

    /**
     * A builder for {@link PictureProfile}.
     */
@@ -265,6 +279,7 @@ public final class PictureProfile implements Parcelable {
        private String mPackageName;
        @NonNull
        private PersistableBundle mParams;
        private PictureProfileHandle mHandle;

        /**
         * Creates a new Builder.
@@ -283,6 +298,7 @@ public final class PictureProfile implements Parcelable {
            mPackageName = p.getPackageName();
            mInputId = p.getInputId();
            mParams = p.getParameters();
            mHandle = p.getHandle();
        }

        /**
@@ -349,6 +365,16 @@ public final class PictureProfile implements Parcelable {
            return this;
        }

        /**
         * Sets profile handle.
         * @hide
         */
        @NonNull
        public Builder setHandle(@NonNull PictureProfileHandle handle) {
            mHandle = handle;
            return this;
        }

        /**
         * Builds the instance.
         */
@@ -361,7 +387,8 @@ public final class PictureProfile implements Parcelable {
                    mName,
                    mInputId,
                    mPackageName,
                    mParams);
                    mParams,
                    mHandle);
            return o;
        }
    }
+29 −2
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ public final class SoundProfile implements Parcelable {
    private final String mPackageName;
    @NonNull
    private final PersistableBundle mParams;
    private final SoundProfileHandle mHandle;

    /** @hide */
    @Retention(RetentionPolicy.SOURCE)
@@ -120,6 +121,7 @@ public final class SoundProfile implements Parcelable {
        mInputId = in.readString();
        mPackageName = in.readString();
        mParams = in.readPersistableBundle();
        mHandle = in.readParcelable(SoundProfileHandle.class.getClassLoader());
    }

    @Override
@@ -130,6 +132,7 @@ public final class SoundProfile implements Parcelable {
        dest.writeString(mInputId);
        dest.writeString(mPackageName);
        dest.writePersistableBundle(mParams);
        dest.writeParcelable(mHandle, flags);
    }

    @Override
@@ -162,13 +165,15 @@ public final class SoundProfile implements Parcelable {
            @NonNull String name,
            @Nullable String inputId,
            @NonNull String packageName,
            @NonNull PersistableBundle params) {
            @NonNull PersistableBundle params,
            @NonNull SoundProfileHandle handle) {
        this.mId = id;
        this.mType = type;
        this.mName = name;
        this.mInputId = inputId;
        this.mPackageName = packageName;
        this.mParams = params;
        this.mHandle = handle;
    }

    /**
@@ -249,6 +254,15 @@ public final class SoundProfile implements Parcelable {
        return new PersistableBundle(mParams);
    }

    /**
     * Gets profile handle
     * @hide
     */
    @NonNull
    public SoundProfileHandle getHandle() {
        return mHandle;
    }

    /**
     * A builder for {@link SoundProfile}
     */
@@ -264,6 +278,7 @@ public final class SoundProfile implements Parcelable {
        private String mPackageName;
        @NonNull
        private PersistableBundle mParams;
        private SoundProfileHandle mHandle;

        /**
         * Creates a new Builder.
@@ -282,6 +297,7 @@ public final class SoundProfile implements Parcelable {
            mPackageName = p.getPackageName();
            mInputId = p.getInputId();
            mParams = p.getParameters();
            mHandle = p.getHandle();
        }

        /**
@@ -348,6 +364,16 @@ public final class SoundProfile implements Parcelable {
            return this;
        }

        /**
         * Sets profile handle.
         * @hide
         */
        @NonNull
        public Builder setHandle(@NonNull SoundProfileHandle handle) {
            mHandle = handle;
            return this;
        }

        /**
         * Builds the instance.
         */
@@ -360,7 +386,8 @@ public final class SoundProfile implements Parcelable {
                    mName,
                    mInputId,
                    mPackageName,
                    mParams);
                    mParams,
                    mHandle);
            return o;
        }
    }
+19 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.media.quality;

parcelable SoundProfileHandle;
Loading