Add pending list of external source.
[Description] After AC off/on, tvinputservice may create later than external source stream changed. So add pending list of external source inputinfo when onStreamConfigurationChanged. Bug:196189979 [Test Report] Test pass. Change-Id: Ifc4b53866803bd0790ecd1e8ba5761533df06c0a
This commit is contained in:
@@ -114,6 +114,8 @@ class TvInputHardwareManager implements TvInputHal.Callback {
|
||||
private final SparseBooleanArray mHdmiStateMap = new SparseBooleanArray();
|
||||
private final List<Message> mPendingHdmiDeviceEvents = new LinkedList<>();
|
||||
|
||||
private final List<Message> mPendingTvinputInfoEvents = new LinkedList<>();
|
||||
|
||||
// Calls to mListener should happen here.
|
||||
private final Handler mHandler = new ListenerHandler();
|
||||
|
||||
@@ -229,7 +231,16 @@ class TvInputHardwareManager implements TvInputHal.Callback {
|
||||
connection.getInputStateLocked(), 0, inputId).sendToTarget();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Message msg = mHandler.obtainMessage(ListenerHandler.TVINPUT_INFO_ADDED,
|
||||
deviceId, cableConnectionStatus, connection);
|
||||
for (Iterator<Message> it = mPendingTvinputInfoEvents.iterator(); it.hasNext();) {
|
||||
if (it.next().arg1 == deviceId) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
mPendingTvinputInfoEvents.add(msg);
|
||||
}
|
||||
ITvInputHardwareCallback callback = connection.getCallbackLocked();
|
||||
if (callback != null) {
|
||||
try {
|
||||
@@ -288,6 +299,8 @@ class TvInputHardwareManager implements TvInputHal.Callback {
|
||||
}
|
||||
mHardwareInputIdMap.put(deviceId, info.getId());
|
||||
mInputMap.put(info.getId(), info);
|
||||
processPendingTvInputInfoEventsLocked();
|
||||
Slog.d(TAG,"deviceId ="+ deviceId+", tvinputinfo = "+info);
|
||||
|
||||
// Process pending state changes
|
||||
|
||||
@@ -529,6 +542,20 @@ class TvInputHardwareManager implements TvInputHal.Callback {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void processPendingTvInputInfoEventsLocked() {
|
||||
for (Iterator<Message> it = mPendingTvinputInfoEvents.iterator(); it.hasNext(); ) {
|
||||
Message msg = it.next();
|
||||
int deviceId = msg.arg1;
|
||||
String inputId = mHardwareInputIdMap.get(deviceId);
|
||||
if (inputId != null) {
|
||||
msg.sendToTarget();
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void updateVolume() {
|
||||
mCurrentMaxIndex = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
|
||||
mCurrentIndex = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
|
||||
@@ -1181,6 +1208,7 @@ class TvInputHardwareManager implements TvInputHal.Callback {
|
||||
private static final int HDMI_DEVICE_ADDED = 4;
|
||||
private static final int HDMI_DEVICE_REMOVED = 5;
|
||||
private static final int HDMI_DEVICE_UPDATED = 6;
|
||||
private static final int TVINPUT_INFO_ADDED = 7;
|
||||
|
||||
@Override
|
||||
public final void handleMessage(Message msg) {
|
||||
@@ -1225,6 +1253,29 @@ class TvInputHardwareManager implements TvInputHal.Callback {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TVINPUT_INFO_ADDED: {
|
||||
int deviceId = msg.arg1;
|
||||
int cableConnectionStatus = msg.arg2;
|
||||
Connection connection =(Connection)msg.obj;
|
||||
|
||||
int previousConfigsLength = connection.getConfigsLengthLocked();
|
||||
int previousCableConnectionStatus = connection.getInputStateLocked();
|
||||
String inputId = mHardwareInputIdMap.get(deviceId);
|
||||
|
||||
if (inputId != null) {
|
||||
if (connection.updateCableConnectionStatusLocked(cableConnectionStatus)) {
|
||||
if (previousCableConnectionStatus != connection.getInputStateLocked()) {
|
||||
mListener.onStateChanged(inputId, connection.getInputStateLocked());
|
||||
}
|
||||
} else {
|
||||
if ((previousConfigsLength == 0)
|
||||
!= (connection.getConfigsLengthLocked() == 0)) {
|
||||
mListener.onStateChanged(inputId, connection.getInputStateLocked());
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
Slog.w(TAG, "Unhandled message: " + msg);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user