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

Commit 7f93eefe authored by Shubang Lu's avatar Shubang Lu
Browse files

[MQ] Handle more picture profiles for TV input

Bug: 416160987
Bug: 416160883
Test: CTS
Flag: EXEMPT bugfix
Change-Id: Ifd2e877ce6d503becab77622d8f1a5b3f5cb0e77
parent 6656eb4c
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -429,6 +429,32 @@ public final class MediaQualityManager {
        }
    }

    /**
     * Gets current picture profile instance for TV input.
     * @hide
     */
    public PictureProfile getCurrentPictureProfileForTvInput(String inputId) {
        try {
            return mService.getCurrentPictureProfileForTvInput(
                    inputId, mUserHandle.getIdentifier());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Gets all picture profiles instance for TV input.
     * @hide
     */
    public List<PictureProfile> getAllPictureProfilesForTvInput(String inputId) {
        try {
            return mService.getAllPictureProfilesForTvInput(
                    inputId, mUserHandle.getIdentifier());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Gets sound profile handle by profile ID.
     * @hide
+2 −0
Original line number Diff line number Diff line
@@ -54,6 +54,8 @@ interface IMediaQualityManager {
    void notifyPictureProfileHandleSelection(in long handle, int userId);

    long getPictureProfileForTvInput(in String inputId, int userId);
    PictureProfile getCurrentPictureProfileForTvInput(in String inputId, int userId);
    List<PictureProfile> getAllPictureProfilesForTvInput(in String inputId, int userId);

    void createSoundProfile(in SoundProfile pp, int userId);
    void updateSoundProfile(in String id, in SoundProfile pp, int userId);
+42 −0
Original line number Diff line number Diff line
@@ -666,6 +666,48 @@ public class MediaQualityService extends SystemService {
            }
        }

        public PictureProfile getCurrentPictureProfileForTvInput(String inputId, int userId) {
            long profileHandle = getPictureProfileForTvInput(inputId, userId);
            if (profileHandle == -1) {
                return null;
            }
            return mMqDatabaseUtils.getPictureProfile(profileHandle);
        }

        public List<PictureProfile> getAllPictureProfilesForTvInput(String inputId, int userId) {
            // TODO: cache profiles
            int callingUid = Binder.getCallingUid();
            int callingPid = Binder.getCallingPid();
            if (!hasGlobalPictureQualityServicePermission(callingUid, callingPid)) {
                mMqManagerNotifier.notifyOnPictureProfileError(
                        null, PictureProfile.ERROR_NO_PERMISSION, callingUid, callingPid);
            }
            String[] columns = {BaseParameters.PARAMETER_ID};
            String selection = BaseParameters.PARAMETER_TYPE + " = ? AND "
                    + BaseParameters.PARAMETER_INPUT_ID + " = ?";
            String[] selectionArguments = {
                    Integer.toString(PictureProfile.TYPE_SYSTEM),
                    inputId
            };
            List<PictureProfile> profiles = new ArrayList<>();
            synchronized (mPictureProfileLock) {
                try (Cursor cursor = mMqDatabaseUtils.getCursorAfterQuerying(
                        mMediaQualityDbHelper.PICTURE_QUALITY_TABLE_NAME,
                        columns, selection, selectionArguments)) {
                    int count = cursor.getCount();
                    if (count == 0) {
                        return profiles;
                    }
                    cursor.moveToFirst();
                    while (cursor.moveToNext()) {
                        profiles.add(MediaQualityUtils.convertCursorToPictureProfileWithTempId(
                                cursor, mPictureProfileTempIdMap));
                    }
                    return profiles;
                }
            }
        }

        @GuardedBy("mSoundProfileLock")
        @Override
        public List<SoundProfileHandle> getSoundProfileHandle(String[] ids, int userId) {