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
Extracts an abstract class to observe changes in backup parameter settings that
are stored as a comma-separated key value list. This class is
responsible for registering and unregistering a content observer on the
setting and updating local references to the parameters.
Refactor BackupManagerConstants and LocalTransportParameters to use this
implementation. This will also be used for the new backup timeout
setting.
Bug: 74346317
Test: 1) m -j RunFrameworksServicesRoboTests ROBOTEST_FILTER=BackupManagerConstantsTest
2) gts-tradefed run commandAndExit gts-dev -m GtsBackupHostTestCases -t com.google.android.gts.backup.TransportFlagsHostSideTest
Change-Id: Id4c50fbcf7479c925515887e3fa70e166dd9955c
Added units for http://ag/3709565. Some refactoring.
Test: m -j RunFrameworksServicesRoboTests
Bug: 72485465
Change-Id: Id75a4e0b96936580fd677041e091340b0fff8c1e
(cherry picked from commit cac3a74059)
Retrievable via 'adb shell dumpsys backup transportstats'.
Sample output:
Average connection time: 36.00 ms
Max connection time: 181 ms
Min connection time: 7 ms
Number of connections: 16
Per transport:
com.google.android.gms/.backup.BackupTransportService
Average connection time: 27.71 ms
Max connection time: 139 ms
Min connection time: 13 ms
Number of connections: 14
com.google.android.gms/.backup.component.D2dTransportService
Average connection time: 181.00 ms
Max connection time: 181 ms
Min connection time: 181 ms
Number of connections: 1
android/com.android.internal.backup.LocalTransportService
Average connection time: 7.00 ms
Max connection time: 7 ms
Min connection time: 7 ms
Number of connections: 1
Bug: 72485465
Test: Will follow in another CL if reviewers OK w/ approach.
Change-Id: I133ed423d0b8471d69e3c3631aadee7d42d0ec0e
(cherry picked from commit e5a976404c)
Says that backups can be canceled if one already running. Put message
for running backups in dumpsys for checking.
Bug: 72484277
Test: Triggered backup, checked dumpsys and bmgr backupnow
Change-Id: I028cf663858e374389f50175aaf5a3e8c9d45e42
Previously, the transport registration extra was a private
constant. Since GMSCore depends on this value being passed, moving
it to a public API prevents having to define it twice in
framework and GMSCore, and ensures compatibility between the two.
TODO: Update GMSCore with this constant once this drops
into GMSCore.
Bug: 72730566
Test: 1) m -j ROBOTEST_FILTER=TransportManagerTest RunFrameworksServicesRoboTests
2) m -j ROBOTEST_FILTER=TransportClientManagerTest RunFrameworksServicesRoboTests
Change-Id: I8f7a2ca0275047a5d3cc1a530cd86499d0170f2f
Around restoreAll() and restoreSome(). And some small refactorings in
restore code paths.
Test: m -j RunFrameworksServicesRoboTests
Change-Id: I0ff446ef4dcf15eade189c79e90a22c0f2eda0d6
Restoring of apps that rotated key wouldn't be possible due to
explicit signature matching.
Amend signature matching strategies to take into account
apps that have rotated key.
Test: atest frameworks/base/services/tests/servicestests/src/com/android/server/backup/utils/AppBackupUtilsTest.java
Test: atest frameworks/base/services/tests/servicestests/src/com/android/server/pm/backup/BackupUtilsTest.java
Test: m -j RunFrameworksServicesRoboTests
Test: runtest -p com.android.server.backup frameworks-services
Bug: 64686581
Bug: 34345052
Change-Id: I91b5ae0afb6f2714ceae02b4d4dc202d6cd4fe4e
Previously we'd only really clear data for K/V packages,
now we consult with the journal of ever backed apps.
Bug: 28405555
Test: manual (adb shell bmgr wipe com.google.android.gms/.backup.BackupTransportService com.android.wallpaperbackup
after adb shell bmgr backupnow --all)
Test: m -j RunFrameworksServicesRoboTests
Test: runtest -p com.android.server.backup frameworks-services
Change-Id: If99cb2c8ab9ddc05386d634818f4585ec47efc00
When connecting to a transport, let the transport
know if this connection is for registration. This is to
prevent updating transport attributes during registration
in GMSCore.
Bug: 72730566
Test: 1) m -j ROBOTEST_FILTER=TransportManagerTest RunFrameworksServicesRoboTests
2) m -j ROBOTEST_FILTER=TransportClientManagerTest RunFrameworksServicesRoboTests
3) adb reboot; adb logcat | grep BackupTransportManager; check no errors with "...not registered tried to change description"
4) GMSCore Robo tests
Change-Id: I5adf6ea3e668a8e8ed8c568728d109814b6f8975
Add @GuardedBy for simple functions that require a single lock
and are named XYZLocked.
Derived by errorprone.
Bug: 73000847
Test: m
Test: m javac-check-framework RUN_ERROR_PRONE=true
Change-Id: Id1d9fbe5018250e3b9d1466fc5f670d5ad902fa3
Now, if adb backup/restore is currently active and the activity is
passed a new intent, the activity instance would be updated with the new intent.
Same for if the activity is relaunched.
Before, the activity would ignore intent changes and use old tokens and
views, leading to backing up/restoring wrong files.
Bug: 65723308
Test: adb backup -f old.ab -all; ctrl-c; adb backup -f new.ab -all;
gts-tradefed run commandAndExit gts-dev -m GtsBackupHostTestCases
Change-Id: Ifa11efecf82a682a578dab7e5795328ab7d0c054
The interface will be removed in a subsequent CL, it will be
easier to deal with merge conflicts.
Test: 1) m -j RunFrameworksServicesRoboTests
2) runtest -p com.android.server.backup frameworks-services
Bug: 65823538
Change-Id: I37c4c6758c646e1b18889ed05aa1b1d7c6129cf0
Extracted connection in TransportClient to static class with weak
reference to TransportClient so that TransportClient is garbage
collected when left undisposed. Created finalize method that logs,
unbinds TransportClient and warns using CloseGuard.
Also adjusted some logging.
Bug: 17140907
Test: m -j RunFrameworksServicesRoboTests
Test: Manually left a dangling TransportClient and observed logs and
connections
Change-Id: I30f89e7c27579089ba29936483abd1b60c9e8e37
This allows a BackupAgent to check whether the transport has client-side
encryption enabled. It can then use this information to decide whether
to back up more sensitive data.
Bug: 72299360
Test: Manually verified full & kv backup agents receive transport flags
Test: m -j RunFrameworksServicesRoboTests
Change-Id: Ibd9b5f9479815e1721e9d6b7663d892b9ab3fcae
Add a new performBackup() return code TRANSPORT_PACKAGE_DATA_LOST. If
the transport returns this then delete the state for the package and
immediately retry it. Thus the retry will be a non-incremental backup.
I have left the new constant as @hide to unblock this change. I will add
this to the current API review change: ag/3477872.
Bug: 71887023
Test: I tested manually by returning the new code for both @pm@ and
other key value packages. No automated test exists for this file, and it
will be tricky to add this before IC.
Change-Id: I4357a8b297c373eb81e25afb82d480b26f6642b6
Previously it shared the INITIAL state with various set up work and
initializing the transport if needed. By moving it to its own state this
will mean we can retry a non-incremental backup of @pm@ if the transport
indicates that it has lost the state.
I removed the "mStatus == BackupTransport.TRANSPORT_NOT_INITIALIZED" as
the mStatus could never have this value at that point.
TRANSPORT_NOT_INITIALIZED is returned by the transport.performBackup(),
which is not executed until after beginBackup() has returned.
Bug: 71887023
Test: Manually tested init case, incremental case, @pm@ error case, init
error case. There are no unit tests for this file, and it's 1200 lines
long which makes writing them for IC difficult.
Change-Id: I23b7512391068316f4c1039faf88cc27905f4492
This method is called by bmgr backupnow. Bmgr pid is not system uid.
When executing the method it fails with permission denied because it
can't bind to the transport. Before binding on-demand we haven't seen
this error because we didn't try to bind in the method, it was always
bound.
Bug: 72215413
Test: adb shell bmgr backupnow -all
Change-Id: I82ad712e893abfec4727d568ab48a49945645eb4
There was a deadlock around the transport lock. We registered transports
with the transport lock held, this kicked-off transport onCreate()
synchronously, which called TransportManager
updateTransportAttributes(), which tried to acquire mentioned lock but
couldn't. This CL removes the lock for any call to the transport or
operation that triggers a call to the transport (it was
TransportClient.connect() or its variants).
Test: Load GMSCore before fix, boot, register transports, check no ANR
Test: m -j RunFrameworksServicesRoboTests
Test: adb shell bmgr transport -c <transport>, being registered & not
Bug: 72147303
Change-Id: I72ca145d7fb73c0ef29c4aa1b620fea4969481db
So that GMSCore can find out and disable restore flow
and Backup UI.
Bug: 33339643
Test: gts-tradefed run gts -m GtsGmscoreHostTestCases -t com.google.android.gts.devicepolicy.DeviceOwnerTest#testBackupServiceActive (new GTS test in companion CL)
Test: cts-tradefed run cts -m CtsDevicePolicyManagerTestCases -t com.android.cts.devicepolicy.DeviceOwnerTest#testBackupServiceEnabling
Change-Id: I62c38dec2395d3aa926566d128b0067ce7d62c26
Let the device owner make backups with a chosen backup
transport mandatory.
BUG: 64012357
Test: make RunFrameworksServicesRoboTests
Test: manually together with the corresponding GmsCore change.
Test: cts-tradefed run cts -m CtsDevicePolicyManagerTestCases --test
com.android.cts.devicepolicy.DeviceOwnerTest#testGetAndSetMandatoryBackupTransport
Test: cts-tradefed run cts -m CtsBackupHostTestCase --test
android.cts.backup.BackupDeviceOwnerHostSideTest#testMandatoryBackupTransport
Change-Id: I9bfae5799beae3459659e697813b75a9b508ae55
This CL is the last of the P1 CLs for binding on-demand. During
transport-usage migration to binding on-demand the permanent-bound
code was still there and we piggybacked on it to register the
transports. Now that everything is migrated we removed the permanent
binding and used the registration code created in the CL #9
(selectTransport) for registering all the transports.
I put a 3s delay on registration after bring-up. Any operation that uses
the transport before that will gracefully fail.
The TransportBoundListener does not return a boolean anymore because it
can't fail anymore (we pass it the data it needs so that it doesn't need
to be exposed to TransportNotRegistered exceptions). It's now called
OnTransportRegisteredListener.
Eligible transports were a similar thing to valid transports from the
permanent binding code, whose only need came from rebinding from what I
could tell. I saw no need for it anymore and removed it. If I missed
something please shout :)
I shuffled methods a bit in TransportManager.
There were a lot of changes to robo test infra to bring together
TransportManager tests and the rest and re-use mocking infra.
Change-Id: If61268228dd0bb724b718abd3dcafdad50e8b3dc
Ref: http://go/br-binding-on-demand
Bug: 17140907
Test: m -j RunFrameworksServicesRoboTest
Test: runtest -p com.android.server.backup frameworks-services
Test: gts-tradefed run commandAndExit gts-dev -m GtsBackupTestCases
Test: gts-tradefed run commandAndExit gts-dev -m GtsBackupHostTestCases
Test: cts-tradefed run commandAndExit cts-dev -m CtsBackupTestCases
Test: adb shell bmgr enable true/false
Test: adb shell bmgr list transports [-c]
Test: adb shell bmgr transport <transport_name>/-c <transport_component>
Test: adb shell bmgr restore <token>/<token> <package>/<package>
Test: adb shell bmgr backup <pacakge>
Test: adb shell bmgr run
Test: adb shell bmgr wipe <transport> <package>
Test: adb shell bmgr fullbackup <package>
Test: adb shell bmgr backupnow --all/<packages>
Test: adb shell cmd jobscheduler run -f android <job_id>
Test: adb shell dumpsys backup
Test: D2D scenario
These indicate if backup manager passed any previous state to the backup
agent when building a backup. The transport will use these to decide
whether to clear any existing encryption related state for the app.
I left the new flags as @hide for now.
Bug: b/71792427
Test: Tested manually with a buid of GmsCore updated to process the new
flag. I am attempting to write a robolectric test.
Change-Id: Ica0f6f578cd7d1ad29af532a45a2ee6685c84747
Migrate selectBackupTransport()/selectBackupTransportAsync() to binding
on-demand. To mimic the bind-if-needed behavior that existed before for
selectBackupTransportAsync we now register-if-needed in the selection.
This means a new registerTransport() method was created in the
TransportManager. I intend to use this method with only few
modifications for the first-binding code.
Change-Id: I39661cff0f7b2f8a27da37905dcd93e0aa9b1178
Ref: http://go/br-binding-on-demand
Bug: 17140907
Test: m -j RunFrameworksServicesRoboTest
Test: adb shell bmgr transport <transport>, observe logs
Test: Robolectric tests for TransportManager will go in registration CL
BackupManagerConstants has a content observer that is meant to be
notified whenever backup settings change. However, that observer is
never registered.
Bug: 71622864
Test: cts-tradefed run cts-dev --module CtsBackupHostTestCase
Change-Id: Icbd90ef3af83dd2f29e26a5d787505bcf5681154