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

Skip to content
Commit c6abc002 authored by Hai Zhang's avatar Hai Zhang
Browse files

Various refactors to UidPermissionPolicy code.

- Use custom flag getter, setter, updater and change listener, since
this allows the compat layer to call it more efficiently. The URI
oriented methods are now only for future unified APIs, if there will
be any.

- Made the change listener actually working by calling it in the
updatePermissionFlags() method which should be the one and only method
that mutates a permission flag.

- Made the persistence actually working by calling requestWrite() in
relevant methods.

- Added the boolean return value for removeAllIndexed() and
retainAllIndexed() for consistency with kotlin-stdlib APIs, and used
it when deciding whether to call requestWrite().

- Renamed UserState.permissionFlags to uidPermissionFlags. Now we have
a consistent way to reference different levels in the hierarchy - the
top level is uidPermissionFlags, the map from permission name to
flags is permissionFlags, while the flags is just flags.

- Switched to keeping only app ID states with non-empty maps. This is
more consistent with what we do with app ops and possible future
parameterized permissions, and may also save a little bit of memory
for things like RRO packages.

    This also means we should always iterate over the user IDs and app
    IDs in system state instead of on userStates or
    uidPermissoinFlags, which may not be complete and may be modified
    during iteration.

- Moved the userId parameter to be following appId or packageState,
instead of always being at the end. It used to make sense for always
being at the end because some parts of the system may not be
multi-user aware so an optional userId parameter at the end made more
sense. However we are always multi-user aware and passing the userId
alone at the end simply started to look too unnatural.

- Refactored trimPermissions() to better handle permission removal,
and delegating setting INSTALL_REVOKED to evalutePermissionState() for
consistency.

Bug: 182523293
Test: presubmit
Change-Id: I3aa177e52190c5996c6d9ecbc7030c6d7b5ae429
parent c8a46e14
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment