This test makes assertions about the case where there are two
users running a test application. It verifies that each user can
have its own unique userdata for the same app, and that upgrades
and downgrades are applicable for all users on the device.
Test: atest MultiUserRollbackTest
Test: atest RollbackTest
Bug: 140401995
Change-Id: I77a18cf99ec8d7f30696119919dae8859f9fb25b
Merged-In: I5e5c154758b3f0e4731696c813519ac798fbbae9
Bumps a timeout from 1 minute to 5 minutes, because in practice a lot
more needs to happen in that time window than we expect to fit in 1
minute.
Bug: 140223710
Test: atest StagedRollbackTest:com.android.tests.rollback.host.StagedRollbackTest#testNativeWatchdogTriggersRollback
Change-Id: I2e937f8e1f87356815a834241ad5e9ec1e953892
Merged-In: I2a98e71102fc1cbf6ea712e070d6db49cdb05cba
We no longer block on the handler thread in getAvailableRollbacks. That
means it is possible we see an available rollback left over from a
previous test run. Update the test to ensure previous rollbacks are
removed and give sufficient time to make a new rollback available before
concluding that no rollback will be made available in this case.
Test: atest RollbackTest:com.android.tests.rollback.RollbackTest#testEnableRollbackTimeoutFailsRollback
Change-Id: I8b22320bb3ee60152ab808706913eff43ab7cc9f
Merged-In: Id94d5452836b07d6f802758bd0dfdd3c276a3c05
This changes RollbackTest to retry checks for available rollbacks for
a certain period of time, using a new RollbackUtils method
waitForAvailableRollbacks.
Currently many of the tests in RollbackTest are flaky due to race conditions
between checking for available rollbacks and the installer onFinished callback.
This CL should fix all of those issues.
The previous attempt to resolve this by adding NewRollbacks speculatively to
the results of getAvailableRollbacks was not successful. This CL reverts that
change so that getAvailableRollbacks once again only returns rollbacks that are
actually available.
Bug: 136548146
Test: atest RollbackTest run on cuttlefish on acloud repeatedly
Change-Id: I0389ef2413e7642fe2f6ef1a33aef218dd1896ed
Merged-In: I27e2513b34f49af2f41cd627a5d2550541831e11
For the case where there are multiple users on the device,
the ROLLBACK_COMMITTED broadcast should be sent to all
users for which the package is being rolled back.
Test: atest RollbackTest
Test: atest SecondaryUserRollbackTest
Bug: 139060321
Change-Id: I901ff8a3331c7a8a8585c855a0caead347321d5d
Merged-In: I8e20da321f52ebf9e6d584a8c59d2a3106a32212
Test flow:
* Staged install com.google.android.modulemetadata
* Crash a native process (apexd) enough times to trigger a rollback
* Wait for device reboot (automatically)
* Assert rollback of com.google.android.modulemetadata has been
committed
Test: atest StagedRollbackTest#testNativeWatchdogTriggersRollback
Bug: 135864628
Change-Id: I5176cc7890e251e7ccc10abdfcfee3a5190721b2
Merged-In: Ibe726c140939190adb3db9c18b3b442ba59548a3
Add target_preparer for uninstalling TestApp.A and TestApp.B before
running SecondaryUserRollbackTest.
Also, fix the tearDown command after each case to uninstall the right
apps.
Test: atest SecondaryUserRollbackTest ; atest SecondaryUserRollbackTest
Bug: 136538996
Change-Id: I35edde58eb8b520f167bace7848956d091155158
Merged-In: I3d5decae03bf9d2f9d78a534399214da05a6d372
This test ensures that if a staged install is abandoned, and then
staged again, the userdata snapshot will match the correct rollback.
Since there will be multiple rollbacks in the ENABLING state for the
same package, it is important to ensure that the userdata for the
abandoned rollback is not used.
Test: atest StagedRollbackTest
Bug: 134035054
Change-Id: Ic977e747103c9a9a44592846de73287788cbac6d
Merged-In: Icae7226dfb393c5ffc31dd0116f61141e84f5a42
To eliminate flakiness when testing timeout conditions for
RollbackTest.testEnableRollbackTimeoutFailsRollback.
Test: atest RollbackTest.testEnableRollbackTimeoutFailsRollback in a loop
Bug: 134373106
Change-Id: I2d1de148a83231f3fd48cc05b7320fa5fdf091ce
Merged-In: I01f3e769711ffa51fa714ff4bc81e70887f427ad
Replace the usage of RollbackTestUtils with the API offered by
com.android.cts.install.lib and com.android.cts.rollback.lib.
Test: atest RollbackTest
Test: atest StagedRollbackTest #testBadApkOnly
Bug: 132757394
Bug: 132422403
Change-Id: I1d6789b4fb7ae94ebf7066a6fd215e4ac48c04df
Merged-In: I25cb9dca103852d7ee3691e4df927e1fc5848074
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: I9e13f2cdaf825a53846765fa52bc425045f41df1
Merged-In: Id1e54769cc2a9631d1464c07bad2b685f78689bc
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: I44f9e786d2a2285475ee423e34d06f5b5a5271e1
Merged-In: Ia25561831616dd2f2644743a399b49e35d5d4ea4
The network stack module may be implemented by NetworkStack (updatable
version built against stable SDK) or NetworkStackNext (test version
shipped only in system images, built against in-development SDK).
Bug: 144168912
Test: atest StagedRollbackTest
Merged-In: I1788e323f763ca88b69b082f38078bee3bfe480d
Change-Id: I963cc20ae4356f1728f6dd1bbf14f48ded978756
A proper fix for the flakiness has been submitted to more recent
versions of the RollbackTest.
Bug: 139108668
Bug: 139175593
Test: atest StagedRollbackTest
Change-Id: Iad20ac3744b0cf4adf0355150ce957de2a24304c
Merged-In: Iaaa728aa58d894ba546677e8295faba2ebfc5e64
The test is flaky because it is testing a race condition.
The flakiness is fixed with the help of some new @TestApi in
I01f3e769711ffa51fa714ff4bc81e70887f427ad. Disable the test on those
branches without the fix merged.
Bug: 134373106
Bug: 136605788
Test: atest RollbackTest
Change-Id: I05edfc142c14631b259ae7aaf2dd31af00363a35
Merged-In: I01f3e769711ffa51fa714ff4bc81e70887f427ad
(cherry picked from commit 75f942dfa807fe6d7b67d0ebca733e018fd66e02)
The test is flaky because it is testing a race condition.
The flakiness is fixed with the help of some new @TestApi in
I01f3e769711ffa51fa714ff4bc81e70887f427ad. Disable the test on those
branches without the fix merged.
Bug: 134373106
Bug: 136605788
Test: atest RollbackTest
Change-Id: I05edfc142c14631b259ae7aaf2dd31af00363a35
Merged-In: I01f3e769711ffa51fa714ff4bc81e70887f427ad
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
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
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
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
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
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
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
* 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
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
Added wait for ACTION_ROLLBACK_COMMITTED and also
minor RollbackTestUtils refactoring.
Test: atest RollbackTest
Bug: 126497394
Change-Id: Ia31b98974733ea19cd73c2688971ea853834e195
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
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
In addition, add some methods to RollbackTestUtils to make old code
reusable for the new test.
Bug: 124043688
Test: atest StagedRollbackTest
Change-Id: I2b259671861c4081f13922f03ea2e251568e06bc
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
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
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
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