Merge "Invalidate the cache for APK-in-APEX" into rvc-dev am: 6959c37c5f
Change-Id: If9b900757161e218eb75c8536f9823035c0f13af
This commit is contained in:
@@ -479,6 +479,12 @@ public abstract class PackageManagerInternal {
|
|||||||
*/
|
*/
|
||||||
public abstract void pruneInstantApps();
|
public abstract void pruneInstantApps();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prunes the cache of the APKs in the given APEXes.
|
||||||
|
* @param apexPackages The list of APEX packages that may contain APK-in-APEX.
|
||||||
|
*/
|
||||||
|
public abstract void pruneCachedApksInApex(@NonNull List<PackageInfo> apexPackages);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The SetupWizard package name.
|
* @return The SetupWizard package name.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -351,6 +351,7 @@ import com.android.server.pm.dex.DexManager;
|
|||||||
import com.android.server.pm.dex.DexoptOptions;
|
import com.android.server.pm.dex.DexoptOptions;
|
||||||
import com.android.server.pm.dex.PackageDexUsage;
|
import com.android.server.pm.dex.PackageDexUsage;
|
||||||
import com.android.server.pm.dex.ViewCompiler;
|
import com.android.server.pm.dex.ViewCompiler;
|
||||||
|
import com.android.server.pm.parsing.PackageCacher;
|
||||||
import com.android.server.pm.parsing.PackageInfoUtils;
|
import com.android.server.pm.parsing.PackageInfoUtils;
|
||||||
import com.android.server.pm.parsing.PackageParser2;
|
import com.android.server.pm.parsing.PackageParser2;
|
||||||
import com.android.server.pm.parsing.library.PackageBackwardCompatibility;
|
import com.android.server.pm.parsing.library.PackageBackwardCompatibility;
|
||||||
@@ -24231,6 +24232,25 @@ public class PackageManagerService extends IPackageManager.Stub
|
|||||||
mInstantAppRegistry.pruneInstantApps();
|
mInstantAppRegistry.pruneInstantApps();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void pruneCachedApksInApex(@NonNull List<PackageInfo> apexPackages) {
|
||||||
|
if (mCacheDir == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final PackageCacher cacher = new PackageCacher(mCacheDir);
|
||||||
|
synchronized (mLock) {
|
||||||
|
for (int i = 0, size = apexPackages.size(); i < size; i++) {
|
||||||
|
final List<String> apkNames =
|
||||||
|
mApexManager.getApksInApex(apexPackages.get(i).packageName);
|
||||||
|
for (int j = 0, apksInApex = apkNames.size(); j < apksInApex; j++) {
|
||||||
|
final AndroidPackage pkg = getPackage(apkNames.get(j));
|
||||||
|
cacher.cleanCachedResult(new File(pkg.getCodePath()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSetupWizardPackageName() {
|
public String getSetupWizardPackageName() {
|
||||||
return mSetupWizardPackage;
|
return mSetupWizardPackage;
|
||||||
|
|||||||
@@ -1226,8 +1226,9 @@ public class StagingManager {
|
|||||||
// APEX checks. For single-package sessions, check if they contain an APEX. For
|
// APEX checks. For single-package sessions, check if they contain an APEX. For
|
||||||
// multi-package sessions, find all the child sessions that contain an APEX.
|
// multi-package sessions, find all the child sessions that contain an APEX.
|
||||||
if (hasApex) {
|
if (hasApex) {
|
||||||
|
final List<PackageInfo> apexPackages;
|
||||||
try {
|
try {
|
||||||
final List<PackageInfo> apexPackages = submitSessionToApexService(session);
|
apexPackages = submitSessionToApexService(session);
|
||||||
for (int i = 0, size = apexPackages.size(); i < size; i++) {
|
for (int i = 0, size = apexPackages.size(); i < size; i++) {
|
||||||
validateApexSignature(apexPackages.get(i));
|
validateApexSignature(apexPackages.get(i));
|
||||||
}
|
}
|
||||||
@@ -1235,6 +1236,10 @@ public class StagingManager {
|
|||||||
session.setStagedSessionFailed(e.error, e.getMessage());
|
session.setStagedSessionFailed(e.error, e.getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final PackageManagerInternal packageManagerInternal =
|
||||||
|
LocalServices.getService(PackageManagerInternal.class);
|
||||||
|
packageManagerInternal.pruneCachedApksInApex(apexPackages);
|
||||||
}
|
}
|
||||||
|
|
||||||
notifyPreRebootVerification_Apex_Complete(session.sessionId);
|
notifyPreRebootVerification_Apex_Complete(session.sessionId);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package com.android.server.pm.parsing;
|
|||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.content.pm.PackageParserCacheHelper;
|
import android.content.pm.PackageParserCacheHelper;
|
||||||
|
import android.os.FileUtils;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.system.ErrnoException;
|
import android.system.ErrnoException;
|
||||||
import android.system.Os;
|
import android.system.Os;
|
||||||
@@ -197,4 +198,18 @@ public class PackageCacher {
|
|||||||
Slog.w(TAG, "Error saving package cache.", e);
|
Slog.w(TAG, "Error saving package cache.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete the cache files for the given {@code packageFile}.
|
||||||
|
*/
|
||||||
|
public void cleanCachedResult(@NonNull File packageFile) {
|
||||||
|
final String packageName = packageFile.getName();
|
||||||
|
final File[] files = FileUtils.listFilesOrEmpty(mCacheDir,
|
||||||
|
(dir, name) -> name.startsWith(packageName));
|
||||||
|
for (File file : files) {
|
||||||
|
if (!file.delete()) {
|
||||||
|
Slog.e(TAG, "Unable to clean cache file: " + file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user