Clear application profile data before perform dexOpt (#2141)

This commit is contained in:
Howard Wu 2022-09-26 10:01:26 +08:00 committed by GitHub
parent 5262c52c0f
commit 86fd75ab7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 1 deletions

View File

@ -83,6 +83,7 @@ public class CompileDialogFragment extends AppCompatDialogFragment {
@Override @Override
protected Throwable doInBackground(String... commands) { protected Throwable doInBackground(String... commands) {
try { try {
LSPManagerServiceHolder.getService().clearApplicationProfileData(commands[0]);
if (LSPManagerServiceHolder.getService().performDexOptMode(commands[0])) { if (LSPManagerServiceHolder.getService().performDexOptMode(commands[0])) {
return null; return null;
} else { } else {

View File

@ -821,6 +821,11 @@ public class LSPManagerService extends ILSPManagerService.Stub {
} }
} }
@Override
public void clearApplicationProfileData(String packageName) throws RemoteException {
PackageService.clearApplicationProfileData(packageName);
}
@Override @Override
public boolean performDexOptMode(String packageName) throws RemoteException { public boolean performDexOptMode(String packageName) throws RemoteException {
return PackageService.performDexOptMode(packageName); return PackageService.performDexOptMode(packageName);

View File

@ -313,11 +313,17 @@ public class PackageService {
return intent; return intent;
} }
public static void clearApplicationProfileData(String packageName) throws RemoteException {
IPackageManager pm = getPackageManager();
if (pm == null) return;
pm.clearApplicationProfileData(packageName);
}
public static boolean performDexOptMode(String packageName) throws RemoteException { public static boolean performDexOptMode(String packageName) throws RemoteException {
IPackageManager pm = getPackageManager(); IPackageManager pm = getPackageManager();
if (pm == null) return false; if (pm == null) return false;
return pm.performDexOptMode(packageName, return pm.performDexOptMode(packageName,
SystemProperties.getBoolean("dalvik.vm.usejitprofiles", false), SystemProperties.getBoolean("dalvik.vm.usejitprofiles", false),
"speed", true, true, null); SystemProperties.get("pm.dexopt.install", "speed-profile"), true, true, null);
} }
} }

View File

@ -93,6 +93,8 @@ public interface IPackageManager extends IInterface {
String targetCompilerFilter, boolean force, boolean bootComplete, String splitName) String targetCompilerFilter, boolean force, boolean bootComplete, String splitName)
throws RemoteException; throws RemoteException;
void clearApplicationProfileData(String packageName) throws RemoteException;
abstract class Stub extends Binder implements IPackageManager { abstract class Stub extends Binder implements IPackageManager {
public static IPackageManager asInterface(IBinder obj) { public static IPackageManager asInterface(IBinder obj) {

View File

@ -87,4 +87,6 @@ interface ILSPManagerService {
void setDexObfuscate(boolean enable) = 43; void setDexObfuscate(boolean enable) = 43;
int getDex2OatWrapperCompatibility() = 44; int getDex2OatWrapperCompatibility() = 44;
void clearApplicationProfileData(in String packageName) = 45;
} }