Handle null case in AppStateAppOpsBridge
AppStateAppOpsBridge#getEntries returns null if no app is requesting AppStateAppOpsBridge#mPermissions, which would cause the settings app to crash in AppStateAppOpsBridge#loadAllExtraInfo or AppStateAppOpsBridge#loadAppOpsStates. Try to skip null case here and set null for extraInfo when we get null from AppStateAppOpsBridge#getEntries. Change-Id: Iac03ec11869eeac62fa055da26b4b7a10dc65bb8 Fix: 147479269 Test: Open All files access and no crash.
This commit is contained in:
@@ -14,7 +14,9 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:key="manage_external_storage_permission_details"
|
||||
android:title="@string/manage_external_storage_title">
|
||||
|
||||
@@ -22,8 +24,9 @@
|
||||
android:key="app_ops_settings_switch"
|
||||
android:title="@string/permit_manage_external_storage"/>
|
||||
|
||||
<Preference
|
||||
android:summary="@string/allow_manage_external_storage_description"
|
||||
android:selectable="false"/>
|
||||
<com.android.settingslib.widget.FooterPreference
|
||||
android:title="@string/allow_manage_external_storage_description"
|
||||
android:selectable="false"
|
||||
settings:searchable="false"/>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
@@ -61,6 +61,7 @@ public abstract class AppStateAppOpsBridge extends AppStateBaseBridge {
|
||||
this(context, appState, callback, appOpsOpCode, permissions,
|
||||
AppGlobals.getPackageManager());
|
||||
}
|
||||
|
||||
AppStateAppOpsBridge(Context context, ApplicationsState appState, Callback callback,
|
||||
int[] appOpsOpCodes, String[] permissions) {
|
||||
this(context, appState, callback, appOpsOpCodes, permissions,
|
||||
@@ -70,9 +71,10 @@ public abstract class AppStateAppOpsBridge extends AppStateBaseBridge {
|
||||
@VisibleForTesting
|
||||
AppStateAppOpsBridge(Context context, ApplicationsState appState, Callback callback,
|
||||
int appOpsOpCode, String[] permissions, IPackageManager packageManager) {
|
||||
this(context, appState, callback, new int[] {appOpsOpCode}, permissions,
|
||||
this(context, appState, callback, new int[]{appOpsOpCode}, permissions,
|
||||
packageManager);
|
||||
}
|
||||
|
||||
AppStateAppOpsBridge(Context context, ApplicationsState appState, Callback callback,
|
||||
int[] appOpsOpCodes, String[] permissions, IPackageManager packageManager) {
|
||||
super(appState, callback);
|
||||
@@ -155,8 +157,12 @@ public abstract class AppStateAppOpsBridge extends AppStateBaseBridge {
|
||||
for (int i = 0; i < N; i++) {
|
||||
AppEntry app = apps.get(i);
|
||||
int userId = UserHandle.getUserId(app.info.uid);
|
||||
ArrayMap<String, PermissionState> userMap = entries.get(userId);
|
||||
app.extraInfo = userMap != null ? userMap.get(app.info.packageName) : null;
|
||||
if (entries != null) {
|
||||
ArrayMap<String, PermissionState> userMap = entries.get(userId);
|
||||
app.extraInfo = userMap != null ? userMap.get(app.info.packageName) : null;
|
||||
} else {
|
||||
app.extraInfo = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,6 +253,10 @@ public abstract class AppStateAppOpsBridge extends AppStateBaseBridge {
|
||||
* a particular package.
|
||||
*/
|
||||
private void loadAppOpsStates(SparseArray<ArrayMap<String, PermissionState>> entries) {
|
||||
if (entries == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Find out which packages have been granted permission from AppOps.
|
||||
final List<AppOpsManager.PackageOps> packageOps = mAppOpsManager.getPackagesForOps(
|
||||
mAppOpsOpCodes);
|
||||
|
Reference in New Issue
Block a user