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

Commit 3cb83bac authored by Shubang Lu's avatar Shubang Lu Committed by Android (Google) Code Review
Browse files

Merge "[MQ API feedback] Use options for includeParams" into main

parents 6d9b3216 e3fe8d83
Loading
Loading
Loading
Loading
+17 −4
Original line number Diff line number Diff line
@@ -27307,11 +27307,11 @@ package android.media.quality {
    method public void addActiveProcessingPictureListener(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.util.List<android.media.quality.ActiveProcessingPicture>>);
    method public void createPictureProfile(@NonNull android.media.quality.PictureProfile);
    method public void createSoundProfile(@NonNull android.media.quality.SoundProfile);
    method @NonNull public java.util.List<android.media.quality.PictureProfile> getAvailablePictureProfiles(boolean);
    method @NonNull public java.util.List<android.media.quality.SoundProfile> getAvailableSoundProfiles(boolean);
    method @NonNull public java.util.List<android.media.quality.PictureProfile> getAvailablePictureProfiles(@Nullable android.media.quality.MediaQualityManager.ProfileQueryParams);
    method @NonNull public java.util.List<android.media.quality.SoundProfile> getAvailableSoundProfiles(@Nullable android.media.quality.MediaQualityManager.ProfileQueryParams);
    method @NonNull public java.util.List<android.media.quality.ParamCapability> getParamCapabilities(@NonNull java.util.List<java.lang.String>);
    method @Nullable public android.media.quality.PictureProfile getPictureProfile(int, @NonNull String, boolean);
    method @Nullable public android.media.quality.SoundProfile getSoundProfile(int, @NonNull String, boolean);
    method @Nullable public android.media.quality.PictureProfile getPictureProfile(int, @NonNull String, @Nullable android.media.quality.MediaQualityManager.ProfileQueryParams);
    method @Nullable public android.media.quality.SoundProfile getSoundProfile(int, @NonNull String, @Nullable android.media.quality.MediaQualityManager.ProfileQueryParams);
    method public boolean isAmbientBacklightEnabled();
    method public boolean isAutoPictureQualityEnabled();
    method public boolean isAutoSoundQualityEnabled();
@@ -27344,6 +27344,19 @@ package android.media.quality {
    method public void onPictureProfileUpdated(@NonNull String, @NonNull android.media.quality.PictureProfile);
  }
  public static final class MediaQualityManager.ProfileQueryParams implements android.os.Parcelable {
    method public boolean areParametersIncluded();
    method public int describeContents();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.media.quality.MediaQualityManager.ProfileQueryParams> CREATOR;
  }
  public static final class MediaQualityManager.ProfileQueryParams.Builder {
    ctor public MediaQualityManager.ProfileQueryParams.Builder();
    method @NonNull public android.media.quality.MediaQualityManager.ProfileQueryParams build();
    method @NonNull public android.media.quality.MediaQualityManager.ProfileQueryParams.Builder setParametersIncluded(boolean);
  }
  public abstract static class MediaQualityManager.SoundProfileCallback {
    ctor public MediaQualityManager.SoundProfileCallback();
    method public void onError(@Nullable String, int);
+2 −2
Original line number Diff line number Diff line
@@ -7995,10 +7995,10 @@ package android.media.quality {
    method public void addGlobalActiveProcessingPictureListener(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.util.List<android.media.quality.ActiveProcessingPicture>>);
    method @NonNull public java.util.List<java.lang.String> getPictureProfileAllowList();
    method @NonNull public java.util.List<java.lang.String> getPictureProfilePackageNames();
    method @NonNull public java.util.List<android.media.quality.PictureProfile> getPictureProfilesByPackage(@NonNull String, boolean);
    method @NonNull public java.util.List<android.media.quality.PictureProfile> getPictureProfilesByPackage(@NonNull String, @Nullable android.media.quality.MediaQualityManager.ProfileQueryParams);
    method @NonNull public java.util.List<java.lang.String> getSoundProfileAllowList();
    method @NonNull public java.util.List<java.lang.String> getSoundProfilePackageNames();
    method @NonNull public java.util.List<android.media.quality.SoundProfile> getSoundProfilesByPackage(@NonNull String, boolean);
    method @NonNull public java.util.List<android.media.quality.SoundProfile> getSoundProfilesByPackage(@NonNull String, @Nullable android.media.quality.MediaQualityManager.ProfileQueryParams);
    method public void setAutoPictureQualityEnabled(boolean);
    method public void setAutoSoundQualityEnabled(boolean);
    method public boolean setDefaultPictureProfile(@Nullable String);
+7 −6
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.media.quality.PictureProfileHandle;
import android.media.quality.PictureProfile;
import android.media.quality.SoundProfileHandle;
import android.media.quality.SoundProfile;
import android.os.Bundle;
import android.os.UserHandle;

/**
@@ -37,10 +38,10 @@ interface IMediaQualityManager {
    void removePictureProfile(in String id, in UserHandle user);
    boolean setDefaultPictureProfile(in String id, in UserHandle user);
    PictureProfile getPictureProfile(
            in int type, in String name, in boolean includeParams, in UserHandle user);
            in int type, in String name, in Bundle options, in UserHandle user);
    List<PictureProfile> getPictureProfilesByPackage(
            in String packageName, in boolean includeParams, in UserHandle user);
    List<PictureProfile> getAvailablePictureProfiles(in boolean includeParams, in UserHandle user);
            in String packageName, in Bundle options, in UserHandle user);
    List<PictureProfile> getAvailablePictureProfiles(in Bundle options, in UserHandle user);
    List<String> getPictureProfilePackageNames(in UserHandle user);
    List<String> getPictureProfileAllowList(in UserHandle user);
    void setPictureProfileAllowList(in List<String> packages, in UserHandle user);
@@ -51,10 +52,10 @@ interface IMediaQualityManager {
    void removeSoundProfile(in String id, in UserHandle user);
    boolean setDefaultSoundProfile(in String id, in UserHandle user);
    SoundProfile getSoundProfile(
            in int type, in String name, in boolean includeParams, in UserHandle user);
            in int type, in String name, in Bundle options, in UserHandle user);
    List<SoundProfile> getSoundProfilesByPackage(
            in String packageName, in boolean includeParams, in UserHandle user);
    List<SoundProfile> getAvailableSoundProfiles(in boolean includeParams, in UserHandle user);
            in String packageName, in Bundle options, in UserHandle user);
    List<SoundProfile> getAvailableSoundProfiles(in Bundle options, in UserHandle user);
    List<String> getSoundProfilePackageNames(in UserHandle user);
    List<String> getSoundProfileAllowList(in UserHandle user);
    void setSoundProfileAllowList(in List<String> packages, in UserHandle user);
+151 −24
Original line number Diff line number Diff line
@@ -25,6 +25,9 @@ import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.content.Context;
import android.media.tv.flags.Flags;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.UserHandle;

@@ -62,6 +65,12 @@ public final class MediaQualityManager {
    private final List<ActiveProcessingPictureListenerRecord> mApListenerRecords =
            new ArrayList<>();

    /**
     * A query option to include parameters in the profile. The default value is {@code false}.
     * @hide
     */
    public static final String OPTION_INCLUDE_PARAMETERS = "include_parameters";


    /**
     * @hide
@@ -219,18 +228,25 @@ public final class MediaQualityManager {
    /**
     * Gets picture profile by given profile type and name.
     *
     * <p>If {@link ProfileQueryParams#areParametersIncluded()} is {@code false},
     * {@link PictureProfile#getParameters()} of the returned profile is an empty bundle.
     *
     * @param type the type of the profile.
     * @param name the name of the profile.
     * @param includeParams {@code true} to include parameters in the profile; {@code false}
     *                      otherwise.
     * @param options the options of the query. {@code null} if default options are used.
     *
     * @return the corresponding picture profile if available; {@code null} if the name doesn't
     * exist.
     */
    @Nullable
    public PictureProfile getPictureProfile(
            @PictureProfile.ProfileType int type, @NonNull String name, boolean includeParams) {
            @PictureProfile.ProfileType int type,
            @NonNull String name,
            @Nullable ProfileQueryParams options) {
        try {
            return mService.getPictureProfile(type, name, includeParams, mUserHandle);
            Bundle optionsBundle = options == null
                    ? ProfileQueryParams.DEFAULT.toBundle() : options.toBundle();
            return mService.getPictureProfile(type, name, optionsBundle, mUserHandle);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -240,18 +256,23 @@ public final class MediaQualityManager {
    /**
     * Gets profiles that available to the given package.
     *
     * <p>If {@link ProfileQueryParams#areParametersIncluded()} is {@code false},
     * {@link PictureProfile#getParameters()} of the returned profiles are empty bundles.
     *
     * @param packageName the package name of the profiles.
     * @param includeParams {@code true} to include parameters in the profile; {@code false}
     *                      otherwise.
     * @param options the options of the query. {@code null} if default options are used.
     * @hide
     */
    @SystemApi
    @NonNull
    @RequiresPermission(android.Manifest.permission.MANAGE_GLOBAL_PICTURE_QUALITY_SERVICE)
    public List<PictureProfile> getPictureProfilesByPackage(
            @NonNull String packageName, boolean includeParams) {
            @NonNull String packageName, @Nullable ProfileQueryParams options) {
        try {
            return mService.getPictureProfilesByPackage(packageName, includeParams, mUserHandle);
            Bundle optionsBundle = options == null
                    ? ProfileQueryParams.DEFAULT.toBundle() : options.toBundle();
            return mService.getPictureProfilesByPackage(
                    packageName, optionsBundle, mUserHandle);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -260,15 +281,19 @@ public final class MediaQualityManager {
    /**
     * Gets profiles that available to the caller.
     *
     * @param includeParams {@code true} to include parameters in the profile; {@code false}
     *                      otherwise.
     * <p>If {@link ProfileQueryParams#areParametersIncluded()} is {@code false},
     * {@link PictureProfile#getParameters()} of the returned profiles are empty bundles.
     *
     * @param options the options of the query. {@code null} if default options are used.
     * @return the corresponding picture profile if available; {@code null} if the name doesn't
     * exist.
     */
    @NonNull
    public List<PictureProfile> getAvailablePictureProfiles(boolean includeParams) {
    public List<PictureProfile> getAvailablePictureProfiles(@Nullable ProfileQueryParams options) {
        try {
            return mService.getAvailablePictureProfiles(includeParams, mUserHandle);
            Bundle optionsBundle = options == null
                    ? ProfileQueryParams.DEFAULT.toBundle() : options.toBundle();
            return mService.getAvailablePictureProfiles(optionsBundle, mUserHandle);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -414,17 +439,24 @@ public final class MediaQualityManager {
    /**
     * Gets sound profile by given profile type and name.
     *
     * <p>If {@link ProfileQueryParams#areParametersIncluded()} is {@code false},
     * {@link SoundProfile#getParameters()} of the returned profile is an empty bundle.
     *
     * @param type the type of the profile.
     * @param name the name of the profile.
     * @param includeParams {@code true} to include parameters in the profile; {@code false}
     *                      otherwise.
     * @param options the options of the query. {@code null} if default options are used.
     *
     * @return the corresponding sound profile if available; {@code null} if the name doesn't exist.
     */
    @Nullable
    public SoundProfile getSoundProfile(
            @SoundProfile.ProfileType int type, @NonNull String name, boolean includeParams) {
            @SoundProfile.ProfileType int type,
            @NonNull String name,
            @Nullable ProfileQueryParams options) {
        try {
            return mService.getSoundProfile(type, name, includeParams, mUserHandle);
            Bundle optionsBundle = options == null
                    ? ProfileQueryParams.DEFAULT.toBundle() : options.toBundle();
            return mService.getSoundProfile(type, name, optionsBundle, mUserHandle);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -434,18 +466,23 @@ public final class MediaQualityManager {
    /**
     * Gets profiles that available to the given package.
     *
     * <p>If {@link ProfileQueryParams#areParametersIncluded()} is {@code false},
     * {@link SoundProfile#getParameters()} of the returned profiles are empty bundles.
     *
     * @param packageName the package name of the profiles.
     * @param includeParams {@code true} to include parameters in the profile; {@code false}
     *                      otherwise.
     * @param options the options of the query. {@code null} if default options are used.
     *
     * @hide
     */
    @SystemApi
    @NonNull
    @RequiresPermission(android.Manifest.permission.MANAGE_GLOBAL_SOUND_QUALITY_SERVICE)
    public List<SoundProfile> getSoundProfilesByPackage(
            @NonNull String packageName, boolean includeParams) {
            @NonNull String packageName, @Nullable ProfileQueryParams options) {
        try {
            return mService.getSoundProfilesByPackage(packageName, includeParams, mUserHandle);
            Bundle optionsBundle = options == null
                    ? ProfileQueryParams.DEFAULT.toBundle() : options.toBundle();
            return mService.getSoundProfilesByPackage(packageName, optionsBundle, mUserHandle);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -454,15 +491,19 @@ public final class MediaQualityManager {
    /**
     * Gets profiles that available to the caller package.
     *
     * @param includeParams {@code true} to include parameters in the profile; {@code false}
     *                      otherwise.
     * <p>If {@link ProfileQueryParams#areParametersIncluded()} is {@code false},
     * {@link SoundProfile#getParameters()} of the returned profiles are empty bundles.
     *
     * @param options the options of the query. {@code null} if default options are used.
     *
     * @return the corresponding sound profile if available; {@code null} if the none available.
     */
    @NonNull
    public List<SoundProfile> getAvailableSoundProfiles(boolean includeParams) {
    public List<SoundProfile> getAvailableSoundProfiles(@Nullable ProfileQueryParams options) {
        try {
            return mService.getAvailableSoundProfiles(includeParams, mUserHandle);
            Bundle optionsBundle = options == null
                    ? ProfileQueryParams.DEFAULT.toBundle() : options.toBundle();
            return mService.getAvailableSoundProfiles(optionsBundle, mUserHandle);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -1139,4 +1180,90 @@ public final class MediaQualityManager {
            return mListener;
        }
    }

    /**
     * Options for profile queries.
     */
    public static final class ProfileQueryParams implements Parcelable {

        private final boolean mParametersIncluded;
        private static final ProfileQueryParams DEFAULT = new Builder().build();

        private ProfileQueryParams(Parcel in) {
            mParametersIncluded = in.readBoolean();
        }

        /** @hide */
        public ProfileQueryParams(boolean parametersIncluded) {
            mParametersIncluded = parametersIncluded;
        }

        @NonNull
        public static final Creator<ProfileQueryParams> CREATOR =
                new Creator<ProfileQueryParams>() {
                    @Override
                    public ProfileQueryParams createFromParcel(Parcel in) {
                        return new ProfileQueryParams(in);
                    }

                    @Override
                    public ProfileQueryParams[] newArray(int size) {
                        return new ProfileQueryParams[size];
                    }
                };

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(@NonNull Parcel dest, int flags) {
            dest.writeBoolean(mParametersIncluded);
        }

        /**
         * Returns {@code true} if the parameters need to be included in query results.
         * {@code false} otherwise.
         */
        public boolean areParametersIncluded() {
            return mParametersIncluded;
        }

        private Bundle toBundle() {
            Bundle bundle = new Bundle();
            bundle.putBoolean(OPTION_INCLUDE_PARAMETERS, mParametersIncluded);
            return bundle;
        }

        /**
         * A builder for {@link ProfileQueryParams}.
         */
        public static final class Builder {
            private boolean mParametersIncluded;

            /**
             * Sets the query option to include parameters in the profile or not.
             *
             * <p>The default value is {@code false}.
             *
             * @see ProfileQueryParams#areParametersIncluded()
             */
            @SuppressLint("MissingGetterMatchingBuilder")
            @NonNull
            public Builder setParametersIncluded(boolean included) {
                mParametersIncluded = included;
                return this;
            }


            /**
             * Builds the instance.
             */
            @NonNull
            public ProfileQueryParams build() {
                return new ProfileQueryParams(mParametersIncluded);
            }
        }
    }
}
+3 −1
Original line number Diff line number Diff line
@@ -181,7 +181,7 @@ public final class PictureProfile implements Parcelable {
     * Gets profile ID.
     *
     * <p>A profile ID is a globally unique ID generated and assigned by the system. For profile
     * objects retrieved from system (e.g {@link MediaQualityManager#getAvailablePictureProfiles()})
     * objects retrieved from system (e.g {@link MediaQualityManager#getAvailablePictureProfiles})
     * this profile ID is non-null; For profiles built locally with {@link Builder}, it's
     * {@code null}.
     *
@@ -249,6 +249,8 @@ public final class PictureProfile implements Parcelable {
     *
     * <p>The keys of commonly used parameters can be found in
     * {@link MediaQualityContract.PictureQuality}.
     *
     * @return The profile parameters. Empty bundle if parameters are not included in a query.
     */
    @NonNull
    public PersistableBundle getParameters() {
Loading