Fix connection enumeration not accounting for discontinuous IDs
The data structure that contains mConnections is a sparse array. This means that you are allowed to insert devices with unique input IDs that are not continuous. However, when trying to perform the search for a specific input ID, the current logic assumes that the IDs are numerically continuous, causing issues (see ag/22753602). Bug: 278628657 Test: atest TvInputService Change-Id: I0311ac994feca73e4216744a49f1731c8e353ca1
This commit is contained in:
@@ -459,9 +459,11 @@ class TvInputHardwareManager implements TvInputHal.Callback {
|
||||
|
||||
private int findDeviceIdForInputIdLocked(String inputId) {
|
||||
for (int i = 0; i < mConnections.size(); ++i) {
|
||||
Connection connection = mConnections.get(i);
|
||||
if (connection.getInfoLocked().getId().equals(inputId)) {
|
||||
return i;
|
||||
int key = mConnections.keyAt(i);
|
||||
Connection connection = mConnections.get(key);
|
||||
if (connection != null && connection.getInfoLocked() != null
|
||||
&& connection.getInfoLocked().getId().equals(inputId)) {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user