Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 40c4f8c8 authored by Yurii Zubrytskyi's avatar Yurii Zubrytskyi
Browse files

[res] Duplicate AssetManager when changes are needed

When adding new apk paths to the ResourcesImpl's AssetManager,
we used to make it in a non-atomical way - first, the paths get
added without recalculating the internal indices, then later it
updates the indices and applies new configuration. This causes
some lookups to fail until the index recalculation, as apk
asset shift in the internal array, and the indices stop pointing
to the correct apks.

In this change, the asset paths update is now more parametrized:

- When creating a ResourcesImpl we know it's not being used yet,
  so we just update the paths in place, and use the same non-
  atomic, but the fastest, code

- When updating an existing object we instead create a new
  AssetManager object with the new paths, and then use that
  instead of the original one that could be in use

    - this helps to keep the currently running lookups to be
      consistent, as the object can't change under the caller
      and suddenly start returning different resources
    - an added bonus is that now we make sure that the paths
      actually change before running any update operations,
      potentially saving lots of time on heavy locking and JNI
      calls

+ Add a lock when accessing the registered shared libraries

Bug: 362700391
Test: manual, run a test app with a resources getter in a loop
      and verify it doesn't get NotFoundException
Flag: EXEMPT bugfix with no single point of entry
Change-Id: If1890a62b34e504fd87dc27ef9dd27863cc718ee
parent 536e0b47
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment