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

Commit d5386fd4 authored by Donghyun Cho's avatar Donghyun Cho Committed by Android (Google) Code Review
Browse files

Merge "CEC: Add a method to control standby mode of the device"

parents 7cf9be02 b3515648
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -16493,6 +16493,7 @@ package android.hardware.hdmi {
    method public android.hardware.hdmi.HdmiPlaybackClient getPlaybackClient();
    method public android.hardware.hdmi.HdmiTvClient getTvClient();
    method public void removeHotplugEventListener(android.hardware.hdmi.HdmiControlManager.HotplugEventListener);
    method public void setStandbyMode(boolean);
    field public static final java.lang.String ACTION_OSD_MESSAGE = "android.hardware.hdmi.action.OSD_MESSAGE";
    field public static final int AVR_VOLUME_MUTED = 101; // 0x65
    field public static final int CLEAR_TIMER_STATUS_CEC_DISABLE = 162; // 0xa2
+14 −0
Original line number Diff line number Diff line
@@ -337,6 +337,20 @@ public final class HdmiControlManager {
        return (HdmiTvClient) getClient(HdmiDeviceInfo.DEVICE_TV);
    }

    /**
     * Controls standby mode of the system. It will also try to turn on/off the connected devices if
     * necessary.
     *
     * @param isStandbyModeOn target status of the system's standby mode
     */
    public void setStandbyMode(boolean isStandbyModeOn) {
        try {
            mService.setStandbyMode(isStandbyModeOn);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Listener used to get hotplug event from HDMI port.
     */
+1 −0
Original line number Diff line number Diff line
@@ -71,4 +71,5 @@ interface IHdmiControlService {
    void clearTimerRecording(int recorderAddress, int sourceType, in byte[] recordSource);
    void sendMhlVendorCommand(int portId, int offset, int length, in byte[] data);
    void addHdmiMhlVendorCommandListener(IHdmiMhlVendorCommandListener listener);
    void setStandbyMode(boolean isStandbyModeOn);
}
+34 −0
Original line number Diff line number Diff line
@@ -1658,6 +1658,17 @@ public final class HdmiControlService extends SystemService {
            HdmiControlService.this.addHdmiMhlVendorCommandListener(listener);
        }

        @Override
        public void setStandbyMode(final boolean isStandbyModeOn) {
            enforceAccessPermission();
            runOnServiceThread(new Runnable() {
                @Override
                public void run() {
                    HdmiControlService.this.setStandbyMode(isStandbyModeOn);
                }
            });
        }

        @Override
        protected void dump(FileDescriptor fd, final PrintWriter writer, String[] args) {
            getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG);
@@ -2203,6 +2214,29 @@ public final class HdmiControlService extends SystemService {
        }
    }

    void setStandbyMode(boolean isStandbyModeOn) {
        assertRunOnServiceThread();
        if (isPowerOnOrTransient() && isStandbyModeOn) {
            mPowerManager.goToSleep(SystemClock.uptimeMillis(),
                    PowerManager.GO_TO_SLEEP_REASON_HDMI, 0);
            if (playback() != null) {
                playback().sendStandby(0 /* unused */);
            }
        } else if (isPowerStandbyOrTransient() && !isStandbyModeOn) {
            mPowerManager.wakeUp(SystemClock.uptimeMillis(), "android.server.hdmi:WAKE");
            if (playback() != null) {
                oneTouchPlay(new IHdmiControlCallback.Stub() {
                    @Override
                    public void onComplete(int result) {
                        if (result != HdmiControlManager.RESULT_SUCCESS) {
                            Slog.w(TAG, "Failed to complete 'one touch play'. result=" + result);
                        }
                    }
                });
            }
        }
    }

    boolean isProhibitMode() {
        synchronized (mLock) {
            return mProhibitMode;