Fix crash on connected devices settings
If disconnected bluetooth devices didn't exist in recent devices, the index will return -1. Our condition didn't check this situation, the IndexOutOfBoundsException will throw when this case happens. This CL adds the condition to check whether index is over than or equal 0 to fix IndexOutOfBoundsException. Bug: 173059077 Test: make -j42 RunSettingsRoboTests Change-Id: Id93f4cb6bded83540045c5e8c21c6f6122a39fed
This commit is contained in:
@@ -144,7 +144,7 @@ public class PreviouslyConnectedDevicePreferenceController extends BasePreferenc
|
||||
|
||||
private void addPreference(int index, Preference preference) {
|
||||
if (preference instanceof BluetoothDevicePreference) {
|
||||
if (mDevicesList.size() >= index) {
|
||||
if (index >= 0 && mDevicesList.size() >= index) {
|
||||
mDevicesList.add(index, preference);
|
||||
} else {
|
||||
mDevicesList.add(preference);
|
||||
|
Reference in New Issue
Block a user