Increasing timeout should help as in the only recent instance where we
saw this bug, it just exceeded the timeout by a second. Mostly the clear
operation happens very fast. Plus no obvious other solution to this
without major changes to BMS.
Fixes: 130347754
Test: 1) atest CtsBackupTestCases
2) atest CtsBackupHostTestCases
3) atest GtsBackupTestCases
4) atest GtsBackupHostTestCases
Change-Id: I462724f2ea9a9bddd3a876e7f69302c35d69a0cb
Make sure mBroadcastReceiver is initialized after its dependencies,
i.e. mTransportManager.
Bug: 130408863
Test: 1) atest RunBackupFrameworksServicesRoboTests
2) atest CtsBackupTestCases
3) atest CtsBackupHostTestCases
4) atest GtsBackupTestCases
5) atest GtsBackupHostTestCases
Manual test:
1) Before fix: Add Thread.sleep() before mTransportManager is
initialized in constructor and tirgger PACKAGE_CHANGED event. Verify
broadcast receiver callback is triggered and systen_process crashes.
2) After fix: Add Thread.sleep() before mTransportManager is
initialized in constructor and tirgger PACKAGE_CHANGED event. Verify
broadcast receiver callback is not triggered.
Change-Id: If1628628176a08a2d33d020ce270de92b606d6df
Bug: None
Test: I solemnly swear I tested this conflict resolution.
Exempt-From-Owner-Approval: Merge conflict resolution for approved change
Change-Id: I39bda8417f709f86b5b389a75ff34df8a28a3d8d
when user is removed.
For non system users, backup state is stored in both the user's own dir and the system dir.
When the user is removed, the user's own dir gets removed by the OS. This code change ensures
that the part of the user backup state which is in the system dir also gets removed.
Bug: 127650374
Test: atest -v CtsBackupHostTestCases:android.cts.backup.MultiUserBackupStateTest
Change-Id: I4ea252e8e6da608e36ec3ac335666923d88a8748
Make the data management label a CharSequence for the system APIs:
- BackupManager#updateTransportAttributes
- BackupManager#getDataManagementLabel
- BackupTransport#dataManagementLabel
Renames dataManagementLabel -> dataManagementIntentLabel to change
return type
Removes getDataManagementLabel AIDL method as usages converted to use
"forUser" version in topic CL.
Bug: 113856654
Test: 1) atest RunBackupFrameworksServicesRoboTests
2) atest BackupManagerTransportAttributesHostSideTest
3) atest $(find \
frameworks/base/services/tests/servicestests/src/com/android/server/backup \
-name '*Test.java')
4) Manual: boot and verify transports registered properly using old API;
Modify LocalTransport to use new API, verify success
Change-Id: Ia48017156debe0a29684909f58927fa1fbf972f9
When a full backup operation times out, resources are cleaned up
including closing and nullifying pipes. However FullRestoreEngine.restoreOneFile()
doesn't stop execution and can access the pipes causing RuntimeException.
This CL adds a flag to show whether the operation has timed out and
checks it before accessing the pipes.
Bug: 126244736
Test: 1) atest RunBackupFrameworksServicesRoboTests
2) atest CtsBackupTestCases
3) atest CtsBackupHostTestCases
4) atest GtsBackupTestCases
5) atest GtsBackupHostTestCases
6) Manual: Test full backup/restore flow using Flipboard app
Change-Id: If400142a6fceaa4065409774bbff1cad8b4c6163
Test: atest ProfileSerialNumberHostSideTest
Currently BackupManager#getUserForSerialNumber goes through users
associated with the calling user (inluding the calling user itself) and
looks for the given serial number. However, to get the list of users it calls
UserManager#getUserProfiles that operates for the users associated with
the calling process (in our case - system user since the call is made
from BMS). While this works for our current use case (only support
backup for system user and their work profile, meaning
BackupManager#getUserForSerialNumber will only be called for system
user), it won't work for a full multi-user case.
Change-Id: Ia42a69a1216ed9a5dae596e44336290d2718de7a
Use the new manifest flag introduced in ag/5762489 to gate clearing data
during restore.
Bug: 120267643
Test: 1) atest RunBackupFrameworksServicesRoboTests
2) atest CtsBackupTestCases
3) atest CtsBackupHostTestCases
4) atest GtsBackupTestCases
5) atest GtsBackupHostTestCases
Change-Id: Ida4a9e96f44d1c740d217faed2b9f928e02865ec
Bug: 123347794
In Q, backup is OFF by default for non-system users. In R, we will change that to ON
unless backup was explicitly deactivated with a (permissioned) call to
setBackupServiceActive.
Therefore, remember this for use in R. Basically the default in R will be
rememberFile.exists() ? rememberFile.value() : ON
Note that this has to be done right after the permission checks and before any other
action since we need to remember that a permissioned call was made irrespective of
whether the call changes the state or not.
Test: 1. atest $(find frameworks/base/services/tests/servicestests/src/com/android/server/backup -name '\''*Test.java'\'')'
2. atest RunBackupFrameworksServicesRoboTests
3. atest CtsBackupTestCases CtsBackupHostTestCases GtsBackupTestCases GtsBackupHostTestCases
Change-Id: I0897d6f9f8d8d8a9fc3c0faabfc9045b416dd25f
A few additional changes (apart from style and usual dependencies) were
needed:
- Additional dependencies (not part of Backup & Restore code) were
ported over:
- ByteRange
- DiffScriptWriter
- OutputStreamWrapper
- SingleStreamDiffScriptWriter
- DiffScripBackupWriter.ENCRYPTION_DIFF_SCRIPT_MAX_CHUNK_SIZE_BYTES is
now a constant rather than a flag.
- Additional tests were added for SingleStreamDiffScriptWriter.
Bug: 111386661
Test: atest RunBackupFrameworksServicesRoboTests
Change-Id: Ia3234bb8d665211e6fa91d6a92d190171b0d2dc1
The launcher needs to know the serial id of the ancenstral device's work
profile and the serial id of the current device's work profile in order
to properly perform a restore.
Test: atest BackupManagerService
Bug: 111301511
Change-Id: Ia929dcc2cb599f935183be1820b1c45f2d6e1de7
Move to a whitelist of system apps that are eligible for backup in
non-system users.
Bug: 123349308
Test: "adb shell bmgr backupnow android" succeeds for system
and non-system users.
Change-Id: I7bc4982a6e105c2343636532dd2010aa43132d23
As part of bmgr activate, if the user is unlocked then we attempt to
start the backup service for them. However, as part of initialization,
AMS enforces the system uid so clear calling identity before starting
the service (as we have the shell uid).
Bug: 123572171
Test: 1) atest RunBackupFrameworksServicesRoboTests
2) atest TrampolineTest
3) Manual: Unlock secondary user -> bmgr activate -> no exception thrown
and service started
Change-Id: I441491e19d9f3c9b49b5778d51ae5331230b129b
The previous check compared app uid directly to FIRST_APPLICATION_UID
which doesn't work for non-system users as uid incorporates the user id
(so system apps in non-system users would always be categorized as
non-system apps).
Bug: 122309666
Test: 1) atest RunBackupFrameworksServicesRoboTests
2) Manual: verify system packages backed up for system user, not backed
up for non-system user.
Change-Id: I5e11b4b7c41d74d43d545e4831d09a9a3a59e5cf
All other schedule call sites for full backup and key value schedule
inline. The operation should be quick and scheduling on a separate
handler makes testing flaky.
Test: 1) atest RunBackupFrameworksServicesRoboTests
2) atest ScheduledBackupHostSideTest
3) atest ProfileScheduledJobHostSideTest
Change-Id: Id6ae557080da5a98c2ac572ca6b4b7973b7a9c29
Key changes in this CL:
- Backup is now disabled by default in non-system users unless DPM
activates backup for this user AND the system user is activated. This
provides gating for the multi-user B&R feature.
- Activation is done via an 'activate' file that is per-user (but lives
in the system user directory to account for locked users).
- isBackupServiceActive() handles both locked and unlocked users.
- Added a bmgr command to expose isBackupServiceActive() for testing
purposes and enforce appropriate permissions.
Future CLs:
- Handle future migration to backup on by default for non-system users
- Change CTS tests to use the new bmgr command
Bug: 121306407
Test: 1) atest TrampolineTest
2) Start system user -> service started; run backup and restore
successfully
3) Start non-system user -> ignored;
4) adb shell bmgr --user 0 activate true -> security exception;
adb shell bmgr --user 10 activate true -> security exception (work
profile);
adb shell bmgr --user 11 activate true/false -> creates/deletes activate
file and starts/stops the service
Change-Id: Ic77db9b8b2e5170dcf89bef863dac4713730797a
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
4) atest CtsBackupHostTestCases
5) atest GtsBackupTestCases
6) atest GtsBackupHostTestCases
Manual testing:
1. Start secondary user -> verify fb-schedule file is created, full backup queue initialised
2. Verify fullbackup of 1 package for system/secondary users, [package] only exists for current user:
* bmgr --user [user-id] fullbackup [package]
* Verify in logs that backup is successful
* Uninstall/install [package]
* Verify data is restored
3. Verify fullbackup of 1 package for secondary user, [package] eixtst for user 0:
* bmgr fullbackup [package]
* bmgr --user [user-id] fullbackup [package]
* Verify in logs that backup is successful
* Uninstall/install [package] for secondary user
* bmgr --user [user-id] restore [token] [package]
* Verify the data restored is different from system user data and belongs to [user-id]
3. Verify backup of all packages for system/secondary users:
* bmgr --user [user-id] backupnow --all
* Verify system packages (android, settings, wallpaper) are skipped for secondary user
* Verify in logs that backup is successful
* Uninstall/install [package]
* Verify data is restored
Base -> Patchset 2: Update method calls to use asUser versions
Patchset 2 -> Patchset 3: Update opComplete callback to accept userId
Patchset 3 -> Patchset 4: Gate system packages from backup/restore for non-system users
Change-Id: Ic3986709ba4d46c0af9da45bb4dd682ee2aef3ce
We create a differnte suppressBackup file for each user, and gate
operations on that.
Backup still can't be toggled for other users that is not SYSTEM.
Test: atest TrampolineTest
Test: Verify backup works and restore works, just for user 0 for now.
BUG: 121198006
Change-Id: Ib4ecf48d248319e9d890515937fc087ef8f46039
Per-user CE directories are managed by vold so we don't need to
initialize or apply restorecon on them in our service.
Once the system user is migrated to the its CE directory, we can remove
the remaining restorecon and mkdirs logic.
Accompanies aosp/875352 and aosp/873133
Bug: 121197420
Test: 1) Boot device; check directories exist and labelled properly
for system user; perform backup successfully
2) Add secondary user; check directories exist and labelled properly;
perform backup succesfully
Change-Id: If848da4c9254db87b393fce6cfc4169785bfac51
1. The book-keeping needs to be per user.
2. The calls into IBackupManager need to pass in the userId.
3. convert clearPendingBackup to an internal service call.
Bug: 121197004
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: If49e00fc1d6aa770815c454f01b53865f6a68db4
Patchset 1: Introduce BackupJobIdManager to allocate/recycle IDs for KeyValueBackupJob and
FullBackupJob
Patchset 2: Update KeyValueBackupJob and FullBackupJob to work for multiple users — take in
userId as a parameter and use BackupJobIdManager to assign job IDs
Patchset 3: Update robo tests
The corresponding GTS ScheduledBackupHostSideTest will be updated in a separate CL with the same
topic.
Bug: 121198009
Test: 1) atest KeyValueBackupJobTest
2) atest KeyValueBackupTaskTest
Change-Id: Ifdba254b7084b3d0a1507cc6512e98399c1aad8f
Certain services were removed from being final fields in ag/5932642.
This change essentially reverts the deletions of those final fields.
Bug: 122591875
Test: atest cts.tests.app.src.android.app.cts.ActivityManagerTest#testIsAppForegroundRemoved
Change-Id: I403d214b31c964ee5587c35260138e0af12fd11e
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