fix system app's abi error after uninstall updated version.
When uninstall an updated system app, we always did as following steps. First we delete data structure by calling deleteInstalledPackageLIF(), then enable it from disabled system packages and re-adding to PackageSettings map by calling addPackageLPw(). At last re-installing apps in system partition with scanPackageTracedLI(). But if an package with sharedUserId readded failed with exception of 'Adding duplicate shared id: xxx', then we cann't reuse it's derived CPU Abis from settings, others we could get CPU Abis uninitialized errors. Test: Manual; Update an system app with sharedUserId Test: Manual; Uninstall and ensure it run ok Change-Id: Icfda17c5004d291c664ed80d578aca4b7cf4a975 Signed-off-by: liulvping <liulvping@xiaomi.com>
This commit is contained in:
@@ -10160,6 +10160,7 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
// them in the case where we're not upgrading or booting for the first time.
|
||||
String primaryCpuAbiFromSettings = null;
|
||||
String secondaryCpuAbiFromSettings = null;
|
||||
boolean needToDeriveAbi = (scanFlags & SCAN_FIRST_BOOT_OR_UPGRADE) != 0;
|
||||
|
||||
// writer
|
||||
synchronized (mPackages) {
|
||||
@@ -10237,11 +10238,14 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
}
|
||||
}
|
||||
|
||||
if ((scanFlags & SCAN_FIRST_BOOT_OR_UPGRADE) == 0) {
|
||||
if (!needToDeriveAbi) {
|
||||
PackageSetting foundPs = mSettings.getPackageLPr(pkg.packageName);
|
||||
if (foundPs != null) {
|
||||
primaryCpuAbiFromSettings = foundPs.primaryCpuAbiString;
|
||||
secondaryCpuAbiFromSettings = foundPs.secondaryCpuAbiString;
|
||||
} else {
|
||||
// when re-adding a system package failed after uninstalling updates.
|
||||
needToDeriveAbi = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10446,7 +10450,7 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
final String cpuAbiOverride = deriveAbiOverride(pkg.cpuAbiOverride, pkgSetting);
|
||||
|
||||
if ((scanFlags & SCAN_NEW_INSTALL) == 0) {
|
||||
if ((scanFlags & SCAN_FIRST_BOOT_OR_UPGRADE) != 0) {
|
||||
if (needToDeriveAbi) {
|
||||
Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "derivePackageAbi");
|
||||
final boolean extractNativeLibs = !pkg.isLibrary();
|
||||
derivePackageAbi(pkg, scanFile, cpuAbiOverride, extractNativeLibs,
|
||||
|
||||
Reference in New Issue
Block a user