Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 04e84e0e authored by Richard Uhler's avatar Richard Uhler
Browse files

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
parent 1f67242c
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -211,7 +211,8 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
            ensureRollbackDataLoadedLocked();
            for (int i = 0; i < mAvailableRollbacks.size(); ++i) {
                PackageRollbackData data = mAvailableRollbacks.get(i);
                if (data.info.higherVersion.equals(installedVersion)) {
                if (data.info.packageName.equals(packageName)
                        && data.info.higherVersion.equals(installedVersion)) {
                    // TODO: For atomic installs, check all dependent packages
                    // for available rollbacks and include that info here.
                    return new RollbackInfo(data.info);
@@ -308,7 +309,8 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
                PackageRollbackData available = mAvailableRollbacks.get(i);
                // TODO: Check if available.info.lowerVersion matches
                // rollback.targetPackage.lowerVersion?
                if (available.info.higherVersion.equals(installedVersion)) {
                if (available.info.packageName.equals(packageName)
                        && available.info.higherVersion.equals(installedVersion)) {
                    data = available;
                    break;
                }
+39 −11
Original line number Diff line number Diff line
@@ -14,27 +14,49 @@

LOCAL_PATH:= $(call my-dir)

# RollbackTestAppV1
# RollbackTestAppAv1.apk
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
LOCAL_MANIFEST_FILE := TestApp/AndroidManifestV1.xml
LOCAL_PACKAGE_NAME := RollbackTestAppV1
LOCAL_SDK_VERSION := current
LOCAL_SRC_FILES := $(call all-java-files-under, TestApp/src)
LOCAL_MANIFEST_FILE := TestApp/Av1.xml
LOCAL_PACKAGE_NAME := RollbackTestAppAv1
include $(BUILD_PACKAGE)
ROLLBACK_TEST_APP_V1 := $(LOCAL_INSTALLED_MODULE)
ROLLBACK_TEST_APP_AV1 := $(LOCAL_INSTALLED_MODULE)

# RollbackTestAppV2
# RollbackTestAppAv2.apk
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
LOCAL_MANIFEST_FILE := TestApp/AndroidManifestV2.xml
LOCAL_PACKAGE_NAME := RollbackTestAppV2
LOCAL_SDK_VERSION := current
LOCAL_SRC_FILES := $(call all-java-files-under, TestApp/src)
LOCAL_MANIFEST_FILE := TestApp/Av2.xml
LOCAL_PACKAGE_NAME := RollbackTestAppAv2
include $(BUILD_PACKAGE)
ROLLBACK_TEST_APP_V2 := $(LOCAL_INSTALLED_MODULE)
ROLLBACK_TEST_APP_AV2 := $(LOCAL_INSTALLED_MODULE)

# RollbackTestAppBv1.apk
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
LOCAL_SDK_VERSION := current
LOCAL_SRC_FILES := $(call all-java-files-under, TestApp/src)
LOCAL_MANIFEST_FILE := TestApp/Bv1.xml
LOCAL_PACKAGE_NAME := RollbackTestAppBv1
include $(BUILD_PACKAGE)
ROLLBACK_TEST_APP_BV1 := $(LOCAL_INSTALLED_MODULE)

# RollbackTestAppBv2.apk
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
LOCAL_SDK_VERSION := current
LOCAL_SRC_FILES := $(call all-java-files-under, TestApp/src)
LOCAL_MANIFEST_FILE := TestApp/Bv2.xml
LOCAL_PACKAGE_NAME := RollbackTestAppBv2
include $(BUILD_PACKAGE)
ROLLBACK_TEST_APP_BV2 := $(LOCAL_INSTALLED_MODULE)

# RollbackTest
include $(CLEAR_VARS)
@@ -43,11 +65,17 @@ LOCAL_PACKAGE_NAME := RollbackTest
LOCAL_MODULE_TAGS := tests
LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
LOCAL_COMPATIBILITY_SUITE := general-tests
LOCAL_JAVA_RESOURCE_FILES := $(ROLLBACK_TEST_APP_V1) $(ROLLBACK_TEST_APP_V2)
LOCAL_JAVA_RESOURCE_FILES := \
  $(ROLLBACK_TEST_APP_AV1) \
  $(ROLLBACK_TEST_APP_AV2) \
  $(ROLLBACK_TEST_APP_BV1) \
  $(ROLLBACK_TEST_APP_BV2)
LOCAL_SDK_VERSION := system_current
LOCAL_TEST_CONFIG := RollbackTest.xml
include $(BUILD_PACKAGE)

# Clean up local variables
ROLLBACK_TEST_APP_V1 :=
ROLLBACK_TEST_APP_V2 :=
ROLLBACK_TEST_APP_AV1 :=
ROLLBACK_TEST_APP_AV2 :=
ROLLBACK_TEST_APP_BV1 :=
ROLLBACK_TEST_APP_BV2 :=
+2 −2
Original line number Diff line number Diff line
@@ -15,14 +15,14 @@
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.tests.rollback.testapp"
    package="com.android.tests.rollback.testapp.A"
    android:versionCode="1"
    android:versionName="1.0" >


    <uses-sdk android:minSdkVersion="19" />

    <application android:label="Rollback Test App V1">
    <application android:label="Rollback Test App A v1">
        <meta-data android:name="version" android:value="1" />
        <receiver android:name="com.android.tests.rollback.testapp.ProcessUserData"
                  android:exported="true" />
+2 −2
Original line number Diff line number Diff line
@@ -15,14 +15,14 @@
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.tests.rollback.testapp"
    package="com.android.tests.rollback.testapp.A"
    android:versionCode="2"
    android:versionName="2.0" >


    <uses-sdk android:minSdkVersion="19" />

    <application android:label="Rollback Test App V2">
    <application android:label="Rollback Test App A v2">
        <meta-data android:name="version" android:value="2" />
        <receiver android:name="com.android.tests.rollback.testapp.ProcessUserData"
                  android:exported="true" />
+36 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2018 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.tests.rollback.testapp.B"
    android:versionCode="1"
    android:versionName="1.0" >


    <uses-sdk android:minSdkVersion="19" />

    <application android:label="Rollback Test App B v1">
        <meta-data android:name="version" android:value="1" />
        <receiver android:name="com.android.tests.rollback.testapp.ProcessUserData"
                  android:exported="true" />
        <activity android:name="com.android.tests.rollback.testapp.MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>
Loading