UidObserverController: Fix incorrect usage of binarySearch return value

Arrays.binarySearch does not return -1 in all cases where the value
cannot be found. It returns a negative index indicating where the value
would be inserted. This was discovered through additional unit testing
on master.

Bug: 274486653
Test: --
  -- atest UidObserverControllerTest (with new tests)
  -- atest CtsCameraTestCases (CameraEvictionTest)
Change-Id: Ifbb7eab343279c74b53d00a3c64cd6236edcad02
This commit is contained in:
Austin Borger
2023-05-08 17:48:00 -07:00
parent ab9ab096e6
commit 765f25210d

View File

@@ -557,7 +557,7 @@ public class UidObserverController {
return true;
}
return Arrays.binarySearch(mUids, uid) != -1;
return Arrays.binarySearch(mUids, uid) >= 0;
}
void addUid(int uid) {