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

Commit 9d09ed1d authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 12597516 from 2546a4c2 to 25Q1-release

Change-Id: I1cd3e6671f6b4531827268cccafbb010f7d28119
parents 081a0e57 2546a4c2
Loading
Loading
Loading
Loading
+28 −1
Original line number Diff line number Diff line
@@ -16,7 +16,11 @@

package android.media.quality;

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;

/**
 * Interface for Media Quality Manager
@@ -24,8 +28,31 @@ import android.media.quality.PictureProfile;
 */
interface IMediaQualityManager {
    PictureProfile createPictureProfile(in PictureProfile pp);
    void updatePictureProfile(in long id, in PictureProfile pp);
    void removePictureProfile(in long id);
    PictureProfile getPictureProfileById(in long id);
    List<PictureProfile> getPictureProfilesByPackage(in String packageName);
    List<PictureProfile> getAvailablePictureProfiles();
    List<PictureProfile> getAvailableAllPictureProfiles();
    List<PictureProfile> getAllPictureProfiles();

    SoundProfile createSoundProfile(in SoundProfile pp);
    void updateSoundProfile(in long id, in SoundProfile pp);
    void removeSoundProfile(in long id);
    SoundProfile getSoundProfileById(in long id);
    List<SoundProfile> getSoundProfilesByPackage(in String packageName);
    List<SoundProfile> getAvailableSoundProfiles();
    List<SoundProfile> getAllSoundProfiles();

    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
+1 −0
Original line number Diff line number Diff line
@@ -26,4 +26,5 @@ import android.media.quality.PictureProfile;
oneway interface IPictureProfileCallback {
    void onPictureProfileAdded(in long id, in PictureProfile p);
    void onPictureProfileUpdated(in long id, in PictureProfile p);
    void onPictureProfileRemoved(in long id, in PictureProfile p);
}
+30 −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;

import android.media.quality.SoundProfile;

/**
 * Interface to receive callbacks from IMediaQuality.
 * @hide
 */
oneway interface ISoundProfileCallback {
    void onSoundProfileAdded(in long id, in SoundProfile p);
    void onSoundProfileUpdated(in long id, in SoundProfile p);
    void onSoundProfileRemoved(in long id, in SoundProfile p);
}
+383 −7
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ import java.util.concurrent.Executor;
 */
@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";

@@ -48,6 +48,8 @@ public class MediaQualityManager {
    private final Object mLock = new Object();
    // @GuardedBy("mLock")
    private final List<PictureProfileCallbackRecord> mPpCallbackRecords = new ArrayList<>();
    // @GuardedBy("mLock")
    private final List<SoundProfileCallbackRecord> mSpCallbackRecords = new ArrayList<>();

    /**
     * @hide
@@ -55,7 +57,7 @@ public class MediaQualityManager {
    public MediaQualityManager(Context context, IMediaQualityManager service) {
        mContext = context;
        mService = service;
        IPictureProfileCallback mqCallback = new IPictureProfileCallback.Stub() {
        IPictureProfileCallback ppCallback = new IPictureProfileCallback.Stub() {
            @Override
            public void onPictureProfileAdded(long profileId, PictureProfile profile) {
                synchronized (mLock) {
@@ -74,14 +76,60 @@ public class MediaQualityManager {
                    }
                }
            }
            @Override
            public void onPictureProfileRemoved(long profileId, PictureProfile profile) {
                synchronized (mLock) {
                    for (PictureProfileCallbackRecord record : mPpCallbackRecords) {
                        // TODO: filter callback record
                        record.postPictureProfileRemoved(profileId, profile);
                    }
                }
            }
        };
        ISoundProfileCallback spCallback = new ISoundProfileCallback.Stub() {
            @Override
            public void onSoundProfileAdded(long profileId, SoundProfile profile) {
                synchronized (mLock) {
                    for (SoundProfileCallbackRecord record : mSpCallbackRecords) {
                        // TODO: filter callback record
                        record.postSoundProfileAdded(profileId, profile);
                    }
                }
            }
            @Override
            public void onSoundProfileUpdated(long profileId, SoundProfile profile) {
                synchronized (mLock) {
                    for (SoundProfileCallbackRecord record : mSpCallbackRecords) {
                        // TODO: filter callback record
                        record.postSoundProfileUpdated(profileId, profile);
                    }
                }
            }
            @Override
            public void onSoundProfileRemoved(long profileId, SoundProfile profile) {
                synchronized (mLock) {
                    for (SoundProfileCallbackRecord record : mSpCallbackRecords) {
                        // TODO: filter callback record
                        record.postSoundProfileRemoved(profileId, profile);
                    }
                }
            }
        };
        try {
            if (mService != null) {
                mService.registerPictureProfileCallback(ppCallback);
                mService.registerSoundProfileCallback(spCallback);
            }
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Registers a {@link PictureProfileCallback}.
     * @hide
     */
    public void registerCallback(
    public void registerPictureProfileCallback(
            @NonNull @CallbackExecutor Executor executor,
            @NonNull PictureProfileCallback callback) {
        Preconditions.checkNotNull(callback);
@@ -95,7 +143,7 @@ public class MediaQualityManager {
     * Unregisters the existing {@link PictureProfileCallback}.
     * @hide
     */
    public void unregisterCallback(@NonNull final PictureProfileCallback callback) {
    public void unregisterPictureProfileCallback(@NonNull final PictureProfileCallback callback) {
        Preconditions.checkNotNull(callback);
        synchronized (mLock) {
            for (Iterator<PictureProfileCallbackRecord> it = mPpCallbackRecords.iterator();
@@ -143,11 +191,11 @@ public class MediaQualityManager {
        }
    }

    /** @SystemApi all stored picture profiles */
    /** @SystemApi all stored picture profiles of all packages */
    @RequiresPermission(android.Manifest.permission.MANAGE_GLOBAL_PICTURE_QUALITY_SERVICE)
    public List<PictureProfile> getAvailableAllPictureProfiles() {
    public List<PictureProfile> getAllPictureProfiles() {
        try {
            return mService.getAvailableAllPictureProfiles();
            return mService.getAllPictureProfiles();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -167,6 +215,246 @@ public class MediaQualityManager {
        }
    }


    /**
     * Updates an existing picture profile and store it in the system.
     */
    public void updatePictureProfile(long profileId, PictureProfile pp) {
        try {
            mService.updatePictureProfile(profileId, pp);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }


    /**
     * Removes a picture profile from the system.
     */
    public void removePictureProfile(long profileId) {
        try {
            mService.removePictureProfile(profileId);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Registers a {@link SoundProfileCallback}.
     * @hide
     */
    public void registerSoundProfileCallback(
            @NonNull @CallbackExecutor Executor executor,
            @NonNull SoundProfileCallback callback) {
        Preconditions.checkNotNull(callback);
        Preconditions.checkNotNull(executor);
        synchronized (mLock) {
            mSpCallbackRecords.add(new SoundProfileCallbackRecord(callback, executor));
        }
    }

    /**
     * Unregisters the existing {@link SoundProfileCallback}.
     * @hide
     */
    public void unregisterSoundProfileCallback(@NonNull final SoundProfileCallback callback) {
        Preconditions.checkNotNull(callback);
        synchronized (mLock) {
            for (Iterator<SoundProfileCallbackRecord> it = mSpCallbackRecords.iterator();
                    it.hasNext(); ) {
                SoundProfileCallbackRecord record = it.next();
                if (record.getCallback() == callback) {
                    it.remove();
                    break;
                }
            }
        }
    }


    /**
     * Gets sound profile by given profile ID.
     * @return the corresponding sound profile if available; {@code null} if the ID doesn't
     *         exist or the profile is not accessible to the caller.
     */
    public SoundProfile getSoundProfileById(long profileId) {
        try {
            return mService.getSoundProfileById(profileId);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }


    /** @SystemApi gets profiles that available to the given package */
    @RequiresPermission(android.Manifest.permission.MANAGE_GLOBAL_SOUND_QUALITY_SERVICE)
    public List<SoundProfile> getSoundProfilesByPackage(String packageName) {
        try {
            return mService.getSoundProfilesByPackage(packageName);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /** Gets profiles that available to the caller package */
    public List<SoundProfile> getAvailableSoundProfiles() {
        try {
            return mService.getAvailableSoundProfiles();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /** @SystemApi all stored sound profiles of all packages */
    @RequiresPermission(android.Manifest.permission.MANAGE_GLOBAL_SOUND_QUALITY_SERVICE)
    public List<SoundProfile> getAllSoundProfiles() {
        try {
            return mService.getAllSoundProfiles();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }


    /**
     * Creates a sound profile and store it in the system.
     *
     * @return the stored profile with an assigned profile ID.
     */
    public SoundProfile createSoundProfile(SoundProfile sp) {
        try {
            return mService.createSoundProfile(sp);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }


    /**
     * Updates an existing sound profile and store it in the system.
     */
    public void updateSoundProfile(long profileId, SoundProfile sp) {
        try {
            mService.updateSoundProfile(profileId, sp);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }


    /**
     * Removes a sound profile from the system.
     */
    public void removeSoundProfile(long profileId) {
        try {
            mService.removeSoundProfile(profileId);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * 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;
@@ -198,6 +486,57 @@ public class MediaQualityManager {
                }
            });
        }

        public void postPictureProfileRemoved(final long id, PictureProfile profile) {
            mExecutor.execute(new Runnable() {
                @Override
                public void run() {
                    mCallback.onPictureProfileRemoved(id, profile);
                }
            });
        }
    }

    private static final class SoundProfileCallbackRecord {
        private final SoundProfileCallback mCallback;
        private final Executor mExecutor;

        SoundProfileCallbackRecord(SoundProfileCallback callback, Executor executor) {
            mCallback = callback;
            mExecutor = executor;
        }

        public SoundProfileCallback getCallback() {
            return mCallback;
        }

        public void postSoundProfileAdded(final long id, SoundProfile profile) {

            mExecutor.execute(new Runnable() {
                @Override
                public void run() {
                    mCallback.onSoundProfileAdded(id, profile);
                }
            });
        }

        public void postSoundProfileUpdated(final long id, SoundProfile profile) {
            mExecutor.execute(new Runnable() {
                @Override
                public void run() {
                    mCallback.onSoundProfileUpdated(id, profile);
                }
            });
        }

        public void postSoundProfileRemoved(final long id, SoundProfile profile) {
            mExecutor.execute(new Runnable() {
                @Override
                public void run() {
                    mCallback.onSoundProfileRemoved(id, profile);
                }
            });
        }
    }

    /**
@@ -215,5 +554,42 @@ public class MediaQualityManager {
         */
        public void onPictureProfileUpdated(long id, PictureProfile profile) {
        }
        /**
         * @hide
         */
        public void onPictureProfileRemoved(long id, PictureProfile profile) {
        }
        /**
         * @hide
         */
        public void onError(int errorCode) {
        }
    }

    /**
     * Callback used to monitor status of sound profiles.
     * @hide
     */
    public abstract static class SoundProfileCallback {
        /**
         * @hide
         */
        public void onSoundProfileAdded(long id, SoundProfile profile) {
        }
        /**
         * @hide
         */
        public void onSoundProfileUpdated(long id, SoundProfile profile) {
        }
        /**
         * @hide
         */
        public void onSoundProfileRemoved(long id, SoundProfile profile) {
        }
        /**
         * @hide
         */
        public void onError(int errorCode) {
        }
    }
}
+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 ParamCapability;
Loading