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

Commit fab62050 authored by Nate Myren's avatar Nate Myren
Browse files

Catch exception when getting PermissionControllerManager in PolicyService

There's a possible race condition when a user is being removed, where we
may try to create a PermissionControllerManager for a user that's no
longer valid. If that happens, handle the exception gracefully

Fixes: 302466721
Test: presubmit
Change-Id: If007f1320c445a29e0d3738275c5716a67bca0d9
parent 1c391eac
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -347,8 +347,15 @@ public final class PermissionPolicyService extends SystemService {
                UserHandle user = UserHandle.getUserHandleForUid(uid);
                PermissionControllerManager manager = mPermControllerManagers.get(user);
                if (manager == null) {
                    try {
                        manager = new PermissionControllerManager(
                                getUserContext(getContext(), user), PermissionThread.getHandler());
                    } catch (IllegalArgumentException exception) {
                        // There's a possible race condition when a user is being removed
                        Log.e(LOG_TAG, "Could not create PermissionControllerManager for user"
                                        + user, exception);
                        return;
                    }
                    mPermControllerManagers.put(user, manager);
                }
                manager.updateUserSensitiveForApp(uid);