UsageStatsService: rewrite locking to avoid contention post-unlock
Various ActivityManager actions require calls to UsageStatsService.reportEventOrAddToQueue(), but that function can block for hundreds of milliseconds while UsageStatsService is initialized during post-unlock. However, the only important part of reportEventOrAddToQueue is the check to see if a user has been unlocked, at which point the action is enqueued on a Handler. Move mUserUnlockedStates to a CopyOnWriteArraySet, which should be updated very infrequently, and allow the common case of "the user is unlocked and an event should be added to the queue" to run concurrently with other UsageStatsService operations. Test: atest android.app.usage.cts.UsageStatsTest Test: atest android.app.usage.UsageStatsTest Test: atest UsageStatsDatabaseTest Bug: 161866124 Change-Id: I11743d78f20db5e5a9471544ae5a1c0ab492202d
Loading
Please register or sign in to comment