Fixing read from mUsersRedirectedToOwnerForMedia sparse array.

ag/21547694 introduced some fixes in ContentProvider for clone
profile. However, a new bug was also introduced due to incorrect
index calculation. This CL fixes the same.

Bug: 270350104
Test: atest AppCloningHostTest
Change-Id: Iea3cc4b40194d809a62457899d7c4e96021692d7
This commit is contained in:
Himanshu Gupta
2023-05-12 21:08:29 +01:00
parent b130b003a5
commit ea5a59c354

View File

@@ -892,8 +892,9 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall
*/
private boolean isContentRedirectionAllowedForUser(int incomingUserId) {
if (MediaStore.AUTHORITY.equals(mAuthority)) {
if (mUsersRedirectedToOwnerForMedia.indexOfKey(incomingUserId) >= 0) {
return mUsersRedirectedToOwnerForMedia.valueAt(incomingUserId);
int incomingUserIdIndex = mUsersRedirectedToOwnerForMedia.indexOfKey(incomingUserId);
if (incomingUserIdIndex >= 0) {
return mUsersRedirectedToOwnerForMedia.valueAt(incomingUserIdIndex);
}
// Haven't seen this user yet, look it up