Commit Graph

75 Commits

Author SHA1 Message Date
shafik
2340e8bca1 Add host side test for secondary user rollback
Run RollbackTest#testBasic only under a secondary user.

The host-driven test adds a new user and then installs the TEST (not the
test app) for that new user.
Note: this was the missing step in the previous attempt to test
RollbackTest under a secondary user.

Test: atest SecondaryUserRollbackTest
Test: test failed when multiuser support was removed from rollback
manager
Test: adb shell pm list packages --user 11 | grep rollback while running
the test in order to make sure the test is installing packages for the right user

Bug: 133852817
Bug: 129747710
Change-Id: Id1e54769cc2a9631d1464c07bad2b685f78689bc
2019-06-19 17:42:18 +01:00
Richard Uhler
efc38fd24e Reduce ENABLE_ROLLBACK timeout to 0 for timeout test.
testEnableRollbackTimeoutFailsRollback works by setting the enable
rollback timeout to 1 millisecond so that we will always time out, but
the test is failing some times because apparently we enable rollback
within the 1 millisecond limit. Reduce the timeout to 0 milliseconds to
try and reduce test flakiness.

Before lowering the timeout, the test failure was easy to reproduce
locally. After lowering the timeout I have not once been able to
reproduce the test failure locally.

Bug: 134373106
Test: atest RollbackTest:com.android.tests.rollback.RollbackTest#testEnableRollbackTimeoutFailsRollback
Change-Id: Ia25561831616dd2f2644743a399b49e35d5d4ea4
2019-06-06 14:06:52 +01:00
Zimuzo
e77a3e1de2 Add network health check watchdog triggered rollback tests
This cl improves code coverage for the PackageWatchdog explicit health
checks.

Updating the NetworkStack triggers an explicit health check with
a time deadline. At the deadline, if network is unavailable on the device,
the update is rolled back, if network is available, nothing happens.

Bug: 132640467
Test: atest StagedRollbackTest

Change-Id: I16a40244de9345930a1c981188aa33546fe872fc
2019-05-30 13:30:26 +01:00
Dario Freni
27ef26c880 Remove tests already covered by CTS.
Bug: 132429173
Bug: 127933960
Test: atest --test-mapping
frameworks/base/services/core/java/com/android/server/rollback/
Change-Id: I88685044d046180866c3cb63538a700cec775fc5
2019-05-22 15:16:37 +01:00
Richard Uhler
bf1bf9607d Add watchdog triggered staged rollback test
Test: atest StagedRollbackTest
Bug: 132758573
Bug: 132866890
Change-Id: I80e4ebf3659702992f32504690ea5ec4bab88534
2019-05-17 14:38:34 +01:00
shafik
4831ad7039 Fail to enable rollback if enable rollback times out
Make PackageManager send a ACTION_CANCEL_ENABLE_ROLLBACK intent to
RollbackManager. RollbackManager marks the relevant rollback as invalid.
Allow enable rollback to continue as usual, before making the rollback
available, RollbackManager checks whether it's valid. If it's not, the
rollback data is deleted.

Add a test case for expired rollback enabling attempt in RollbackTest.

Test: atest RollbackTest#testEnableRollbackTimeoutFailsRollback
Test: manual -
      * Set ENABLE_ROLLBACK_TIMEOUT_MILLIS to 1 ms using DeviceConfig
      * Install a mainline module with rollback enabled
      * adb shell dumpsys rollback
      * observe that no rollback was made available
Fixes: 131679409

Change-Id: Iaa4dbff002b820aff1fc3e1b985f129cf5ebe2e6
2019-05-09 12:38:04 +01:00
TreeHugger Robot
df10681a03 Merge "Fix handling of multi-package enable rollback failures." into qt-dev 2019-05-03 11:31:34 +00:00
Richard Uhler
4756970d3f Fix handling of multi-package enable rollback failures.
Failure to enable rollback for one of the packages in a multi-package
install should fail to enable rollback for all packages in the
multi-package install. That was not the case prior to this CL, which
could lead to partial rollbacks.

Keep track of how many child sessions we expect to enable rollback for
and double check that we succeeded before making the rollback available.
This involves some cleanup of how we track parent vs child sessions when
enabling rollback.

Bug: 128656191
Test: atest RollbackTest, with new test added.

Change-Id: I737896cdc1915396748c5c1959b5397af793258a
2019-05-03 10:48:04 +01:00
Richard Uhler
2124d4b313 Ensure race between rollback and roll forward is properly handled
If rollback for a package is committed at the same time the package is
updated, it's possible we will incorrectly roll back the newly updated
version of the application.

Add a hidden API to the package installer that lets you set a required
existing version of a package to be updated. If the expected package
version is not installed at the time of commit, the update install
fails.

The RollbackManager uses this new API to ensure that rollback will fail
if the package in question was just updated.

Test: atest RollbackTest, with new test added and manual confirmation
      that the race condition was exercised by the new test.
Bug: 128831080

Change-Id: Ifa5627e257d2ef13e2b213ef0dbc93932797ce0d
2019-05-01 09:10:36 +00:00
Richard Uhler
1924d6dbb8 Expire rollback when apex is updated.
RollbackManager relies on package changed broadcasts to expire rollbacks
when an application is updated, but we don't receive package changed
broadcasts for apex.

This change adds an extra check when starting RollbackManager to see if
any apex versions have changed and expires rollbacks as appropriate.

Adds a test case to cover the scenario and refactors the test code
to properly set up the test apex in all cases with minimal reboots.

Bug: 126358044
Test: atest StagedRollbackTest, with new test added.
Change-Id: I7ea4953e4aff8d1c7560d6c61e6be5e4e8e1f194
2019-04-26 13:22:51 +01:00
Richard Uhler
e846376e62 Add test for rollback of same version apk.
The test is marked @Ignore because of a bug in RollbackManager that
fails to expire a rollback when there is a new update of an apk to its
same version code:

STACKTRACE:
java.lang.AssertionError: expected null, but was:<android.content.rollback.RollbackInfo@28c0495>
  at org.junit.Assert.fail(Assert.java:88)
  at org.junit.Assert.failNotNull(Assert.java:755)
  at org.junit.Assert.assertNull(Assert.java:737)
  at org.junit.Assert.assertNull(Assert.java:747)
  at com.android.tests.rollback.RollbackTestUtils.getUniqueRollbackInfoForPackage(RollbackTestUtils.java:321)
  at com.android.tests.rollback.RollbackTest.testSameVersionUpdate(RollbackTest.java:795)

Bug: 120200473
Test: atest RollbackTest
Change-Id: Ib03692c170ee689fcf667689dad25647e55f984f
2019-04-23 15:58:33 +01:00
Richard Uhler
0741b41d94 Block getAvailableRollbacks on the handler thread.
To reduce flakiness in the CTS test, which checks for an available
rollback immediately after an app update is committed.

Remove sleeps from the RollbackTest that should no longer be needed.

Test: atest RollbackTest CtsRollbackManagerTestCases
Bug: 127933960
Change-Id: I60adb0f58eaba02d08ecd44b44866a8505c58238
2019-03-27 15:20:06 +00:00
Richard Uhler
fbac4ca9ad Fix issues with RollbackTest
* Add missing permission needed in testBadUpdateRollback test.
* Re-enable testRollbackWithSplits test now that the build issues have
  been sorted out.

Bug: 127920549
Test: atest RollbackTest
Change-Id: I5bd70aea4f1ad0345d7a37e78c0f3b5ef0615ed1
2019-03-21 11:12:12 +00:00
TreeHugger Robot
a1feb4cd63 Merge "Refine broadcast in commitRollback" 2019-03-20 19:12:02 +00:00
Zimuzo Ezeozue
1c6c5dece8 Merge "Fix flaky RollbackTest#testBadUpdateRollback" 2019-03-20 17:21:20 +00:00
shafik
74fec184ac Refine broadcast in commitRollback
Silence qualified user warning by using sendBroadcastAsUser.
The user is UserHandle.SYSTEM.
Limit recievers to those holding MANAGE_ROLLBACKS permission.

Test: warning does not appear in logcat when running atest RollbackTest
Fixes: 128280826
Change-Id: I85b905d2b20f3993859ec87948f309c1934a4a26
2019-03-20 17:05:47 +00:00
Zimuzo
790a3ccfa6 Fix flaky RollbackTest#testBadUpdateRollback
Added wait for ACTION_ROLLBACK_COMMITTED and also
minor RollbackTestUtils refactoring.

Test: atest RollbackTest
Bug: 126497394
Change-Id: Ia31b98974733ea19cd73c2688971ea853834e195
2019-03-20 14:39:11 +00:00
Richard Uhler
ce844797cd Merge "Only allow rollback to be enabled on modules." 2019-03-20 09:40:13 +00:00
Matt Pape
12187ae675 Remove interface for Rollback and Rollback Boot.
Per API council feedback, we are making changes to include only the
namespace in the system API defined in DeviceConfig.java. Strings which
define property names should be defined in code local to the feature
instead.

Bug: 126411407
Test: atest FrameworksCoreTests:DeviceConfigTest
      atest FrameworksServicesTests:PackageManagerServiceTest

Change-Id: Ie3b0539f51a582fb7583ece88e5d3bde0cc1efd7
2019-03-18 13:20:44 -07:00
Richard Uhler
1fc10c1209 Only allow rollback to be enabled on modules.
Only allow rollback to be enabled on the modules included in a mainline
update. We don't want to support rollbacks for all apks in general yet.

Enforce that only installers granted the MANAGE_ROLLBACKS permission can
enable rollback for a package.

Introduce a new TEST_MANAGE_ROLLBACKS permission that can be used to
enable rollback on packages that are not modules. This allows us to
continue testing rollbacks, given we can't do a mainline update as part
of the rollback tests.

Test: atest RollbackTest, with new tests for permissions added.
Bug: 128277794
Change-Id: I29ab9a750a1283592b8a855322ece516e42260ca
2019-03-18 14:05:28 +00:00
Shafik Nassar
ddb007f669 Merge "Test staged rollback for apk and apex install" 2019-03-13 00:29:09 +00:00
shafik
26b3e5b955 Test staged rollback for apk and apex install
In addition, add some methods to RollbackTestUtils to make old code
reusable for the new test.

Bug: 124043688
Test: atest StagedRollbackTest
Change-Id: I2b259671861c4081f13922f03ea2e251568e06bc
2019-03-12 12:19:14 +00:00
Richard Uhler
8a9774550d Use test stubs for RollbackTests, not system stubs.
Adds @TestApi for all system apis needed for RollbackTests.

Removes @SystemApi for RollbackManager.expireRollbackForPackage and
RollbackManager.reloadPersistedData, which were always intended to be
used solely for testing.

Bug: 127282563
Test: atest RollbackTest StagedRollbackTest
Change-Id: I183b8a484b4a08f36fc19d64241ab408d28c64ca
2019-03-12 12:14:37 +00:00
shafik
92ea53f448 API cleanup: add boolean param to setEnableRollback
Mark PackageInstaller.SessionParams#setEnableRollback() as @removed and
@deprecated.
Add PackageInstaller.SessionParams#setEnableRollback(enable).
Replace old API usages in RollbackTestUtils with the new API.

Also, add PackageInstaller.SessionInfo#getEnableRollback().

Fixes: 127282838
Test: atest RollbackTest
Change-Id: I696680207be5ac06560d2abb525f91a100301b4c
2019-03-11 09:48:54 +00:00
TreeHugger Robot
1d5ead8dbf Merge "Avoid building RollbackTestApps into the device image." 2019-03-07 19:13:25 +00:00
Richard Uhler
a7291341e3 Avoid building RollbackTestApps into the device image.
The current approach for including built apks as java resources in
RollbackTest.apk appears to cause the RollbackTestApp apks to be
included in the device release image. Convert the Android.mk for
RollbackTest to Android.bp to work around this issue.

This breaks the split apk tests, but we can figure out how to address
that later. Marking the split apk tests @Ignore for now.

Bug: 123695037
Bug: 127520966
Test: make -j80 dist tests, verify no RollbackT*.apk is included in the
      built device image.
Test: atest RollbackTest; atest StagedRollbackTest, verify no
      RollbackT*.apk is included in the built system image.

Change-Id: Ib413785b0974faddf19ac8dd7387b2642dab37e4
2019-03-07 14:57:53 +00:00
shafik
f90c69f42f Test Rollback Manager can handle time change
Test flow:
	* Install app A with rollback enabled
	* Wait half of the expiration time
	* Install app B with rollback enabled
	* Move time forward by expiration time
	* Wait half of the expiration time
	- At this point, an expiration check should run and expire app A
	but not app B
	* Assert app A rollback is expired
	* Assert app B rollback is not expired
	* Wait half of the expiration time
	* Assert app B rollback is expired

Note: installing app A before app B is done solely to schedule an
expiration check before app B rollback has expired

Test: atest RollbackTest#testTimeChangeDoesNotAffectLifetime
Test: run the same test without the registering the time change handler
in RollbackManagerServiceImpl - test fails
Bug: 124095332

Change-Id: I4bc2d449e4195e059fa43e7568783683a60e2197
2019-03-05 10:55:53 +00:00
Brett Chabot
502ec7ae4b Migrate remainder of frameworks/base to androidx.test
See go/jetpack-test-android-migration

Exempt-From-Owner-Approval: automated package name refactoring

Test: m  m -j BroadcastRadioTests KeystoreTests mediaframeworktest ActivityManagerPerfTests AppLaunch AppLaunchWear BackgroundDexOptServiceIntegrationTests AppCompatibilityTest DynamicCodeLoggerIntegrationTests FlickerLibTest InternalTests PackageWatchdogTest RcsTests RollbackTestAppAv1 RollbackTestAppAv2 RollbackTestAppACrashingV2 RollbackTestAppBv1 RollbackTestAppBv2 RollbackTestAppASplitV1 RollbackTestAppASplitV2 RollbackTest ServiceCrashTest UsageStatsPerfTests UsbTests WindowAnimationJank
Change-Id: I32fe3297656eec6060da6c7e24582bcd5315fb16
2019-03-02 00:35:17 +00:00
Richard Uhler
e79a94198a Test for userdata restore in staged rollback test.
Bug: 124044231
Test: frameworks/base/tests/RollbackTest$ atest
Change-Id: Ic323b2e45c05ac4706d96fe15b109fdceaf53da4
2019-03-01 09:29:01 +00:00
TreeHugger Robot
94e316b413 Merge "Test Rollback Expiration lifetime" 2019-02-26 19:34:48 +00:00
shafik
6d61f5e505 Test Rollback Expiration lifetime
Add a test that checks whether the rollback data is expired after the
lifetime duration expires.
Since the default expiration time is 48 hours, the test first changes
the expiration time to a more reasonable (and testable) amount.

Flow:
	* Change rollback lifetime duration to 30s
	* Install v1 of an app
	* Install v2 of an app (with rollback enabled)
	* Check that package rollback is available
	* Wait for the lifetime duration
	* Check that package is not available for rollback

Test: atest RollbackTest
Test: atest RollbackTest#testRollbackExpiresAfterLifetime
Bug: 124096729
Change-Id: I4c6b3df14ed7b98b72d3c8a49a0dd5b2e864e2b2
2019-02-26 16:04:31 +00:00
Richard Uhler
ab009ea44c RollbackManager: Backup and restore split apks.
Previously RollbackManager would only backup and restore the base apk
for a package. This change fixes it to backup and restore split apks as
well.

Adds a new test for rollback of packages built with splits.

Also, switch to using resources to distinguish between v1 and v2 of an
application instead of meta-data, given we use resources anyway now to
distinguish between split versions.

Bug: 124848643
Test: atest RollbackTest, with new test for splits added.
Change-Id: Id1f32db7b728bdeda6c7223bc69a7e80ba569dda
2019-02-26 16:02:44 +00:00
Dario Freni
60a96c1791 Add "Staged" to API related to staged sessions.
Also, throw an IllegalArgumentException is these APIs are called on
sessions that are not marked as staged.

Test: tested new apis with an ad-hoc app. atest RollbackTest
StagedRollbackTest
Fix: 124507718

Change-Id: I3529aaff404d644ab6dad98f29411141e8df865d
2019-02-25 13:09:48 +00:00
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