Make DexOptHelper.forceDexOpt a legacy dexopt only method.
This change also moves the declaration of these two methods from the IPackageManager interface to the PackageManagerInternal interface because IPackageManager is in f/b/core and therefore cannot access LegacyDexoptDisabledException. Test: adb shell pm force-dex-opt com.android.egg Bug: 251903639 Change-Id: I2ea6ed39b2e1f4877a83d0a7737537c00ce7e7a6
This commit is contained in:
@@ -572,8 +572,6 @@ interface IPackageManager {
|
||||
boolean performDexOptSecondary(String packageName,
|
||||
String targetCompilerFilter, boolean force);
|
||||
|
||||
void forceDexOpt(String packageName);
|
||||
|
||||
int getMoveStatus(int moveId);
|
||||
|
||||
void registerMoveCallback(in IPackageMoveObserver callback);
|
||||
|
||||
@@ -1327,6 +1327,11 @@ public abstract class PackageManagerInternal {
|
||||
public abstract void legacyDumpProfiles(@NonNull String packageName,
|
||||
boolean dumpClassesAndMethods) throws LegacyDexoptDisabledException;
|
||||
|
||||
/** @deprecated For legacy shell command only. */
|
||||
@Deprecated
|
||||
public abstract void legacyForceDexOpt(@NonNull String packageName)
|
||||
throws LegacyDexoptDisabledException;
|
||||
|
||||
/** @deprecated For legacy shell command only. */
|
||||
@Deprecated
|
||||
public abstract void legacyReconcileSecondaryDexFiles(String packageName)
|
||||
|
||||
@@ -566,7 +566,10 @@ public final class DexOptHelper {
|
||||
mPm.getDexManager().getPackageUseInfoOrDefault(p.getPackageName()), options);
|
||||
}
|
||||
|
||||
public void forceDexOpt(@NonNull Computer snapshot, String packageName) {
|
||||
/** @deprecated For legacy shell command only. */
|
||||
@Deprecated
|
||||
public void forceDexOpt(@NonNull Computer snapshot, String packageName)
|
||||
throws LegacyDexoptDisabledException {
|
||||
PackageManagerServiceUtils.enforceSystemOrRoot("forceDexOpt");
|
||||
|
||||
final PackageStateInternal packageState = snapshot.getPackageStateInternal(packageName);
|
||||
@@ -586,19 +589,7 @@ public final class DexOptHelper {
|
||||
getDefaultCompilerFilter(), null /* splitName */,
|
||||
DexoptOptions.DEXOPT_FORCE | DexoptOptions.DEXOPT_BOOT_COMPLETE);
|
||||
|
||||
@DexOptResult int res;
|
||||
if (useArtService()) {
|
||||
// performDexOptWithArtService ignores the snapshot and takes its own, so it can race
|
||||
// with the package checks above, but at worst the effect is only a bit less friendly
|
||||
// error below.
|
||||
res = performDexOptWithArtService(options, ArtFlags.FLAG_SHOULD_INCLUDE_DEPENDENCIES);
|
||||
} else {
|
||||
try {
|
||||
res = performDexOptInternalWithDependenciesLI(pkg, packageState, options);
|
||||
} catch (LegacyDexoptDisabledException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
@DexOptResult int res = performDexOptInternalWithDependenciesLI(pkg, packageState, options);
|
||||
|
||||
Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
|
||||
if (res != PackageDexOptimizer.DEX_OPT_PERFORMED) {
|
||||
|
||||
@@ -301,12 +301,6 @@ public abstract class IPackageManagerBase extends IPackageManager.Stub {
|
||||
return mPreferredActivityHelper.findPersistentPreferredActivity(snapshot(), intent, userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public final void forceDexOpt(String packageName) {
|
||||
mDexOptHelper.forceDexOpt(snapshot(), packageName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public final ActivityInfo getActivityInfo(ComponentName component,
|
||||
|
||||
@@ -6621,6 +6621,13 @@ public class PackageManagerService implements PackageSender, TestUtilityService
|
||||
}
|
||||
}
|
||||
|
||||
/** @deprecated For legacy shell command only. */
|
||||
@Override
|
||||
@Deprecated
|
||||
public void legacyForceDexOpt(String packageName) throws LegacyDexoptDisabledException {
|
||||
mDexOptHelper.forceDexOpt(snapshotComputer(), packageName);
|
||||
}
|
||||
|
||||
/** @deprecated For legacy shell command only. */
|
||||
@Override
|
||||
@Deprecated
|
||||
|
||||
@@ -1977,8 +1977,8 @@ class PackageManagerShellCommand extends ShellCommand {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int runForceDexOpt() throws RemoteException {
|
||||
mInterface.forceDexOpt(getNextArgRequired());
|
||||
public int runForceDexOpt() throws RemoteException, LegacyDexoptDisabledException {
|
||||
mPm.legacyForceDexOpt(getNextArgRequired());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user