Skip to content
Commit abffa29b authored by Tim Murray's avatar Tim Murray
Browse files

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
parent 5d9b76bd
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