Invalidate the cache when users are added or removed.
There is a list of methods which could be cached under the same key because they are invalidated at the same time. This includes things which are related to adding or removing UserData from mUserList in UserManagerService.
The cache should not be invalidated only when a user is removed, because if a client makes a binder call on a non-existing user then the cache would store the result. Then when a user with this exact id is created and the cache would not be invalidated then it would keep invalid data.
The User Serial number is one of those caches. The caches which should have a shared cache api name (different debug name if possible), so it could be invalidated at the same time and efficiently allocate a limited number of cache keys.
Flag: android.multiuser.invalidate_cache_on_users_changed_read_only
Test: atest UserManagerTest
Bug: 372383485
Change-Id: I105976711dc59c076e65896856eeeb0de871be61
2 files changed