404 Commits

Author SHA1 Message Date
Neil Fuller
b5d1c15ec2 Switch from Byte.toHexString() to HexEncoding
Switch from Byte.toHexString() to HexEncoding equivalents.

Bug: 124232146
Test: build only
Exempt-From-Owner-Approval: Cherry-picking OWNERS approved internal version
Merged-In: Id244e5247eb87c67446cbd65eb5d320f3617b8cd
Change-Id: Id244e5247eb87c67446cbd65eb5d320f3617b8cd
2019-04-11 09:27:45 +00:00
Nicolas Geoffray
972b39e4e4 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
Exempt-From-Owner-Approval: PS1 was approved by owner, PS2 is a build fix.

(cherry picked from commit 8d144eb8bd3487a68c3a0cf58d9744e7d9e1d78b)
Merged-In: Ie9a2b4eaa85cda59951703433f7a2d03bc12095d

Change-Id: I76383308418485ad6739f8a404d02c2771e4afe4
2018-12-02 20:39:29 +00:00
Shaowei Shen
49a987c277 Merge "Fix [kv-3]PerformBackupTask using last package status to decide status sent to IBackupObserver." into pi-dev 2018-05-03 02:05:17 +00:00
Anton Philippov
09589d0073 Don't run obb backup for shared storage backup package.
This fixes an issue when adb backup would hang (and hold wakelock)
forever when run with '-obb' and '-shared'.

Bug: 75997810
Test: 'adb backup -obb -shared' finishes successfully
Change-Id: I015add6dc525984592e733266b3e046f41d2cb93
2018-05-01 14:27:00 +01:00
shaoweishen
59ab5f4934 Fix [kv-3]PerformBackupTask using last package status to decide status sent to IBackupObserver.
We only report failure to IBackupObserver.backupFinished() when we meet
transport failure, but now it will report failure when the last package
meet TRANSPORT_PACKAGE_REJECTED or TRANSPORT_QUOTA_EXCEEDED, add above
two states in FINAL to prevent the situation, and update related
test, also javadoc of IBackupObserver.

Bug: 77271953

Test: make -j RunFrameworksServicesRoboTests ROBOTEST_FILTER=PerformBackupTaskTest
Change-Id: Ic2bfdf9f50d700f8ccb509e081ae8e0afb186020
2018-04-24 09:54:37 +08:00
Henry Liu
cfa5a82f82 Fix [kv-4] PerformBackupTask possible NPE/Wrong package report.
mCurrentPackage is null when package doesn't exist, which lead test
failed with NPE
Use request.packageName for case BackupTransport.AGENT_UNKNOWN instead

Bug: 77272500

Test: m -j RunFrameworksServicesRoboTests ROBOTEST_FILTER=PerformBackupTaskTest
Change-Id: I27be85f0c3f95e36edd92d0d552189fbcf6952dd
(cherry picked from commit 87f1209ac6398c1045845640e620fc9d3b36f9f5)
2018-04-12 02:44:50 +00:00
Daniel Cashman
960a0c6c57 Merge "Add SigningInfo class to expose package signing details." into pi-dev 2018-04-11 19:21:07 +00:00
Anton Philippov
133f93bbbb Merge "Pass app version to agent in adb restore for kv." into pi-dev 2018-04-11 16:53:30 +00:00
Anton Philippov
f8cefdec4b Pass app version to agent in adb restore for kv.
This is a temporary solution for P to unblock GTS tests.

Bug: 77852250
Test: manual:
1. adb backup -f saved-wifi-api100.ab -keyvalue com.android.providers.settings
2. adb restore saved-wifi-api100.ab
3. See that SettingsBackupAgent receives appVersionCode in onRestore()

Change-Id: I6092bea570e7e27cb5b72165e9284ad2befc21b6
2018-04-11 14:58:14 +01:00
Dan Cashman
5c9f527e33 Add SigningInfo class to expose package signing details.
Attempt to simplify the exposure of package signing information via
PackageInfo by creating a new class and corresponding methods for
querying a package's signing information.

Bug: 74831530
Test: PkgInstallSignatureVerificationTest
Change-Id: Idbc008b41a921f89cefb224b26f910da4d238dea
2018-04-10 22:19:20 +00:00
Bernardo Rufino
51c4f038b2 Catch IAE from unbind onServiceDisconnected()
We still don't know the underlying cause of this, but we shouldn't crash
the system_server. Catching for now.

Bug: 74940472
Bug: 77574274
Test: m -j RunFrameworksServicesRoboTests
Change-Id: I36fc2e65f8766f6b8fd68104d8830b72668d84eb
2018-04-05 10:14:01 +00:00
TreeHugger Robot
bb0bcc4460 Merge "Clear app data before full restore for specified packages" into pi-dev 2018-03-29 13:23:24 +00:00
Artem Iglikov
5b53875fdc Clear app data before full restore for specified packages
In some cases (deferred restore) the app data needs to be cleared even
if the app has implemented backup agent. As a quick fix introduce
PACKAGES_TO_CLEAR_DATA_BEFORE_FULL_RESTORE secure setting, which
transport can fill prior to restore.

Bug: 69069240
Test: adb shell settings put secure packages_to_clear_data_before_full_restore com.google.android.apps.nexuslauncher && adb shell bmgr restore com.google.android.apps.nexuslauncher
Change-Id: I2a4651365d9cf4747f32d2ba69312f54cd03d118
2018-03-29 11:01:50 +01:00
Annie Meng
92892163d5 DO NOT MERGE Unrevert update references to backup agent timeouts
Cherry-picked from master (ag/3800434).

Reintroduce change (ag/3742803) that was reverted due to SUW crash
(ag/3780292).

Updates references to backup/restore agent timeouts from hardcoded
constants to the Global setting backup_agent_timeout_parameters.

Bug: 70276070
Test: 1) m -j RunFrameworksServicesRoboTests
2) Manual testing of affected backup/restore paths:
- Wipe device; restore cloud backup via SUW
- adb shell bmgr list sets
- adb shell bmgr restore [package]
- adb shell bmgr restore [token]
- adb backup -all
- adb backup -shared
- adb backup -obb -all
- adb shell bmgr backupnow --all
- adb shell bmgr backupnow [key value package]
- adb shell bmgr backupnow [full data package]
- adb backup -keyvalue [key value package]
- adb restore backup.ab

Change-Id: If9aad572d688451d37178cd7c2d7844be054953c
2018-03-28 18:07:19 +01:00
Artem Iglikov
b873780a3d DO NOT MERGE Revert "DO NOT MERGE Update references to backup/restore agent timeouts"
This reverts commit f77cae61250c727630616b5672df2781e84a7e80.

Reason for revert: crashes SUW

Bug: 76128378
Change-Id: Ia77af64892aa5a03109cc4ef4c2c04b256000ba9
2018-03-22 13:07:34 +00:00
Annie Meng
f77cae6125 DO NOT MERGE Update references to backup/restore agent timeouts
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
2018-03-20 23:48:27 +00:00
Annie Meng
d069a888cf DO NOT MERGE Create a setting for backup/restore agent timeouts
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
2018-03-15 17:43:56 +00:00
Michal Karpinski
528c3e572a Allow restoring of apps that rotated key
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
Test: atest frameworks/base/services/tests/servicestests/src/
      com/android/server/pm/ShortcutManagerTest1.java
Test: atest frameworks/base/services/tests/servicestests/src/
      com/android/server/pm/ShortcutManagerTest2.java
Test: atest frameworks/base/services/tests/servicestests/src/
      com/android/server/pm/ShortcutManagerTest3.java
Test: atest frameworks/base/services/tests/servicestests/src/
      com/android/server/pm/ShortcutManagerTest4.java
Test: atest frameworks/base/services/tests/servicestests/src/
      com/android/server/pm/ShortcutManagerTest5.java
Test: atest frameworks/base/services/tests/servicestests/src/
      com/android/server/pm/ShortcutManagerTest6.java
Test: atest frameworks/base/services/tests/servicestests/src/
      com/android/server/pm/ShortcutManagerTest7.java
Test: atest frameworks/base/services/tests/servicestests/src/
      com/android/server/pm/ShortcutManagerTest8.java
Test: atest frameworks/base/services/tests/servicestests/src/
      com/android/server/pm/ShortcutManagerTest9.java
Test: atest frameworks/base/services/tests/servicestests/src/
      com/android/server/pm/ShortcutManagerTest10.java
Test: atest CtsShortcutManagerTestCases
Bug: 64686581
Bug: 34345052
Bug: 74208476
Bug: 74159113

Change-Id: Ica23bbfec89648d9348c65db4597188e8c18e1d8
2018-03-14 16:11:18 +00:00
Annie Meng
d3b6e9fe22 Merge "DO NOT MERGE Create a key value settings observer for backup parameters" into pi-dev 2018-03-14 13:40:46 +00:00
Annie Meng
7d3033b11f DO NOT MERGE Create a key value settings observer for backup parameters
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
2018-03-13 18:47:46 +00:00
Bernardo Rufino
602bf1a8a8 Add tests for TransportStats and some refactor
Added units for http://ag/3709565. Some refactoring.

Test: m -j RunFrameworksServicesRoboTests
Bug: 72485465
Change-Id: Id75a4e0b96936580fd677041e091340b0fff8c1e
(cherry picked from commit cac3a7405997ab9783b537128107a71e6f5b75a2)
2018-03-12 15:33:43 +00:00
Bernardo Rufino
60719a4e74 Add measurements for TransportClient connections
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 e5a976404c66c054fbec9b124f816a90f9d6b4dc)
2018-03-12 12:19:56 +00:00
Amith Yamasani
14c716c911 Revert "Allow restoring of apps that rotated key"
This reverts commit 313d225cd19885979596cf690103a8d77e19c3dc.

Reason for revert: b/74159113

Change-Id: I483ecdd80d26fca8451cd270b4fcbe34379839cb
2018-03-05 20:40:23 +00:00
TreeHugger Robot
9371be3b88 Merge "Bmgr about running backups" 2018-02-28 14:26:34 +00:00
Bernardo Rufino
760c1f552c Bmgr about running backups
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
2018-02-28 12:11:26 +00:00
Michal Karpinski
961f409d37 Merge "Allow restoring of apps that rotated key" 2018-02-28 10:08:14 +00:00
Annie Meng
0b0ebb616d Merge "Move transport constant to BackupTransport API" 2018-02-27 17:39:58 +00:00
Annie Meng
1b9877ab44 Move transport constant to BackupTransport API
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
2018-02-27 15:17:56 +00:00
Bernardo Rufino
12b6bafcf4 More tests for ActiveRestoreSession
Around restoreAll() and restoreSome(). And some small refactorings in
restore code paths.

Test: m -j RunFrameworksServicesRoboTests
Change-Id: I0ff446ef4dcf15eade189c79e90a22c0f2eda0d6
2018-02-27 12:24:34 +00:00
Michal Karpinski
313d225cd1 Allow restoring of apps that rotated key
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
2018-02-26 11:05:40 +00:00
Michal Karpinski
92c8756876 Support bmgr wipe also for full backup apps
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
2018-02-23 15:16:08 +00:00
Michal Karpinski
c31222f009 Add Backup and Restore directory OWNERS
Bug: 73454476
Change-Id: Id28cbf7d919e95720c51d6a14388e9fea9d84650
2018-02-15 14:50:44 +00:00
TreeHugger Robot
0eb747e51e Merge "Update transport connection with registration info" 2018-02-15 13:57:50 +00:00
Annie Meng
36c5613a93 Update transport connection with registration info
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
2018-02-15 10:40:01 +00:00
Andreas Gampe
bbab23ff97 Frameworks: Annotate trivial @GuardedBy in services/ misc
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
2018-02-08 02:19:42 -08:00
Annie Meng
d38749b6ff Update adb backup/restore confirmation activity on new intent
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
2018-01-29 12:43:20 +00:00
Michal Karpinski
fe4ae0c5b1 Rename RefactoredBackupManagerService to BackupManagerService
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
2018-01-26 10:37:32 +00:00
TreeHugger Robot
1e7f8014a8 Merge "Binding on-demand #12: Log and unbind dangling TransportClients" 2018-01-25 16:08:15 +00:00
Bernardo Rufino
3184cc9948 Binding on-demand #12: Log and unbind dangling TransportClients
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
2018-01-25 12:38:04 +00:00
Robert Berry
39194c0582 Add #getTransportFlags to BackupDataOutput
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
2018-01-25 09:28:55 +00:00
Oscar Key
f5b99ad2ea Let the transport ask for non-incremental backup.
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
2018-01-23 17:16:28 +00:00
Oscar Key
8056728f7c Move backup of @pm@ into its own state.
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
2018-01-23 15:16:34 +00:00
Oscar Key
38902fc09e Merge "Make various members private in PerformBackupTask." 2018-01-22 21:07:49 +00:00
Oscar Key
3d2f335c21 Make various members private in PerformBackupTask.
Test: None. No functional changes.
Change-Id: Ia35bdd7637887b4c02a71e96e9037842078fdba4
2018-01-22 16:10:36 +00:00
TreeHugger Robot
b56074b37b Merge "Clear calling uid in isAppEligibleForBackup() and variant" 2018-01-19 21:54:36 +00:00
Bernardo Rufino
5d94c398eb Merge "Binding on-demand #11: Dump TransportClients" 2018-01-19 20:57:49 +00:00
Bernardo Rufino
c3e509cacc Clear calling uid in isAppEligibleForBackup() and variant
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
2018-01-19 19:02:09 +00:00
Bernardo Rufino
861b420bc3 Binding on-demand #11: Dump TransportClients
And adjust logs.

Change-Id: I04fcfb77bac14db36cc30288878bbb65332deb81
Ref: http://go/br-binding-on-demand
Bug: 17140907
Test: adb shell dumpsys backup
2018-01-19 14:56:21 +00:00
Bernardo Rufino
a4517cdb7d Remove use of streams in TransportManager
Test: m -j RunFrameworksServicesRoboTests
Change-Id: Ie5d81ca9e8c8fcda482fa520aa46841800b88210
2018-01-19 12:09:15 +00:00
Bernardo Rufino
070081bc4f Don't use transport binder with the lock held
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
2018-01-18 19:20:49 +00:00