Loading services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceSource.java +1 −1 Original line number Diff line number Diff line Loading @@ -82,7 +82,7 @@ abstract class HdmiCecLocalDeviceSource extends HdmiCecLocalDevice { callback); if (action == null) { Slog.w(TAG, "Cannot initiate queryDisplayStatus"); invokeCallback(callback, HdmiControlManager.RESULT_EXCEPTION); invokeCallback(callback, HdmiControlManager.POWER_STATUS_UNKNOWN); return; } addAndStartAction(action); Loading services/core/java/com/android/server/hdmi/HdmiControlService.java +11 −8 Original line number Diff line number Diff line Loading @@ -2724,6 +2724,15 @@ public class HdmiControlService extends SystemService { return mIsCecAvailable; } /** * Queries the display status of the TV and calls {@code callback} upon completion. * * If this is a non-source device, or if the query fails for any reason, the callback will * be called with {@link HdmiControlManager.POWER_STATUS_UNKNOWN}. * * If the query succeeds, the callback will be called with one of the other power status * constants. */ @ServiceThreadOnly protected void queryDisplayStatus(final IHdmiControlCallback callback) { assertRunOnServiceThread(); Loading @@ -2741,7 +2750,7 @@ public class HdmiControlService extends SystemService { if (source == null) { Slog.w(TAG, "Local source device not available"); invokeCallback(callback, HdmiControlManager.RESULT_SOURCE_NOT_AVAILABLE); invokeCallback(callback, HdmiControlManager.POWER_STATUS_UNKNOWN); return; } source.queryDisplayStatus(callback); Loading Loading @@ -3110,13 +3119,7 @@ public class HdmiControlService extends SystemService { if (isEnabled == HdmiControlManager.HDMI_CEC_CONTROL_ENABLED) { queryDisplayStatus(new IHdmiControlCallback.Stub() { public void onComplete(int status) { if (status == HdmiControlManager.POWER_STATUS_UNKNOWN || status == HdmiControlManager.RESULT_EXCEPTION || status == HdmiControlManager.RESULT_SOURCE_NOT_AVAILABLE) { mIsCecAvailable = false; } else { mIsCecAvailable = true; } mIsCecAvailable = status != HdmiControlManager.POWER_STATUS_UNKNOWN; if (!listeners.isEmpty()) { invokeHdmiControlStatusChangeListenerLocked(listeners, isEnabled, mIsCecAvailable); Loading services/tests/servicestests/src/com/android/server/hdmi/HdmiControlServiceTest.java +46 −0 Original line number Diff line number Diff line Loading @@ -668,6 +668,52 @@ public class HdmiControlServiceTest { assertThat(hdmiControlStatusCallback.mCecAvailable).isTrue(); } @Test public void initCec_statusListener_CecEnabled_CecAvailable_TvTransientToOn() { HdmiControlStatusCallback hdmiControlStatusCallback = new HdmiControlStatusCallback(); mHdmiControlServiceSpy.setControlEnabled(HdmiControlManager.HDMI_CEC_CONTROL_DISABLED); mTestLooper.dispatchAll(); mHdmiControlServiceSpy.addHdmiControlStatusChangeListener(hdmiControlStatusCallback); mHdmiControlServiceSpy.setControlEnabled(HdmiControlManager.HDMI_CEC_CONTROL_ENABLED); mHdmiControlServiceSpy.allocateLogicalAddress(mLocalDevices, INITIATED_BY_ENABLE_CEC); mTestLooper.dispatchAll(); HdmiCecMessage reportPowerStatus = HdmiCecMessageBuilder.buildReportPowerStatus( Constants.ADDR_TV, mHdmiControlServiceSpy.playback().getDeviceInfo().getLogicalAddress(), HdmiControlManager.POWER_STATUS_TRANSIENT_TO_ON); mNativeWrapper.onCecMessage(reportPowerStatus); mTestLooper.dispatchAll(); assertThat(hdmiControlStatusCallback.mCecEnabled).isTrue(); assertThat(hdmiControlStatusCallback.mCecAvailable).isTrue(); } @Test public void initCec_statusListener_CecEnabled_CecAvailable_TvTransientToStandby() { HdmiControlStatusCallback hdmiControlStatusCallback = new HdmiControlStatusCallback(); mHdmiControlServiceSpy.setControlEnabled(HdmiControlManager.HDMI_CEC_CONTROL_DISABLED); mTestLooper.dispatchAll(); mHdmiControlServiceSpy.addHdmiControlStatusChangeListener(hdmiControlStatusCallback); mHdmiControlServiceSpy.setControlEnabled(HdmiControlManager.HDMI_CEC_CONTROL_ENABLED); mHdmiControlServiceSpy.allocateLogicalAddress(mLocalDevices, INITIATED_BY_ENABLE_CEC); mTestLooper.dispatchAll(); HdmiCecMessage reportPowerStatus = HdmiCecMessageBuilder.buildReportPowerStatus( Constants.ADDR_TV, mHdmiControlServiceSpy.playback().getDeviceInfo().getLogicalAddress(), HdmiControlManager.POWER_STATUS_TRANSIENT_TO_STANDBY); mNativeWrapper.onCecMessage(reportPowerStatus); mTestLooper.dispatchAll(); assertThat(hdmiControlStatusCallback.mCecEnabled).isTrue(); assertThat(hdmiControlStatusCallback.mCecAvailable).isTrue(); } @Test public void handleCecCommand_errorParameter_returnsAbortInvalidOperand() { // Validity ERROR_PARAMETER. Taken from HdmiCecMessageValidatorTest#isValid_menuStatus Loading Loading
services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceSource.java +1 −1 Original line number Diff line number Diff line Loading @@ -82,7 +82,7 @@ abstract class HdmiCecLocalDeviceSource extends HdmiCecLocalDevice { callback); if (action == null) { Slog.w(TAG, "Cannot initiate queryDisplayStatus"); invokeCallback(callback, HdmiControlManager.RESULT_EXCEPTION); invokeCallback(callback, HdmiControlManager.POWER_STATUS_UNKNOWN); return; } addAndStartAction(action); Loading
services/core/java/com/android/server/hdmi/HdmiControlService.java +11 −8 Original line number Diff line number Diff line Loading @@ -2724,6 +2724,15 @@ public class HdmiControlService extends SystemService { return mIsCecAvailable; } /** * Queries the display status of the TV and calls {@code callback} upon completion. * * If this is a non-source device, or if the query fails for any reason, the callback will * be called with {@link HdmiControlManager.POWER_STATUS_UNKNOWN}. * * If the query succeeds, the callback will be called with one of the other power status * constants. */ @ServiceThreadOnly protected void queryDisplayStatus(final IHdmiControlCallback callback) { assertRunOnServiceThread(); Loading @@ -2741,7 +2750,7 @@ public class HdmiControlService extends SystemService { if (source == null) { Slog.w(TAG, "Local source device not available"); invokeCallback(callback, HdmiControlManager.RESULT_SOURCE_NOT_AVAILABLE); invokeCallback(callback, HdmiControlManager.POWER_STATUS_UNKNOWN); return; } source.queryDisplayStatus(callback); Loading Loading @@ -3110,13 +3119,7 @@ public class HdmiControlService extends SystemService { if (isEnabled == HdmiControlManager.HDMI_CEC_CONTROL_ENABLED) { queryDisplayStatus(new IHdmiControlCallback.Stub() { public void onComplete(int status) { if (status == HdmiControlManager.POWER_STATUS_UNKNOWN || status == HdmiControlManager.RESULT_EXCEPTION || status == HdmiControlManager.RESULT_SOURCE_NOT_AVAILABLE) { mIsCecAvailable = false; } else { mIsCecAvailable = true; } mIsCecAvailable = status != HdmiControlManager.POWER_STATUS_UNKNOWN; if (!listeners.isEmpty()) { invokeHdmiControlStatusChangeListenerLocked(listeners, isEnabled, mIsCecAvailable); Loading
services/tests/servicestests/src/com/android/server/hdmi/HdmiControlServiceTest.java +46 −0 Original line number Diff line number Diff line Loading @@ -668,6 +668,52 @@ public class HdmiControlServiceTest { assertThat(hdmiControlStatusCallback.mCecAvailable).isTrue(); } @Test public void initCec_statusListener_CecEnabled_CecAvailable_TvTransientToOn() { HdmiControlStatusCallback hdmiControlStatusCallback = new HdmiControlStatusCallback(); mHdmiControlServiceSpy.setControlEnabled(HdmiControlManager.HDMI_CEC_CONTROL_DISABLED); mTestLooper.dispatchAll(); mHdmiControlServiceSpy.addHdmiControlStatusChangeListener(hdmiControlStatusCallback); mHdmiControlServiceSpy.setControlEnabled(HdmiControlManager.HDMI_CEC_CONTROL_ENABLED); mHdmiControlServiceSpy.allocateLogicalAddress(mLocalDevices, INITIATED_BY_ENABLE_CEC); mTestLooper.dispatchAll(); HdmiCecMessage reportPowerStatus = HdmiCecMessageBuilder.buildReportPowerStatus( Constants.ADDR_TV, mHdmiControlServiceSpy.playback().getDeviceInfo().getLogicalAddress(), HdmiControlManager.POWER_STATUS_TRANSIENT_TO_ON); mNativeWrapper.onCecMessage(reportPowerStatus); mTestLooper.dispatchAll(); assertThat(hdmiControlStatusCallback.mCecEnabled).isTrue(); assertThat(hdmiControlStatusCallback.mCecAvailable).isTrue(); } @Test public void initCec_statusListener_CecEnabled_CecAvailable_TvTransientToStandby() { HdmiControlStatusCallback hdmiControlStatusCallback = new HdmiControlStatusCallback(); mHdmiControlServiceSpy.setControlEnabled(HdmiControlManager.HDMI_CEC_CONTROL_DISABLED); mTestLooper.dispatchAll(); mHdmiControlServiceSpy.addHdmiControlStatusChangeListener(hdmiControlStatusCallback); mHdmiControlServiceSpy.setControlEnabled(HdmiControlManager.HDMI_CEC_CONTROL_ENABLED); mHdmiControlServiceSpy.allocateLogicalAddress(mLocalDevices, INITIATED_BY_ENABLE_CEC); mTestLooper.dispatchAll(); HdmiCecMessage reportPowerStatus = HdmiCecMessageBuilder.buildReportPowerStatus( Constants.ADDR_TV, mHdmiControlServiceSpy.playback().getDeviceInfo().getLogicalAddress(), HdmiControlManager.POWER_STATUS_TRANSIENT_TO_STANDBY); mNativeWrapper.onCecMessage(reportPowerStatus); mTestLooper.dispatchAll(); assertThat(hdmiControlStatusCallback.mCecEnabled).isTrue(); assertThat(hdmiControlStatusCallback.mCecAvailable).isTrue(); } @Test public void handleCecCommand_errorParameter_returnsAbortInvalidOperand() { // Validity ERROR_PARAMETER. Taken from HdmiCecMessageValidatorTest#isValid_menuStatus Loading