Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eede68f1 authored by Arthur Ishiguro's avatar Arthur Ishiguro
Browse files

Fix IndexOutOfBoundsException in HubEndpointInfo

new ArrayList<>(int) only sets the capacity, and add() is needed when
adding new elements initially to prevent out of bounds exception.

Bug: 378487799
Flag: android.chre.flags.offload_api
Test: Run default Context Hub HAL, verify no service crash

Change-Id: I650e4dba20e74faf5aed3e7a433b6737f536ab3e
parent 8c9cb5a8
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -156,7 +156,7 @@ public final class HubEndpointInfo implements Parcelable {
        mRequiredPermissions = Arrays.asList(endpointInfo.requiredPermissions);
        mHubServiceInfos = new ArrayList<>(endpointInfo.services.length);
        for (int i = 0; i < endpointInfo.services.length; i++) {
            mHubServiceInfos.set(i, new HubServiceInfo(endpointInfo.services[i]));
            mHubServiceInfos.add(new HubServiceInfo(endpointInfo.services[i]));
        }
    }