Merge "Pause media session on TV power toggle" into sc-dev
This commit is contained in:
@@ -139,8 +139,12 @@ abstract class HdmiCecLocalDeviceSource extends HdmiCecLocalDevice {
|
|||||||
@ServiceThreadOnly
|
@ServiceThreadOnly
|
||||||
void toggleAndFollowTvPower() {
|
void toggleAndFollowTvPower() {
|
||||||
assertRunOnServiceThread();
|
assertRunOnServiceThread();
|
||||||
// Wake up Android framework to take over CEC control from the microprocessor.
|
if (mService.getPowerManager().isInteractive()) {
|
||||||
mService.wakeUp();
|
mService.pauseActiveMediaSessions();
|
||||||
|
} else {
|
||||||
|
// Wake up Android framework to take over CEC control from the microprocessor.
|
||||||
|
mService.wakeUp();
|
||||||
|
}
|
||||||
mService.queryDisplayStatus(new IHdmiControlCallback.Stub() {
|
mService.queryDisplayStatus(new IHdmiControlCallback.Stub() {
|
||||||
@Override
|
@Override
|
||||||
public void onComplete(int status) {
|
public void onComplete(int status) {
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ import static com.android.server.hdmi.HdmiControlService.INITIATED_BY_ENABLE_CEC
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.hardware.hdmi.HdmiControlManager;
|
import android.hardware.hdmi.HdmiControlManager;
|
||||||
import android.hardware.hdmi.HdmiDeviceInfo;
|
import android.hardware.hdmi.HdmiDeviceInfo;
|
||||||
@@ -34,6 +36,7 @@ import android.os.IPowerManager;
|
|||||||
import android.os.IThermalService;
|
import android.os.IThermalService;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
|
import android.os.RemoteException;
|
||||||
import android.os.test.TestLooper;
|
import android.os.test.TestLooper;
|
||||||
import android.platform.test.annotations.Presubmit;
|
import android.platform.test.annotations.Presubmit;
|
||||||
import android.sysprop.HdmiProperties;
|
import android.sysprop.HdmiProperties;
|
||||||
@@ -1551,6 +1554,31 @@ public class HdmiCecLocalDevicePlaybackTest {
|
|||||||
assertThat(mStandby).isFalse();
|
assertThat(mStandby).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void toggleAndFollowTvPower_isInteractive() throws RemoteException {
|
||||||
|
when(mIPowerManagerMock.isInteractive()).thenReturn(true);
|
||||||
|
mActiveMediaSessionsPaused = false;
|
||||||
|
mWokenUp = false;
|
||||||
|
|
||||||
|
mHdmiControlService.toggleAndFollowTvPower();
|
||||||
|
|
||||||
|
assertThat(mActiveMediaSessionsPaused).isTrue();
|
||||||
|
assertThat(mWokenUp).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void toggleAndFollowTvPower_isNotInteractive() throws RemoteException {
|
||||||
|
when(mIPowerManagerMock.isInteractive()).thenReturn(false);
|
||||||
|
mActiveMediaSessionsPaused = false;
|
||||||
|
mWokenUp = false;
|
||||||
|
|
||||||
|
mHdmiControlService.toggleAndFollowTvPower();
|
||||||
|
|
||||||
|
assertThat(mActiveMediaSessionsPaused).isFalse();
|
||||||
|
assertThat(mWokenUp).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldHandleTvPowerKey_CecDisabled() {
|
public void shouldHandleTvPowerKey_CecDisabled() {
|
||||||
mHdmiCecLocalDevicePlayback.mService.getHdmiCecConfig().setIntValue(
|
mHdmiCecLocalDevicePlayback.mService.getHdmiCecConfig().setIntValue(
|
||||||
|
|||||||
Reference in New Issue
Block a user