[MQ] Add auto-PQ, SR, and capabilities methods
Test: mmm
Flag: android.media.tv.flags.media_quality_fw
Bug: 377071801
Bug: 377072035
Change-Id: I9d8eeba27bfef9611f34e9b6bca98f0a83a2ad9d
diff --git a/media/java/android/media/quality/IMediaQualityManager.aidl b/media/java/android/media/quality/IMediaQualityManager.aidl
index 8c17236..83f8e79 100644
--- a/media/java/android/media/quality/IMediaQualityManager.aidl
+++ b/media/java/android/media/quality/IMediaQualityManager.aidl
@@ -18,6 +18,7 @@
import android.media.quality.IPictureProfileCallback;
import android.media.quality.ISoundProfileCallback;
+import android.media.quality.ParamCapability;
import android.media.quality.PictureProfile;
import android.media.quality.SoundProfile;
@@ -44,4 +45,14 @@
void registerPictureProfileCallback(in IPictureProfileCallback cb);
void registerSoundProfileCallback(in ISoundProfileCallback cb);
+
+ List<ParamCapability> getParamCapabilities(in List<String> names);
+
+ boolean isSupported();
+ void setAutoPictureQualityEnabled(in boolean enabled);
+ boolean isAutoPictureQualityEnabled();
+ void setSuperResolutionEnabled(in boolean enabled);
+ boolean isSuperResolutionEnabled();
+ void setAutoSoundQualityEnabled(in boolean enabled);
+ boolean isAutoSoundQualityEnabled();
}
\ No newline at end of file
diff --git a/media/java/android/media/quality/MediaQualityManager.java b/media/java/android/media/quality/MediaQualityManager.java
index 61600ed..23f3b59 100644
--- a/media/java/android/media/quality/MediaQualityManager.java
+++ b/media/java/android/media/quality/MediaQualityManager.java
@@ -39,7 +39,7 @@
*/
@FlaggedApi(Flags.FLAG_MEDIA_QUALITY_FW)
@SystemService(Context.MEDIA_QUALITY_SERVICE)
-public class MediaQualityManager {
+public final class MediaQualityManager {
// TODO: unhide the APIs for api review
private static final String TAG = "MediaQualityManager";
@@ -287,7 +287,7 @@
/** @SystemApi gets profiles that available to the given package */
- @RequiresPermission(android.Manifest.permission.MANAGE_GLOBAL_PICTURE_QUALITY_SERVICE)
+ @RequiresPermission(android.Manifest.permission.MANAGE_GLOBAL_SOUND_QUALITY_SERVICE)
public List<SoundProfile> getSoundProfilesByPackage(String packageName) {
try {
return mService.getSoundProfilesByPackage(packageName);
@@ -306,7 +306,7 @@
}
/** @SystemApi all stored sound profiles of all packages */
- @RequiresPermission(android.Manifest.permission.MANAGE_GLOBAL_PICTURE_QUALITY_SERVICE)
+ @RequiresPermission(android.Manifest.permission.MANAGE_GLOBAL_SOUND_QUALITY_SERVICE)
public List<SoundProfile> getAllSoundProfiles() {
try {
return mService.getAllSoundProfiles();
@@ -353,6 +353,108 @@
}
}
+ /**
+ * Gets capability information of the given parameters.
+ */
+ public List<ParamCapability> getParamCapabilities(List<String> names) {
+ try {
+ return mService.getParamCapabilities(names);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Returns {@code true} if media quality HAL is implemented; {@code false} otherwise.
+ */
+ public boolean isSupported() {
+ try {
+ return mService.isSupported();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Enables or disables auto picture quality.
+ * <p>If enabled, picture quality parameters can be adjusted dynamically by hardware based on
+ * different use cases.
+ *
+ * @param enabled {@code true} to enable, {@code false} to disable.
+ */
+ @RequiresPermission(android.Manifest.permission.MANAGE_GLOBAL_PICTURE_QUALITY_SERVICE)
+ public void setAutoPictureQualityEnabled(boolean enabled) {
+ try {
+ mService.setAutoPictureQualityEnabled(enabled);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Returns {@code true} if auto picture quality is enabled; {@code false} otherwise.
+ */
+ public boolean isAutoPictureQualityEnabled() {
+ try {
+ return mService.isAutoPictureQualityEnabled();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Enables or disables super resolution.
+ * <p>Super resolution is a feature to improve resolution.
+ *
+ * @param enabled {@code true} to enable, {@code false} to disable.
+ */
+ @RequiresPermission(android.Manifest.permission.MANAGE_GLOBAL_PICTURE_QUALITY_SERVICE)
+ public void setSuperResolutionEnabled(boolean enabled) {
+ try {
+ mService.setSuperResolutionEnabled(enabled);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Returns {@code true} if super resolution is enabled; {@code false} otherwise.
+ */
+ public boolean isSuperResolutionEnabled() {
+ try {
+ return mService.isSuperResolutionEnabled();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Enables or disables auto sound quality.
+ * <p>If enabled, sound quality parameters can be adjusted dynamically by hardware based on
+ * different use cases.
+ *
+ * @param enabled {@code true} to enable, {@code false} to disable.
+ */
+ @RequiresPermission(android.Manifest.permission.MANAGE_GLOBAL_SOUND_QUALITY_SERVICE)
+ public void setAutoSoundQualityEnabled(boolean enabled) {
+ try {
+ mService.setAutoSoundQualityEnabled(enabled);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Returns {@code true} if auto sound quality is enabled; {@code false} otherwise.
+ */
+ public boolean isAutoSoundQualityEnabled() {
+ try {
+ return mService.isAutoSoundQualityEnabled();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
private static final class PictureProfileCallbackRecord {
private final PictureProfileCallback mCallback;
private final Executor mExecutor;
diff --git a/media/java/android/media/quality/ParamCapability.aidl b/media/java/android/media/quality/ParamCapability.aidl
new file mode 100644
index 0000000..b43409d
--- /dev/null
+++ b/media/java/android/media/quality/ParamCapability.aidl
@@ -0,0 +1,19 @@
+/*
+ * 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 ParamCapability;
diff --git a/media/java/android/media/quality/ParamCapability.java b/media/java/android/media/quality/ParamCapability.java
new file mode 100644
index 0000000..70e8592
--- /dev/null
+++ b/media/java/android/media/quality/ParamCapability.java
@@ -0,0 +1,187 @@
+/*
+ * 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;
+
+import android.annotation.FlaggedApi;
+import android.annotation.IntDef;
+import android.annotation.StringDef;
+import android.media.tv.flags.Flags;
+import android.os.Bundle;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import androidx.annotation.NonNull;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Capability info of media quality parameters
+ * @hide
+ */
+@FlaggedApi(Flags.FLAG_MEDIA_QUALITY_FW)
+public class ParamCapability implements Parcelable {
+
+ /** @hide */
+ @IntDef(flag = true, prefix = { "TYPE_" }, value = {
+ TYPE_INT,
+ TYPE_LONG,
+ TYPE_DOUBLE,
+ TYPE_STRING,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface ParamType {}
+
+ /**
+ * Integer parameter type
+ */
+ public static final int TYPE_INT = 1;
+
+ /**
+ * Long integer parameter type
+ */
+ public static final int TYPE_LONG = 2;
+
+ /**
+ * Double parameter type
+ */
+ public static final int TYPE_DOUBLE = 3;
+
+ /**
+ * String parameter type
+ */
+ public static final int TYPE_STRING = 4;
+
+ /** @hide */
+ @StringDef(prefix = { "CAPABILITY_" }, value = {
+ CAPABILITY_MAX,
+ CAPABILITY_MIN,
+ CAPABILITY_DEFAULT,
+ CAPABILITY_ENUM,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface Capability {}
+
+ /**
+ * The key for the max possible value of this parameter.
+ */
+ public static final String CAPABILITY_MAX = "max";
+
+ /**
+ * The key for the min possible value of this parameter.
+ */
+ public static final String CAPABILITY_MIN = "min";
+
+ /**
+ * The key for the default value of this parameter.
+ */
+ public static final String CAPABILITY_DEFAULT = "default";
+
+ /**
+ * The key for the enumeration of this parameter.
+ */
+ public static final String CAPABILITY_ENUM = "enum";
+
+ @NonNull
+ private final String mName;
+ private final boolean mIsSupported;
+ @ParamType
+ private final int mType;
+ @NonNull
+ private final Bundle mCaps;
+
+ protected ParamCapability(Parcel in) {
+ mName = in.readString();
+ mIsSupported = in.readBoolean();
+ mType = in.readInt();
+ mCaps = in.readBundle();
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeString(mName);
+ dest.writeBoolean(mIsSupported);
+ dest.writeInt(mType);
+ dest.writeBundle(mCaps);
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ public static final Creator<ParamCapability> CREATOR = new Creator<ParamCapability>() {
+ @Override
+ public ParamCapability createFromParcel(Parcel in) {
+ return new ParamCapability(in);
+ }
+
+ @Override
+ public ParamCapability[] newArray(int size) {
+ return new ParamCapability[size];
+ }
+ };
+
+
+ /**
+ * Creates a new ParamCapability.
+ *
+ * @hide
+ */
+ public ParamCapability(
+ @NonNull String name,
+ boolean isSupported,
+ int type,
+ @NonNull Bundle caps) {
+ this.mName = name;
+ this.mIsSupported = isSupported;
+ this.mType = type;
+ this.mCaps = caps;
+ }
+
+ /**
+ * Gets parameter name.
+ */
+ @NonNull
+ public String getParamName() {
+ return mName;
+ }
+
+ /**
+ * Returns whether this parameter is supported or not.
+ */
+ public boolean isSupported() {
+ return mIsSupported;
+ }
+
+ /**
+ * Gets parameter type.
+ */
+ @ParamType
+ public int getParamType() {
+ return mType;
+ }
+
+ /**
+ * Gets capability information.
+ * <p>e.g. use the key {@link #CAPABILITY_MAX} to get the max value.
+ */
+ @NonNull
+ public Bundle getCapabilities() {
+ return new Bundle(mCaps);
+ }
+}
diff --git a/services/core/java/com/android/server/media/quality/MediaQualityService.java b/services/core/java/com/android/server/media/quality/MediaQualityService.java
index 57c9f51..e15d414 100644
--- a/services/core/java/com/android/server/media/quality/MediaQualityService.java
+++ b/services/core/java/com/android/server/media/quality/MediaQualityService.java
@@ -20,6 +20,7 @@
import android.media.quality.IMediaQualityManager;
import android.media.quality.IPictureProfileCallback;
import android.media.quality.ISoundProfileCallback;
+import android.media.quality.ParamCapability;
import android.media.quality.PictureProfile;
import android.media.quality.SoundProfile;
@@ -117,5 +118,44 @@
@Override
public void registerSoundProfileCallback(final ISoundProfileCallback callback) {
}
+
+
+ @Override
+ public List<ParamCapability> getParamCapabilities(List<String> names) {
+ return new ArrayList<>();
+ }
+
+
+ @Override
+ public boolean isSupported() {
+ return false;
+ }
+
+ @Override
+ public void setAutoPictureQualityEnabled(boolean enabled) {
+ }
+
+ @Override
+ public boolean isAutoPictureQualityEnabled() {
+ return false;
+ }
+
+ @Override
+ public void setSuperResolutionEnabled(boolean enabled) {
+ }
+
+ @Override
+ public boolean isSuperResolutionEnabled() {
+ return false;
+ }
+
+ @Override
+ public void setAutoSoundQualityEnabled(boolean enabled) {
+ }
+
+ @Override
+ public boolean isAutoSoundQualityEnabled() {
+ return false;
+ }
}
}