Fix RoleSearchIndexablesProvider. By clearing the calling identity before determining whether a role is available, to avoid the SecurityException. Bug: 135665821 Test: manual Change-Id: Ibee46949c65a5cd068a5453ca053025108da2096
diff --git a/src/com/android/packageinstaller/role/service/RoleSearchIndexablesProvider.java b/src/com/android/packageinstaller/role/service/RoleSearchIndexablesProvider.java index 5507627..4d5341c 100644 --- a/src/com/android/packageinstaller/role/service/RoleSearchIndexablesProvider.java +++ b/src/com/android/packageinstaller/role/service/RoleSearchIndexablesProvider.java
@@ -19,6 +19,7 @@ import android.content.Context; import android.database.Cursor; import android.database.MatrixCursor; +import android.os.Binder; import android.provider.SearchIndexablesContract; import android.util.ArrayMap; @@ -50,8 +51,13 @@ for (int i = 0; i < rolesSize; i++) { Role role = roles.valueAt(i); - if (!role.isAvailable(context) || !role.isVisible(context)) { - continue; + long token = Binder.clearCallingIdentity(); + try { + if (!role.isAvailable(context) || !role.isVisible(context)) { + continue; + } + } finally { + Binder.restoreCallingIdentity(token); } String label = context.getString(role.getLabelResource());