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

Commit f794ef9e authored by Haofan Wang's avatar Haofan Wang Committed by Cherrypicker Worker
Browse files

Handle apply default picture profile for Tv Input[1/2]

For the cases that APK does not use media codec to set default TV input
picture profile, we need TvView to retrieve the TV input picture profile
handle from Media Quality Framework, then set this handle to
SurfaceView, so that the Composer HAL is able to get the correct default
handle.

Bug: 420934125
Test: Tested on Gambit and check the log. Discover that the handle is
correct and succrddfully send to the Composer HAL.
Flag: EXEMPT bugfix
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:6f7a6ddde40f622933e1ae0bedd67f74d5c688ea)
Merged-In: I475c7fb983faade61d4cf84556e46b53d3e3d125
Change-Id: I475c7fb983faade61d4cf84556e46b53d3e3d125
parent afaaf340
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -35,6 +35,8 @@ import android.graphics.RectF;
import android.graphics.Region;
import android.media.AudioPresentation;
import android.media.PlaybackParams;
import android.media.quality.MediaQualityManager;
import android.media.quality.PictureProfileHandle;
import android.media.tv.TvInputManager.Session;
import android.media.tv.TvInputManager.Session.FinishedInputEventCallback;
import android.media.tv.TvInputManager.SessionCallback;
@@ -98,6 +100,7 @@ public class TvView extends ViewGroup {
    private boolean mOverlayViewCreated;
    private Rect mOverlayViewFrame;
    private final TvInputManager mTvInputManager;
    private final MediaQualityManager mMediaQualityManager;
    private MySessionCallback mSessionCallback;
    private TvInputCallback mCallback;
    private OnUnhandledInputEventListener mOnUnhandledInputEventListener;
@@ -194,6 +197,8 @@ public class TvView extends ViewGroup {
        mDefStyleAttr = defStyleAttr;
        resetSurfaceView();
        mTvInputManager = (TvInputManager) getContext().getSystemService(Context.TV_INPUT_SERVICE);
        mMediaQualityManager = (MediaQualityManager) getContext().getSystemService(
                Context.MEDIA_QUALITY_SERVICE);
        mTvAppAttributionSource = getContext().getAttributionSource();
    }

@@ -391,6 +396,21 @@ public class TvView extends ViewGroup {
            // MySessionCallback.this is different from mSessionCallback, we know that this callback
            // is obsolete and should ignore it.
            mSessionCallback = new MySessionCallback(inputId, channelUri, params);
            if (mSurfaceView != null && mMediaQualityManager != null) {
                String idForProfile = inputId;
                TvInputInfo tvInputInfo = mTvInputManager.getTvInputInfo(inputId);
                if (tvInputInfo != null && tvInputInfo.getParentId() != null) {
                    idForProfile = tvInputInfo.getParentId();
                    if (DEBUG) {
                        Log.d(TAG, "the parent of inputId received is " + idForProfile);
                    }
                }
                long handle = mMediaQualityManager.getPictureProfileForTvInput(idForProfile);
                if (handle > 0) {
                    PictureProfileHandle pph = new PictureProfileHandle(handle);
                    mSurfaceView.sendPictureProfileHandle(pph);
                }
            }
            if (mTvInputManager != null) {
                mTvInputManager.createSession(
                        inputId, mTvAppAttributionSource, mSessionCallback, mHandler);