Merge "Make some accessor methods more widely available in PackageManager."

This commit is contained in:
Martin Stjernholm
2023-01-18 11:34:46 +00:00
committed by Android (Google) Code Review
2 changed files with 15 additions and 10 deletions

View File

@@ -32,6 +32,7 @@ import static com.android.server.pm.PackageManagerServiceCompilerMapping.getComp
import static com.android.server.pm.PackageManagerServiceCompilerMapping.getDefaultCompilerFilter;
import static com.android.server.pm.PackageManagerServiceUtils.REMOVE_IF_APEX_PKG;
import static com.android.server.pm.PackageManagerServiceUtils.REMOVE_IF_NULL_PKG;
import static com.android.server.pm.PackageManagerServiceUtils.getPackageManagerLocal;
import static dalvik.system.DexFile.isProfileGuidedCompilerFilter;
@@ -88,7 +89,6 @@ import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
@@ -916,14 +916,6 @@ public final class DexOptHelper {
return false;
}
private @NonNull PackageManagerLocal getPackageManagerLocal() {
try {
return LocalManagerRegistry.getManagerOrThrow(PackageManagerLocal.class);
} catch (ManagerNotFoundException e) {
throw new RuntimeException(e);
}
}
/**
* Called whenever we need to fall back from ART Service to the legacy dexopt code.
*/
@@ -1003,7 +995,7 @@ public final class DexOptHelper {
/**
* Returns {@link ArtManagerLocal} if ART Service should be used for package dexopt.
*/
private static @Nullable ArtManagerLocal getArtManagerLocal() {
public static @Nullable ArtManagerLocal getArtManagerLocal() {
if (!useArtService()) {
return null;
}

View File

@@ -24,6 +24,7 @@ import static android.system.OsConstants.O_CREAT;
import static android.system.OsConstants.O_RDWR;
import static com.android.internal.content.NativeLibraryHelper.LIB_DIR_NAME;
import static com.android.server.LocalManagerRegistry.ManagerNotFoundException;
import static com.android.server.pm.PackageManagerService.COMPRESSED_EXTENSION;
import static com.android.server.pm.PackageManagerService.DEBUG_COMPRESSION;
import static com.android.server.pm.PackageManagerService.DEBUG_INTENT_MATCHING;
@@ -91,6 +92,7 @@ import com.android.internal.util.FastPrintWriter;
import com.android.internal.util.HexDump;
import com.android.server.EventLogTags;
import com.android.server.IntentResolver;
import com.android.server.LocalManagerRegistry;
import com.android.server.Watchdog;
import com.android.server.compat.PlatformCompat;
import com.android.server.pm.dex.PackageDexUsage;
@@ -200,6 +202,17 @@ public class PackageManagerServiceUtils {
*/
private static final boolean FORCE_PACKAGE_PARSED_CACHE_ENABLED = false;
/**
* Returns the registered PackageManagerLocal instance, or else throws an unchecked error.
*/
public static @NonNull PackageManagerLocal getPackageManagerLocal() {
try {
return LocalManagerRegistry.getManagerOrThrow(PackageManagerLocal.class);
} catch (ManagerNotFoundException e) {
throw new RuntimeException(e);
}
}
/**
* Checks if the package was inactive during since <code>thresholdTimeinMillis</code>.
* Package is considered active, if: