Settings is using a MemoryIntArray to communicate the settings table
version enabling apps to have up-to-date local caches. However, ashmem
allows an arbitrary process with a handle to the fd (even in read only
mode) to unpin the memory which can then be garbage collected. Here we
make this mechanism fault tolerant against bad apps unpinning the ashmem
region. First, we no longer unpin the ashmem on the client side and if
the ashmem region is purged and cannot be pinned we recreate it and
hook up again with the local app caches. The change also adds a test
that clients can only read while owner can read/write.
bug:28764789
Change-Id: I1ef79b4b21e976124b268c9126a55d614157059b
We used the system proterties as a shared memory mechanism
to propagate information to local settings caches when the
content has changed and the cache should be cleared. The
system properties are unfortunately updated asynchronously
leading to cases where clients may read stale data.
This change adds a simple int array data structure backed
by shared memory which guarantees individual values are
atomically read and updated without memory tear. Multi-
index opearations are not synchronized between each other.
The settings provider is using the new data structure to
propagate the settings generation which drives when caches
are purged.
We have a single memory array keeping the generation for
different settings tables per user. Since memory array is
not a compact data structure and the user space exceeds
the memory array size we use an in-memory map from keys
to indices in the memory array where the generation id of
a key is stored. A key is derived by the setting type in
the 4 most significant bits and the user id in the 28 least
significant bits.
The mapping from a key to an index is cleared if the user is
removed and the corresponding index in the memory arry is
reset to make it available for other users. The size of the
memory array is derived from the max user count that can be
created at the same time.
bug:18826179
Change-Id: I64009cc5105309ef9aa83aba90b82afc8ad8c659
- Encode '\u000' - '\u001F', so KXmlParser can read them properly.
Otherwise KXmlParser will ignore CRs/LFs in attributes, and CRs
in text.
- Originally FastXmlSerializer would throw if a string contains
dangling surrogate pairs. Now we REPLACE them with.
Bug 27792649
Change-Id: I10c547dad2475b68f60e9e8208d9a3eae8e20063
Also fix a couple of issues in the code:
1. Check that fields are static before attempting to read them.
Currently, if a non-static field's name starts with one of the
specified constant prefixes (by default, "CMD_" and "EVENT_")
we'd get an NPE.
2. Only read final fields.
Change-Id: I0e07c4c27a66180cbaf7f2b1c235daafc080863b
These are very simple tests with no dependencies, and moving them
out of FrameworksCoreTests makes it possible to iterate much more
quickly. "runtest frameworks-core" takes almost a minute just to
push to the device, before any tests even start running.
Bug: 25691379
Change-Id: I8d99316a5940e0171883b97c578f9a6882b699a0