summaryrefslogtreecommitdiff
path: root/core/java/android/app/PropertyInvalidatedCache.java
Commit message (Collapse)AuthorAgeFilesLines
* Fix concurrency issue in PropertyInvalidatedCacheLee Shombert2022-12-281-2/+17
| | | | | | | | | | | | | | | | | Bug: 253063488 Ensure the global lock is held while fetching the list of active caches. The global lock is necessary while the list is being fetched; it is not necessary while each cache in the list is cleared. Added a new test for PropertyInvalidatedCache.onTrimMemory(). This test will not catch race conditions but does verify that onTrimMemory() behaves as expected. Test: atest * FrameworksCoreTests:PropertyInvalidatedCacheTests Change-Id: I5022620cd4f2561179af709246a9bf149423143f (cherry picked from commit 803254d0ab3109165ffc1e3f409c07a692a9ac37)
* Refactor PropertyInvalidatedCache locksLee Shombert2022-09-141-36/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 241763149 Refactor the sCorkLock into sCorkLock, which protects code that specifically supports corking, and sGlobalLock, which protects all other code that touches global objects (like the list of all caches). Deadlock was not actually observed in the bug and has never been reported, but the possibility was identified and is being fixed here. Bypass the bulk of disableLocal(name) if the name has already been bypassed. This speeds repeated calls to disableLocal() by not iterating over sCaches. Many threads were terminated by a watchdog while iterating over sCaches inside disableLocal(). It is not known why this block of code was running so often when the time out expired. An open question is whether or not disabled caches should be removed from the sCaches array. The only reason to leave them in the array is to report on them during dumpsys, but this seems like a small benefit Test: atest * FrameworksCoreTests:IpcDataCacheTest * FrameworksCoreTests:PropertyInvalidatedCacheTests * CtsOsTestCases:IpcDataCacheTest Change-Id: I4c298f380044c0be93cdb47d66d7d7e2b260004f
* Work-around for system property failuresLee Shombert2022-08-101-1/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 236932163 This change adds a work-around to PropertyInvalidatedCache for failures to set a system property. Such failures cause fatal crashes in Android but it is believed that a simple retry will succeed. (Note: the failures have only been reported on partner devices and cannot be reproduced on Pixel phones, so no root-cause is available yet.) RuntimeExceptions (thrown from android_os_SystemProperties.cpp) are caught and retried. The retry limit is 5 times with a 200ms delay between attempts. This means that the maximum delay is 1s, whcih should avoid triggering an ANR. In addition to automated testing, a manual test was created with ambush code in the system property component of libc. The ambush code injected an error into the set-property logic for cache keys. It was observed that the system recovered properly. Test: atest: * FrameworksCoreTests:PropertyInvalidatedCacheTests * FrameworksCoreTests:IpcDataCacheTest Change-Id: I3a124b185c7499a45b27df7cbf889ae6d1d33377 (cherry picked from commit 9b0f81025ca809b0b0cac29fb75f02c568b98a23)
* Avoid ANRs in dumpCacheInfoLee Shombert2022-06-071-25/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 233566891 PropertyInvalidatedCache.dumpCacheInfo() sometimes triggers an ANR in system_server, with a thread blocked writing to dumpsys TransferPipe while holding a cache lock. Other threads are blocked on the cache lock. There does not seem be a true deadlock, but if IO is slow then all the threads slow down enough to trigger the ANR. This change stages the output of dumpCacheInfo() in a byte array. The byte array is written while holding the appropriate cache locks. When the byte array has been completely generated and all locks have been released, the output is sent back to the caller over the dumpsys TransferPipe. The two PrintWriter objects are properly closed now. The previous code worked as a side effect of the many calls to flush(), which are unnecessary now. As a consequence of this change, it will be possible add a unit-test for the output of 'dumpsys cacheinfo' by calling the method that creates the byte array. Such a unit test is not part of this commit.cache. Tested manually by running 'dumpsys cacheinfo' and verifying that the output is correct. Test: * FrameworksCoreTests:IpcDataCacheTest Change-Id: Icbd0197ca883cf0560ba2eb637951abee033eced
* Allow selective detailed dumps of cachesLee Shombert2022-04-281-21/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 227383489 'dumpsys cacheinfo' can now dump more information about caches, by supplying arguments to the command. If no switches are specified then the behavior is unchanged from the baseline. If any switches are specified then zero or more caches are selected; the command dumps statistics and content for every selected cache. The four switches each include a key string. The switch Selects a cache if --------------------- ------------------ -name-has=<key> the cache name contains the key -property-has=<key> the property name contains the key -name-like=<regex> the cache name matches the regex key -property-like=<regex> the property name matches the regex key Tested by running the following commands and manually verifying the output. dumpsys cacheinfo com.android.systemui dumpsys cacheinfo com.android.systemui -name-has=OrganizationOwned dumpsys cacheinfo com.android.systemui -name-like=OrganizationOwned - no results, as this regex does not match any cache dumpsys cacheinfo com.android.systemui -name-like=.*OrganizationOwned.* dumpsys cacheinfo com.android.systemui -property-has=package_info dumpsys cacheinfo com.android.systemui -property-like=cache_key.package.* Test: * atest FrameworksCoreTests:IpcDataCacheTest * atest FrameworksCoreTests:PropertyInvalidatedCacheTests Change-Id: I141d7e85ba3ea8b0f2615bbd49537c1170fb5449
* Helper classes for IpcDataCache clientsLee Shombert2022-04-111-4/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 227653108 This adds a helper class that can reduce much of the boilerplate in code that uses IpcDataCache (or the internal-only variant, PropertyInvalidatedCache). See the changes to DevicePolicyManager for example usage. Two PropertyInvalidatedCaches APIs are exposed for testing. The method createPropertyName() is changed so that apis like "Foo" are converted to "foo", not "_foo". Unit tests for the new behavior are added to IpcDataCacheTest. This was manually tested by dumping the cache info from builds with and without this change. Special attention is paid to the DevicePolicyManager caches. The same caches were found (as identified by their key and api) and the caches were enabled/disabled the same. In the course of testing, multiple instances of DevicePolicyManager caches were observed. Cache performance is better if the caches are static; making them static will be addressed in b/228452829. Test: * atest FrameworksCoreTests:IpcDataCacheTest * atest FrameworksCoreTests:PropertyInvalidatedCacheTests * atest FrameworksServicesTests:DevicePolicyConstantsTest * atest FrameworksServicesTests:DevicePolicyEventLoggerTest * atest FrameworksServicesTests:DevicePolicyManagerServiceMigrationTest * atest FrameworksServicesTests:DevicePolicyManagerTest * atest FrameworksServicesTests:EnterpriseSpecificIdCalculatorTest * atest FrameworksServicesTests:OverlayPackagesProviderTest * atest FrameworksServicesTests:OwnersTest * atest FrameworksServicesTests:PolicyVersionUpgraderTest * atest FrameworksServicesTests:SecurityEventTest * atest FrameworksServicesTests:SystemUpdatePolicyTest * atest FrameworksServicesTests:TransferOwnershipMetadataManagerTest * atest MixedDeviceOwnerTest#testIsDeviceOrganizationOwnedWithManagedProfile * atest MixedDeviceOwnerTest#testSetKeyguardDisabledFeatures * atest MixedManagedProfileOwnerTest#testIsDeviceOrganizationOwnedWithManagedProfile * atest MixedManagedProfileOwnerTest#testNetworkLoggingDelegate * atest MixedManagedProfileOwnerTest#testSetKeyguardDisabledFeatures * atest OrgOwnedProfileOwnerTest#testIsDeviceOrganizationOwnedWithManagedProfile * atest OrgOwnedProfileOwnerTest#testNetworkLoggingDelegate * atest OrgOwnedProfileOwnerTest#testSetKeyguardDisabledFeatures * atest android.devicepolicy.cts.DevicePolicyManagerTest * atest android.devicepolicy.cts.NetworkLoggingTest * atest com.android.cts.devicepolicy.DeviceOwnerTest#testAdminActionBookkeeping Change-Id: I2f4fe4ed25db5fb3100334b9d2ce748ee928c10d
* Create os/IpcDataCacheLee Shombert2022-03-071-28/+43
| | | | | | | | | | | | | | | | | | Bug: 219609105 Create os/IpcDataCache as a subclass of PropertyInvalidatedCache. The APIs in the new class are the SystemApi for mainline modules. Note that IpcDataCache.invalidateCache(String) is a new system API, relative to the list in PropertyInvalidateCache. The new API is static, which is the most common use case for invalidateCache calls. The corresponding CTS test is updated in the next review. However, it is also cloned into the current unit test. Test: * atest FrameworksCoreTests:PropertyInvalidatedCacheTests * atest FrameworksCoreTests:IpcDataCacheTest Change-Id: I83ce97a4154b9065e0686ee99a25c90f955366ff
* Correct the PropertyInvalidatedCache module definitionLee Shombert2022-03-021-29/+18
| | | | | | | | | | | | | | | | | Bug: 219609105 Change the meaning of "module" in PropertyInvalidatedCache to be a string rather than an integer. One piece of the unit test has been removed because of this. Lint uncovered several lock errors. These are corrected as well. The corresponding CTS test is updated in the next review. Test: * atest FrameworksCoreTests:PropertyInvalidatedCacheTests Change-Id: Iaaa55974df2d22fc052d5b4b4744384c012f070a
* Export PropertyInvalidatedCache SystemApisLee Shombert2022-02-011-36/+291
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 152453213 Tag: #refactor Make selected APIs of PropertyInvalidatedCache system APIs for mainline modules. Only APIs that are believed to be needed by Bluetooth have been exposed. APIs used only by framework code have not been exposed. Export the following methods as system apis, visible only to mainline modules. ctor public PropertyInvalidatedCache(int, @NonNull String, @NonNull String); method public boolean bypass(@NonNull Query); method public final void clear(); method public final void disableLocal(); method public final void invalidateCache(); method public static void invalidateCache(@NonNull String); method public Result query(@NonNull Query); method public abstract Result recompute(@NonNull Query); All APIs originally tagged @VisibleForTesting are now tagged @TestApi. A CTS test for the class is in the next CL. Test: atest PropertyInvalidatedCacheTests Change-Id: Ica0f60d60aee0b2100cbb1ee93f00d7e0f4356ab
* Clean up PropertyInvalidatedCache for SystemApiLee Shombert2022-01-101-35/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 152453213 Tag: #refactor This commit prepares PropertyInvalidatedCache to function as a system api. The changes may be summarized as follows: 1. Visibility changes - some formerly protected or public methods are now private. 2. Use of ParcelFileDescriptor instead of FileDescriptor. 3. Null-ness annotations have been added to public methods. 4. An onTrimMemory() method has been created that hides some class internals from ActivityThread. An existing test (os/PropertyInvalidatedCacheTest) has been deleted. Its contents have been merged into app/PropertyInvalidatedCacheTests. The deleted test may never have been used. Test: atest PropertyInvalidatedCacheTests Change-Id: I619e715c3deca016b21c69bf34a8e61771957e68
* Prepare PropertyInvalidatedCache for SystemApiLee Shombert2022-01-041-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 152453213 Tag: #refactor This commit prepares PropertyInvalidatedCache to function as a system api. Specifically, the methods recompute() and bypass() which may be overridden by clients are now public (instead of protected). This forces an update to all existing clients, to accommodate the change in method visibility. Two small changes have been made as cleanup: 1. The awkwardly named debugCompareQueryResults() is now resultEquals(), which is more or less consistent with how other equality tests are named in Android. This name change affects two clients. 2. PackageManager has changed to use resultEquals() instead of maybeCheckConsistency(). This provides a simpler and more consistent use of the APIs. maybeCheckConsistency() has been made private. Test: atest PropertyInvalidatedCacheTests Change-Id: I4110f8e887a4fd8c784141e8892557a9d1b80a94
* PropertyInvalidatedCache unit testLee Shombert2021-07-071-67/+185
| | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 192588767 This change corrects a latent defect related by the new bypass() method in PropertyInvalidatedCache. The defect is not current issue because there are no clients using the bypass() method yet. PropertyInvalidatedCache is modified to work without sytsem properties, because test code generaly does not have permission to read or write properties. The modification has minimal impact when there is not testing in progress. New tests for basic cache functionality are added. Bypass statistics are included in 'dumpsys cacheinfo'. We can identify caches with a low hit ratio due to wildcard users, and revisit the logic for those particular caches. Lint warnings were corrected in the class javadoc comment and by changing all occurrences of String.format() to TextUtils.formatSimple(). Test: atest * FrameworksCoreTests:PropertyInvalidatedCacheTests Change-Id: Ie3fbd2f4cb8a38b205a555af389814d7d64dd6bd
* Modify PropertyInvalidatedCacheLee Shombert2021-06-211-5/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 186778818 This makes two changes to PropertyInvalidatedCache. 1. disableLocal() now disables all current and future caches that use the same name (not the necessarily the same property) , in the local process. Previously, disableLocal() only disabled a single cache instance, but the intent was always to disable all instances of the same cache in the process. disableInstance() is available with the old behavior. 2. A bypass() method has been added. If bypass() returns true, query() will skip the cache and go straight to the binder call as though the cache had been disabled. The default implementation always returns false. Caches can override the implementation to avoid caching selected queries. These changes specifically address the problem of caches that are created dynamically and which should be disabled in the local process. A unit-test is added for PropertyInvalidatedCache. This is not a complete test because test processes are not allowed to set system properties. The unit-test will be improved in the future by modifying PropertyInvalidatedCache to use an invalidation mechanism other than system properties. Manual test: boot a phone with a baseline build and with the build under test and verified that the list of disabled caches is the same. Use 'dumpsys cacheinfo' to get the cache status. Test: atest * FrameworksServicesTests:UserManagerServiceCreateProfileTest Change-Id: I9f604b872911290e4e3d8a58b3e28e328b2000a9
* Enable in-process permission caches for system_serverLee Shombert2020-10-121-3/+6
| | | | | | | | | | | | | | | | | | | | | | | Bug: 170472470 Do not disable the permission caches inside the system server. This is beneficial because permission checks require many binder calls, and the cache, even though it is in-process, eliminates those calls. 1. Make the PermissionManager cache more effective by increasing the maximum size to 2048. Experiments show that the high-water mark is about 600. 2. Suppress cache content in the 'dumpsys cacheinfo' output. dumpsys fails if the output is too large in a single process, and the new caches push the system server cacheinfo over the limit. The content can be added to the output by setting the new DETAILED boolean in PropertyInvalidatedCache to true, but this flag should never be committed with a value of true. Test: two atest runs * atest FrameworksServicesTests:com.android.server.devicepolicy.DevicePolicyManagerTest#testGetPermissionGrantState * atest FrameworksServicesTests:NetworkPolicyManagerServiceTest Change-Id: I7d3c1f34b44216bb510319ca5b6aced1cc53e05d
* Merge changes from topic "sep11" am: c0b288133a am: 69e6f07347 am: ↵Jeff Sharkey2020-09-151-2/+2
|\ | | | | | | | | | | | | | | 741c0a78cc am: da7478b570 am: 487d394296 Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1426195 Change-Id: Id01f468b43fd5b2aada78608010625b392c1b647
| * Update language to comply with Android's inclusive language guidanceJeff Sharkey2020-09-141-2/+2
| | | | | | | | | | | | | | | | | | See https://source.android.com/setup/contribute/respectful-code for reference Test: none Bug: 168334533 Exempt-From-Owner-Approval: docs updates Change-Id: I53003332717baf57dc088b2f6b969cdb1863f65e
* | Reduce auto-cork delay to 50msLee Shombert2020-08-171-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 160971853 Reduce the auto-cork delay from 2s to 50ms. Testing shows that this introduces a very few new invalidate calls for the package_info cache key, and greatly improves the hit ratio for the associated caches. This change includes a fix to the cache-clear counter. Some clears were missing. Test: * phone reboot * atest CtsContactsProviderTestCases * atest FrameworksServicesTests:UserSystemPackageInstallerTest * atest FrameworksServicesTests:PackageManagerSettingsTests Verified that hit ratios improved over the baseline. Verified that the number of extra invalidates did not increase by more than 5. Change-Id: I4b70b1da8c3927c74077e6da0e60dc56c2e007f1
* | Enhance PropertyInvalidatedCache debuggingLee Shombert2020-08-051-16/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 162103383 Update 'dumpsys cacheinfo': add the number times a cache is cleared, rename misses due to cache disabled/unset/corked to "skips", and fix the logic counting cache invalidates. Make the cache name distinct from the property. There is no change to legacy caches (which continue to use the property as the name) but caches that share the cache_key.package_info property now have distinct names. Add the property name to auto-corker debug messages. Test: Boot and run 'dumpsys cacheinfo' to verify the output. Change-Id: I3e3e500dc9a1559fd7ccdc49fb00292ab5f712c1
* | Enhance PropertyInvalidatedCache debugLee Shombert2020-07-151-21/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 159039903 A set of small changes to the class to allow for addition debugging. 1. Distinguish a cache that is disabled because the nonce has not set from a cache that is disabled because it is corked. 2. Count the times the cache was bypassed because it was corked, unset, or disabled. This does not count the times the cache was bypassed because it was locally disabled. Add these counts to dumpsys. 3. Count the number of times a cache is invalidated, corked, and recorked (corked while already corked). Add these counts to dumpsys. 4. Log some additional information if cache inconsistency is detected. 5. Record cache overflows and cache high-water marks. Test: Run the following tests with and without the changes. Verify that the changes do not affect behavior. * CtsContactsProviderTestCases * FrameworksServicesTests * FrameworksServicesTests:UserManagerServiceCreateProfileTest * PlatformScenarioTests * PtsChreTestCases * FrameworksServicesTests:UserManagerServiceUserInfoTest * FrameworksServicesTests:UserManagerServiceIdRecyclingTest * CtsProviderTestCases * FrameworksServicesTests:UserSystemPackageInstallerTest * FrameworksServicesTests:PackageManagerSettingsTests * FrameworksServicesTests:UserLifecycleTests * CtsCalendarProviderTestCases * BluetoothInstrumentationTests Pull a bug report and verify that the new counters are included. Change-Id: I38d5545947d6f09c7e62e094c7b2858aab4a8cf9
* | Merge "Add performance counters to cacheinfo dumps." into rvc-dev am: ↵Collin Fijalkovich2020-05-271-0/+25
|\| | | | | | | | | | | 4edffac782 am: 23e5f201c8 am: 959b44ba0b am: cf0702af73 Change-Id: I8459abf3d6f654023d4cce5b881b382893c7302f
| * Add performance counters to cacheinfo dumps.Collin Fijalkovich2020-05-261-0/+25
| | | | | | | | | | | | | | | | | | | | Tracks the number of hits, misses, refreshes, and invalidations on a per-cache basis, and makes that information available through dumpsys cacheinfo. Bug: 157175501 Test: adb shell dumpsys cacheinfo Change-Id: Icabdd82acda2edc54d787d0a2d15a33ba18fd668
* | Merge changes from topic "dump-cacheinfo" into rvc-dev am: acb2bba925 am: ↵Collin Fijalkovich2020-05-181-1/+87
|\| | | | | | | | | | | 5f2f1b3feb am: c11d18e807 am: 8f3b7d8ca3 Change-Id: I70d6e5f4824f3aa0da8b93155933e9768af660ea
| * Add cache debugging information to bugreports.Collin Fijalkovich2020-05-131-1/+87
| | | | | | | | | | | | | | | | | | | | | | | | Following the model for dumpsys gfxinfo, this patchset adds a CacheBinder service that dumps cache state information from each process. Bug: 153661880 Test: adb shell dumpsys cacheinfo Test: adb bugreport Change-Id: Ie7cce70e56777a200e3e3e92ab895126b6f29032
| * Maintain global list of caches; purge on low memoryDaniel Colascione2020-05-131-0/+25
| | | | | | | | | | | | | | | | Bug: 140788621 Test: m Merged-In: I3ba88e0a6f6c0f26465903988e7432156bd5be20 Change-Id: I3ba88e0a6f6c0f26465903988e7432156bd5be20 (cherry picked from commit 22c2ddb201e52e54d82d2a8dba77c19d74e654ba)
* | Maintain global list of caches; purge on low memoryDaniel Colascione2020-04-281-0/+25
| | | | | | | | | | | | Bug: 140788621 Test: m Change-Id: I3ba88e0a6f6c0f26465903988e7432156bd5be20
* | Merge "Disable binder caches in unit tests" into rvc-dev am: 9bca3a380d am: ↵Lee Shombert2020-04-191-3/+37
|\| | | | | | | | | | | 656bf159fd am: 72569532fa am: 94dcd6f6ba Change-Id: I84258c476ca40a6f6bf487a038914abc15af7133
| * Disable binder caches in unit testsLee Shombert2020-04-171-3/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 152451909 Unit tests often execute server code in the context if a test process. Such a process does not have the same permissions as formal system processes. In particular, such a process does not have permission to invalidate binder caches. This change disables all binder cache code in the current process. This means caching is disabled and invalidation never occurs. There are no permission violations and the test process is also unable to affect (through cache invalidation) the actual system processes. Test: Ran a list of atests. Two had security violations before the change but were okay after the change: * FrameworksServicesTests * UserSystemPackageInstallerTest Ran additional tests to verify no regressions: * PlatformScenarioTests * PtsChreTestCases * BluetoothInstrumentationTests * UserLifecycleTests Change-Id: I011ee1eb39b2d52c69b6d5164b64f7418d2bbdd4
| * RESTRICT AUTOMERGE: Add a facility for time-based cache corkingDaniel Colascione2020-04-171-0/+112
| | | | | | | | | | | | | | | | | | | | AutoCorker addresses the situation where big invalidation storms kill performance but we don't have a way to insert a manual cork around these update storms. Bug: 140788621 Test: m Change-Id: If07d693886fca340c7a18d5a607a4f235aa7107d
| * RESTRICT AUTOMERGE: Add a "cork" mechanism to prevent cache invalidation ↵Daniel Colascione2020-04-171-0/+93
| | | | | | | | | | | | | | | | flooding Bug: 140788621 Test: subsequent CL Change-Id: Idfc42110e655571578bae208b98ee61a6eb1b2c3
* | Add a facility for time-based cache corkingDaniel Colascione2020-03-201-0/+112
| | | | | | | | | | | | | | | | | | | | AutoCorker addresses the situation where big invalidation storms kill performance but we don't have a way to insert a manual cork around these update storms. Bug: 140788621 Test: m Change-Id: If07d693886fca340c7a18d5a607a4f235aa7107d
* | Merge changes from topic "cache-cork"Daniel Colascione2020-03-181-0/+95
|\ \ | | | | | | | | | | | | | | | | | | | | | * changes: Cork permission and package cache around bulk permission update Cork package information cache invalidations during boot Add a "cork" mechanism to prevent cache invalidation flooding Add TODO for resolving property-set race
| * | Add a "cork" mechanism to prevent cache invalidation floodingDaniel Colascione2020-03-061-0/+93
| | | | | | | | | | | | | | | | | | Bug: 140788621 Test: subsequent CL Change-Id: Idfc42110e655571578bae208b98ee61a6eb1b2c3
| * | Add TODO for resolving property-set raceDaniel Colascione2020-03-041-0/+2
| |/ | | | | | | | | | | Test: it's a comment Bug: 140788621 Change-Id: I02bb0571164db1d7c28197c6e189aef9d6890e4c
* / Modify PropertyInvalidatedCache debuggingLee Shombert2020-03-091-6/+12
|/ | | | | | | | | | | | | | | | | | Bug: 140788621 There is no change in behavior unless DEBUG or VERIFY are true. 1. Do not log queries to a disabled cache. 2. If verification fails, log the failure and return the correct value. This allows the system to continue running for further debug. Test: Boot the phone with a test image that sets DEBUG and VERIFY true. Verified that there are limited messages about a disabled cache (especially for the package_info cache). Force verification failures by removing cache invalidation from UserManager. Verify that the cache failures are logged but the system runs normally. Change-Id: I80c604867a6d879c74ff8f8e8a0be0ac110c6581
* Cache package and permission informationDaniel Colascione2020-02-201-1/+1
| | | | | | | | | | We use the package settings class as a central point for invalidating on package information changes; for permission changes, we invalidate from inside the individual permission data objects. Bug: 140788621 Test: boots, package tests (pending) Change-Id: Iec14d4ec872124e7ef4612c72d94c89a7319ace0
* Enhance PropertyInvalidatedCache debugLee Shombert2020-01-301-7/+27
| | | | | | | | | | | | | | | | | | | Bug: 140788621 Add the cache name to most debug messages. The cache name defaults to the property name but can be overridden. Overriding the cache name makes the most sense when multiple caches share a single proprerty. This function is only called from inside debug log messages. Wrap the default invocation of Query.toString() with a cache instance method that can be overridden. A cache that uses a simple type (like Integer) for its Query to provide nicely formatted query strings in the debug logs. This function is only called from inside debug log messages. Test: Created a test build using the hasSystemFeature() binder cache, overriding cache name and the object query string. Change-Id: If379ac3e8494e9fef0ff9f5cc5ca0412d02e5502
* Added verification mode to PropertyInvalidatedCacheCollin Fijalkovich2020-01-091-3/+29
| | | | | | | | | | | | | Created a compile-time flag VERIFY that when enabled will compare any answer returned out of the cache with the true server response. If the answers differ and the invalidation nonce has not changed, the cache will log which query induced the response. Bug: 146018074 Test: Manually flashed and verified that the cache captures invalid responses. Change-Id: I716b6aad5c4dac975e96fa05f0e18829f76c8636
* Add property-invalidated cacheDaniel Colascione2019-12-021-0/+428
The PropertyInvalidatedCache class provides a framework for caching frequently-read, seldom-written information between processes. Test: caching CLs Test: atest FrameworksCoreSystemPropertiesTests Bug: 140788621 Change-Id: I2d650129389e9567e4982b3a613fb8d1cbc97f4b