Commit Graph

511 Commits

Author SHA1 Message Date
Annie Meng
99c350da2c [Multi-user] Convert key-value flow to use user id
Change paths that key-value backup/restore flow goes through to use
user id.

Bug: 121198605
Bug: 121198606
Test: 1) atest RunBackupFrameworksServicesRoboTests
2) atest $(find \
frameworks/base/services/tests/servicestests/src/com/android/server/backup \
-name '*Test.java')
3) adb shell bmgr backupnow [kv package]
Change-Id: Ie192391561f8e03f623c4d86914b3787ff2c0f88
2019-01-14 18:05:10 +00:00
Annie Meng
345ec1b990 Merge "[Multi-user] Make package changes receiver per-user" 2019-01-10 15:56:23 +00:00
Annie Meng
4f98512cc5 [Multi-user] Make package changes receiver per-user
Makes the BroadcastReceiver that receives changes to installed packages
and sdcards tied to a specific user.

Bug: 121198607
Test: 1) atest RunBackupFrameworksServicesRoboTests
2) Manual testing with user 0 and 11:
- User started -> receiver registered for correct user;
- Package changed -> correct receiver;
- Package added -> correct receiver, updates bookkeeping for correct user;
- Package removed -> correct receiver, updates bookkeeping for correct user;

Change-Id: I68c034da6ec775a4d0489a2d09fc32854dcf11dc
2019-01-10 14:25:47 +00:00
Chandan Nath
4a5e370b61 [Multi-user] adb fullbackup: support userId
Bug: 121198030

Test: 1) atest RunBackupFrameworksServicesRoboTests
2) atest $(find \
frameworks/base/services/tests/servicestests/src/com/android/server/backup \
-name '*Test.java')
3) atest CtsBackupTestCases CtsBackupHostTestCases GtsBackupTestCases GtsBackupHostTestCases
4) tested "adb backup -all -obb -apk". confirmed that log contains "obb dir: /storage/emu.." etc. restore of wallpaper worked.

Change-Id: Ic8ff71c5dd949aecc7561a3bac5033e822fcf305
2019-01-09 20:39:26 +00:00
Annie Meng
834b72e770 Merge "[Multi-user] Make backup and initialize receivers per user" 2019-01-09 13:48:28 +00:00
Varun Shah
8f7cd8787d Merge "Moved isAppForeground to ActivityManagerInternal." 2019-01-09 01:03:43 +00:00
Annie Meng
356e09b0d4 [Multi-user] Make backup and initialize receivers per user
Makes the PendingIntent and BroadcastReceiver for running backup and
initialize operations tied to a specific user. Also some style cleanup.

Bug: 121305979
Test: 1) atest RunBackupFrameworksServicesRoboTests
2) adb shell bmgr clear [transport] -> init successfully
3) adb shell bmgr run -> backup successful
4) adb shell bmgr enable false -> runs device init successfully
Change-Id: Ic3f411fbf97c758974a0af10a36e4812d19a534d
2019-01-08 20:19:43 +00:00
Annie Meng
e505098033 Merge "[Multi-user] Clean up backup enabled initialization" 2019-01-08 10:08:28 +00:00
Varun Shah
98c84e193e Moved isAppForeground to ActivityManagerInternal.
Removed isAppForeground from the ActivityManager aidl and added it to
ActivityManagerInternal. Updated all of its references as well.

Bug: 119327603
Test: atest cts.tests.app.src.android.app.cts.ActivityManagerTest#testIsAppForegroundRemoved
Test: atest WifiServiceImplTest
Test: atest WifiLockManagerTest

Change-Id: I5c0fbe41df3cd00e02f8c0e1005fc9cf5832df77
2019-01-07 12:47:27 -08:00
Chandan Nath
2fbb91c4a9 Merge changes Ibd37ae12,I9a33547c
* changes:
  backup: no-op code cleanup
  [Multi-user] Make backup dirs user-specific
2019-01-07 17:45:53 +00:00
Annie Meng
6e95fc95ce [Multi-user] Clean up backup enabled initialization
Remove indirection in setting backup enabled state to call directly into
the UserBMS instance.

Bug: 121305979
Test: 1) atest RunBackupFrameworksServicesRoboTests
2) During SUW -> backup initializes off;
Turn backup on in SUW -> backup enabled;
Subsequent boots -> backup initializes on
Change-Id: Ief688c4e1c14b443db87eda43ec0ee398282662f
2019-01-07 16:50:24 +00:00
Chandan Nath
b3bf0c63e2 backup: no-op code cleanup
1. remove unused methods,imports,members
2. make members private/final as much as possible

Bug: 122371936

Test: 1) atest RunBackupFrameworksServicesRoboTests
2) atest $(find \
frameworks/base/services/tests/servicestests/src/com/android/server/backup \
-name '*Test.java')
3) atest CtsBackupTestCases
4) atest CtsBackupHostTestCases

Change-Id: Ibd37ae124be87487b0b30bcb92b012c1713f6555
2019-01-07 15:16:22 +00:00
Chandan Nath
801f2ec567 [Multi-user] Make backup dirs user-specific
1. For system user, functionality remains almost (see 2) exactly the
same.
2. Change the full backup dir which is used only to write temporary
manifest and meta dirs by the system process when doing full backup.
This is so that we dont have to worry unnecessarily about yet another dir.

Bug: 120424138

Test: 1) atest RunBackupFrameworksServicesRoboTests
2) atest $(find \
frameworks/base/services/tests/servicestests/src/com/android/server/backup \
-name '*Test.java')
3) atest CtsBackupTestCases
4) atest CtsBackupHostTestCases
5) atest GtsBackupTestCases
6) atest GtsBackupHostTestCases
7) 'adb shell bmgr' enabled/backupnow flow

Change-Id: I9a33547c9595a86b62869ee731d4c75a029922e8
2019-01-07 14:56:51 +00:00
Annie Meng
c0a76041cb [Multi-user] Make various backup settings be per-user
Use the "forUser" variation of getting/putting settings for the
following backup settings:
- backup_auto_restore
- backup_transport
- packages_to_clear_data_before_full_restore

Bug: 121305979
Test: 1) atest RunBackupFrameworksServicesRoboTests
2) Verify default auto restore is true;
Toggle auto restore in UI -> changes UserBMS state;
Change current transport via bmgr -> changes UserBMS state;
Check settings for user 0 different from user 10;
3) Run backup pass, restore pass

Change-Id: I69e2a4f9c870dd7b5661dfa17f891384825926f5
2019-01-07 14:36:57 +00:00
Annie Meng
443143af4b [Multi-user] Change device provisioned to per-user setup complete
Migrate from the global setting DEVICE_PROVISIONED to the per-user
setting USER_SETUP_COMPLETE. The logic for how the service handles
provisioned state is the same, only the setting we use to determine the
state is changed, as well as a rename to reflect this ("provisioned" ->
"setup complete").

ProvisionedObserver is now SetupObserver (move didn't persist b/c of
amount of changes to the file)

The BackupManagerMonitor log event id referencing provisioned will be
changed in a future CL as it requires an API change.

Bug: 121305979
Test: 1) atest RunBackupFrameworksServicesRoboTests
2) Reset device, go through SUW -> not setupComplete;
Finish SUW -> setupComplete (verify logging + dumpsys) and jobs
scheduled;
Perform backup (not blocked by setupComplete);
Add new user -> setupComplete only after finishing SUW

Change-Id: Iddf9ce7853a13b2d51135047de1b270af7034c06
2019-01-07 12:09:24 +00:00
Annie Meng
180e51535c [Multi-user] Make each user have their own backup thread
The original backup thread is now only used by Trampoline and BMS for
general non-user specific operations. Each UserBMS instance has its own
'backup-[user id]' thread to allow for parallelism between users. When a
user is stopped, we quit this thread.

Bug: 121305979
Test: 1) atest RunBackupFrameworksServicesRoboTests
2) Start system user -> verify backup-0 thread created;
Start secondary user -> verify backup-10 thread created;
Stop secondary user -> verify backup-10 thread stopped;
Verify work posted to the thread is executed (register transports, bmgr
backupnow, etc.)

Change-Id: Iaa37fb3e2eb442653e27565ca13a88a0582efa9d
2019-01-04 12:33:29 +00:00
Chandan Nath
2de1d8577d Merge "[Multi-user] No-op refactor to move backup dirs and settings, which should be user-specific, to one class for each." 2019-01-03 13:05:49 +00:00
Chandan Nath
71508fda92 [Multi-user] No-op refactor to move backup dirs and settings, which should be user-specific,
to one class for each.

This is to be able to see all filesystem access by backup/restore
together so as to prepare to make all these directories be per user.

Bug: 120424138

Test: 1) atest RunBackupFrameworksServicesRoboTests
2) atest $(find \
frameworks/base/services/tests/servicestests/src/com/android/server/backup \
-name '*Test.java')
3) atest CtsBackupTestCases
4) atest CtsBackupHostTestCases
5) 'adb shell bmgr' enabled/backupnow flow

Change-Id: I9f30d22b9f609eaaf06d9e5a6fa5879ed1f0e653
2019-01-02 22:41:36 +00:00
Chandan Nath
91824ff096 [Backup cleanup] remove unused (and no-op) method setBackupProvisioned
Bug: 120120742

Test: 1) atest RunBackupFrameworksServicesRoboTests
2) atest $(find \
frameworks/base/services/tests/servicestests/src/com/android/server/backup \
-name '*Test.java')
3) atest CtsBackupTestCases
4) atest CtsBackupHostTestCases
5) atest GtsBackupTestCases
6) atest GtsBackupHostTestCases

Change-Id: I7b712f346f851ca4f2b6b7d62a0a8fdcc7c77a56
2018-12-21 12:11:23 +00:00
Annie Meng
71452ce204 [Multi-User] Unregister stopped users in BMS
Adds a handler for system service callbacks when a user is stopped. This
currently only unregisters the user in bookkeeping but will be used in
the future for cleanup work such as cancelling scheduled jobs, etc.

Bug: 120212806
Test: 1) atest RunBackupFrameworksServicesRoboTests
2) atest TrampolineTest
3) Enable multi user + register user -> service started for user; stop
user -> user is unregistered

Change-Id: Ic712da646f961b9bb02c7d77d964a13345eca7ec
2018-12-21 10:07:37 +00:00
Annie Meng
816fd23605 [Multi-user] Consolidate system and non-system user unlock callbacks
In Trampoline, initializing the BMS service and starting the service for
the system user are now handled separately. System and non-system users
now both use the same unlock callback to bring up their UserBMS instance.

Bug: 120212806
Test: 1) atest RunBackupFrameworksServicesRoboTests
2) atest TrampolineTest
3) Unlock system user -> starts service for user
4) Multi-user enabled + unlock non-system user -> starts service for
user

Change-Id: Id49bb4a3834eb299be69d924b94a36794a4eb2e4
2018-12-20 16:53:48 +00:00
Chandan Nath
8cd86f195e [Multi-user] Change Trampoline,BackupManagerService to use userId
Also, a few additional small changes:
1) move getTransportWhitelist from UserBackupManagerService to
BackupManagerService since it doesn't depend on the user
2) remove setBackupProvisioned from BackupManagerService and
UserBackupManagerService since its unused and is a no-op. I'll remove
it from Trampoline and the AIDL in a future CL.

Bug: 120120742

Test: 1) atest RunBackupFrameworksServicesRoboTests
2) atest $(find \
frameworks/base/services/tests/servicestests/src/com/android/server/backup \
-name '*Test.java')
3) atest CtsBackupTestCases
4) atest CtsBackupHostTestCases
5) atest GtsBackupTestCases
6) atest GtsBackupHostTestCases
7) 'adb shell bmgr' enabled/backupnow flow

Change-Id: Iec932dac2ccd6200888e22b35a524a2aec834854
2018-12-19 19:48:13 +00:00
Annie Meng
9f6e3e6948 Merge "[Multi-user] Store user id in UserBMS" 2018-12-19 16:23:03 +00:00
Chandan Nath
2ec8b91026 Merge "[Multi-user] Change more BackupManager AIDL methods to accept userId in methods" 2018-12-19 11:50:10 +00:00
Annie Meng
f55148bfe6 [Multi-user] Store user id in UserBMS
The user id will be used in methods to other system services and passed
to backup/restore subclasses.

Bug: 120212806
Test: atest RunFrameworksServicesRoboTests
Change-Id: I9aca91c3aca30ac0861438e438c4b96bb78e14ed
2018-12-19 10:57:01 +00:00
Chandan Nath
d1ee43e576 [Multi-user] Change more BackupManager AIDL methods to accept userId in methods
Bug: 120120742

Test: 1) atest RunFrameworksServicesRoboTests
2) atest $(find \
frameworks/base/services/tests/servicestests/src/com/android/server/backup \
-name '*Test.java')
3) atest CtsBackupTestCases
4) atest CtsBackupHostTestCases
5) atest GtsBackupTestCases
6) atest GtsBackupHostTestCases
7) 'adb shell bmgr' enabled/backupnow flow

Change-Id: Ia0641f66dd0a935420f1aee332bb2e21ca03610e
2018-12-18 14:10:17 +00:00
Annie Meng
6a93c233fe [Multi-user] Decouple UserBMS and BMS creation
The BMS constructor is now only responsible for setting up the system
service. User registration logic is moved to its own helper that
Trampoline calls during a user unlock callback.

** Logic **
All IBackupManager methods that BMS implements now use bookkeeping to
get the UserBMS instance to act on. Currently the system user instance
is hardcoded in most methods as we don't pass in the user id parameter
(except for a few added in ag/5667585).

If these methods are called on a non-registered user, we log and return
a default value.

** Tests **
Each IBackupManager method now has four corresponding tests:
1) Permission denial test: No INTERACT_ACROSS_USERS_FULL permission +
non-calling user id = security exception (added in ag/5667585, only for
methods that take in an user id param currently).
2) Permission grant test: INTERACT_ACROSS_USERS_FULL permission +
non-calling user id = call forwarded.
3) Registered user test: Passing an user id that has a corresponding
UserBMS instance -> delegate call to that UserBMS instance.
4) Unknown user test: Passing an user id that has no corresponding
UserBMS instance -> no call forwarded.

These tests will be updated when more methods take in an user id param.

Bug: 120212806
Test: 1) atest RunFrameworksServicesRoboTests
2) Unlock system user -> starts service, registers transports
3) adb shell bmgr flows
4) atest TrampolineTest
5) CTS + GTS Backup test cases
6) SUW + Cloud restore; D2D
Change-Id: Ic04f754c75af905ee34c609063c08406e23671d5
2018-12-17 22:00:51 +00:00
Ruslan Tkhakokhov
a2fe6c5bb9 [Multi-user] Add -user param to adb backup/restore
Add an optional parameter -user to provide ID of the user for which to
run backup/restore operation. Add robolectric test to verify the
new parameter is proccessed correctly.

Bug: 119908153
Test: 1) atest BackupTest
      2) atest BackupManagerServiceTest
      3) atest TrampolineTest
      4) atest GtsBackupTestCases
      5) atest GtsBackupHostTestCases
      6) Manual:
        - Run "adb backup -all" and verify that backup is successfull
        - Run "adb restore" and verify that restore is successfull
        - Run "adb backup -all -user 10" and verify that backup faield as
          it's only currently supported for system user
        - Run "adb restore -user 10" and verify that restore failed as it's
          only currently supported for system user

Change-Id: I6dbf9c87eedd5a72da0446beff7d2551f98f2654
2018-12-17 16:48:13 +00:00
Chandan Nath
cd44f75895 [Multi-user] Change BackupManager AIDL to accept userId in methods
Bug: 120120742

Test: 1) atest RunFrameworksServicesRoboTests
2) atest $(find \
frameworks/base/services/tests/servicestests/src/com/android/server/backup \
-name '*Test.java')
3) atest CtsBackupTestCases
4) atest CtsBackupHostTestCases
5) atest GtsBackupTestCases
6) atest GtsBackupHostTestCases
7) Toggle Backup/'Backup Now' in Settings
8) 'adb shell bmgr' enabled/backupnow flow

Change-Id: I5dba38f6a24e07947d1b0948f9caefeca011205d
2018-12-11 17:06:30 +00:00
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