Commit Graph

42 Commits

Author SHA1 Message Date
Nikita Ioffe
3383005724 Merge "RMS: Pass in rollback_id in the calls to installd" 2019-02-21 11:09:26 +00:00
Richard Uhler
b226f96c48 Merge changes I5383c533,Iaf739837
* changes:
  Add test for staged rollback of apex only install.
  Rename "Basic" staged rollback test to "ApkOnly"
2019-02-21 09:28:16 +00:00
Richard Uhler
7fabc93642 Add test for staged rollback of apex only install.
Bug: 124043688
Test: atest StagedRollbackTest

Change-Id: I5383c533483e48d3f300e66e9554677d6057c494
2019-02-20 16:36:54 +00:00
Richard Uhler
67c3746c1f Rename "Basic" staged rollback test to "ApkOnly"
In preparation for adding Apex and Apex + Apk tests.

Bug: 124043688
Test: atest StagedRollbackTest
Change-Id: Iaf7398370c65403373bf4e7c2f82c8eb9cc0930c
2019-02-20 16:36:54 +00:00
Nikita Ioffe
5dcd179749 RMS: Pass in rollback_id in the calls to installd
- snapshotAppData gets PackageRollbackInfo and updates pending backups
  and inodes of CE user data snapshots;
- computePendingBackups/Restores is now merged into
  commitPendingBackupAndRestoreForUser;
- essentially commitPendingBackupAndRestoreForUser now gets lists of
  pending and recently executed rollbacks, computs what backups and
  restores are pending and commits them.

Bug: 124029909
Test: RollbackTest, AppDataRollbackHelperTest
Change-Id: I5aecdfd47b535492165614ee7cf9676778e292ad
2019-02-19 15:11:50 +00:00
Richard Uhler
f500684d90 Add StagedRollbackTest to TEST_MAPPING.
Bug: 124043688
Test: frameworks/base/tests/RollbackTest$ atest
Change-Id: Ifbfb725a5909fe80aae6af4d90f9d0d3804839c5
2019-02-19 09:59:06 +00:00
Richard Uhler
c5e2e803fd Create basic test for rollback of staged install.
The new test tests rollback of a staged install involving a single apk.

Test: atest StagedRollbackTest
Bug: 124043688
Bug: 124221060
Bug: 124284714

Change-Id: Ie125d44c4d30d142ee32beac4c42e735a47ec71e
2019-02-18 11:08:26 +00:00
Richard Uhler
00baa4b4fc Stub out code for a host driven StagedRollbackTest.
The test doesn't test anything meaningful yet, but it builds and runs.

Bug: 124043688
Test: atest StagedRollbackTest
Change-Id: If9b5d57e28846b0ba28a580b74a486bbedb8f8d5
2019-02-14 14:58:02 +00:00
Richard Uhler
8ab0ee8c83 Move RollbackTest app code to a new subdirectory.
In preparation for adding another subdirectory for a host-driven test of
staged rollbacks.

Bug: 124043688
Test: atest RollbackTest
Change-Id: I001427c7a659c2c934345e1dba1c421209accb6c
2019-02-14 14:50:01 +00:00
Zimuzo Ezeozue
3ba176eeb2 Merge "Fix RollbackTest#testBadUpdateRollback" 2019-02-07 10:47:49 +00:00
Zimuzo Ezeozue
ed6a17b24a Merge "Allow non-mainline package rollbacks" 2019-02-05 13:59:42 +00:00
Zimuzo
753626b42f Fix RollbackTest#testBadUpdateRollback
It appears that the device can be under high broadcast pressure and 5
seconds may not be a long enough wait to receive broadcast from test
app in instrumented app. We now remove the 5 seconds wait and rely on
test runner timeout to not wait forever.

Test: atest RollbackTest
Bug: 123886893 120598832
Change-Id: Ic686da15cfb64e5a84fb9f7c2795b94ef481d3bd
2019-02-05 11:24:27 +00:00
Zimuzo
9e57ecb5c4 Allow non-mainline package rollbacks
If3aaf8f2c454f45b9d79c9dae5a21d356e4cf029 prevented rolling back
packages that were not part of a mainline update. This made it
difficult to test and the auto PackageWatchdog test was ignored in the
meantime. We are now allowing non-mainling package rollbacks and
re-enabling the test.

I8dd7e6d1e144251830108c58f4a752c411d7295b introduced a refactoring bug
when rolling back packages, the module metadata provider was rolled
back instead. This was not caught because the test was ignored.

Test: atest RollbackTest
Bug: 120598832

Change-Id: I8fcc9492a05f0b3788ba4762ad3e3e5ac086d43b
2019-02-05 10:40:46 +00:00
Richard Uhler
b002577d72 Create dummy apex files for testing Rollbacks.
Bug: 112431924
Test: RollbackTest builds

Change-Id: I50404ca06710ca0173cb5717ca88b77f6b46cd2e
2019-02-05 10:05:52 +00:00
TreeHugger Robot
f0513785ed Merge "Revert "Convert RollbackTest Android.mk to an Android.bp."" 2019-02-04 18:05:32 +00:00
Richard Uhler
4937fadf67 Revert "Convert RollbackTest Android.mk to an Android.bp."
This reverts commit 0145c883e0.

Reason for revert: Causes the RollbackTest apps to be installed to the system partition, which breaks the rollback tests.
Bug: 123695037

Change-Id: I3ee89ecb370144c67fe88bb389abafdda59dc502
2019-02-04 12:51:58 +00:00
TreeHugger Robot
92f6c4c539 Merge "Make method private to fix checkstyle error." 2019-02-04 11:05:34 +00:00
Zimuzo
03eeb13794 Add statsd logging for RollbackHealthObserver events
Use new rollback status codes in RollbackPackageHealthObserver

Test: Builds ok
Bug: 120598832
Change-Id: If3aaf8f2c454f45b9d79c9dae5a21d356e4cf029
2019-01-31 21:19:02 +00:00
Richard Uhler
4b80033434 Make method private to fix checkstyle error.
Checkstyle wants all public methods to have javadocs. Rather than add
javadocs for this method, mark it private, which is more appropriate.

Bug: 112431924
Test: atest RollbackTest
Change-Id: I438d16b0e4164482ba5f6527aecd50c65ce41418
2019-01-31 15:29:04 +00:00
Richard Uhler
39e2a4394e Merge "Convert RollbackTest Android.mk to an Android.bp." 2019-01-31 09:26:22 +00:00
Zimuzo
c119780925 Fix null RollbackManager in RollbackHealthObserver and minor todos
1. RollbackManager was instantiated by Context#getSystemService in
   RollbackHealthObserver. At this time, RollbackManager has not yet
   been published as a service to the system, so RollbackManager was null.
   We now #getSystemService lazily so RollbackManager is never null.
2. Pass causePackages from RollbackHealthObserver to RollbackManager
3. Also fixed flaky ignored test exercising PackageWatchdog auto rollback

Test: atest RollbackTest
Bug: 123615508 112431924

Change-Id: I8f15c257b1efd96a96656405d3d7f74576a32c8e
2019-01-30 14:37:03 +00:00
Richard Uhler
0145c883e0 Convert RollbackTest Android.mk to an Android.bp.
Which is more convenient for building a dummy apex module to test
rollback of staged installs.

Bug: 112431924
Test: atest RollbackTest

Change-Id: I30c2fc7d37ca30e47b49012edc02a1fc637ba6f6
2019-01-29 16:14:36 +00:00
Richard Uhler
2a48c29cb6 Specify status results for RollbackManager.commitRollback.
Rather than implicitly reusing the PackageInstaller status codes.

Bug: 112431924
Test: atest RollbackTest
Change-Id: I86929c0c1a5153c7f58e255e104b30fe96ddeca8
2019-01-29 13:35:56 +00:00
Richard Uhler
bf5b5c4461 Add a way to record causePackages for rollbacks.
By passing a new causePackages list of VersionedPackage to
commitRollback and adding a RollbackInfo.getCausePackages() method to
retrieve the cause packages for committed rollbacks.

Bug: 112431924
Test: atest RollbackTest
Change-Id: I3b52511fd7e31b6304e7a7c34180dbb4d20f6dbf
2019-01-29 09:20:19 +00:00
Richard Uhler
e87368e1fd Commit rollbacks by ID, not by RollbackInfo.
To make it clear that the system only pays attention to the provided
rollback ID when committing a rollback.

Also, rename executeRollback to commitRollback in IRollbackManager.aidl,
now that we are touching the code anyway.

Bug: 112431924
Test: atest RollbackTest
Change-Id: I315e75c39019536fb2f090a0c84ed4cf7c03ce8c
2019-01-28 12:39:05 +00:00
Richard Uhler
4b092ef6f7 Use "commit" instead of "execute" for rollbacks.
Which makes more sense for rollback of staged installs, where the caller
will have to reboot the device before the rollback takes effect.

Internal references to "execute" in IRollbackManager.aidl and the
rollback manager service implementation will be renamed in a follow up
CL.

Bug: 112431924
Test: atest RollbackTest
Change-Id: Ic2bb479873b309fc145e4eda3b347849ac219ac9
2019-01-25 14:56:02 +00:00
Richard Uhler
dca7beb740 Rename PACKAGE_ROLLBACK_EXECUTED to ROLLBACK_COMMITTED.
Because there's no need to distinguish between package and other kinds
of rollbacks, and for rollback of staged installs, committed is a more
appropriate name than executed.

Bug: 112431924
Test: atest RollbackTest
Change-Id: I2a409de29ba82a7a3df2fd0b17f939795caa61d5
2019-01-25 14:23:27 +00:00
Richard Uhler
beb7e38f39 Use RollbackManager.getAvailableRollbacks in RollbackTest
Instead of getAvailableRollback and getPackagesWithAvailableRollbacks,
which are soon to be removed.

Bug: 112431924
Test: atest RollbackTest
Change-Id: Ia69342a41bebb91a9fa8044ef8d8b495aba7187f
2019-01-25 14:23:26 +00:00
Richard Uhler
0a79b32332 Include all relevant packages in RollbackInfo.
Instead of a single target package. Needed for rollback of multiPackage
installs.

Additionally, expose this information by a public method rather than a
public field.

Bug: 112431924
Test: atest RollbackTest
Change-Id: I6e3ce87385abd37c48047db27bc443d3719ee023
2019-01-25 10:19:31 +00:00
Zimuzo
c4073cc206 Add RollbackPackageHealthObserver
With the help of PackageWatchdog, RollbackPackageHealthObserver will
monitor packages after enabling rollbacks and will execute the rollback
automatically if it detects frequent crashes.

Test: atest RollbackTest
Bug: 112431924
Change-Id: Ic85464583f7c6b0778d853a87670d250a42c33de
2019-01-24 15:07:35 +00:00
Richard Uhler
f8f1b38fd1 Remove package name from ROLLBACK_EXECUTED broadcast.
The receiver of the broadcast would likely want to query the rolled back
packages via RollbackManager regardless, and it's not clear which
package to put when an atomic set of packages is rolled back.

Bug: 112431924
Test: atest RollbackTest
Change-Id: Ic8db00b62d8993e00a0dd2cb79ae68c430b45bb8
2019-01-23 13:22:44 +00:00
Richard Uhler
a7e9b2db4b Use VersionedPackage in PackageRollbackInfo.
Rather than defining a new custom PackageRollbackInfo.PackageVersion
type.

Also clean up PackageRollbackInfo API by replacing public fields with
methods and picking better names.

Bug: 112431924
Test: atest RollbackTest
Change-Id: I68a91e07b8745df9c5ecb22fdccbfcd76385814a
2019-01-23 11:02:56 +00:00
Narayan Kamath
869f706d86 RollbackManager: Support userdata snapshot / restore.
The only significant missing piece of functionality is the
handling of credential encrypted data in the case where one
or more users haven't unlocked their device. This will be handled
in a follow-up change.

Bug: 112431924
Test: atest RollbackTest
Change-Id: I4582018337ce0344379f6f73d6fd6c9ce31c58a0
2019-01-22 17:00:13 +00:00
Richard Uhler
31bc9606dd Improve test coverage of rollback data persistence.
Tests that we properly persist data about multiple available rollbacks
and available multi-package rollbacks.

Test: atest RollbackTest
Bug: 112431924
Change-Id: Ib31a0388e6420a942fac00f27fef33c0a866ea0b
2019-01-17 09:30:50 +00:00
Richard Uhler
f1910c5aa5 Add support for rollback of multiPackage installs.
The RollbackManager APIs still need to be updated to expose information
about dependant rollbacks.

Test: atest RollbackTest, with multiPackage test now enabled.
Bug: 112431924
Change-Id: Ib05902aa2bc8b8e228ad6faf3d9418190c5bc946
2019-01-11 10:43:18 +00:00
Richard Uhler
2d7c7f0d68 Make rollbacks available only after session commit.
In preparation for supporting rollback of multi-package installs, where
we need to use the SessionInfo to determine what the multi-package
install sets are.

Expire rollbacks relative to when they were committed, not when they
were first enabled.

Test: atest RollbackTest
Bug: 112431924

Change-Id: Ia8795813157ede3c1c5c5429d7b711db88c3e91a
2019-01-11 09:41:15 +00:00
Richard Uhler
95bfe2f94b Add TEST_MAPPING for RollbackManagerService.
Test: atest, run from the rollback and RollbackTest directories.
Bug: 112431924
Change-Id: Ia57536a84461fcdabe6ff9a7ff3ba6f8c14be238
2019-01-07 10:35:35 +00:00
Richard Uhler
de7907a505 Add test for multi-package rollback.
The test is marked @Ignore for now because we don't yet properly support
rollback of multi-package installs.

Test: atest RollbackTest (with selinux disabled).
Test: atest RollbackTest fails without the @Ignore.
Bug: 112431924

Change-Id: Ia76d48756bc1078344dcf1f2c5696ab79eb0c40c
2019-01-03 09:16:54 +00:00
Richard Uhler
04e84e0ee9 Fix bug where RollbackManagerService ignores package name.
RollbackManagerService incorrectly ignores the package name passed to
getAvailableRollback and executeRollback.

This CL fixes the bug and adds a regression test. The infrastructure for
having multiple test apps in RollbackTest will also be useful for
testing rollback of multi-package installs.

Test: atest RollbackTest (with selinux disabled)
Bug: 112431924

Change-Id: I84c8fdeb97aba557a1f8fd2e71a2bb0d87b10636
2019-01-03 09:16:44 +00:00
Richard Uhler
1f67242cd9 Add test for user data rollback.
The test is currently marked @Ignore because we haven't implemented
support for user data rollback yet.

Test: atest RollbackTest (selinux disabled)
Test: atest RollbackTest fails without the @Ignore.
Bug: 112431924
Change-Id: I3f7906001c932969bdf2125d198f379bf35a99fb
2019-01-03 09:14:52 +00:00
Richard Uhler
c739c8c3f9 Make RollbackManager @SystemApi.
Require callers hold a new MANAGE_ROLLBACKS permission to interact with
the RollbackManager.

Bug: 112431924
Test: atest RollbackTest, with new test for permissions added,
      and with selinux in permissive mode.
Test: atest CtsPermission2TestCases:PermissionPolicyTest
Change-Id: I73f4f3457d85be580670cd69c89066d2cc348186
2019-01-02 09:19:45 +00:00
Richard Uhler
b29f145505 Add RollbackManagerService
This change adds RollbackManagerService as a new system service for
managing apk level rollbacks.

To work properly this requires additional selinux policy changes. Fails
gracefully in case of selinux denials, until we have a chance to sort
out the proper selinux policy.

Bug: 112431924
Bug: 116512606
Test: atest RollbackTest, with selinux enforcement off.
Test: atest CtsPermission2TestCases:PermissionPolicyTest
Change-Id: Id72aae9c4d8da9aaab3922ec9233ba335bc0198f
2018-12-31 12:38:07 +00:00