summaryrefslogtreecommitdiff
path: root/libs/androidfw/StringPool.cpp
diff options
context:
space:
mode:
author Paul Hadfield <hadfieldp@google.com> 2022-03-03 13:26:39 +0000
committer Paul Hadfield <hadfieldp@google.com> 2022-03-07 11:51:24 +0000
commit8354946ce561a9008075b4a5500c783f4b251007 (patch)
treecd9606d6d19cf474c4db87c4fe0652838e339fb6 /libs/androidfw/StringPool.cpp
parenta8196fc56c2c000d69c9dc4f9529c319c85f6a43 (diff)
Fix onPackageChanged handling of disabled packages
TransportManager#onPackageChanged was not correctly handling the circumstance where broadcast ACTION_PACKAGE_CHANGED was received with EXTRA_CHANGED_COMPONENT_NAME_LIST containing only the package name, instead of >=1 component names. When that happens it indicates that a package-wide change has occurred, such as the package being enabled or disabled. If the package in question contains backup transports, they should be unregistered if the package is disabled, and re- registered if the package is enabled. But the current TransportManager#onPackageChanged doesn't know enough to do so. We can determine the enabled state of the package by calling PackageManager#getApplicationEnabledSetting. This commit modifies onPackageChanged to do that, and then (un/re)-register the packaged transports as appropriate. To test I extend the Roboelectric ShadowApplicationPackageManager so that the {get,set}ApplicationEnabledState() methods are exposed for use in the test setup. Note, this is a retake of ag/15301455, with handling added for a race condition which caused flakiness in CtsUtilTestCases: the onPackageChanged method must handle a possible exception thrown by the PackageManager if the package has just been removed. Bug: 162725876 Fixes: 162725876 Test: 1. atest -v TransportManagerTest 2. atest CtsBackupHostTestCases|CtsBackupTestCases|CtsUtilTestCases 3. manual test on device: 1 device:/ # bmgr list transports 2 device:/ # pm disable com.google.android.gms 3 device:/ # bmgr list transports 4 device:/ # pm enable com.google.android.gms 5 device:/ # bmgr list transports observe logcat showing BackupTransportManager MORE_DEBUG: step 2: Package c.g.a.gms was disabled. step 4: Package c.g.a.gms was enabled. Transport c.g.a.gms/.b.c.D2dTransportService registered Change-Id: I1ba20a50dfb9a6918605bbd3216a08f0047e2c10 (cherry picked from commit d68bb3786d6431411973ae1a54ac43de93552b90)
Diffstat (limited to 'libs/androidfw/StringPool.cpp')
0 files changed, 0 insertions, 0 deletions