use of com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly in project platform_frameworks_base by android.
the class HdmiCecLocalDeviceTv method launchDeviceDiscovery.
@ServiceThreadOnly
private void launchDeviceDiscovery() {
assertRunOnServiceThread();
clearDeviceInfoList();
DeviceDiscoveryAction action = new DeviceDiscoveryAction(this, new DeviceDiscoveryCallback() {
@Override
public void onDeviceDiscoveryDone(List<HdmiDeviceInfo> deviceInfos) {
for (HdmiDeviceInfo info : deviceInfos) {
addCecDevice(info);
}
// we should put device info of local device manually here
for (HdmiCecLocalDevice device : mService.getAllLocalDevices()) {
addCecDevice(device.getDeviceInfo());
}
mSelectRequestBuffer.process();
resetSelectRequestBuffer();
addAndStartAction(new HotplugDetectionAction(HdmiCecLocalDeviceTv.this));
addAndStartAction(new PowerStatusMonitorAction(HdmiCecLocalDeviceTv.this));
// If there is AVR, initiate System Audio Auto initiation action,
// which turns on and off system audio according to last system
// audio setting.
HdmiDeviceInfo avr = getAvrDeviceInfo();
if (avr != null) {
onNewAvrAdded(avr);
} else {
setSystemAudioMode(false, true);
}
}
});
addAndStartAction(action);
}
use of com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly in project platform_frameworks_base by android.
the class HdmiCecLocalDeviceTv method handleActiveSource.
@Override
@ServiceThreadOnly
protected boolean handleActiveSource(HdmiCecMessage message) {
assertRunOnServiceThread();
int logicalAddress = message.getSource();
int physicalAddress = HdmiUtils.twoBytesToInt(message.getParams());
HdmiDeviceInfo info = getCecDeviceInfo(logicalAddress);
if (info == null) {
if (!handleNewDeviceAtTheTailOfActivePath(physicalAddress)) {
HdmiLogger.debug("Device info %X not found; buffering the command", logicalAddress);
mDelayedMessageBuffer.add(message);
}
} else if (isInputReady(info.getId()) || info.getDeviceType() == HdmiDeviceInfo.DEVICE_AUDIO_SYSTEM) {
updateDevicePowerStatus(logicalAddress, HdmiControlManager.POWER_STATUS_ON);
ActiveSource activeSource = ActiveSource.of(logicalAddress, physicalAddress);
ActiveSourceHandler.create(this, null).process(activeSource, info.getDeviceType());
} else {
HdmiLogger.debug("Input not ready for device: %X; buffering the command", info.getId());
mDelayedMessageBuffer.add(message);
}
return true;
}
use of com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly in project platform_frameworks_base by android.
the class HdmiCecLocalDeviceTv method disableArcIfExist.
@ServiceThreadOnly
private void disableArcIfExist() {
assertRunOnServiceThread();
HdmiDeviceInfo avr = getAvrDeviceInfo();
if (avr == null) {
return;
}
// Seq #44.
removeAction(RequestArcInitiationAction.class);
if (!hasAction(RequestArcTerminationAction.class) && isArcEstablished()) {
addAndStartAction(new RequestArcTerminationAction(this, avr.getLogicalAddress()));
}
}
use of com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly in project platform_frameworks_base by android.
the class HdmiControlService method changeInputForMhl.
/**
* Performs input change, routing control for MHL device.
*
* @param portId MHL port, or the last port to go back to if {@code contentOn} is false
* @param contentOn {@code true} if RAP data is content on; otherwise false
*/
@ServiceThreadOnly
void changeInputForMhl(int portId, boolean contentOn) {
assertRunOnServiceThread();
if (tv() == null)
return;
final int lastInput = contentOn ? tv().getActivePortId() : Constants.INVALID_PORT_ID;
if (portId != Constants.INVALID_PORT_ID) {
tv().doManualPortSwitching(portId, new IHdmiControlCallback.Stub() {
@Override
public void onComplete(int result) throws RemoteException {
// Keep the last input to switch back later when RAP[ContentOff] is received.
// This effectively sets the port to invalid one if the switching is for
// RAP[ContentOff].
setLastInputForMhl(lastInput);
}
});
}
// MHL device is always directly connected to the port. Update the active port ID to avoid
// unnecessary post-routing control task.
tv().setActivePortId(portId);
// The port is either the MHL-enabled port where the mobile device is connected, or
// the last port to go back to when turnoff command is received. Note that the last port
// may not be the MHL-enabled one. In this case the device info to be passed to
// input change listener should be the one describing the corresponding HDMI port.
HdmiMhlLocalDeviceStub device = mMhlController.getLocalDevice(portId);
HdmiDeviceInfo info = (device != null) ? device.getInfo() : mPortDeviceMap.get(portId, HdmiDeviceInfo.INACTIVE_DEVICE);
invokeInputChangeListener(info);
}
use of com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly in project platform_frameworks_base by android.
the class HdmiControlService method initPortInfo.
// Initialize HDMI port information. Combine the information from CEC and MHL HAL and
// keep them in one place.
@ServiceThreadOnly
private void initPortInfo() {
assertRunOnServiceThread();
HdmiPortInfo[] cecPortInfo = null;
// each port. Return empty array if CEC HAL didn't provide the info.
if (mCecController != null) {
cecPortInfo = mCecController.getPortInfos();
}
if (cecPortInfo == null) {
return;
}
SparseArray<HdmiPortInfo> portInfoMap = new SparseArray<>();
SparseIntArray portIdMap = new SparseIntArray();
SparseArray<HdmiDeviceInfo> portDeviceMap = new SparseArray<>();
for (HdmiPortInfo info : cecPortInfo) {
portIdMap.put(info.getAddress(), info.getId());
portInfoMap.put(info.getId(), info);
portDeviceMap.put(info.getId(), new HdmiDeviceInfo(info.getAddress(), info.getId()));
}
mPortIdMap = new UnmodifiableSparseIntArray(portIdMap);
mPortInfoMap = new UnmodifiableSparseArray<>(portInfoMap);
mPortDeviceMap = new UnmodifiableSparseArray<>(portDeviceMap);
HdmiPortInfo[] mhlPortInfo = mMhlController.getPortInfos();
ArraySet<Integer> mhlSupportedPorts = new ArraySet<Integer>(mhlPortInfo.length);
for (HdmiPortInfo info : mhlPortInfo) {
if (info.isMhlSupported()) {
mhlSupportedPorts.add(info.getId());
}
}
// cec port info if we do not have have port that supports MHL.
if (mhlSupportedPorts.isEmpty()) {
mPortInfo = Collections.unmodifiableList(Arrays.asList(cecPortInfo));
return;
}
ArrayList<HdmiPortInfo> result = new ArrayList<>(cecPortInfo.length);
for (HdmiPortInfo info : cecPortInfo) {
if (mhlSupportedPorts.contains(info.getId())) {
result.add(new HdmiPortInfo(info.getId(), info.getType(), info.getAddress(), info.isCecSupported(), true, info.isArcSupported()));
} else {
result.add(info);
}
}
mPortInfo = Collections.unmodifiableList(result);
}
Aggregations