683 Commits

Author SHA1 Message Date
Jeff Sharkey
487d394296 Merge changes from topic "sep11" am: c0b288133a am: 69e6f07347 am: 741c0a78cc am: da7478b570
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1426195

Change-Id: I79488866c538bf9e76d0a6429e30262978f6fdab
2020-09-15 00:13:08 +00:00
Jeff Sharkey
4172f8a62c Update language to comply with Android's inclusive language guidance
See https://source.android.com/setup/contribute/respectful-code for reference

Test: none
Bug: 168334533
Exempt-From-Owner-Approval: docs updates
Change-Id: If75259aab72329f9f8b0e1972a96370ca5134e2c
2020-09-14 10:00:10 -06:00
Xin Li
628590d7ec Merge Android R (rvc-dev-plus-aosp-without-vendor@6692709)
Bug: 166295507
Merged-In: I3d92a6de21a938f6b352ec26dc23420c0fe02b27
Change-Id: Ifdb80563ef042738778ebb8a7581a97c4e3d96e2
2020-08-31 21:21:38 -07:00
Tom Cherry
dd64d79408 Log only a summary 'Found stale backup journal' message. am: 4b4e781943 am: 2ae5c5405d
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12240609

Change-Id: I47e5638db690847ba56c465f53d5d63095c4e609
2020-07-27 18:05:33 +00:00
Tom Cherry
9db78024c5 Log only a summary 'Found stale backup journal' message.
With the goal of reducing log spam, print only a summary 'Found stale
backup journal' messages instead of logging within the inner loop.
Previously, over 12k messages could be printed at a time from this
function.

Before this CL:
 - a backup was scheduled for each packageName from each stale
   journal
 - one (or two, if MORE_DEBUG) message was logged for each
   packageName in each journal file.

After this CL:

 - packageNames are de-duplicated before scheduling backups or logging
   (it's not clear to me whether duplicate packageNames previously
   occurred, in practice).
 - one message is logged for the number (if > 0) of stale journals.
 - one message is logged for the number (including their names, if
   MORE_DEBUG) of packages.

Bug: 161940947
Test: fewer 'Found state backup journal' messages printed
Merged-In: Ia1343e4cea31feb1eba9da561d20736eb5df0a14
Change-Id: Ia1343e4cea31feb1eba9da561d20736eb5df0a14
2020-07-27 09:27:39 -07:00
Tom Cherry
4b4e781943 Log only a summary 'Found stale backup journal' message.
With the goal of reducing log spam, print only a summary 'Found stale
backup journal' messages instead of logging within the inner loop.
Previously, over 12k messages could be printed at a time from this
function.

Before this CL:
 - a backup was scheduled for each packageName from each stale
   journal
 - one (or two, if MORE_DEBUG) message was logged for each
   packageName in each journal file.

After this CL:

 - packageNames are de-duplicated before scheduling backups or logging
   (it's not clear to me whether duplicate packageNames previously
   occurred, in practice).
 - one message is logged for the number (if > 0) of stale journals.
 - one message is logged for the number (including their names, if
   MORE_DEBUG) of packages.

Bug: 161940947
Test: fewer 'Found state backup journal' messages printed
Merged-In: Ia1343e4cea31feb1eba9da561d20736eb5df0a14
Change-Id: Ia1343e4cea31feb1eba9da561d20736eb5df0a14
(cherry picked from commit 112e3c2d049d304b0aa57750fcaa6415ea2b6fef)
2020-07-27 16:26:31 +00:00
Tobias Thierer
781f492b1e Merge "services/backup/OWNERS: Add more people." am: 944082eca5 am: 87783595af am: fdf9fe2499 am: 7b5aeaa798
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1341773

Change-Id: Ie9650c78546e0c502e0af8e0800e9dcd34efdc7b
2020-07-08 11:52:07 +00:00
Tobias Thierer
fdf9fe2499 Merge "services/backup/OWNERS: Add more people." am: 944082eca5 am: 87783595af
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1341773

Change-Id: I7e93f5e05f1834034fdea4b86a4bc96edd4a2d64
2020-07-08 11:32:32 +00:00
TreeHugger Robot
90abbee47f Merge "Fix state deletion for transient backup issues." into rvc-qpr-dev am: 2170ba0f9f
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12086616

Change-Id: Ife1bcb70febb986e465689224dedc47d5025a5b2
2020-07-07 18:43:26 +00:00
Tobias Thierer
723f5f365f Fix state deletion for transient backup issues.
Since Android 10, backupPm() includes sendDataToTransport(), which was
not previously the case. This means that error handling logic that
deletes the backup state file (causing initialize_device() on the next
attempt, which deletes any existing backup) will now also be triggered
upon errors during sendDataToTransport(), which wasn't previously
(Android <= 9) the case.

This has the potential of making an existing temporary outage much
worse:

  1. A few devices might run into temporary issues, e.g. a B&R server
     returning HTTP 503 Service Unavailable (treated as a
     TransientHttpStatusException instanceof NetworkException, which
     is mapped to TRANSPORT_ERROR during handleTransportStatus(),
     which results in a TaskException with stateCompromised==false
     but which backupPm() wraps in another TaskException that forces
     stateCompromised=true).
  2. On their next backup attempt, those devices throw away any
     existing backup and start from scratch (initialize_device()),
     increasing the load on the server.
  3. This leads to a positive-feedback loop where more devices than
     before run into HTTP 503 Service Unavailable.
  4. As a result, masses of devices delete their backups and then
     hammer the B&R server with attempts to upload new backups.
  5. Backups are unavailable to any users who would otherwise rely
     on them during this outage.

To improve on this dangerous situation, this CL changes the code to
force stateCompromised=true only for TaskExceptions thrown
specifically during extractPmAgentData(), and (as before) for all
AgentExceptions.

Note that the code is still quite brittle. It still seems like we
are probably forcing stateCompromised=true in too many situations,
but it's hard to say so this CL is being conservative about the
changes. Changing back to the old behavior could be done through
a local change around KeyValueBackupTask.java:676; a future CL may
do this to have a safety hatch in case we want to cherry-pick this
CL into an upcoming Android release late in the release cycle.

[1] https://android.googlesource.com/platform/frameworks/base/+/refs/heads/pie-dev/services/backup/java/com/android/server/backup/internal/PerformBackupTask.java#1035
[2] https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/services/backup/java/com/android/server/backup/keyvalue/KeyValueBackupTask.java#1040
[3] https://source.corp.google.com/piper///depot/google3/java/com/google/android/gmscore/integ/modules/backup/transport/src/com/google/android/gms/backup/transport/GmsBackupTransport.java;l=770;rcl=281845876

Bug: 144030477
Test: Checked that the following passes after this CL, but
  testRunTask_whenTransportReturnsErrorForPm_updatesFilesAndCleansUp()
  fails if I revert the state of KeyValueBackupTask.java to before this CL:
    ROBOTEST_FILTER=KeyValueBackupTaskTest make \
    RunBackupFrameworksServicesRoboTests

Change-Id: I6c622c55fbd804ec0a12e0bea7ade1308f7a3877
(cherry picked from commit 819ed81faaa295d9e1096f13f599cb43d48cda88)
2020-07-07 11:55:20 +00:00
Tobias Thierer
19838ea5ae services/backup/OWNERS: Add more people.
Fixes: 159055442
Test: Treehugger
Change-Id: Ib2d49b3d347aef0141e6b703054e1f1840c380f2
2020-07-07 12:25:53 +01:00
Tobias Thierer
82dfc06f7b Merge "Update services/backup/OWNERS" am: 5079d626d9 am: 349777a814
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1337174

Change-Id: I786a1df7376d4970af219a6ddaee8a3f6cb9c9e2
2020-06-30 12:56:54 +00:00
Tobias Thierer
5079d626d9 Merge "Update services/backup/OWNERS" 2020-06-30 12:31:01 +00:00
Ruslan Tkhakokhov
7346d708a8 Change secure setting that controls skipping of user-facing packages
Bug: 159648065
Test: N/A

Change the setting key to be 'backup_skip_user_facing_packages'. See the
bug for context.

Change-Id: I315141a509976821c7db311544a5c0f4e6fd1917
2020-06-22 23:31:20 +00:00
Josh Gao
72376bf05d Merge "Fix file descriptor ownership." 2020-06-19 22:31:53 +00:00
Josh Gao
ead6dacf40 Fix file descriptor ownership.
Previously, we attempt to pass ownership of the fd owned by a
ParcelFileDescriptor to a FileInputStream, which explodes when we try to
close it.

Bug: http://b/156867945
Bug: http://b/159264419
Test: treehugger
Change-Id: I9d5124658beb50f0a08499ed09e652037cb9ae66
(cherry picked from commit 3e29e4a39c9090e2815359a1fba0030f62ed8bbb)
2020-06-18 15:52:16 -07:00
Tobias Thierer
ec6e081965 Update services/backup/OWNERS
- Remove former team members.
 - Add tobiast@

Bug: 159055442
Test: Treehugger
Change-Id: I9749f30b43934a1f34526ecf2110dab73c9bd08e
2020-06-16 18:28:40 +01:00
Tobias Thierer
b401cc30cd services/backup/OWNERS: Sync with internal version.
https://r.android.com/950439 and http://ag/7949925 already attempted
this, but a whitespace difference remained.

This CL copies ('cp') the internal file to AOSP master; the Merged-In line
refers to the internal CL that added the extra empty line, which should
lead to automerger skipping this CL when merging into branches that have
the other CL.

Bug: 129861520
Bug: 159055442
Test: Treehugger

Change-Id: I3f83e223a1c7d812f74515008e4c6005ebc3dbe2
Merged-In: I42c27dfc0f3f792c46fe60e0f6807e51a2c3f21e
2020-06-15 23:34:16 +01:00
Josh Gao
3e29e4a39c Fix file descriptor ownership.
Previously, we attempt to pass ownership of the fd owned by a
ParcelFileDescriptor to a FileInputStream, which explodes when we try to
close it.

Bug: http://b/156867945
Test: treehugger
Change-Id: I9d5124658beb50f0a08499ed09e652037cb9ae66
2020-06-15 13:17:10 -07:00
Jeff Sharkey
4d1d7b56cd Add custom Error Prone check for SDK comparisons.
Over the years we've had several obscure bugs related to how SDK level
comparisons are performed, specifically during the window of time
where we've started distributing the "frankenbuild" to developers.

Consider the case where a framework developer shipping release "R"
wants to only grant a specific behavior to modern apps; they could
write this in two different ways:

1. if (targetSdkVersion > Build.VERSION_CODES.Q) {
2. if (targetSdkVersion >= Build.VERSION_CODES.R) {

The safer of these two options is (2), which will ensure that
developers only get the behavior when *both* the app and the
platform concur on the specific SDK level having shipped.

Consider the breakage that would happen with option (1) if we
started shipping APKs that are based on the final R SDK, but are
then installed on earlier preview releases which still consider R
to be CUR_DEVELOPMENT; they'd risk crashing due to behaviors that
were never part of the official R SDK.

Bug: 64412239
Test: ./build/soong/soong_ui.bash --make-mode services RUN_ERROR_PRONE=true
Exempt-From-Owner-Approval: trivial blueprint changes
Change-Id: Ia20181f8602451ac9a719ea488d148e160708592
2020-05-04 23:09:48 +00:00
Ruslan Tkhakokhov
f9c5bd837c Skip backup/restore of wallpaper package
Do not backup or restore wallpaper package when
'backup_skip_user_facing_data' is set. See https://b.corp.google.com/issues/153940088#comment2 for context.

Bug: 153940088
Test: 1. atest UserBackupManagerServiceTest
      2. atest PerformUnifiedRestoreTaskTest
      3. atest CtsBackupTestCases
      4. atest CtsBackupHostTestCases
      5. Manual:
          1) adb shell settings secure put backup_skip_user_facing_data
	  1
	  2) adb shell bmgr backupnow com.android.wallpaperbackup ->
	  verify skipped
	  3) adb shell bmgr restore 1 com.android.wallpaperbackup ->
	  verify skipped
	  4) adb shell settings secure put backup_skip_user_facing_data
	  0 -> verify com.android.wallpaperbackup is backed up /
	  restored

Change-Id: Iedd0c4030a635e294a04d35bd525ca852c929b92
2020-04-24 09:42:01 +00:00
Nikhar Agrawal
7f87c19483 Enforce BACKUP permission for BackupManager#excludeKeysFromRestore()
Bug: 153415469
Test: atest UserBackupManagerServiceTest

Change-Id: I3d3c0e518a2e9b3805da02f4b0850c428cb8ff0e
2020-04-17 15:17:05 +00:00
Al Sutton
c4d9e91f85 Add userId to log messages - DO NOT MERGE
Add the user ID so it's easier to see which user log messages refer to.

There's a bit of churn around conditionals in this to ensure that the
code complies with the style guidelines.

Fixes: 148376687
Test: make RunBackupFrameworksServicesRoboTests
Change-Id: I3ca92d21492fae4b89cb73fb39db1a490c796f5d
2020-03-18 11:59:47 +00:00
Al Sutton
feebe8143e Revert "Add feature flag for "no data" backup calls"
This reverts commit 27c64a3bed785f1bd4bda4896b4df0807d0804d2.

Reason for revert: The GMSCore code to handle the flag will be part of DP2 and so we can remove the flag ahead of the cut.

GMSCore CL Status; https://cl-status.corp.google.com/#/summary/gmscore_prod/291378558
GMSCore Calendar; http://go/gms-schedule

Bug: 147481066
Test: m -j RunBackupFrameworksServicesRoboTests
Change-Id: I4159e064e739c6f366063c7fadd7cca40a7f07d9
2020-02-21 10:49:57 +00:00
Al Sutton
d5db369554 Add debug logging when keys are blocked
Adding a log statement at debug level so when the key blocking system
is tested end-to-end there's an easy indicator of a key being blocked.

Bug: 149548272
Test: No code which affects functionality to test
Change-Id: I9de8a7d47ffb75520d1adcba620ec13345c1c4ae
2020-02-20 08:53:56 +00:00
Ruslan Tkhakokhov
88cb2d9df8 Merge "Get blocked restore keys directly from UserBMS" 2020-02-10 18:21:23 +00:00
Ruslan Tkhakokhov
9de0b77cbc Get blocked restore keys directly from UserBMS
Bug: 145126096
Test: atest KeyValueRestoreExclusionHostSideTest
      atest PerformUnifiedRestoreHostSideTest
      atest UserBackupPreferencesTest

Currently PerformUnifiedRestoreTask gets the list of blocked restore
keys at construction. However, at that point the list might not be fully
constructed yet. We should get the keys through the getter avaialble in
UserBMS when we need them.

Change-Id: I62ad34138ba7a893e66d6af05d2e242c9c964a44
2020-02-10 16:41:15 +00:00
Chandan Nath
72b16f67d7 Merge "Avoid warning logs on blocking Binder calls out of system_server to IBackupTransport" 2020-02-04 11:54:00 +00:00
nathch
d153d5fd22 Avoid warning logs on blocking Binder calls out of system_server to IBackupTransport
The implementations of IBackupTransport are whitelisted therefore in the short-term,
its OK to allow these calls and avoid the warning logs which can be distracting when
looking at logs to investigate bugs and are not of any real value since we are already
aware of this.

Bug: 148783926

Test: atest -v CtsBackupTestCases
Test: atest -v CtsBackupHostTestCases
Change-Id: I13e2a638891d0369310bc2c665fa772306a28199
2020-02-03 17:09:34 +00:00
nathch
555e7c632b Add logging for error conditions when reading or writing backup enabled
state.

Also add debug logging when reading or writing backup enabled state to
be able to better investigate bugs.

Bug: 148587496
Bug: 147352819

Test: atest -v RunBackupFrameworksServicesRoboTests
Test: atest -v $(find frameworks/base/services/tests/servicestests/src/com/android/server/backup -name '\''*Test.java'\'')'
Change-Id: I3c9b158ce57558daa5437cebe6aa0a0c924692fc
2020-01-30 13:22:41 +00:00
Ruslan Tkhakokhov
9e76d042ca Stage 'android' package in PerformUnifiedRestoreTask
Bug: 145126096
Test: atest KeyValueRestoreExclusionHostSideTest
      atest PerformUnifiedRestoreTaskTest

In a KV restore after getting data from the transport, we save it into a
stage file. Then we go through the keys and do filtering: skip the keys
that should be excluded and extract the widget data into a separate
file. The rest of the data is wirtten into the file where the app's
backup agent will read it from.

However, this process is skipped for 'android' package. It was done as
an optimization before the ability to exclude keys from restore was
introduced: as 'android' backup data doesn't contain any widget info.
However, now we need to process 'android' package as well because it can
contain keys to be excluded.

Change-Id: I612f8cc9c6903c9bd257762360dadb81ed12d106
2020-01-28 16:37:35 +00:00
nathch
89c5325c38 Add log when acquiring and releasing wakelock.
This is so that we can add a CTS test which asserts through logcat
inspection that backup and restore operations acquire and release
wakelock in the expected manner.

Change-Id: I1a73bd674c22ad7f0f37aba100aee819abe9f4d2
2020-01-27 01:27:48 +00:00
Al Sutton
27c64a3bed Add feature flag for "no data" backup calls
This will allow us to turn off the new functionality while the
transport implementations are updated.

Bug: 147481066
Test: m -j RunBackupFrameworksServicesRoboTests
Change-Id: I8c0019ff80d94dd8d94299a7b03b78e3081f2b8e
2020-01-22 13:23:45 +00:00
Al Sutton
7ab8dc3128 Notify transports of empty K/V backups
In order to allow transports to know when a K/V backup would have
been performed, but was not due to no data changes being reported,
we need to introduce some code to find the K/V backup participants,
remove any which are backed up in this sweep or are currently failing
to back up due to an error, and then inform the transport of the
remaing set.

This CL introduces the code to do that.

We use a state file to determine if a package backed up without an
error on the last run, if the backup fails we remove the file for
that package. When all packages with changed data have been backed
up we get a list of all packages which have the file set (i.e. were
successful), remove the set of packages backed up on this run, and
inform the transport the rest had no data changes.

Bug:147481066
Test: m -j RunBackupFrameworksServicesRoboTests
Change-Id: I5c9f94c925096faf7b65307c0be1a7aba48c1cfb
2020-01-21 14:00:03 +00:00
nathch
f203e2a674 Remove RunBackupReceiver
Currently, the logic for backupnow is split between UserBackupManagerService,
RunBackupReceiver and BackupHandler. This makes it very confusing as
the pre checks are split over three classes and there's no obvious
reason why it is like that.

On the other hand, requestBackup is split nicely into checks in
UserBackupManagerService and starting the work from BackupHandler.

This change removes RunBackupReceiver for backupNow and splits the logic
only between UserBackupManager and BackupHandler - in the direction of
making it consistent with requestBackup by moving the checks to
UseBackupManagerService. (except the check for isBackupRunning which
needs to be in the same synchronised block as setBackupRunning).

Also, this CL moves the wakelock acquire from RunBackupReceiver (removed in this CL)
to BackupHandler. Previously, RunBackupReceiver would acquire the wakelock and then
send MSG_RUN_BACKUP. BackupHandler would then have to release that wakelock when it finds
it cant run the backup because there's no transport.
Now, the acquire is in BackupHandler after checking the transport. Therefore we dont need
that release (when there's no transport) anymore

A side benefit is we get rid of an extra hop to the broadcast receiver
so potentially backups should be scheduled (albeit very slightly)
faster.

Test: atest -v RunBackupFrameworksServicesRoboTests
Test: atest -v $(find frameworks/base/services/tests/servicestests/src/com/android/server/backup -name '\''*Test.java'\'')
Test: atest -v CtsBackupTestCases
Test: atest -v CtsBackupHostTestCases

Bug: 147741497
Change-Id: I40051540c7e8531ef05076eab7ccc5b44b0c08d2
2020-01-16 10:58:38 +00:00
nathch
6b19ce6f0b Remove unnecessary synchronized block
The only two actions within the block are sending an intent and
canceling a job none of which have anything to do with the queuelock

Test: atest -v RunBackupFrameworksServicesRoboTests
Test: atest -v CtsBackupTestCases
Test: atest -v CtsBackupHostTestCases

Bug: 136738613
Change-Id: Ieedb73edf6cd40792232b48a26613b497c87ba02
2020-01-14 23:55:15 +00:00
nathch
179065be04 Remove unused messages which are not sent from anywhere.
Test: Compile with cd frameworks/base && mm

Bug: 136738613
Change-Id: I25352abe71745487a3b741764ba84a4c67c38ec8
2020-01-14 00:01:50 +00:00
nathch
b6798a7fb6 Fix bad test for testGetUserForAncestralSerialNumber which was
previously marked as @Ignore.

The test was bad because it set 11 as the ancestral serial number for
the system user UserBackupManagerService but asserted that 11 corresponds
to user 1 - which is not the system user. This CL fixes the assert.

Also added corresponding test for non system user.

Fixes: 147012496

Test: atest com.android.server.backup.BackupManagerServiceTest
Change-Id: Iab736885264aa4befc644678e5fe66d602ed00e3
2020-01-10 18:49:48 +00:00
nathch
5d51c314c2 Dump information for all users running backup in backup dumpsys.
Currently backup dumpsys in bugreport only contains information
for system user making it hard to debug backup bugs in non-system
users. Therefore, add dumpsys information for all users running backup.

For system user, keep the dumpsys format the same for compatibility with
cts and gts tests. For non-system users, add a prefix "User <userid>:"
to all dumpsys headers.

The changes in Android.bp and AndroidManifest.xml are to support mocking
of the static method DumpUtils.checkDumpAndUsageStatsPermission in the
test testDump_systemUserFirst

Bug: 143867387

Test: atest com.android.server.backup.BackupManagerServiceTest

Test: atest com.android.server.backup.UserBackupManagerServiceTest

Test: adb shell pm create-user test1 -> say this gives 11
adb shell am start-user 11
adb shell bmgr --user 11 activate true
adb shell dumpsys backup users -> "Backup Manager is running for users: 0 11"
adb shell dumpsys backup -> contains both
"Backup Manager is enabled / setup complete / not pending init" and
"User 11:Backup Manager is disabled / not setup complete / not pending init"
adb shell pm remove-user 11

Test: "adb bugreport" on device with secondary user as created above and check that result
contains dumpsys for both system and secondary users.

Test: atest -v CtsBackupTestCases
Test: atest -v CtsBackupHostTestCases

Change-Id: Ib94c168f8e89b0ba8f398152ea744fe3d626efc4
2020-01-10 13:10:45 +00:00
Ruslan Tkhakokhov
e9388dacfe Handle uncaught exceptions in BackupHandler
Bug: 144431410
Test: 1. atest BackupHandlerTest
      2. Manual (with and without the fix):
           1) Locally create a host-side CTS test that extends
              BaseMultiUserBackupHostSideTest
           2) Modify the test so that it creates a user, starts backup
              init and removes the user
           3) Add log in BackupHandler to indicate when an exception is
              suppressed.
           3) If the fix is applied, verify the crash doesn't happen and
              the log message from 3) is present. If the fix isn't applied
              verify that the crash happens.

After backup service for a  user is stopped, leftover work on the
corresponding BackupHandler can throw exceptions. If uncaught, they
can crash the system process. Catch all uncaught BackupHandler
exceptions after the backup service has entered the stopping state, to
allow any leftover work to finish harmlessly.

Change-Id: I8c233ad0e117ec0ae65599a762d87f15f8a3cec2
2020-01-06 10:23:31 +00:00
Daulet Zhanguzin
15d63e4466 Replace com.android.internal.util.Preconditions.checkNotNull with
java.util.Objects.requireNonNull

Bug: 126528330

Test: Treehugger
Change-Id: I54e2f3cc4353128de012ccbb39cd912ea1696161
2020-01-03 15:16:57 +00:00
Al Sutton
eff34ec911 Merge "Rename variable to avoid mis-labelling as a TODO comment" 2019-12-31 10:07:32 +00:00
Chandan Nath
e4df2f6cbc Merge "remove unused private fields and unnecessary TODOs" 2019-12-30 20:40:06 +00:00
nathch
5e5a4486b0 remove unused private fields and unnecessary TODOs
1. the private members in BackupManagerServiceTest were all unused
2. remove TODO for b/124359804 which is marked as wont-fix.
3. remove adb backup multi-user TODOs as adb backup is deprecated and we
don't intend to extend multi-user support to it.

Bug: 136738613

Test: m -j
Change-Id: Ia4c6ebce7b9bb7ab8bfe1f6a18f9b67ec6098cd2
2019-12-30 11:01:46 +00:00
Al Sutton
1b8c06fa0b Rename variable to avoid mis-labelling as a TODO comment
Currently this variable gets picked up by simple scans for work
labelled TODO. By renaming it we can use simple filters to find
work in need of doing.

Bug: None
Test: atest BackupFrameworksServicesRoboTests
Change-Id: I5a5b5c6e49febae2636b6b4dc97ab3e922aa3eef
2019-12-30 10:55:24 +00:00
nathch
84c99f332e Remove duplicate code in initializing transports
Use enforceCallingOrSelfPermission which is the same as
enforceCallingPermission except it grants own permissions
when not processing an IPC.

Also remove unused private field from KeyValueBackupTask

Bug: 146939599
Bug: 136738613

Test: 1) adb shell bmgr enable true
2) adb shell bmgr enable false
3) adb shell am broadcast -a "android.app.backup.intent.INIT"
logcat is as expected:
BackupManagerService: Backup enabled => false
BackupManagerService: Running a device init; 3 pending
BackupManagerService: initializeTransport(): [com.android.localtransport/.LocalTransport, com.google.android.gms/.backup.migrate.service.D2dTransport, com.google.android.gms/.backup.BackupTransportService]
BackupManagerService: Initializing (wiping) backup transport storage: com.android.localtransport/.LocalTransport
....
BackupManagerService: Initializing (wiping) backup transport storage: com.google.android.gms/.backup.migrate.service.D2dTransport
...
BackupManagerService: Initializing (wiping) backup transport storage: com.google.android.gms/.backup.BackupTransportService

Change-Id: I98d87f3163cd7fbc1f7aa6712ec421cc8efd5d29
2019-12-28 12:59:17 +00:00
Carmen Agimof
79dc7ed61e Merge "Do not try to do a restore at install if the user is not ready for backup." 2019-12-13 16:41:21 +00:00
Carmen Agimof
4e55418864 Do not try to do a restore at install if the user is not ready for
backup.

Bug: 144155744

This solves a bug which makes staged installs hang. This is
happening because when installing, the PackageManager is waiting for a response to be sent back from
the BackupManagerService after it finishes restoring. In the case of staged installs which happen at boot,
isUserReadyForBackup is false, so the method does nothing and the
PackageManager keeps on waiting on a response.

Test: 1) atest RunBackupFrameworksServicesRoboTests and atest AutoRestoreHostSideTest
2) Manual:
   - Applied ag/9722795
   - run `atest com.android.tests.rollback.host.StagedRollbackTest#testStagedInstallHang`
   - The log file doesn't contain any "Watchdog: *** WATCHDOG KILLING SYSTEM PROCESS: Blocked in handler on main thread (main)".

Change-Id: I294c309b0c7e5a9e12bdbd0c3fc4946767f91cee
2019-12-12 16:29:00 +00:00
Ruslan Tkhakokhov
d7f5fdb43b Pass excluded keys to the backup agent in onRestore
Pass the list of the keys excluded from KV restore to the backup agent to make it aware of what data has been removed (in case it has any application-level consequences) as well as the data that should be removed by the agent itself.

Bug: 145126096
Test: atest CtsBackupTestCases
Change-Id: I34415b149b379fb5bb67b0fbcd70ec9b9858acfe
2019-12-11 13:43:32 +00:00
Jiyong Park
e86e89acff Add filegroups for services.* libraries
... in preparation for creating a stub library from services.jar

Bug: 139391334
Test: m

Exempt-From-Owner-Approval: cherry-pick from internal

Merged-In: Ifd6cfc77acf2284804a2f64011c2733b5c222369
(cherry picked from commit bae2e907966dce0cb3eaf3e3a81cca4364b7d941)
Change-Id: Ifd6cfc77acf2284804a2f64011c2733b5c222369
2019-12-11 15:55:33 +09:00