Created KeyValueBackupReporter, which includes:
* Logcat (main and event buffers).
* Backup observer.
* Backup manager monitor.
Also removed traces since they weren't very useful. Hopefully this will clear
KVBT of noise and help spot refactor opportunities. Did some small refactors
along w/ it.
Methods are starting to fit in one (big) screen :)
Bug: 110082831
Test: atest KeyValueBackupTaskTest
Test: adb shell bmgr backupnow <kv_package> and verify logs
Test: Kicked-off KV in different scenarios to check logs, this is
tracked in https://docs.google.com/spreadsheets/d/1EcZ61qapj2cW_Yr99gIlQz0QVJ_BQfVc_1dHBor2cOo/edit?usp=sharing
Test: adb shell bmgr backupnow <kv_package> <fb_package>
Verify PFTBT is kicked-off and logs
Change-Id: I1486049861543b5ad558b45cf0e0206532e20632
This is the first CL of key-value backup refactor.
* Method execute() that executed the state machine states is now empty
and run() is created with the initial version of the linear task. It's
basically composed of begin + loop + end. Although it still has the notion
of state, it's more restricted than before (with private methods returning
the next state). This is intentional to avoid making this CL too heavy to
review and to avoid too much behavioral changes here. In the next CLs I
intend to remove BackupState.
* Introduction of RemoteCall, which encapsulates an outbound call that
leaves the system_server, with time-out and cancellation built-in.
Agent calls are now triggered using this. As a result there is no more
operationComplete() method either.
* Cancellation now is cleaner. We don't need a step lock anymore, only a
(volatile) boolean that is checked in every queue iteration. If asked
to cancel during an ongoing agent call we rely on RemoteCall.cancel()
to return control of the task thread to us. We wait for the cancel
acknowledgement to preserve the contract of no more transport calls.
* PFTBT instantiation moved from the constructor to the run() method,
which makes more sense.
* No need for mFinished, mBackupData == null bookkeeping since time-outs,
cancellation and legitimate agent responses won't step into one another
anymore.
* Ternary (mQueue.isEmpty) ? BackupState.FINAL : BackupState.RUNNING_QUEUE gone
because we check this in the beginning of invokeNextAgent() and now we
don't pay the state-machine tick price associated with the handler.
* PerformBackupTask call sites now call static method start(), that
spins up a new dedicated thread for the task. This new thread is
assigned the same (process) priority as the backup thread
(THREAD_PRIORITY_BACKGROUND).
Work left for future CLs:
* RemoteCall spins up a new thread for kicking off the call, this is for
system agents that are executed inline. Old PBT also executed in the same
thread (backup handler thread), so maintaining this to keep this CL at
a reasonable size.
Test: atest PerformBackupTaskTest
Test: atest RunFrameworksServicesRoboTests
Test: atest frameworks/base/services/tests/servicestests/src/com/android/server/backup
Test: atest CtsBackupTestCases
Test: atest CtsBackupHostTestCases
Test: atest GtsBackupTestCases
Test: atest GtsBackupHostTestCases
Test: adb shell bmgr backupnow <kv_packages>
Test: 1. adb shell bmgr backup <p1> <p2>
2. adb shell bmgr run
A) 3. Cancel while sending <p1> data to transport
4. Verify <p1> is backed-up and not pending
Verify <p2> is not backed-up and is pending
B) 3. Cancel while waiting for <p1> agent
4. Verify <p1> is not backed-up and is pending
Verify <p2> is not backed-up and is pending
Change-Id: Ia456c4e807de95d662c9e923245be07e8996f58a
With KV Refactor in mind:
* Tests around calling agent.
* Tests around agent writing data.
* Tests around transport handling agent data.
* Small modification on ShadowBackupData{Input,Output} to allow empty data.
* Small refactor.
Test: atest PerformBackupTaskTest
Change-Id: Ia9296859926d09d5bbcb0532fb869ace110240e4
With KV Refactor in mind.
* Split empty queue test into multiple tests.
* Tests around packages failing backup pre-conditions.
* Added verifications for event logging.
* Renamed some tests to better reflect important parts of it.
* More tests about one package.
* Introduced PackageData to help mock packages, much like TransportData.
* Some small refactors.
Test: atest PerformBackupTaskTest
Change-Id: I23aba2b26e82f8643cc1c90f9408510ab34045fd
With KV Refactor in mind.
* Added tests around empty queue and single package backups.
* Refactored a bit some of the existing tests.
* Moved from mocking BMS to using a real instance and had to adjust a
few things for this.
Test: atest PerformBackupTaskTest
Change-Id: I0ee3be32c7cbac5ed2cdc2717408749907c15ade
PerformAdbRestoreTask and FullRestoreEngine has shared a lot of code,
remove the copy that was in PerformAdbRestoreTask.
Test: adb restore
Change-Id: Ib4ce8b50eff8aed4a2c0660808c05b80f378ea98
Before we were considering that the app was enabled in this case, which
might not be always true.
Bug: 80227098
Test: atest AppBackupUtilsTest
Test: Check app w/ manifest enabled="true" is backed-up, but
enabled="false" is not.
Change-Id: I4625aa39ba0de45ce6689f2375245081a5d4d722
BMS.backupNow is called from GMSCore, which has a different calling
identity than the framework. This causes an IllegalArgumentException due
to uid mismatch when backupNow tries to schedule a job.
This occurs when the following conditions are combined:
1) Battery saver mode enabled
2) Network change detected
3) Backup pass is scheduled for now
Bug: 79441902
Test: 1) m -j RunFrameworksServicesRoboTests
2) Manual: Enabled battery saver, modified code to run backupNow with
each network change and overwrite previously scheduled KeyValueJob.
Then, change wifi to trigger scheduling the KeyValueJob.
Verified:
- IllegalStateException b/c of uid mismatch without change
- No exception and correct calling uid with change
Change-Id: Iac90cd435e3fc32ff5428236aa15507b36aa833d
When the agent provides a prohibited key, the code flow will directly be returned
without excuting next backup state. The next state should be execute instantly to
make sure the backup mechanism can be executed properly.
Bug: 77272601
Test: 1.m -j RunFrameworksServicesRoboTests
2.Manual testing by test package with prohibited key.
- adb backup -all
- adb backup -shared
- adb backup -obb -all
- adb shell bmgr backupnow --all
- adb shell bmgr backupnow [test key value package]
- adb backup -keyvalue [test key value package]
Change-Id: I46e1aa8dd0f75cf54087b43cee50ee952d85abc1
This fixes an issue when adb backup would hang (and hold wakelock)
forever when run with '-obb' and '-shared'.
Bug: 75997810
Test: 'adb backup -obb -shared' finishes successfully
Change-Id: I015add6dc525984592e733266b3e046f41d2cb93
We only report failure to IBackupObserver.backupFinished() when we meet
transport failure, but now it will report failure when the last package
meet TRANSPORT_PACKAGE_REJECTED or TRANSPORT_QUOTA_EXCEEDED, add above
two states in FINAL to prevent the situation, and update related
test, also javadoc of IBackupObserver.
Bug: 77271953
Test: make -j RunFrameworksServicesRoboTests ROBOTEST_FILTER=PerformBackupTaskTest
Change-Id: Ic2bfdf9f50d700f8ccb509e081ae8e0afb186020
Remove IBackupObserver.backupFinished() before
executeNextState(BackupState.FINAL), add test cases to verify it and
format PerformBackupTaskTest.java
Bug: 77272662
Test: make RunFrameworksServicesRoboTests
Change-Id: Ia464d0326437fb8680ab88619829c483e2c1164d
mCurrentPackage is null when package doesn't exist, which lead test
failed with NPE
Use request.packageName for case BackupTransport.AGENT_UNKNOWN instead
Bug: 77272500
Test: m -j RunFrameworksServicesRoboTests ROBOTEST_FILTER=PerformBackupTaskTest
Change-Id: I27be85f0c3f95e36edd92d0d552189fbcf6952dd
(cherry picked from commit 87f1209ac6)
mCurrentPackage is null when package doesn't exist, which lead test
failed with NPE
Use request.packageName for case BackupTransport.AGENT_UNKNOWN instead
Bug: 77272500
Test: m -j RunFrameworksServicesRoboTests ROBOTEST_FILTER=PerformBackupTaskTest
Change-Id: I27be85f0c3f95e36edd92d0d552189fbcf6952dd
This is a temporary solution for P to unblock GTS tests.
Bug: 77852250
Test: manual:
1. adb backup -f saved-wifi-api100.ab -keyvalue com.android.providers.settings
2. adb restore saved-wifi-api100.ab
3. See that SettingsBackupAgent receives appVersionCode in onRestore()
Change-Id: I6092bea570e7e27cb5b72165e9284ad2befc21b6
Attempt to simplify the exposure of package signing information via
PackageInfo by creating a new class and corresponding methods for
querying a package's signing information.
Bug: 74831530
Test: PkgInstallSignatureVerificationTest
Change-Id: Idbc008b41a921f89cefb224b26f910da4d238dea
We still don't know the underlying cause of this, but we shouldn't crash
the system_server. Catching for now.
Bug: 74940472
Bug: 77574274
Test: m -j RunFrameworksServicesRoboTests
Change-Id: I36fc2e65f8766f6b8fd68104d8830b72668d84eb
In some cases (deferred restore) the app data needs to be cleared even
if the app has implemented backup agent. As a quick fix introduce
PACKAGES_TO_CLEAR_DATA_BEFORE_FULL_RESTORE secure setting, which
transport can fill prior to restore.
Bug: 69069240
Test: adb shell settings put secure packages_to_clear_data_before_full_restore com.google.android.apps.nexuslauncher && adb shell bmgr restore com.google.android.apps.nexuslauncher
Change-Id: I2a4651365d9cf4747f32d2ba69312f54cd03d118
With the newly created Global setting for backup/restore agent timeouts
(backup_agent_timeout_parameters introduced in ag/3731401), update
references in backup and restore code to get the timeout values from
the setting instead of referencing constants in BMS.
This makes these timeouts configurable outside of the framework.
The default value of the setting is the same as the constants in BMS so
this should have no change on the timeout values used in the backup and
restore flow.
Bug: 70276070
Test: 1) m -j RunFrameworksServicesRoboTests
Change-Id: I0259bba76d0fed48158b8316f430b315ea98086e
With the newly created Global setting for backup/restore agent timeouts
(backup_agent_timeout_parameters introduced in ag/3731401), update
references in backup and restore code to get the timeout values from
the setting instead of referencing constants in BMS.
This makes these timeouts configurable outside of the framework.
The default value of the setting is the same as the constants in BMS so
this should have no change on the timeout values used in the backup and
restore flow.
Bug: 70276070
Test: 1) m -j RunFrameworksServicesRoboTests
Change-Id: I0259bba76d0fed48158b8316f430b315ea98086e
Part of push to make backup and restore agent timeouts configurable. Creates
a Global setting for the current static BackupManagerService timeouts so
that they can be overriden with P/H. We keep the current default values,
which will be updated once we investigate what more appropriate values are.
Remame the constants to better reflect what they're used
for. Next, we will update the framework to use these constants.
This depends on the refactor of how we observe changes to key value
backup settings (ag/3709997).
Bug: 70276070
Test: m -j RunFrameworksServicesRoboTests ROBOTEST_FILTER=BackupAgentTimeoutParametersTest
Change-Id: Id506314ce0c8bd5e4d1d8b4001b26cbad0056c99
Part of push to make backup and restore agent timeouts configurable. Creates
a Global setting for the current static BackupManagerService timeouts so
that they can be overriden with P/H. We keep the current default values,
which will be updated once we investigate what more appropriate values are.
Remame the constants to better reflect what they're used
for. Next, we will update the framework to use these constants.
This depends on the refactor of how we observe changes to key value
backup settings (ag/3709997).
Bug: 70276070
Test: m -j RunFrameworksServicesRoboTests ROBOTEST_FILTER=BackupAgentTimeoutParametersTest
Change-Id: Id506314ce0c8bd5e4d1d8b4001b26cbad0056c99