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

Commit 568530db authored by Haofan Wang's avatar Haofan Wang
Browse files

Notify application about previous stream status

Test: gabmit
Bug: 425486793
Bug: 427625166
Flag: EXEMPT bugfix
Change-Id: Ifb3e4974ec7ed65ebf3021a610d97eba65b6c2ea
parent 1982c924
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -387,6 +387,30 @@ public final class PictureProfile implements Parcelable {
        return new PersistableBundle(mParams);
    }

    /**
     * Add a string parameter
     * Used by system only.
     * @hide
     */
    public void addStringParameter(String key, String value) {
        mParams.putString(key, value);
    }

    /**
     * Copies all info from the given profile
     * @hide
     */
    public static PictureProfile copyFrom(PictureProfile orig) {
        return new PictureProfile(
                orig.mId,
                orig.mType,
                orig.mName,
                orig.mInputId,
                orig.mPackageName,
                new PersistableBundle(orig.mParams),
                orig.mHandle);
    }

    /**
     * Gets profile handle
     * @hide
+27 −2
Original line number Diff line number Diff line
@@ -2183,10 +2183,25 @@ public class MediaQualityService extends SystemService {
                            PersistableBundle currentSdrParameter = currentSdr.getParameters();
                            currentSdrParameter.putString(
                                    STREAM_STATUS_NOT_CREATED, newStatus);
                            currentSdrParameter.putString(STREAM_STATUS, PictureProfile.STATUS_SDR);
                            // Add previous stream status information so that application can use
                            // this flag to indicate that there is a onStreamStatusChange.
                            currentSdrParameter.putString(PREVIOUS_STREAM_STATUS, profileStatus);
                            currentSdr.addStringParameter(STREAM_STATUS, PictureProfile.STATUS_SDR);
                            // PREVIOUS_STREAM_STATUS is used for one time, so copy the current
                            // profile
                            PictureProfile currentCopy = PictureProfile.copyFrom(currentSdr);
                            currentCopy.addStringParameter(PREVIOUS_STREAM_STATUS, profileStatus);
                            mHandleToPictureProfile.put(profileHandle, currentSdr);
                            mCurrentPictureHandleToOriginal.removeValue(profileHandle);
                            mCurrentPictureHandleToOriginal.put(
                                    currentSdr.getHandle().getId(), profileHandle);
                            mMqManagerNotifier.notifyOnPictureProfileUpdated(
                                    currentCopy.getProfileId(), currentCopy, Process.INVALID_UID,
                                    Process.INVALID_PID);

                            mPictureProfileForHal.add(profileHandle);
                            mPictureProfileForHal.add(currentSdr.getHandle().getId());
                            mHalNotifier.notifyHalOnPictureProfileChange(profileHandle,
                                    currentSdrParameter);

@@ -2199,12 +2214,17 @@ public class MediaQualityService extends SystemService {
                        // Add previous stream status information so that application can use this
                        // flag to indicate that there is a onStreamStatusChange.
                        currentProfileParameters.putString(PREVIOUS_STREAM_STATUS, profileStatus);
                        current.addStringParameter(STREAM_STATUS, newStatus);
                        // PREVIOUS_STREAM_STATUS is used for one time, so copy the current profile
                        PictureProfile currentCopy = PictureProfile.copyFrom(current);
                        currentCopy.addStringParameter(PREVIOUS_STREAM_STATUS, profileStatus);
                        mHandleToPictureProfile.put(profileHandle, current);
                        mCurrentPictureHandleToOriginal.removeValue(profileHandle);
                        mCurrentPictureHandleToOriginal.put(
                                current.getHandle().getId(), profileHandle);
                        // TODO: use package name to notify
                        mMqManagerNotifier.notifyOnPictureProfileUpdated(
                                current.getProfileId(), current, Process.INVALID_UID,
                                currentCopy.getProfileId(), currentCopy, Process.INVALID_UID,
                                Process.INVALID_PID);

                        mPictureProfileForHal.add(profileHandle);
@@ -2230,12 +2250,17 @@ public class MediaQualityService extends SystemService {
                        // Add previous stream status information so that application can use this
                        // flag to indicate that there is a onStreamStatusChange.
                        currentProfileParameters.putString(PREVIOUS_STREAM_STATUS, profileStatus);
                        current.addStringParameter(STREAM_STATUS, PictureProfile.STATUS_SDR);
                        // PREVIOUS_STREAM_STATUS is used for one time, so copy the current profile
                        PictureProfile currentCopy = PictureProfile.copyFrom(current);
                        currentCopy.addStringParameter(PREVIOUS_STREAM_STATUS, profileStatus);
                        mHandleToPictureProfile.put(profileHandle, current);
                        mCurrentPictureHandleToOriginal.removeValue(profileHandle);
                        mCurrentPictureHandleToOriginal.put(
                                current.getHandle().getId(), profileHandle);
                        // TODO: use package name to notify
                        mMqManagerNotifier.notifyOnPictureProfileUpdated(
                                current.getProfileId(), current, Process.INVALID_UID,
                                currentCopy.getProfileId(), currentCopy, Process.INVALID_UID,
                                Process.INVALID_PID);

                        mPictureProfileForHal.add(current.getHandle().getId());