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

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

Merge "[MQ API] Unhide APIs of sound profile" into main

parents d97dc754 041f6133
Loading
Loading
Loading
Loading
+49 −0
Original line number Diff line number Diff line
@@ -27072,17 +27072,31 @@ package android.media.quality {
    field public static final String PARAMETER_SHARPNESS = "sharpness";
  }
  public static final class MediaQualityContract.SoundQuality {
    field public static final String PARAMETER_BALANCE = "balance";
    field public static final String PARAMETER_BASS = "bass";
    field public static final String PARAMETER_TREBLE = "treble";
  }
  @FlaggedApi("android.media.tv.flags.media_quality_fw") public final class MediaQualityManager {
    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();
    method @NonNull public java.util.List<android.media.quality.SoundProfile> getAvailableSoundProfiles();
    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);
    method @Nullable public android.media.quality.SoundProfile getSoundProfile(int, @NonNull String);
    method public boolean isAutoPictureQualityEnabled();
    method public boolean isAutoSoundQualityEnabled();
    method public boolean isSuperResolutionEnabled();
    method public void registerPictureProfileCallback(@NonNull java.util.concurrent.Executor, @NonNull android.media.quality.MediaQualityManager.PictureProfileCallback);
    method public void registerSoundProfileCallback(@NonNull java.util.concurrent.Executor, @NonNull android.media.quality.MediaQualityManager.SoundProfileCallback);
    method public void removePictureProfile(@NonNull String);
    method public void removeSoundProfile(@NonNull String);
    method public void unregisterPictureProfileCallback(@NonNull android.media.quality.MediaQualityManager.PictureProfileCallback);
    method public void unregisterSoundProfileCallback(@NonNull android.media.quality.MediaQualityManager.SoundProfileCallback);
    method public void updatePictureProfile(@NonNull String, @NonNull android.media.quality.PictureProfile);
    method public void updateSoundProfile(@NonNull String, @NonNull android.media.quality.SoundProfile);
  }
  public abstract static class MediaQualityManager.PictureProfileCallback {
@@ -27094,6 +27108,15 @@ package android.media.quality {
    method public void onPictureProfileUpdated(@NonNull String, @NonNull android.media.quality.PictureProfile);
  }
  public abstract static class MediaQualityManager.SoundProfileCallback {
    ctor public MediaQualityManager.SoundProfileCallback();
    method public void onError(int);
    method public void onParamCapabilitiesChanged(@Nullable String, @NonNull java.util.List<android.media.quality.ParamCapability>);
    method public void onSoundProfileAdded(@NonNull String, @NonNull android.media.quality.SoundProfile);
    method public void onSoundProfileRemoved(@NonNull String, @NonNull android.media.quality.SoundProfile);
    method public void onSoundProfileUpdated(@NonNull String, @NonNull android.media.quality.SoundProfile);
  }
  @FlaggedApi("android.media.tv.flags.media_quality_fw") public final class ParamCapability implements android.os.Parcelable {
    method public int describeContents();
    method @NonNull public android.os.Bundle getCapabilities();
@@ -27138,6 +27161,32 @@ package android.media.quality {
    method @NonNull public android.media.quality.PictureProfile.Builder setParameters(@NonNull android.os.PersistableBundle);
  }
  @FlaggedApi("android.media.tv.flags.media_quality_fw") public final class SoundProfile implements android.os.Parcelable {
    method public int describeContents();
    method @Nullable public String getInputId();
    method @NonNull public String getName();
    method @Nullable public String getPackageName();
    method @NonNull public android.os.PersistableBundle getParameters();
    method @Nullable public String getProfileId();
    method public int getProfileType();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.media.quality.SoundProfile> CREATOR;
    field public static final int ERROR_DUPLICATE = 2; // 0x2
    field public static final int ERROR_INVALID_ARGUMENT = 3; // 0x3
    field public static final int ERROR_NOT_ALLOWLISTED = 4; // 0x4
    field public static final int ERROR_NO_PERMISSION = 1; // 0x1
    field public static final int ERROR_UNKNOWN = 0; // 0x0
    field public static final int TYPE_APPLICATION = 2; // 0x2
    field public static final int TYPE_SYSTEM = 1; // 0x1
  }
  public static final class SoundProfile.Builder {
    ctor public SoundProfile.Builder(@NonNull String);
    ctor public SoundProfile.Builder(@NonNull android.media.quality.SoundProfile);
    method @NonNull public android.media.quality.SoundProfile build();
    method @NonNull public android.media.quality.SoundProfile.Builder setParameters(@NonNull android.os.PersistableBundle);
  }
}
package android.media.session {
+11 −0
Original line number Diff line number Diff line
@@ -8110,8 +8110,13 @@ package android.media.quality {
    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);
    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);
    method public void setAutoPictureQualityEnabled(boolean);
    method public void setAutoSoundQualityEnabled(boolean);
    method public void setPictureProfileAllowList(@NonNull java.util.List<java.lang.String>);
    method public void setSoundProfileAllowList(@NonNull java.util.List<java.lang.String>);
    method public void setSuperResolutionEnabled(boolean);
  }
@@ -8129,6 +8134,12 @@ package android.media.quality {
    field @NonNull public static final android.media.quality.PictureProfileHandle NONE;
  }
  public static final class SoundProfile.Builder {
    method @NonNull public android.media.quality.SoundProfile.Builder setInputId(@NonNull String);
    method @NonNull public android.media.quality.SoundProfile.Builder setPackageName(@NonNull String);
    method @NonNull public android.media.quality.SoundProfile.Builder setProfileType(int);
  }
}
package android.media.session {
+24 −2
Original line number Diff line number Diff line
@@ -79,12 +79,34 @@ public class MediaQualityContract {
    }

    /**
     * @hide
     * Parameters for sound quality.
     */
    public static final class SoundQuality {
        /**
         * The audio volume balance.
         *
         * <p>Type: INTEGER
         */
    public static final class SoundQuality implements BaseParameters {
        public static final String PARAMETER_BALANCE = "balance";

        /**
         * The bass.
         *
         * <p>Bass setting adjust the low sound frequencies.
         * <p>Type: INTEGER
         */
        public static final String PARAMETER_BASS = "bass";

        /**
         * The treble.
         *
         * <p>Treble setting adjust the high sound frequencies.
         * <p>Type: INTEGER
         */
        public static final String PARAMETER_TREBLE = "treble";

        private SoundQuality() {
        }
    }

    private MediaQualityContract() {
+11 −18
Original line number Diff line number Diff line
@@ -323,7 +323,6 @@ public final class MediaQualityManager {

    /**
     * Registers a {@link SoundProfileCallback}.
     * @hide
     */
    public void registerSoundProfileCallback(
            @NonNull @CallbackExecutor Executor executor,
@@ -337,7 +336,6 @@ public final class MediaQualityManager {

    /**
     * Unregisters the existing {@link SoundProfileCallback}.
     * @hide
     */
    public void unregisterSoundProfileCallback(@NonNull final SoundProfileCallback callback) {
        Preconditions.checkNotNull(callback);
@@ -359,7 +357,6 @@ public final class MediaQualityManager {
     *
     * @return the corresponding sound profile if available; {@code null} if the name doesn't
     *         exist.
     * @hide
     */
    @Nullable
    public SoundProfile getSoundProfile(
@@ -373,9 +370,11 @@ public final class MediaQualityManager {


    /**
     * @SystemApi gets profiles that available to the given package
     * Gets profiles that available to the given package.
     *
     * @hide
     */
    @SystemApi
    @NonNull
    @RequiresPermission(android.Manifest.permission.MANAGE_GLOBAL_SOUND_QUALITY_SERVICE)
    public List<SoundProfile> getSoundProfilesByPackage(@NonNull String packageName) {
@@ -387,8 +386,7 @@ public final class MediaQualityManager {
    }

    /**
     * Gets profiles that available to the caller package
     * @hide
     * Gets profiles that available to the caller package.
     */
    @NonNull
    public List<SoundProfile> getAvailableSoundProfiles() {
@@ -400,11 +398,13 @@ public final class MediaQualityManager {
    }

    /**
     * @SystemApi Gets all package names whose sound profiles are available.
     * Gets all package names whose sound profiles are available.
     *
     * @see #getSoundProfilesByPackage(String)
     *
     * @hide
     */
    @SystemApi
    @NonNull
    @RequiresPermission(android.Manifest.permission.MANAGE_GLOBAL_SOUND_QUALITY_SERVICE)
    public List<String> getSoundProfilePackageNames() {
@@ -420,8 +420,7 @@ public final class MediaQualityManager {
     * Creates a sound profile and store it in the system.
     *
     * <p>If the profile is created successfully,
     * {@link SoundProfileCallback#onSoundProfileAdded(long, SoundProfile)} is invoked.
     * @hide
     * {@link SoundProfileCallback#onSoundProfileAdded(String, SoundProfile)} is invoked.
     */
    public void createSoundProfile(@NonNull SoundProfile sp) {
        try {
@@ -434,7 +433,6 @@ public final class MediaQualityManager {

    /**
     * Updates an existing sound profile and store it in the system.
     * @hide
     */
    public void updateSoundProfile(@NonNull String profileId, @NonNull SoundProfile sp) {
        try {
@@ -447,7 +445,6 @@ public final class MediaQualityManager {

    /**
     * Removes a sound profile from the system.
     * @hide
     */
    public void removeSoundProfile(@NonNull String profileId) {
        try {
@@ -508,6 +505,7 @@ public final class MediaQualityManager {
     * @see #removeSoundProfile(String)
     * @hide
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.MANAGE_GLOBAL_SOUND_QUALITY_SERVICE)
    @NonNull
    public List<String> getSoundProfileAllowList() {
@@ -522,6 +520,7 @@ public final class MediaQualityManager {
     * Sets the allowlist of packages that can create and removed sound profiles
     * @hide
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.MANAGE_GLOBAL_SOUND_QUALITY_SERVICE)
    public void setSoundProfileAllowList(@NonNull List<String> packageNames) {
        try {
@@ -608,6 +607,7 @@ public final class MediaQualityManager {
     * @param enabled {@code true} to enable, {@code false} to disable.
     * @hide
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.MANAGE_GLOBAL_SOUND_QUALITY_SERVICE)
    public void setAutoSoundQualityEnabled(boolean enabled) {
        try {
@@ -619,7 +619,6 @@ public final class MediaQualityManager {

    /**
     * Returns {@code true} if auto sound quality is enabled; {@code false} otherwise.
     * @hide
     */
    public boolean isAutoSoundQualityEnabled() {
        try {
@@ -905,7 +904,6 @@ public final class MediaQualityManager {

    /**
     * Callback used to monitor status of sound profiles.
     * @hide
     */
    public abstract static class SoundProfileCallback {
        /**
@@ -913,7 +911,6 @@ public final class MediaQualityManager {
         *
         * @param profileId the ID of the profile.
         * @param profile the newly added profile.
         * @hide
         */
        public void onSoundProfileAdded(
                @NonNull String profileId, @NonNull SoundProfile profile) {
@@ -924,7 +921,6 @@ public final class MediaQualityManager {
         *
         * @param profileId the ID of the profile.
         * @param profile the profile with updated info.
         * @hide
         */
        public void onSoundProfileUpdated(
                @NonNull String profileId, @NonNull SoundProfile profile) {
@@ -935,7 +931,6 @@ public final class MediaQualityManager {
         *
         * @param profileId the ID of the profile.
         * @param profile the removed profile.
         * @hide
         */
        public void onSoundProfileRemoved(
                @NonNull String profileId, @NonNull SoundProfile profile) {
@@ -945,7 +940,6 @@ public final class MediaQualityManager {
         * This is invoked when an issue has occurred.
         *
         * @param errorCode the error code
         * @hide
         */
        public void onError(@SoundProfile.ErrorCode int errorCode) {
        }
@@ -957,7 +951,6 @@ public final class MediaQualityManager {
         * @param profileId the ID of the profile used by the media content. {@code null} if there
         *                  is no associated profile
         * @param updatedCaps the updated capabilities.
         * @hide
         */
        public void onParamCapabilitiesChanged(
                @Nullable String profileId, @NonNull List<ParamCapability> updatedCaps) {
+7 −5
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.media.quality;

import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import android.annotation.SystemApi;
import android.media.tv.TvInputInfo;
import android.media.tv.flags.Flags;
import android.os.Parcel;
@@ -33,10 +34,9 @@ import java.lang.annotation.RetentionPolicy;

/**
 * Profile for sound quality.
 * @hide
 */
@FlaggedApi(Flags.FLAG_MEDIA_QUALITY_FW)
public class SoundProfile implements Parcelable {
public final class SoundProfile implements Parcelable {
    @Nullable
    private String mId;
    private final int mType;
@@ -113,7 +113,7 @@ public class SoundProfile implements Parcelable {
     */
    public static final int ERROR_NOT_ALLOWLISTED = 4;

    protected SoundProfile(@NonNull Parcel in) {
    private SoundProfile(@NonNull Parcel in) {
        mId = in.readString();
        mType = in.readInt();
        mName = in.readString();
@@ -251,9 +251,8 @@ public class SoundProfile implements Parcelable {

    /**
     * A builder for {@link SoundProfile}
     * @hide
     */
    public static class Builder {
    public static final class Builder {
        @Nullable
        private String mId;
        private int mType = TYPE_APPLICATION;
@@ -300,6 +299,7 @@ public class SoundProfile implements Parcelable {
         *
         * @hide
         */
        @SystemApi
        @RequiresPermission(android.Manifest.permission.MANAGE_GLOBAL_SOUND_QUALITY_SERVICE)
        @NonNull
        public Builder setProfileType(@ProfileType int value) {
@@ -314,6 +314,7 @@ public class SoundProfile implements Parcelable {
         *
         * @hide
         */
        @SystemApi
        @RequiresPermission(android.Manifest.permission.MANAGE_GLOBAL_SOUND_QUALITY_SERVICE)
        @NonNull
        public Builder setInputId(@NonNull String value) {
@@ -328,6 +329,7 @@ public class SoundProfile implements Parcelable {
         *
         * @hide
         */
        @SystemApi
        @RequiresPermission(android.Manifest.permission.MANAGE_GLOBAL_SOUND_QUALITY_SERVICE)
        @NonNull
        public Builder setPackageName(@NonNull String value) {