Return the freed bytes from deleteOdex API
This will help quantify the number of bytes we free for telemetry purposes. Test: installd_tests Bug: 187458876 Change-Id: I8900816699834e0801d2bd9c770468db9c9db924
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 {
|
||||
if (!checkBeforeRemote()) return;
|
||||
if (!checkBeforeRemote()) return -1;
|
||||
BlockGuard.getVmPolicy().onPathAccess(apkPath);
|
||||
BlockGuard.getVmPolicy().onPathAccess(outputPath);
|
||||
try {
|
||||
mInstalld.deleteOdex(apkPath, instructionSet, outputPath);
|
||||
return mInstalld.deleteOdex(apkPath, instructionSet, outputPath);
|
||||
} catch (Exception e) {
|
||||
throw InstallerException.from(e);
|
||||
}
|
||||
|
||||
@@ -25550,14 +25550,14 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
}
|
||||
}
|
||||
|
||||
void deleteOatArtifactsOfPackage(String packageName) {
|
||||
long deleteOatArtifactsOfPackage(String packageName) {
|
||||
final AndroidPackage pkg;
|
||||
final PackageSetting pkgSetting;
|
||||
synchronized (mLock) {
|
||||
pkg = mPackages.get(packageName);
|
||||
pkgSetting = mSettings.getPackageLPr(packageName);
|
||||
}
|
||||
mDexManager.deleteOptimizedFiles(ArtUtils.createArtPackageInfo(pkg, pkgSetting));
|
||||
return mDexManager.deleteOptimizedFiles(ArtUtils.createArtPackageInfo(pkg, pkgSetting));
|
||||
}
|
||||
|
||||
Set<String> getUnusedPackages(long downgradeTimeThresholdMillis) {
|
||||
|
||||
@@ -1034,18 +1034,26 @@ public class DexManager {
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @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 isa : packageInfo.getInstructionSets()) {
|
||||
try {
|
||||
mInstaller.deleteOdex(codePath, isa, packageInfo.getOatDir());
|
||||
freedBytes += mInstaller.deleteOdex(codePath, isa, packageInfo.getOatDir());
|
||||
} catch (InstallerException e) {
|
||||
Log.e(TAG, "Failed deleting oat files for " + codePath, e);
|
||||
hadErrors = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return hadErrors ? -1 : freedBytes;
|
||||
}
|
||||
|
||||
public static class RegisterDexModuleResult {
|
||||
|
||||
Reference in New Issue
Block a user