Commit Graph

482 Commits

Author SHA1 Message Date
Annie Meng
59f6f7fffa [Multi-user] Initialize user state in UserBMS
Move per-user state initialization (directories for bookkeeping data and
transport manager) from BMS to UserBMS.

The UserBMS constructor is now private and callers should use the static
helper to create a new instance. This is primarily for three reasons:
1) Allows for extracting logic out of the constructor into helpers.
2) Allows for performing necessary user-specific setup in the future
such as data migration.
3) Allows for writing unit tests without having setters/getters
exclusively for tests.

Bug: 120212806
Test: 1) atest RunFrameworksServicesRoboTests
2) boot -> unlock user -> service started and verify transports
registered
3) adb shell bmgr backupnow [package] -> writes to /data dir
   adb shell bmgr enable false -> writes to /data dir
4) adb shell bmgr backupnow --all -> writes to /cache dir

Change-Id: If88d95059951dbae0abf691629db1a05d27f743d
2018-12-10 12:43:44 +00:00
Annie Meng
604eb2a838 [Multi-user] Consolidate BMS creation
Part of prep work to create a UserBMS instance per user.

Moves BMS state initialization to the BMS constructor. Most of this
state will then be moved to the UserBMS constructor since it's per-user
state.

Bug: 120212806
Test: 1) atest RunFrameworksServicesRoboTests
2) atest TrampolineTest
3) boot -> unlock user -> create service
4) adb shell bmgr flows

Change-Id: I140c4db3d5c147e3dd09e590eaf15a9f4d8b3da1
2018-12-10 12:43:15 +00:00
Annie Meng
3b2e750a93 [Multi-user] Stop migrating legacy backup setting
The backup enabled setting BACKUP_ENABLED was deprecated since Android
N and replaced by a file containing enabled state.

Stop migrating this setting for the system user to be able to
consolidate starting the backup service for system and non-system users.

There's been several Android versions since the deprecation that the
chance we need the setting is slim (as devices shouldn't OTA from N to
current). Without the setting, the default would be backup off (absence
of file) which can then be enabled again via SUW or Settings.

Bug: 120212806
Test: 1) boot and unlock system user
2) adb shell bmgr backup [package]; adb shell bmgr restore [package]
3) atest RunFrameworksServicesRoboTests
Change-Id: I6d2b375a9400dffa9f75528d42f36b4af2e14187
2018-12-10 12:41:51 +00:00
Annie Meng
a6d828755e [Multi-user] Create setting for multi-user backup service support
Whether the backup service supports multi-user is now configured in a
Global setting: backup_multi_user_enabled

This allows us to develop multi-user support hidden behind a flag. In a
future CL, we'll also gate the types of users we support.

Also create basic infrastructure for starting the service for a newly
unlocked user (currently a no-op).

Bug: 120212806
Test: 1) atest TrampolineTest
2) adb shell settings put global backup_multi_user_enabled 0;
   unlock system user -> verify service started;
   unlock user 10 -> verify service not started;
3) adb shell settings put global backup_multi_user_enabled 1;
   unlock system user -> verify service started;
   unlock user 10 -> verify service started;

Change-Id: I048e017cfa6148097cebe2eb2916d1b53c53d3b0
2018-12-10 12:33:28 +00:00
Bram Bonné
ae12b3c5a1 Ports the first part of encryption/key to AOSP.
A few additional changes (apart from style and usual dependencies) were needed:
- Dependency on KeyStore was removed (see b/75771701).
- References to internal names were removed or renamed.
- ByteStringUtils is used as a replacement for the Guava bytes-to-hex-string conversions.
- Uses java's Optional rather than Guava's Optional.
- Change to Slog for logging.
- TertiaryKeyRotationTracker.MAX_BACKUPS_UNTIL_TERTIARY_KEY_ROTATION is now a constant rather than a flag.

Bug: 111386661
Test: atest RunFrameworksServicesRoboTests
Change-Id: If9bcfb1f73ba78c278947b8499236bb536e625eb
2018-12-05 16:11:28 +00:00
Annie Meng
8c0d41ac2d Merge "[Multi-user] Rename GlobalBackupManagerService -> BackupManagerService" 2018-11-29 13:36:57 +00:00
Annie Meng
384230f9e0 [Multi-user] Rename GlobalBackupManagerService -> BackupManagerService
Restore original naming since UserBackupManagerService is now merged.

Just find and replace, no functionality changes in this CL.

Bug: 118520567
Test: 1) atest RunFrameworksServicesRoboTests
2) atest $(find \
frameworks/base/services/tests/servicestests/src/com/android/server/backup \
-name '*Test.java')
3) adb shell bmgr flows
Change-Id: Ia37997cec93fac9ebb5102edfff9000c9cff4eb1
2018-11-28 12:30:21 +00:00
Annie Meng
178828f259 Merge "[Multi-user] Extract BackupManagerService to UserBackupManagerService" 2018-11-28 10:37:18 +00:00
Patrick Baumann
fc2851e4d5 Removes ASEC-related logic from the framework
This change removes remaining ASEC-related logic from the framework in
preparation for install refactoring.

Bug: 109941548
Test: install still works
Change-Id: Ic7322038e45c026bcc59800a5a9fafdbb461021f
2018-11-27 12:56:14 -08:00
Annie Meng
813716b199 [Multi-user] Extract BackupManagerService to UserBackupManagerService
BMS is split into GlobalBMS and UserBMS.
UserBMS:
- Core backup/restore implementations and bookkeeping.
- Will be per user in a future CL (only one instance in this CL to limit
scope of changes).

GlobalBMS:
- System service definition, interaction with Trampoline, user-aware
operations.
- Will be renamed back to BMS in a future CL (so BMS history can follow
UserBMS in this CL).

*** Reviewers, please pay attention to the patchset breakdown to better
understand what is a rename/move vs. new changes ***

* Base -> Patchset 2: BMS splits into GlobalBMS and UserBMS (MOVE ONLY)

Patchset 1: Rename BMS -> UserBMS
Patchset 2: Move parts of UserBMS to GlobalBMS
No new functionality, only moving existing code.

* Patchset 2 -> Patchset 3: New functionality for GlobalBMS

- Switch references from BMS to GlobalBMS in Trampoline.java.
- Change the definition of the system service in SystemServer.java to
GlobalBMS.
- Instantiate one instance of UserBMS in GlobalBMS constructor.
- Add all IBackupManager methods, which for now just directly calls the
corresponding method in UserBMS.

* Patchset 3 -> Patchset 4: Migrate usages of BMS in code (RENAME ONLY)

Find and replace, no new functionality.

* Patchset 4 -> Patchset 5: Migrate usages of BMS in tests (RENAME ONLY)

Find and replace, no new functionality.

* Patchset 5 -> Patchset 6: New tests for GlobalBMS

Add tests for all the new IBackupManager methods added (just tests
straight redirection for now).

* Overall: View Patchset 2 -> [Latest Patchset] for new code.

TODO: Modify art-profile with rename

Bug: 118520567
Test: 1) atest RunFrameworksServicesRoboTests
2) atest $(find
frameworks/base/services/tests/servicestests/src/com/android/server/backup
-name '*Test.java')
3) atest GtsBackupHostTestCases
4) atest CtsBackupTestCases
5) atest CtsBackupHostTestCases
6) atest DeviceOwnerTest
7) 'Backup Now' in Settings
8) Cloud and d2d restore in SUW; deferred restore
9) All 'adb shell bmgr' flows
10) adb backup; adb restore
Change-Id: Ib5a5837375fe950bc7d33a5e31cca16b605541f9
2018-11-27 14:23:30 +00:00
Nicolas Geoffray
850f109ec8 Merge "Start using shared libraries class loader." 2018-11-22 10:24:38 +00:00
Nicolas Geoffray
8d144eb8bd Start using shared libraries class loader.
Change 1/2. Change 2/2 will setup the class loader namespace for
shared libraries.

This change sets up shared libraries class loaders for applications
and for dexopt.

bug: 111174995
Test: DexoptUtilsTest, device boots

Change-Id: Ie9a2b4eaa85cda59951703433f7a2d03bc12095d
2018-11-22 10:06:41 +00:00
Bram Bonné
70bb9a6462 Ports encryption/storage from gmscore to AOSP.
A few additional changes (apart from style and usual dependencies) were needed:
- BackupEncryptionDbHelper now extends SQLiteOpenHelper directly,
implementing relevant methods.
- Dependencies on Guava are replaced by their Java equivalents.

Bug: 111386661
Test: atest RunFrameworksServicesRoboTests
Change-Id: I4566980fc81d6cff5e7012184502e028980512ae
2018-11-20 09:38:11 +00:00
Annie Meng
56a5c27584 [Multi-user] Fix BMS checkstyle
Now that checkstyle runs a preupload hook for frameworks/services, when
we move BMS -> UserBMS, checkstyle will complain of errors because it
sees it as a new file.

This CL just fixes checkstyle complaints (mostly adding javadocs,
variable naming, operand placement, etc.) for BMS so the CL that creates
UserBMS can have as little changes as possible to ease review.

There is no change in functionality in this CL.

Bug: 118520567
Test: atest RunFrameworksServicesRoboTests
Change-Id: I1118d6deef83d1abfbc8fd94883d7d162a4399cb
2018-11-16 17:49:16 +00:00
Annie Meng
832d53c436 Merge "[Multi-user] Clean up BMS structure" 2018-11-16 13:09:48 +00:00
Annie Meng
2863ea6c11 [Multi-user] Clean up BMS structure
Part of preparation to extract out user BMS.

Remove unused components:
- Backup traces
- Unused fields

Clean-up work:
- Better organize BMS class structure to be able to separate global vs.
user state. This is purely a move and no functionality has changed:
> static fields, static methods, instance fields, constructor, methods,
private static methods, static inner class (system service definition).
- Add javadoc comments to comply with new checkstyle preupload hook.

Bug: 118520567
Test: 1) atest RunFrameworksServicesRoboTests
2) atest FrameworksServicesTests

Change-Id: I5ac868ff0df0ec007b64d686647d9a676e374e40
2018-11-15 12:54:41 +00:00
Bram Bonné
865003370b Ports chunking/cdc from gmscore to AOSP.
Some additional changes (apart from the regular style modifications)
were needed:
- Guava crypto methods are replaced by their javax equivalents.
- Preconditions checks now depend on com.android.util rather than Guava.

Bug: 111386661,116575321
Test: atest RunFrameworksServicesRoboTests
Change-Id: I43f92f1c0fb3acf62469712d8db212f94429116c
2018-11-14 14:56:45 +00:00
Ruslan Tkhakokhov
eb6dabcdde KV] Don't set current token if no data was moved
Bug: 119299848
Test:
1) atest KeyValueBackupTaskTest
2) Manual:
 - Run 'adb shell bmgr init' for the active transport to wipe all backup data
 - Run 'adb shell dumpsys backup' and verify string 'Current: 0', i.e. the current token is
   set to 0
 - Create a test app implementing a BackupAgent that writes no data in onBackup() and
   install it on the device
 - Run 'adb shell bmgr backupnow --non-incremental <test_app_package>' to initiate a backup,
   where --non-incremental flag makes sure PM is not added to the backup queue
 - Run 'adb shell dumpsys backup' and verify string 'Current: 0' again

Change-Id: I595bea9874fd84d0c81b32a509c970a1b142872c
2018-11-13 21:13:14 +00:00
Annie Meng
523c949dd7 [Multi-user] Clean up backup service creation and disable
Part of prep to make BMS multi-user aware.

Current disable logic:
- Trampoline is a proxy to BMS that enforces system- and policy-imposed
disabling of the backup service (user-configurable disabling is in BMS).
- Backup service can be disabled by system property = permanent disable.
- Backup service can be disabled by a privileged caller like Device
Policy Manager = temporary disable.

In multi-user context:
- The system user is the main actor in creation and disabling of the
backup service.
- BMS is only created when the system user is unlocked -> system user
will always be unlocked first and is always running.
- Device Policy Manager acts on the system user and shuts down backup
mechanism for the whole device -> disable for system user disables for
all users.
- Non-system users have no impact on the creation/disabling of the
backup service.

This CL:
- Clean up and document the above logic.
- Move synchronization on backup suppress file from 'this' to private
lock.

Bug: 118520567
Test: 1) atest TrampolineTest
2) atest DevicePolicyManagerTest
3) Manual:
- Before unlocking system user > service not started
- Unlock system user > service started

Change-Id: I207858bcfd1e0b9de43291bec178066b59c3a7cb
2018-10-31 18:43:17 +00:00
TreeHugger Robot
5dffe46881 Merge "Ports second part of the chunking code from gmscore to AOSP." 2018-10-30 11:46:34 +00:00
Chandan Nath
0e7b2e6b40 cleanup Trampoline
remove unused boolean and make private where possible

Bug: 118605476

Test: 1) atest RunFrameworksServicesRoboTests
2) atest TrampolineTest
3) flashed device and ran:adb shell bmgr backupnow --all
Ended with "Backup finished with result: Success". in logcat, there were
a few Scotty exceptions but those are known and ignorable as they come
from the server

Change-Id: I08fbe494f9268e80e8f16a8f66405ee8a743e9c3
2018-10-29 17:03:53 +00:00
Bram Bonné
84c66b8e0c Ports second part of the chunking code from gmscore to AOSP.
Bug: 111386661
Test: atest RunFrameworksServicesRoboTests
Change-Id: I993adf481a22f862a3c5ffaa99723d8dbda679df
2018-10-29 13:32:03 +01:00
TreeHugger Robot
861872dace Merge "Remove BackupManagerServiceInterface" 2018-10-16 10:01:08 +00:00
Bernardo Rufino
d77874c423 Merge "[KV] Only discard state if non-null" 2018-10-15 09:17:18 +00:00
Bernardo Rufino
5dcff70658 [KV] Only discard state if non-null
To avoid NPEs. Added tests. This design is not optimal but left any
re-design to be done when we move applyStateTransition() to more upper
levels, which is going to happen when we extract package-backup.

Bug: 117269444
Test: atest FrameworksServicesRoboTests
Test: 1. Set BackupApp to time-out on agent onCreate()
      2. adb shell bmgr backupnow --non-incremental
         com.google.android.apps.backupapp
      3. Verify it doesn't crash
Change-Id: I7a3fd3d3d5a4b5931206564c197edd86b6321933
2018-10-12 15:09:47 +01:00
Bram Bonné
477a17e6d8 Ports part of the backup/encryption/chunking code from gmscore.
Some additional changes (apart from style) were needed:
- ChunkOrderingType.java is an @IntDef referencing the possible values
for the ChunkOrderingType enum in the proto.
- EncryptedChunk.java is no longer an AutoValue class.
- Inlined some constants from Guava.

Bug: 111386661,116575321
Test: atest RunFrameworksServicesRoboTests
Change-Id: I7656cae13de0bd918be5016ffb155de4b8fd5f71
2018-10-05 12:58:06 +02:00
Bernardo Rufino
a5ccb6c032 Remove BackupManagerServiceInterface
Interface was created for switching between refactored and
non-refactored version, not needed anymore. Removed with IntelliJ's
Refactor > Inline... tool.

Bug: 22388012
Test: atest FrameworksServicesTests
Test: atest FrameworksServicesRoboTests
Test: adb shell bmgr backupnow <package>
Change-Id: I7d92b73676634ddd09a1bc71cbcfc4400ad1be90
2018-10-02 14:13:07 +01:00
Bram Bonné
ab4bbc038e Merge "Moves all backup chunk-model related classes over to the framework." 2018-09-27 12:19:58 +00:00
Bernardo Rufino
4fee398440 Merge "[KV] Exceptions for error-handling" 2018-09-26 09:11:20 +00:00
TreeHugger Robot
d142f36457 Merge "Set KV MORE_DEBUG to false and add tests" 2018-09-25 18:52:18 +00:00
Bernardo Rufino
1f1bae9073 [KV] Exceptions for error-handling
Added 2 exceptions:
* TaskException: For what we used to call transport-level failures,
  these bring queue processing to a halt.
* AgentException: For failures that happen due to the backup agent, these
  only prevent the backup of the current package, still allowing backup
  for the remaining packages in the queue.

These are usually thrown deep in the call stack and caught in backupPackage()
(and similarly backupPm()) and run(), the former for clean-up, where
they are re-thrown and the latter for further processing where they are
finally swallowed. The clean-up is more explicit now.

This enabled further refactoring of backupPackage()/backupPm(),
extractAgentData() and sendDataToTransport().

One change that I intend to revisit is reporting to the observer.
Previously we used to detect some exceptional cases and set mStatus
(which doesn't exist anymore) to other more general exceptional case and
then in this general case handling report the success/failure to the observer.
With the new exception-throwing model I changed this and the leaves are
actually responsible for reporting success/failure to the observer (see
changes in the reporter). This is to avoid too many changes in this CL.

I'm entertaining the idea of extracting out package backup as a separate
class and leave only queue-processing and generic bookkeeping to this
class.

Test: atest FrameworksServicesRoboTests
Test: adb shell bmgr backupnow <kv_package>
Change-Id: If3b1da7a5eb939e453f94fad76f5790696d1265a
2018-09-25 15:49:43 +01:00
Bram Bonné
226dfa2eda Moves all backup chunk-model related classes over to the framework.
Includes the proto definition of ChunksMetadata and related classes.

Some additional changes (apart from style) were needed:
- EncryptedChunkOrdering was modified to be a non-AutoValue class, and
tests were added.
- Protos are now read from an InputStream manually, as any protos should not
be used directly in the platform.
- Helper classes are added for reading from ProtoInputStream.

Bug: 111386661,116575321
Test: atest RunFrameworksServicesRoboTests
Change-Id: I8b74ad059d72e305be7817f79f8c61aa50f7b268
2018-09-25 16:04:32 +02:00
Bernardo Rufino
e58291256b Fix caller log on appIsRunningAndEligibleForBackupWithTransport
Test: atest FrameworksServicesRoboTests
Test: adb shell bmgr backupnow --all
Change-Id: I577db6fb92880916a231ffa36a468bd64d8cae09
2018-09-20 11:59:10 +01:00
Bernardo Rufino
cad924cfd4 Set KV MORE_DEBUG to false and add tests
Forgot this one in the CL. Also added tests to catch this in presubmit.

Test: atest FrameworksServicesRoboTests
Test: adb shell bmgr backupnow <kv_package> and verify no MORE_DEBUG
      logs

Change-Id: I14affca28609bcd855e13fdcc160994c71ed9695
2018-09-20 11:52:07 +01:00
TreeHugger Robot
071f28ded1 Merge "Revert the mandatory backups feature." 2018-09-13 08:45:35 +00:00
Lenka Trochtova
3b6e08772e Revert the mandatory backups feature.
Bug: 79736299
Test: make RunFrameworksServicesRoboTests
Test: cts-tradefed run cts -m CtsBackupHostTestCase

Change-Id: I1209174c9f6aa794c7ca67f4a8737c0589d5fd69
2018-09-12 13:39:05 +02:00
Bram Bonné
629d31c543 Merge "Moves first parts of backup crypto code (ChunkHash class) to the framework." 2018-09-12 10:02:24 +00:00
Bram Bonné
cf2b7c3b39 Moves first parts of backup crypto code (ChunkHash class) to the framework.
Some changes were needed to the original code:
- Guava's EqualsTester tests are replaced by regular equals tests.
- Guava's primitives.UnsignedBytes.LexicographicalComparator needed to
be copied over, as no corresponding comparator exists in the framework.

Bug: 111386661
Test: atest RunFrameworksServicesRoboTests
Change-Id: I24fef4b47f7777b9be0c2e51f0be48e45b323987
2018-09-11 19:32:25 +02:00
TreeHugger Robot
944dca780e Merge "[KV] Refactor clean-up" 2018-09-10 11:56:20 +00:00
Annie Meng
1374690674 [FBR] Extract app metadata backup to helper
In full backup, we backup additional metadata about the app
(manifest, widget, apk, obb) not specified by the app's backup agent.
This CL extracts these methods out to their own helper (AppMetadataBackupWriter)
and adds unit tests for these methods.

** Note: The backup behavior is the same, only the structure has changed.
Behavioral changes will be done in future CLs. **

What this CL covers:
- Move the backup of this extra app data out of the FullBackupEngine to
separate agent data backup and non-agent data backup.
- Move logic of deciding what data to backup from FullBackupEngine to
FullBackupRunner (where the writer is used).
- Add unit tests for metadata backup.
- Some style fixes/clean up.

Not covered (future CLs):
- Refactoring FullBackupEngine/FullBackupRunner mechanism.
- Streaming backup data directly instead of writing to temporary files.
- Separating out and fixing apk and obb backup.

Bug: 110081582
Test: 1) atest AppDataBackupWriterTest
2) atest RunFrameworksServicesRoboTests
3) atest GtsBackupHostTestCases
4) Verify success for:
 - adb shell bmgr backupnow <full backup package>; adb restore 1 <full
backup package>
 - adb backup <full backup package>; adb restore
 - cloud backup and restore
5) Use local transport and adb backup to inspect manifest and widget data
written and file metadata consistent between runs.
6) Verify compatibility with adb backup -keyvalue manifest

Change-Id: Icb43fd2e0505c2416738ee3ef370b206363fac68
2018-09-07 14:56:45 +01:00
Bernardo Rufino
ef0d93eb71 [KV] Refactor clean-up
Only clean-up after possibly calling quota exceeded to avoid bug linked.
Small refactors and tests.

Test: atest KeyValueBackupTaskTest
Test: atest KeyValueQuotaTest
Bug: 114002519
Bug: 110082831
Change-Id: If53aaa59287cf9f2ac8d9ad47afc0a62161373c5
2018-09-07 14:23:31 +01:00
Bernardo Rufino
74eee1031c Use RemoteCall for quota exceeded in backups
For both key-value and full-backup. This makes the tasks wait for the
quota exceeded call, allowing the agent to complete before being torn
down (as described in bug). Also added a short time-out (3s) in case of
misbehaving agents.

Bug: 68762178
Bug: 110082831
Test: atest FrameworksServicesRoboTests
Test: 1. while true; do atest FullBackupQuotaTest; done
      2. Stop after ~50 executions, verify all succeeded.
Test: 1. while true; do atest KeyValueQuotaTest; done
      2. Stop after ~50 executions, verify all succeeded.
Test: CtsBackupTestCases

Change-Id: Ib582e75a4d317ab53a6df8cb261966a04ef085fb
2018-09-03 13:53:33 +00:00
Bernardo Rufino
6a422d6a61 [KV] Consider throwing BackupAgent a failure
And not a success as it used to be.

Bug: 111051813
Bug: 110082831
Test: atest KeyValueBackupTaskTest
Test: 1. BackupApp throwing in onBackup.
      2. adb shell bmgr backupnow com.google.android.apps.backupapp
      3. Verify logs and that it threw and we did not save backup data for it.
Test: 1. BackupApp not throwing.
      2. adb shell bmgr backupnow com.google.android.apps.backupapp
      3. Verify logs and that data was sent to transport.

Change-Id: Idb7fe298f64786668989c30cdce53355aeef7277
2018-08-31 17:32:26 +01:00
Bernardo Rufino
47b3cf937c [KV] Remove states
To do so, had to:
* Remove PM state and put it back into the queue.
* Introduce 'active' boolean in the queue loop, which when false breaks
  out of the loop. (This is because the states collapsed into 'keep
  going' and 'finish' states.)
* Renamed extractNextAgentData() to backupPackage().
* Queue handling from backupPackage() to run().
* Agent result handling from run to backupPackage().

Bug: 110082831
Test: atest KeyValueBackupTaskTest
Test: adb shell bmgr backupnow <kv_package>
Change-Id: If6efcbf91f10426d3c955b83deb1ecd8e714f79a
2018-08-31 15:00:38 +01:00
Bernardo Rufino
0830f64222 [KV] Refactor sendDataToTransport() and finishTask()
Refactor sendDataToTransport():
* Instead of truncating backup data when reading backup data / writing widget
  data, consider the IOException a transport-level failure. Added tests for
  this.
* Extracted a few methods: validateBackupData(), updateFiles(),
  handleTransportStatus().
* Put the if (size > 0) check outside try-catch block.
* Used try-with-resources.
* Clean files in case of transport error, quota exceeded.

Refactor finishTask():
* Extracted triggerTransportInitializationLocked(), assigned queue lock
  to private final var in ctor.
* In triggerTransportInitializationLocked() set the status to T_ERROR if
  we failed to query the name of the transport.
* Tests for TRANSPORT_NOT_INITIALIZED.

General:
* Small refactors in KVBT.
* Small refactors in test.

Bug: 110082831
Bug: 113311470
Test: adb shell bmgr backupnow <kv_package>
Test: 1. adb shell bmgr backupnow <kv_package>
      2. Transport returns T_NOT_INITIALIZED
      3. Make sure PM metadata state file is deleted.
Test: atest KeyValueBackupTaskTest
Change-Id: I8d85c24cba6da4fbaf14234e2ce6d8e0699a3eed
2018-08-31 08:29:12 +01:00
Bernardo Rufino
e80f270e7f [KV] Cancellation and small refactors
* Refactored cancellation a bit.
* Added tests for cancellation, had to break down handleCancel() in 2 methods.
* Removed BackupRequest.
* Removed onPmFoundInQueue() report.
* Renamed a few methods.
* Moved PM package synthetization to backupPm().

Test: atest RunFrameworksServicesRoboTests
Test: adb shell bmgr backupnow <kv_package>
Test: 1. adb shell bmgr backup <kv_package>
      2. adb shell bmgr run
Test: 1. adb shell bmgr backupnow com.google.android.apps.backupapp
      2. Cancel while in-flight
      3. Verify data not backed-up
Test: 1. adb shell bmgr backupnow --non-incremental com.google.android.apps.backupapp
      2. While in-flight, check blank_state file exists.
      3. When it finishes, check blank_state file does not exist.
Test: atest BackupManagerHostTest
Change-Id: Ie74a19189dc700ef517417b54ecb8930c6aa41ce
2018-08-15 09:17:21 +01:00
Bernardo Rufino
bd758fd738 [KV] Extract event reporting and remove traces
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
2018-08-09 14:24:11 +01:00
Bernardo Rufino
8fe7b59a71 Add null check for full-backup task
The backup-already-running code-path leaves the field null.

Bug: 112359186
Test: atest KeyValueBackupTaskTest
Test: 1. adb shell bmgr backupnow --all &>/dev/null&
      2. adb shell bmgr backupnow com.google.android.apps.backupapp
      3. Verify it finishes and no error

Change-Id: I6880c4e7752b943608d41c946e8d18d46cd9da38
2018-08-09 12:01:04 +01:00
Bernardo Rufino
75f73f07fe [KV] Move KVBT to its own package
And related classes.

Test: atest RunFrameworksServicesRoboTests
Test: adb shell bmgr backupnow com.google.android.apps.backupapp
Test: 1. adb shell bmgr backup com.google.android.apps.backupapp
      2. adb shell bmgr run
Test adb shell cmd jobscheduler run -f android 20537

Change-Id: I1aba694786a4e2a5add5c388cd095700ade1ace9
2018-08-06 12:20:04 +01:00
Bernardo Rufino
088a0ef493 [KV] Refactor logs
Unify formatting. Start w/ upper case, using ',' instead of ';', '-'.

Test: atest KeyValueBackupTask
Test: 1. adb shell bmgr backupnow com.google.android.apps.backupapp
      2. Verify logs
Test: atest CtsBackupTestCases
Test: atest CtsBackupHostTestCases
Test: atest GtsBackupTestCases
Test: atest GtsBackupHostTestCases

Change-Id: I171110f69e66d0311cbf030b210600ddf1ad5656
2018-08-03 15:59:19 +01:00