This manually cherry picks ag/8713360 into master. I had to do a manual
cherry pick as the cherry pick from gerrit fails with:
"Could not perform action: Cannot create new patch set of change 8677635
because it is abandoned"
Currently we call .quit() on the underlying thread which will cause all
messages to stop being processed. This has the side effect that, because
the backup system is a state machine where the state transitions are
messages, the message to transition into a state where the WakeLock is
released may not occur when a user is torn down.
This change adds a stop method we can call instead of .quit() on the
thread which drops any remaining messages and then releases the
WakeLock.
We also wrap the wakelock acquire/release calls to prevent any acquire/release on
the underlying wakelock after a quit. For the acquire, this avoids a non-released
wakelock and for the release, this avoids a runtime exception which can happen
when we release a released wakelock
Test: atest CtsBackupTestCases CtsBackupHostTestCases
Test: m RunBackupFrameworksServicesRoboTests && atest RunBackupFrameworksServicesRoboTests
Bug: 136264323
Change-Id: Ic8742bf01a0ff71bd57dd73b01a423d3432bf7b2
The filesystem is checked when the BMS is created for a user so we
don't need to recheck it every time we perform a backup related
operation because wihout the BMS we shouldn't say the system is
read for the user to back up their data.
Change-Id: Iaaa7d7381182ba7e05173cc4f5d25ce61054e210
Test: atest CtsBackupTestCases CtsBackupHostTestCases TrampolineTest BackupManagerServiceTest
Fixes: 133584471
1) FullRestoreEngine: mAllowObbs, mBytes are not used
2) PerformUnifiedRestoreTask: mSavedStateName is not used
also, use final,private where possible
Bug: 136738613
Test: atest -v CtsBackupTestCases CtsBackupHostTestCases
Change-Id: Ic65bbefdd47ba6f0c8ba9d117256972e15af2f8e
Unsubscribe listeners as otherwise they schedule work on a stopped handler thread
after the user backup manager service is stopped
Also cleanup by removing unused code:
a) mBackupThread from BackupManagerService
b) TAG from BackupAgentTimeoutParameters
c) getRunningFullBackupTask from UserBackupManagerService
Bug: 135261178
Bug: 135180752
Test: 1. atest -v RunBackupFrameworksServicesRoboTests
2. atest -v $(find frameworks/base/services/tests/servicestests/src/com/android/server/backup -name '\''*Test.java'\'')
3. atest -v CtsBackupTestCases
4. atest -v CtsBackupHostTestCases
Change-Id: Ie199dd49c336a2519c0f8e6c8dda12d8cba8350a
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