Generalize queryDisplayStatus() to all source devices
Bug: 167962015 Test: atest HdmiCecLocalDevicePlaybackTest Change-Id: I51527f9055a7be374614b452f75d8ab9ced6454f
This commit is contained in:
@@ -143,25 +143,6 @@ public class HdmiCecLocalDevicePlayback extends HdmiCecLocalDeviceSource {
|
||||
String.valueOf(addr));
|
||||
}
|
||||
|
||||
@ServiceThreadOnly
|
||||
void queryDisplayStatus(IHdmiControlCallback callback) {
|
||||
assertRunOnServiceThread();
|
||||
List<DevicePowerStatusAction> actions = getActions(DevicePowerStatusAction.class);
|
||||
if (!actions.isEmpty()) {
|
||||
Slog.i(TAG, "queryDisplayStatus already in progress");
|
||||
actions.get(0).addCallback(callback);
|
||||
return;
|
||||
}
|
||||
DevicePowerStatusAction action = DevicePowerStatusAction.create(this, Constants.ADDR_TV,
|
||||
callback);
|
||||
if (action == null) {
|
||||
Slog.w(TAG, "Cannot initiate queryDisplayStatus");
|
||||
invokeCallback(callback, HdmiControlManager.RESULT_EXCEPTION);
|
||||
return;
|
||||
}
|
||||
addAndStartAction(action);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ServiceThreadOnly
|
||||
void onHotplug(int portId, boolean connected) {
|
||||
|
||||
@@ -70,6 +70,25 @@ abstract class HdmiCecLocalDeviceSource extends HdmiCecLocalDevice {
|
||||
super(service, deviceType);
|
||||
}
|
||||
|
||||
@ServiceThreadOnly
|
||||
void queryDisplayStatus(IHdmiControlCallback callback) {
|
||||
assertRunOnServiceThread();
|
||||
List<DevicePowerStatusAction> actions = getActions(DevicePowerStatusAction.class);
|
||||
if (!actions.isEmpty()) {
|
||||
Slog.i(TAG, "queryDisplayStatus already in progress");
|
||||
actions.get(0).addCallback(callback);
|
||||
return;
|
||||
}
|
||||
DevicePowerStatusAction action = DevicePowerStatusAction.create(this, Constants.ADDR_TV,
|
||||
callback);
|
||||
if (action == null) {
|
||||
Slog.w(TAG, "Cannot initiate queryDisplayStatus");
|
||||
invokeCallback(callback, HdmiControlManager.RESULT_EXCEPTION);
|
||||
return;
|
||||
}
|
||||
addAndStartAction(action);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ServiceThreadOnly
|
||||
void onHotplug(int portId, boolean connected) {
|
||||
|
||||
@@ -2400,9 +2400,13 @@ public class HdmiControlService extends SystemService {
|
||||
return;
|
||||
}
|
||||
|
||||
HdmiCecLocalDevicePlayback source = playback();
|
||||
HdmiCecLocalDeviceSource source = playback();
|
||||
if (source == null) {
|
||||
Slog.w(TAG, "Local playback device not available");
|
||||
source = audioSystem();
|
||||
}
|
||||
|
||||
if (source == null) {
|
||||
Slog.w(TAG, "Local source device not available");
|
||||
invokeCallback(callback, HdmiControlManager.RESULT_SOURCE_NOT_AVAILABLE);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1182,6 +1182,20 @@ public class HdmiCecLocalDevicePlaybackTest {
|
||||
externalDevice.getPhysicalAddress());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryDisplayStatus() {
|
||||
mHdmiControlService.queryDisplayStatus(new IHdmiControlCallback.Stub() {
|
||||
@Override
|
||||
public void onComplete(int result) {
|
||||
}
|
||||
});
|
||||
mTestLooper.dispatchAll();
|
||||
|
||||
HdmiCecMessage expectedMessage = HdmiCecMessageBuilder.buildGiveDevicePowerStatus(
|
||||
mPlaybackLogicalAddress, Constants.ADDR_TV);
|
||||
assertThat(mNativeWrapper.getResultMessages()).contains(expectedMessage);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toggleAndFollowTvPower_ToTv_TvStatusOn() {
|
||||
mHdmiCecLocalDevicePlayback.mService.getHdmiCecConfig().setStringValue(
|
||||
|
||||
Reference in New Issue
Block a user