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

Commit 79fc3279 authored by Dongwon Kang's avatar Dongwon Kang Committed by Android (Google) Code Review
Browse files

Merge "TIF: verify the hardware input ID from getHardwareInputId()." into lmp-dev

parents 611f8f17 911d0827
Loading
Loading
Loading
Loading
+20 −3
Original line number Diff line number Diff line
@@ -94,6 +94,8 @@ public abstract class TvInputService extends Service {
    private final RemoteCallbackList<ITvInputServiceCallback> mCallbacks =
            new RemoteCallbackList<ITvInputServiceCallback>();

    private TvInputManager mTvInputManager;

    @Override
    public final IBinder onBind(Intent intent) {
        return new ITvInputService.Stub() {
@@ -225,6 +227,17 @@ public abstract class TvInputService extends Service {
        return null;
    }

    private boolean isPassthroughInput(String inputId) {
        if (mTvInputManager == null) {
            mTvInputManager = (TvInputManager) getSystemService(Context.TV_INPUT_SERVICE);
        }
        TvInputInfo info = mTvInputManager.getTvInputInfo(inputId);
        if (info != null && info.isPassthroughInput()) {
            return true;
        }
        return false;
    }

    /**
     * Base class for derived classes to implement to provide a TV input session.
     */
@@ -1229,9 +1242,14 @@ public abstract class TvInputService extends Service {
                        HardwareSession proxySession =
                                ((HardwareSession) sessionImpl);
                        String harewareInputId = proxySession.getHardwareInputId();
                        if (TextUtils.isEmpty(harewareInputId) ||
                                !isPassthroughInput(harewareInputId)) {
                            if (TextUtils.isEmpty(harewareInputId)) {
                            sessionImpl.onRelease();
                                Log.w(TAG, "Hardware input id is not setup yet.");
                            } else {
                                Log.w(TAG, "Invalid hardware input id : " + harewareInputId);
                            }
                            sessionImpl.onRelease();
                            try {
                                cb.onSessionCreated(null, null);
                            } catch (RemoteException e) {
@@ -1239,7 +1257,6 @@ public abstract class TvInputService extends Service {
                            }
                            return;
                        }
                        // TODO: check if the given ID is really hardware TV input.
                        proxySession.mProxySession = stub;
                        proxySession.mProxySessionCallback = cb;
                        proxySession.mServiceHandler = mServiceHandler;