To create a TvInputInfo
, we can use the Builder
in the TvInputInfo
, which goes to
//frameworks/base/media/java/android/media/tv/TvInputInfo.java
public TvInputInfo build() {
...
hdmiConnectionRelativePosition = getRelativePosition(mContext, mHdmiDeviceInfo);
and then
private static int getRelativePosition(Context context, HdmiDeviceInfo info) {
HdmiControlManager hcm = (HdmiControlManager) context.getSystemService(Context.HDMI_CONTROL_SERVICE);
if (hcm == null) {
return HdmiUtils.HDMI_RELATIVE_POSITION_UNKNOWN;
}
return HdmiUtils.getHdmiAddressRelativePosition(info.getPhysicalAddress(), hcm.getPhysicalAddress());
}
The hcm.getPhysicalAddress()
at the last line goes to
mService.getPhysicalAddress()
and mHdmiCecController.getPhysicalAddress()
Finally, reach
//frameworks/base/services/core/java/com/android/server/hdmi/HdmiCecController.java
@ServiceThreadOnly
int getPhysicalAddress() {
assertRunOnServiceThread();
return mNativeWrapperImpl.nativeGetPhysicalAddress();
}
Here, calling assertRunOnServiceThread()
outside of the HdmiControlService
throws an exception.
private void assertRunOnServiceThread() {
if (Looper.myLooper() != mControlHandler.getLooper()) {
throw new IllegalStateException("Should run on service thread.");
}
Is it a known issue?
Or if there exists some other method to create a TvInputInfo
without reaching the above assertRunOnServiceThread
statement?