Merge changes from topics "delete_odex", "verify-prof" am: 4ebbeba91b
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1735259 Change-Id: Iffd57180322992d75a9d2bd70b029e0798d58a16
This commit is contained in:
@@ -557,13 +557,17 @@ public class Installer extends SystemService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteOdex(String apkPath, String instructionSet, String outputPath)
|
/**
|
||||||
|
* Deletes the optimized artifacts generated by ART and returns the number
|
||||||
|
* of freed bytes.
|
||||||
|
*/
|
||||||
|
public long deleteOdex(String apkPath, String instructionSet, String outputPath)
|
||||||
throws InstallerException {
|
throws InstallerException {
|
||||||
if (!checkBeforeRemote()) return;
|
if (!checkBeforeRemote()) return -1;
|
||||||
BlockGuard.getVmPolicy().onPathAccess(apkPath);
|
BlockGuard.getVmPolicy().onPathAccess(apkPath);
|
||||||
BlockGuard.getVmPolicy().onPathAccess(outputPath);
|
BlockGuard.getVmPolicy().onPathAccess(outputPath);
|
||||||
try {
|
try {
|
||||||
mInstalld.deleteOdex(apkPath, instructionSet, outputPath);
|
return mInstalld.deleteOdex(apkPath, instructionSet, outputPath);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw InstallerException.from(e);
|
throw InstallerException.from(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25555,14 +25555,14 @@ public class PackageManagerService extends IPackageManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void deleteOatArtifactsOfPackage(String packageName) {
|
long deleteOatArtifactsOfPackage(String packageName) {
|
||||||
final AndroidPackage pkg;
|
final AndroidPackage pkg;
|
||||||
final PackageSetting pkgSetting;
|
final PackageSetting pkgSetting;
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
pkg = mPackages.get(packageName);
|
pkg = mPackages.get(packageName);
|
||||||
pkgSetting = mSettings.getPackageLPr(packageName);
|
pkgSetting = mSettings.getPackageLPr(packageName);
|
||||||
}
|
}
|
||||||
mDexManager.deleteOptimizedFiles(ArtUtils.createArtPackageInfo(pkg, pkgSetting));
|
return mDexManager.deleteOptimizedFiles(ArtUtils.createArtPackageInfo(pkg, pkgSetting));
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<String> getUnusedPackages(long downgradeTimeThresholdMillis) {
|
Set<String> getUnusedPackages(long downgradeTimeThresholdMillis) {
|
||||||
|
|||||||
@@ -1034,18 +1034,26 @@ public class DexManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes all the optimizations files generated by ART.
|
* Deletes all the optimizations files generated by ART.
|
||||||
|
* This is best effort, and the method will log but not throw errors
|
||||||
|
* for individual deletes
|
||||||
|
*
|
||||||
* @param packageInfo the package information.
|
* @param packageInfo the package information.
|
||||||
|
* @return the number of freed bytes or -1 if there was an error in the process.
|
||||||
*/
|
*/
|
||||||
public void deleteOptimizedFiles(ArtPackageInfo packageInfo) {
|
public long deleteOptimizedFiles(ArtPackageInfo packageInfo) {
|
||||||
|
long freedBytes = 0;
|
||||||
|
boolean hadErrors = false;
|
||||||
for (String codePath : packageInfo.getCodePaths()) {
|
for (String codePath : packageInfo.getCodePaths()) {
|
||||||
for (String isa : packageInfo.getInstructionSets()) {
|
for (String isa : packageInfo.getInstructionSets()) {
|
||||||
try {
|
try {
|
||||||
mInstaller.deleteOdex(codePath, isa, packageInfo.getOatDir());
|
freedBytes += mInstaller.deleteOdex(codePath, isa, packageInfo.getOatDir());
|
||||||
} catch (InstallerException e) {
|
} catch (InstallerException e) {
|
||||||
Log.e(TAG, "Failed deleting oat files for " + codePath, e);
|
Log.e(TAG, "Failed deleting oat files for " + codePath, e);
|
||||||
|
hadErrors = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return hadErrors ? -1 : freedBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class RegisterDexModuleResult {
|
public static class RegisterDexModuleResult {
|
||||||
|
|||||||
Reference in New Issue
Block a user