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

Commit 732493d2 authored by TYM Tsai's avatar TYM Tsai
Browse files

Prevent installing app with same package name as static shared lib

This change prevents a regular application from being installed if its
package name is already in use by an existing static shared library.

BUg: 340233132
Flag: EXEMPT bugfix
Test: atest CtsPackageInstallTestCases
Test: atest CtsPackageManagerTestCases
Test: atest android.os.cts.StaticSharedLibsHostTests#testHasSharedLibraryUableToInstallNamesakeApp
Test: manual test
1. install normal app and success
2. install TrichromeLibrary.apk and success
3. install the bug app and install failure.

Change-Id: I8dbcf59ebfabc7d11cfc373af6e4781aa778a390
parent a749bdc8
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -1737,6 +1737,15 @@ final class InstallPackageHelper {
                if (libraryInfo != null) {
                    signatureCheckPs = mPm.mSettings.getPackageLPr(libraryInfo.getPackageName());
                }
            } else {
                // To prevent a new package from being installed if its package name is
                // already in use by an existing static library on the system.
                WatchedLongSparseArray<SharedLibraryInfo> libraryInfos =
                        mSharedLibraries.getStaticLibraryInfos(parsedPackage.getPackageName());
                if (libraryInfos != null && libraryInfos.size() > 0) {
                    throw new PrepareFailure(INSTALL_FAILED_DUPLICATE_PACKAGE,
                            "The package name is same as an existing shared libs");
                }
            }

            if (signatureCheckPs != null) {