Don't allow update of a static shared library

Unless it's installed from adb which is necessary
to work for development purposes.

Bug: 140243304
Test: atest StaticSharedLibsHostTests
Change-Id: I8609797d563571b06344a4d1efc5903361e1bf41
This commit is contained in:
Rhed Jao
2020-09-04 14:20:32 +08:00
parent b0e58545c1
commit 4709c78879

View File

@@ -17758,12 +17758,10 @@ public class PackageManagerService extends IPackageManager.Stub
if (parsedPackage.isStaticSharedLibrary()) {
// Static libs have a synthetic package name containing the version
// and cannot be updated as an update would get a new package name,
// unless this is the exact same version code which is useful for
// development.
// unless this is installed from adb which is useful for development.
AndroidPackage existingPkg = mPackages.get(parsedPackage.getPackageName());
if (existingPkg != null
&& existingPkg.getLongVersionCode()
!= parsedPackage.getLongVersionCode()) {
&& (installFlags & PackageManager.INSTALL_FROM_ADB) == 0) {
throw new PrepareFailure(INSTALL_FAILED_DUPLICATE_PACKAGE,
"Packages declaring "
+ "static-shared libs cannot be updated");