+171
−0
Loading
Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more
This solves the issue of new state visibility when we invoke externally provided listeners - they may check the current state when they are called and they should always see the new state, but currently they may see the old state if the thread mutating the state hasn't finished mutation. The onStateMutated() callback provides a way to invoke the externally provided listener at the right time (after state mutation is committed), so that they can always see the new state without worrying about the race condition. Meanwhile, this also provides a good place to consolidate the invocation for listeners like OnPermissionsChangeListener which only needs to be invoked once for each UID. Changed the listeners to use abstract classes instead of interfaces for slightly better performance in accordance with System Health team's guidelines. Made the OnPermissionsChangeListener only notified when runtime permissions are changed. Previously we had the code to notify it when permission flags for install permissions has changed, however the PackageManager permission flags actually should only be applied to runtime permissions. Meanwhile also existing grantRuntimePermission() may grant a non-runtime permission like a development or role permission, the existing implementation actually doesn't notify the listener in this case, so notifying for flags change that doesn't happen while not notifying for grant state changes makes even less sense. Bug: 252884423 Test: presubmit Change-Id: I1f973e5e3c0ad4aa6ae23f6e238aef5aafa66e2e