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

Commit 903d6b72 authored by Jaewan Kim's avatar Jaewan Kim Committed by Youngsang Cho
Browse files

TIF: Add unblock content

When a TV content is blocked by the parental control settings,
TV input service will notify TV to request user's PIN code verification.

If the verification succeeds, TV input service will be notified back
that content is unblocked so it can keep playing the content.

Bug: 13172379
Change-Id: I7b31d762eb54612c4d8779ee133211f32fb73b05
parent 55982169
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -16673,6 +16673,7 @@ package android.media.tv {
    method public void dispatchTrackInfoChanged(java.util.List<android.media.tv.TvTrackInfo>);
    method public void dispatchVideoAvailable();
    method public void dispatchVideoUnavailable(int);
    method public abstract void onContentUnblocked(android.media.tv.TvContentRating);
    method public android.view.View onCreateOverlayView();
    method public boolean onGenericMotionEvent(android.view.MotionEvent);
    method public boolean onKeyDown(int, android.view.KeyEvent);
+2 −0
Original line number Diff line number Diff line
@@ -56,6 +56,8 @@ interface ITvInputManager {
    void relayoutOverlayView(in IBinder sessionToken, in Rect frame, int userId);
    void removeOverlayView(in IBinder sessionToken, int userId);

    void unblockContent(in IBinder sessionToken, in String unblockedRating, int userId);

    // For TV input hardware binding
    List<TvInputHardwareInfo> getHardwareList();
    /*
+2 −0
Original line number Diff line number Diff line
@@ -41,4 +41,6 @@ oneway interface ITvInputSession {
    void createOverlayView(in IBinder windowToken, in Rect frame);
    void relayoutOverlayView(in Rect frame);
    void removeOverlayView();

    void unblockContent(in String unblockedRating);
}
+10 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
    private static final int DO_CREATE_OVERLAY_VIEW = 9;
    private static final int DO_RELAYOUT_OVERLAY_VIEW = 10;
    private static final int DO_REMOVE_OVERLAY_VIEW = 11;
    private static final int DO_UNBLOCK_CONTENT = 12;

    private final HandlerCaller mCaller;

@@ -132,6 +133,10 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
                mTvInputSessionImpl.removeOverlayView(true);
                return;
            }
            case DO_UNBLOCK_CONTENT: {
                mTvInputSessionImpl.unblockContent((String) msg.obj);
                return;
            }
            default: {
                Log.w(TAG, "Unhandled message code: " + msg.what);
                return;
@@ -196,6 +201,11 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
        mCaller.executeOrSendMessage(mCaller.obtainMessage(DO_REMOVE_OVERLAY_VIEW));
    }

    @Override
    public void unblockContent(String unblockedRating) {
        mCaller.executeOrSendMessage(mCaller.obtainMessageO(DO_UNBLOCK_CONTENT, unblockedRating));
    }

    private final class TvInputEventReceiver extends InputEventReceiver {
        public TvInputEventReceiver(InputChannel inputChannel, Looper looper) {
            super(inputChannel, looper);
+15 −0
Original line number Diff line number Diff line
@@ -877,6 +877,21 @@ public final class TvInputManager {
            }
        }

        /**
         * Unblock content blocked by parental controls.
         */
        void unblockContent(TvContentRating unblockedRating) {
            if (mToken == null) {
                Log.w(TAG, "The session has been already released");
                return;
            }
            try {
                mService.unblockContent(mToken, unblockedRating.flattenToString(), mUserId);
            } catch (RemoteException e) {
                throw new RuntimeException(e);
            }
        }

        /**
         * Dispatches an input event to this session.
         *
Loading