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

Commit af8399a6 authored by Winson's avatar Winson
Browse files

Fix original-package support

This broke in P. Basic support was broken by a simple negation
issue with the logic that checks for the original package.

That, along with the suggestion in the bug to fix the renamed
package association means this should now work as expected,
carrying data over from a previous installed, differently named
package.

Bug: 131355130
Bug: 132749720
Bug: 111967720

Test: atest PackageManagerServiceHostTests

Change-Id: Ifc4c7af47c4b633cd27ba4a40b6baa0e27960d71
parent a621dad0
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -19,6 +19,9 @@ java_test_host {
        "tradefed",
        "junit",
    ],
    static_libs: [
        "frameworks-base-hostutils",
    ],
    test_suites: ["general-tests"],
    java_resources: [
        ":com.android.overlaytest.overlaid",
+1 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.overlaytest.remounted;

import static org.junit.Assert.fail;

import com.android.internal.util.test.SystemPreparer;
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test;

+2 −2
Original line number Diff line number Diff line
@@ -11053,7 +11053,7 @@ public class PackageManagerService extends IPackageManager.Stub
        } else {
            pkgSetting = result.pkgSetting;
            if (originalPkgSetting != null) {
                mSettings.addRenamedPackageLPw(parsedPackage.getPackageName(),
                mSettings.addRenamedPackageLPw(parsedPackage.getRealPackage(),
                        originalPkgSetting.name);
                mTransferredPackages.add(originalPkgSetting.name);
            }
@@ -11162,7 +11162,7 @@ public class PackageManagerService extends IPackageManager.Stub
    @GuardedBy("mLock")
    private @Nullable PackageSetting getOriginalPackageLocked(@NonNull AndroidPackage pkg,
            @Nullable String renamedPkgName) {
        if (!isPackageRenamed(pkg, renamedPkgName)) {
        if (isPackageRenamed(pkg, renamedPkgName)) {
            return null;
        }
        for (int i = ArrayUtils.size(pkg.getOriginalPackages()) - 1; i >= 0; --i) {
+3 −0
Original line number Diff line number Diff line
@@ -69,6 +69,9 @@
            "exclude-annotation": "androidx.test.filters.Suppress"
        }
      ]
    },
    {
      "name": "PackageManagerServiceHostTests"
    }
  ],
  "postsubmit": [
+33 −0
Original line number Diff line number Diff line
// Copyright (C) 2020 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.

java_test_host {
    name: "PackageManagerServiceHostTests",
    srcs: ["src/**/*.kt"],
    libs: [
        "tradefed",
        "junit",
        "truth-prebuilt",
    ],
    static_libs: [
        "frameworks-base-hostutils",
    ],
    test_suites: ["general-tests"],
    java_resources: [
        ":PackageManagerDummyAppVersion1",
        ":PackageManagerDummyAppVersion2",
        ":PackageManagerDummyAppVersion3",
        ":PackageManagerDummyAppOriginalOverride",
    ]
}
Loading