Merge "Add option to clear profile data to 'cmd package compile'" into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
5868ea7e01
@@ -382,6 +382,13 @@ interface IPackageManager {
|
||||
*/
|
||||
void clearApplicationUserData(in String packageName, IPackageDataObserver observer, int userId);
|
||||
|
||||
/**
|
||||
* Clear the profile data of an application.
|
||||
* @param packageName The package name of the application whose profile data
|
||||
* need to be deleted
|
||||
*/
|
||||
void clearApplicationProfileData(in String packageName);
|
||||
|
||||
/**
|
||||
* Get package statistics including the code, data and cache size for
|
||||
* an already installed package
|
||||
|
||||
@@ -166,6 +166,10 @@ public final class Installer extends SystemService {
|
||||
mInstaller.execute("rmpackagedir", packageDir);
|
||||
}
|
||||
|
||||
public void rmProfiles(String pkgName) throws InstallerException {
|
||||
mInstaller.execute("rmprofiles", pkgName);
|
||||
}
|
||||
|
||||
public void createUserConfig(int userid) throws InstallerException {
|
||||
mInstaller.execute("mkuserconfig", userid);
|
||||
}
|
||||
|
||||
@@ -15153,6 +15153,16 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearApplicationProfileData(String packageName) {
|
||||
enforceSystemOrRoot("Only the system can clear all profile data");
|
||||
try {
|
||||
mInstaller.rmProfiles(packageName);
|
||||
} catch (InstallerException ex) {
|
||||
Log.e(TAG, "Could not clear profile data of package " + packageName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearApplicationUserData(final String packageName,
|
||||
final IPackageDataObserver observer, final int userId) {
|
||||
|
||||
@@ -234,6 +234,7 @@ class PackageManagerShellCommand extends ShellCommand {
|
||||
boolean extractOnly = false;
|
||||
boolean forceCompilation = false;
|
||||
boolean allPackages = false;
|
||||
boolean clearProfileData = false;
|
||||
String compilationMode = "default";
|
||||
|
||||
String opt;
|
||||
@@ -242,12 +243,20 @@ class PackageManagerShellCommand extends ShellCommand {
|
||||
case "-a":
|
||||
allPackages = true;
|
||||
break;
|
||||
case "-m":
|
||||
compilationMode = getNextArgRequired();
|
||||
case "-c":
|
||||
clearProfileData = true;
|
||||
break;
|
||||
case "-f":
|
||||
forceCompilation = true;
|
||||
break;
|
||||
case "-m":
|
||||
compilationMode = getNextArgRequired();
|
||||
break;
|
||||
case "--reset":
|
||||
forceCompilation = true;
|
||||
clearProfileData = true;
|
||||
compilationMode = "extract";
|
||||
break;
|
||||
default:
|
||||
pw.println("Error: Unknown option: " + opt);
|
||||
return 1;
|
||||
@@ -290,7 +299,10 @@ class PackageManagerShellCommand extends ShellCommand {
|
||||
|
||||
List<String> failedPackages = new ArrayList<>();
|
||||
for (String packageName : packageNames) {
|
||||
pw.println(packageName);
|
||||
if (clearProfileData) {
|
||||
mInterface.clearApplicationProfileData(packageName);
|
||||
}
|
||||
|
||||
boolean result = mInterface.performDexOpt(packageName, null /* instructionSet */,
|
||||
useJitProfiles, extractOnly, forceCompilation);
|
||||
if (!result) {
|
||||
@@ -1170,9 +1182,12 @@ class PackageManagerShellCommand extends ShellCommand {
|
||||
pw.println(" Trigger compilation of TARGET-PACKAGE or all packages if \"-a\".");
|
||||
pw.println(" Options:");
|
||||
pw.println(" -a: compile all packages");
|
||||
pw.println(" -c: clear profile data before compiling");
|
||||
pw.println(" -f: force compilation even if not needed");
|
||||
pw.println(" -m: select compilation mode");
|
||||
pw.println(" MODE can be one of \"default\", \"all\", \"profile\", and \"extract\"");
|
||||
pw.println(" -f: force compilation even if not needed");
|
||||
pw.println(" --reset: restore the package to post-install state");
|
||||
pw.println(" shorthand for \"-c -f -m extract\"");
|
||||
pw.println(" list features");
|
||||
pw.println(" Prints all features of the system.");
|
||||
pw.println(" list instrumentation [-f] [TARGET-PACKAGE]");
|
||||
|
||||
Reference in New Issue
Block a user