Commit Graph

329 Commits

Author SHA1 Message Date
Bartosz Fabianowski
9fcc8ffd7b Send backup success notification to background apps as well
When the backup manager is configured to notify one or more apps of
successful backups, the notifications should be sent to apps that are
currently stopped as well.

Bug: 63885845
Test: cts-tradefed run cts-dev --module CtsBackupHostTestCase
Change-Id: I7086aee105229e0f8db4b1ec26639d53a4e0af37
2018-01-03 09:14:47 +01:00
Bernardo Rufino
a67d10763a Merge "Binding on-demand #7: PerformInitializeTask usage" 2018-01-02 11:34:33 +00:00
Denis Kuznetsov
02a1c08096 Add notification on succesful backups
Bug: 63885845
Test: make RunFrameworksServicesRoboTests

Change-Id: I6c8d04de7f5d7e82d695b1bf36de0aa27452db19
2017-12-28 20:12:03 +01:00
Bernardo Rufino
79155590e6 Binding on-demand #7: PerformInitializeTask usage
Migrate transport initialization task to binding on-demand. Added
Robolectric tests for the task as well.

Bug: 17140907
Test: m -j RunFrameworksServicesRoboTest
Test: adb shell bmgr init <transport>, observed logs & transport dir
Change-Id: I2d6c1acd31741169080edef2f938fabf43b0649a
2017-12-22 17:06:20 +00:00
Bernardo Rufino
7b3701a32c Log d when transport updates its attributes
Bug: 17140907
Test: Triggered an update and checked logs
Change-Id: I21926086ec0078872f3840737f77f79417178f6c
2017-12-20 15:35:52 +00:00
Bernardo Rufino
7f14edea1d Binding on-demand #6: Transport attributes usage
Migrate the attribute queries from the Transport to the
TransportManager. Migrate all calls except currentDestinationString
because that's the one that changes and we should only migrate
after we have GMSCore that implements the push-from-transport
model.

Looking at method recordInitPendingLocked(), we only sent
MSG_RETRY_INIT if the transport threw while calling transportDirName
or the binder was null. With binding on-demand both of these cases
can't happen - i.e. we can't fail anymore. So, I removed the
message entirely.

Change-Id: I45a305704274c8b0c88637e3ccafc658639b2dfa
Ref: http://go/br-binding-on-demand
Bug: 17140907
Test: m -j RunFrameworksServicesRoboTests
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: runtest -p com.android.server.backup frameworks-services
Test: adb shell bmgr backupnow <packages>
Test: adb shell bmgr fullbackup <packages>
Test: adb shell cmd jobscheduler run -f android <job_id>
Test: adb shell bmgr enable false (being enabled before)
Test: adb shell dumpsys backup
Test: adb shell bmgr init <transport>
Test: Observed logs and used debugger to check proper code was being
Test: called in above commands
2017-12-15 16:32:30 +00:00
Bernardo Rufino
c4cded9c80 Merge "Binding on-demand #5: PerformUnifiedRestoreTask usage" 2017-12-14 13:19:46 +00:00
Bernardo Rufino
998fdaa636 Binding on-demand #5: PerformUnifiedRestoreTask usage
Migrate restore flow and related.

Change-Id: Ib61863e401067d7d4a9669982be8b3d87af0caa2
Ref: http://go/br-binding-on-demand
Bug: 17140907
Test: adb shell bmgr restore <set> <package> and observed logs
Test: adb shell bmgr restore <set> and observed logs
Test: Backed-up and re-installed app, observing logs
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: Looking into adding GTS/CTS for restore scenarios
2017-12-11 14:09:41 +00:00
Christopher Tate
1d99c391ec Cancel alarms & jobs when an app's data is cleared
In the same bit of code, fix a system restore issue:  in the
course of setup + restore, we reestablish permission grants and
notification state up front for the to-be-restored app, and
then bring in its data.  However, a data wipe is part of the
prologue for that data delivery -- so we were inadvertently
unwinding the permission grants and notification state restore
that we'd just performed.  Now, we distinguish the restore flow
from other clear-data operations so we don't unwind that operation.

Finally take the opportunity to elide a lot of copypasta code into
a single predicate-driven implementation.

Bug: 67508896
Bug: 69538432
Test: atest android.app.cts.AlarmManagerTest

Change-Id: I15c912c3c99645599ae9bd6fb7337fa86b4e5757
2017-12-08 13:53:42 -08:00
Bernardo Rufino
f93a0918b6 Binding on-demand #4: PerformClearTask usage
Migeate the clear flow.

Change-Id: Id268f772ae0f7a88b3e060c9597d777e0b73121a
Ref: http://go/br-binding-on-demand
Bug: 17140907
Test: adb shell bmgr wipe <transport> <package> and observed logs
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
2017-12-06 11:55:56 +00:00
Dianne Hackborn
3accca05dd Add major version code to platform.
It turns the version code into almost a 64-bit integer, with the
new major part being the upper 32 bits.

The only tricky part about this is the backup manager, since it
stored 32-bit version codes in its backup data sets.  This is dealt
with by, when the major version code is not 0, writing MIN_INT as
the version code and following that by the full long version code,
which we can detect when reading.  Note that this makes backup sets
containing apps with major version codes incompatible with older
versions of the platform.

Bug: 64459786
Test: Added in Change-Id: Iab8a682b62103babd6c16a56b8dc1e97d7078658
Change-Id: Ibfffe235bbfcf358b3741abd3f7197fdb063d3f3
2017-12-04 13:02:10 -08:00
Bernardo Rufino
728dceac63 Remove old BackupManagerService
As discussed, only removed the class, local interface and trampoline
still exist. That will go into a next CL.

Bug: 65823538
Test: make RunFrameworksServicesRoboTests
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 backupnow <kv and full-backup packages>
Test: adb backup & adb restore
Change-Id: Ifcb4c02e364b8c4899ff376ff20cd8c89fc1af28
2017-12-01 16:21:23 +00:00
Bernardo Rufino
ab953332bc Binding on-demand #3: updateTransportAttributes() API
This CL introduces the updateTransportAttributes() API to be used by the
transport hosts. It doesn't actually use the description attributes yet,
this will go in another CL. This is because I want to test that CL
together with transport usage. Tests are lacking for TransportManager
and BMS, I'll still add them, but I'm trying to migrate Robolectric
first.

Ref: http://go/br-binding-on-demand
Bug: 17140907
Test: make RunFrameworksServicesRoboTests
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
Change-Id: I56f7b5a5026d21d8f11afb371d5560d4913c5f2a
2017-11-30 14:26:13 +00:00
Bernardo Rufino
4719ed513e Binding on-demand #2: PerformFullTransportBackupTask usage
Migrate the full-backup task to use binding on-demand

Ref: http://go/br-binding-on-demand
Bug: 17140907
Test: make RunFrameworksServicesRoboTests
Test: runtest -p com.android.server.backup frameworks-services
Test: adb shell bmgr backupnow <packages>
      With transports manually unbound and also canceled the operation a
      few times. Then inspected TransportClient logcat
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: Manually unbound before GTS/CTS above.

Change-Id: I15abe970db0b9858e0e2e4eb666358db3a9d50ad
2017-11-24 11:02:45 +00:00
Bernardo Rufino
af547f4a15 Binding on-demand #1: TransportClient infra + PerformBackupTask usage
This CL introduces TransportClient infra-structure and integration in
TransportManager, plus a few unit tests. Also start using binding
on-demand for PerformBackupTask.

Ref: http://go/br-binding-on-demand
Bug: 17140907
Test: make RunFrameworksServicesRoboTests
Test: runtest -p com.android.server.backup frameworks-services
Test: adb shell bmgr backupnow <packages>
      With transports manually unbound and also canceled the operation a
      few times. Then inspected TransportClient logcat
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: Manually unbound before GTS/CTS above.
Change-Id: I63cbde27131205787d90663603a4f8f61d187607
2017-11-21 15:01:47 +00:00
Peter Visontay
d85c85f9d0 Merge "In backup/restore code wrap Binder.restoreCallingIdentity() in finally{}." 2017-11-03 11:53:20 +00:00
Makoto Onuki
2eccd02628 Make the battery saver knobs hidden public,
so other components (system UI, settings, etc) can use them.

Bug: 68769804
Test: Build & presubmit
Change-Id: I30fe78e49d2187bee7c7aeba735cd9c26fc332a5
2017-11-01 14:49:10 -07:00
Peter Visontay
a9565cb487 In backup/restore code wrap Binder.restoreCallingIdentity() in finally{}.
Test: none.
Bug: 68755611
Change-Id: Ic4326f3b50060be117ca7556cde15b0db10cc239
2017-11-01 18:44:01 +00:00
Michal Karpinski
387267eafe Don't overly call transport.transportDirName()
Test: runtest -p com.android.server.backup frameworks-services
Bug: 63401141
Change-Id: I485bd98f805fd6be689765e77a582820c53e9bc0
2017-10-20 11:00:38 +01:00
Christopher Tate
8808609896 Fix backup server
Mea culpa.  Properly do the trampoline indirection dance so
that we can asynchronously bring up the service components.
We'd previously accidentally introduced an ordering problem such
that the init process... didn't.

Bug: 67676879
Test: 'adb shell dumpsys backup' and 'adb shell bmgr list transports' after boot
Change-Id: I3e9a904a009f4745727e5eb13f7307c6deda1e4f
2017-10-12 13:37:02 +01:00
Christopher Tate
73093a477d Backup OS service now processes unlock off the main thread
We now perform the slow work of unlocking the primary user on the
background handler thread rather than on the main thread.  This
is expected to shave 150ms+ off of our total unlock latency on
some products.

Bug: 63389800
Test: manual
Change-Id: I70be032a64de3270476615fd9dde1b427e19aa91
2017-10-05 14:45:17 -07:00
Christopher Tate
66c94726c9 Fix system server crash when told to init backup transports
Refactor + merge gone awry; and pay attention to typed vs typeless
use of toArray().

Change-Id: I031ded949a6e3f2a296c9bf007129e4ebf796a4b
Fix: 67419822
Test: adb root && adb wait-for-device && \
      adb shell cmd activity broadcast -a android.app.backup.intent.INIT
2017-10-04 16:00:24 -07:00
Christopher Tate
43f2d3d337 Reduce lock interactions in backup transport management
1. process package update broadcasts on our background thread rather
   than on the main looper thread

2. don't synchronize unnecessarily around access to simple
   transport metadata

We mustn't block the main looper thread for anything that might wind
up interlocked with calls to the transport, because those might take
arbitrary amounts of time.  We were previously entering such an
implicitly interlocked code path during package-changed broadcast
handling, and in pathological cases were causing the watchdog to
restart the system.  This situation is addressed in a couple of ways:
first, by no longer performing package-update work on the main looper
thread at all; and second, by eliminating lock reliance entirely from
data-access paths that don't actually need it.

Bug: 65438129
Bug: 64133971
Test: manual + CTS
Change-Id: I361ad4a0729f319db7339bd341a6d33aa3b64fed
2017-09-29 12:20:34 -07:00
Michal Karpinski
bef5f4a64f Switch to use RefactoredBackupManagerService
Keeping the legacy BackupManagerService for now, but we'll remove
it in a few weeks if there's no issues noticed.
In case of any problems, this CL can be cleanly reverted as a fallback.

Test: pretty much all we got in store
1) runtest -p com.android.server.backup frameworks-services
2) make gts -j40 && gts-tradefed run gts -m GtsBackupHostTestCases
3) make cts -j40 && cts-tradefed run cts -m CtsBackupTestCases
4) make pts -j40 && pts-tradefed run pts -m PtsBackupHostSideTestCases
5) manual: "adb shell bmgr backupnow --all" and then cloud restore,
   D2D scenarios (both as source and target)
Bug: 65823538
Change-Id: I701764995c4fe2611a4941aecb45315aa457658e
2017-09-28 14:10:56 +01:00
Michal Karpinski
9464a3160d [RefactoredBMS] Use buffered DataInputStream vs RandomAccessFile
This CL replicates ag/2239004 in RefactoredBMS.

Test: runtest -p com.android.server.backup frameworks-services
Bug: 37973765
Change-Id: Id83445d433987730c5cdf9b9684b647baf3c3d1b
2017-09-19 11:44:41 +01:00
Michal Karpinski
c1741631d8 [RefactoredBMS] Refresh in-memory SharedPreferences instances after restore
This CL replicates ag/2284557 in RefactoredBMS (only the BMS part, the
rest is already live code).

Test: runtest -p com.android.server.backup frameworks-services
Bug: 37973765
Change-Id: I4f6cb85b879e0ee7b2b20ac998977f8c6d8fdfe0
2017-09-19 11:08:15 +01:00
Michal Karpinski
9d395bb3e2 [RefactoredBMS] Tear down agent after preflight rejection
This CL replicates ag/2520584 in RefactoredBMS.

Test: runtest -p com.android.server.backup frameworks-services
Bug: 37973765
Change-Id: I13ac110dbc197df473dd6a0cf24866133dfefab8
2017-09-19 10:46:43 +01:00
Michal Karpinski
fcd615fad2 [RefactoredBMS] Do not perform backup/restore of instant apps
This CL replicates ag/2256021 in RefactoredBMS.

Test: runtest -p com.android.server.backup frameworks-services
Bug: 37973765
Change-Id: Icf615b97025aa09681f9d25b1de3f94e60a45ee4
2017-09-19 10:34:12 +01:00
Michal Karpinski
5c90ff0f26 [RefactoredBMS] Correct scope of "disabled?" check viz backup/restore decisions
This CL replicates ag/2204901 in RefactoredBMS.
Also adjusts tests and adds new ones for appIsDisabled method.

Test: runtest -p com.android.server.backup frameworks-services
Bug: 37973765
Change-Id: Ibaa15ba935ca1ada657e912b18a5a0b3bcffd00f
2017-09-18 17:00:22 +01:00
Michal Karpinski
5246299c58 [RefactoredBMS] Don't mix "current dataset" tokens for different backup transports
This CL replicates ag/2191170 in RefactoredBMS.

Test: runtest -p com.android.server.backup frameworks-services
Bug: 37973765
Change-Id: Ic3fd528071cef8143e2c3f6b659722f951f0deb9
2017-09-18 14:32:47 +01:00
Michal Karpinski
f9b74cc7ef [RefactoredBMS] Ensure backup doesn't reuse ack tokens nearby in time
This CL replicates both ag/2551800 and ag/2613950 in RefactoredBMS.

Test: runtest -p com.android.server.backup frameworks-services
Bug: 37973765
Change-Id: I5e42dee67d587adabbfb81de03f3205d92a46add
2017-09-18 14:18:17 +01:00
Michal Karpinski
78ec67a264 [RefactoredBMS] Eliminate a race condition that could lead to
calling PBT#finalizeBackup() twice

This CL replicates ag/2510127 in RefactoredBMS.

Test: runtest -p com.android.server.backup frameworks-services
Bug: 37973765
Change-Id: Ic8571c08dd92386d0e4f79d7866aeb0f19f38106
2017-09-18 13:44:31 +01:00
Michal Karpinski
f95cf5d9c3 [RefactoredBMS] Offload the mRunningFullBackupTask.handleCancel()
call from the main thread to another thread

This CL replicates both ag/2135862 and ag/2465381 in RefactoredBMS.

Test: runtest -p com.android.server.backup frameworks-services
Bug: 37973765
Change-Id: I895cb27bc910d9970ab1c33cd54a773b8f9b6cf6
2017-09-18 13:34:44 +01:00
Michal Karpinski
3f09d6cf3b [RefactoredBMS] Add log before doRestoreFinished is called on BackupAgent.
This CL replicates ag/2140301 in RefactoredBMS.

Test: runtest -p com.android.server.backup frameworks-services
Bug: 37973765
Change-Id: I2c2795c89035dd6c38aee8aec4e4a95cfdba0846
2017-09-18 13:23:51 +01:00
Michal Karpinski
3d87a5bfaf [RefactoredBMS] Add tracing for UserState and a few services
This CL replicates ag/2500023 in RefactoredBMS.

Test: adb shell am instrument -w -e package com.android.server.backup com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner
Bug: 37973765
Change-Id: I3d638a98ff61954797d9e5a70a28e0c2962112c6
2017-09-18 12:25:50 +01:00
Michal Karpinski
a7924a6795 [RefactoredBMS] Call removeMessages() only for certain operations in RefactoredBackupManagerService#handleCancel()
This CL replicates ag/2147459 in RefactoredBMS.

Test: adb shell am instrument -w -e package com.android.server.backup com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner
Bug: 37973765
Change-Id: I55d1825477ce82c47fd5850bf00f34ee8c1b9fc0
2017-09-18 12:20:34 +01:00
Tim Zheng
bcc0c1d113 BackupManagerService uses BackupManagerConstants.
This change update the backup manager service to use newly created
BackupManagerConstants for some configuration parameters.

This is part 2 of the change.

Test: Used 'adb logcat -b system' to verify the settings worked.
Bug: 63351792
Change-Id: Ia6c9a2afbbaf3481a742a67c48ce9995c1ce6483
2017-09-15 11:50:09 -07:00
Tim Zheng
cc1e76a4b3 Add a backup manager constants secure settings.
This change add one secure settings which is a key value list consisting
of 7 individual settings; it also provides a class to get these settings
and use the default values specified in default.xml file when the settings
are missing.

This is the first part of a 2 part change. A subsequent change will use
these settings in backup service manger for setting up backup frequency.

Test: This change builds. Manual tests will be included in part 2 of the
change.
Bug: 63351792
Change-Id: I62baddbf3e0b96af6b7de3dfdeac3479e5b3ded8
2017-09-14 16:32:21 -07:00
Bernardo Rufino
5176c02501 Add logs to IOExceptions during adb backup
Test: Run adb backup
Bug: 65435587
Change-Id: I744cb2878654b716858d7c9bedeb12fb9978df6b
2017-09-13 14:10:20 +01:00
Christopher Tate
39be7faab2 Merge "Set flags on the correct Intent, please" into oc-mr1-dev am: 33894b2998
am: a80316daa3

Change-Id: I486096da329ccfed44ba6e5e9f6e14af47db8932
2017-09-04 11:15:39 +00:00
Christopher Tate
ed961d90ea Set flags on the correct Intent, please
Bug: 65115426
Test: passes CTS backup suite
Change-Id: I497d077f563fef7b0800df626d15651c721d4ca7
2017-09-01 13:39:10 -07:00
Artem Iglikov
026e93323e Add tests for TransportManager#ensureTransportReady().
This involves some refactoring, so that TransportManager doesn't use API
not available in pre-O.

Bug: 37616038
Test: make RunFrameworksServicesRoboTests
Change-Id: I6a79bdbbee2a37a9fecff7865bdec37be2c7e59a
2017-09-01 15:28:31 +01:00
Artem Iglikov
bd476eae4b Update TransportManager tests.
This applies changes that disappeared for some reason from ag/2314382

Bug: 37616038
Test: make RunFrameworksServicesRoboTests
Change-Id: Iabfafd8c6afaac7304194f7645d08ef9e6f3b3aa
2017-09-01 11:03:03 +01:00
Artem Iglikov
5ed1dab192 Add a test for TransportManager#onPackageAdded().
Also set up robolectric tests for framework services.

Bug: 37616038
Test: make RunFrameworksServicesRoboTests
Change-Id: Ia27a58365a0826ec5bc9f8a7544024b52cfbb3ec
2017-08-31 16:59:28 +01:00
Bernardo Rufino
0d0d180305 Merge "Merge "Solve AppBackupUtils.signaturesMatch() policies" into oc-mr1-dev am: a743c01d00" into oc-mr1-dev-plus-aosp
am: 13889d75c7

Change-Id: Ifd1afbf731cfb10d2e37d86d0c5b1d64011eb9d6
2017-08-22 20:02:06 +00:00
Bernardo Rufino
cbcc34e4da Solve AppBackupUtils.signaturesMatch() policies
Now we reject unsigned apps, either source or target. Also
added javadoc.

Bug: 37977154
Test: runtest -p com.android.server.backup frameworks-services
Change-Id: I44df43d5322ae64d97f8b19c20db508033301f91
2017-08-22 15:54:04 +01:00
TreeHugger Robot
5f1d35ee21 Merge "Locking changes in ProcessedPackagesJournal" 2017-08-09 14:09:17 +00:00
Robert Berry
a1109ef8da Locking changes in ProcessedPackagesJournal
A follow-up CL to apply the code feedback from the first one.

Bug: 36850431
Test: adb shell am instrument -w -e package com.android.server.backup com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner
Change-Id: I8785eb358658757b329ac871194243c47e6d87a9
2017-08-09 13:12:05 +01:00
Robert Berry
bfcff7be30 Merge "Do not remove uninstalled packages from journal" into oc-mr1-dev am: b152fb8d30
am: dae011cc5a

Change-Id: I2940aafdf07b572ee69d988599a2f8084c290dab
2017-08-08 21:43:36 +00:00
TreeHugger Robot
b152fb8d30 Merge "Do not remove uninstalled packages from journal" into oc-mr1-dev 2017-08-08 21:19:41 +00:00