Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5a2d70af authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Clean up android.content.pm.cache_sdk_system_features" into main

parents 16b4552e 82754ec0
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -1450,10 +1450,8 @@ public final class ActivityThread extends ClientTransactionHandler
            ApplicationSharedMemory instance =
                    ApplicationSharedMemory.fromFileDescriptor(
                            applicationSharedMemoryFd, /* mutable= */ false);
            if (android.content.pm.Flags.cacheSdkSystemFeatures()) {
            SystemFeaturesCache.setInstance(
                    new SystemFeaturesCache(instance.readSystemFeaturesCache()));
            }
            instance.closeFileDescriptor();
            ApplicationSharedMemory.setInstance(instance);

+2 −5
Original line number Diff line number Diff line
@@ -2271,13 +2271,10 @@ public class ApplicationPackageManager extends PackageManager {
    protected ApplicationPackageManager(ContextImpl context, IPackageManager pm) {
        mContext = context;
        mPM = pm;
        mUseSystemFeaturesCache = isSystemFeaturesCacheEnabledAndAvailable();
        mUseSystemFeaturesCache = isSystemFeaturesCacheAvailable();
    }

    private static boolean isSystemFeaturesCacheEnabledAndAvailable() {
        if (!android.content.pm.Flags.cacheSdkSystemFeatures()) {
            return false;
        }
    private static boolean isSystemFeaturesCacheAvailable() {
        if (ActivityThread.isSystem() && !SystemFeaturesCache.hasInstance()) {
            // There are a handful of utility "system" processes that are neither system_server nor
            // bound as applications. For these processes, we don't have access to application
+3 −4
Original line number Diff line number Diff line
@@ -49,8 +49,8 @@ public final class SystemFeaturesCache {
    /**
     * Installs the process-global cache instance.
     *
     * <p>Note: Usage should be gated on android.content.pm.Flags.cacheSdkSystemFeature(). In
     * practice, this should only be called from 1) SystemServer init, or 2) bindApplication.
     * <p>Note: In practice, this should only be called from 1) SystemServer init,
     * or 2) bindApplication.
     */
    @MainThread
    public static void setInstance(SystemFeaturesCache instance) {
@@ -63,8 +63,7 @@ public final class SystemFeaturesCache {
    /**
     * Gets the process-global cache instance.
     *
     * Note: Usage should be gated on android.content.pm.Flags.cacheSdkSystemFeature(), and should
     * always occur after the instance has been installed early in the process lifecycle.
     * Note: Usage must occur after the instance has been installed early in the process lifecycle.
     */
    public static @NonNull SystemFeaturesCache getInstance() {
        SystemFeaturesCache instance = sInstance;
+0 −7
Original line number Diff line number Diff line
@@ -126,13 +126,6 @@ flag {
    }
}

flag {
    name: "cache_sdk_system_features"
    namespace: "system_performance"
    description: "Feature flag to enable optimized cache for SDK-defined system feature lookups."
    bug: "326623529"
}

flag {
    name: "provide_info_of_apk_in_apex"
    is_exported: true
+1 −3
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import static android.content.pm.PackageManager.FEATURE_WATCH;
import static com.google.common.truth.Truth.assertThat;

import static org.junit.Assert.assertThrows;
import static org.junit.Assume.assumeTrue;

import android.util.ArrayMap;

@@ -149,8 +148,7 @@ public class SystemFeaturesCacheTest {
    }

    @Test
    public void testSingletonAutomaticallySetWithFeatureEnabled() {
        assumeTrue(android.content.pm.Flags.cacheSdkSystemFeatures());
    public void testSingletonAutomaticallySet() {
        assertThat(SystemFeaturesCache.hasInstance()).isTrue();
        assertThat(SystemFeaturesCache.getInstance()).isNotNull();
    }
Loading