Skip to content
Commit 5af1c38c authored by Nikolas Havrikov's avatar Nikolas Havrikov
Browse files

Avoid accumulation of user state persist requests

This CL tackles the problem which arises that arises from frequent
association changes for a given user.
Until now, every association change allocates a map of previously
used ids, which it holds until the current user state is written to
storage.
Unfortunately, frequent association changes can lead to a significant
pileup of persist requests, leading to out-of-memory errors and an
unresponsive system.

It does not help that the requests to write out the user state are
handled by the singleton background thread, which is shared across
all system services. This CL does not solve this particular issue,
and so it remains a future work item.

This CL introduces a dedicated PersistUserStateHandler, which
differs from the current handler in two ways:
1. It only ever accepts one persist request per user at a time.
   This prevents the aforementioned request pileup and OOM errors.
2. It reads the previously used ids and the changed associations
   at the time of writing out the state instead of the time of
   request arrival. This does not change the intended behavior,
   and comes with the advantage of not having to allocate Runnables.

Test: atest CtsCompanionDeviceManagerCoreTestCases
Test: atest CtsCompanionDeviceManagerUiAutomationTestCases
Change-Id: I9aaad5a25fc4c09fcd9808a84d8ba2ce7962bfc5
parent ce65b04d
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