Throttle calls to grant default roles.

Package changes can be very frequent when for instance a new user is
created, and we used to re-run granting default roles every time a
package change is detected. In such cases the grant is inherently
async, so we can throttle it with a certain interval for better
performance.

This CL adds a throttled runnable and makes the async call in
RoleManagerService package change receiver throttled with an interval
of 1 second. The package hash computation is also moved to FgThread in
this case. The original blocking call in onStartUser() is not
affected and still runs on main thread.

Test: manual
Change-Id: I211ee3d4acbdf0662c6dfe4d67b35d253e12a472
3 files changed