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

Commit f107453a authored by Anna Bauza's avatar Anna Bauza
Browse files

Initialize caches os UserManagerService creation.

PIC requires initial invalidation in order to start caching. This CL invalidates all caches in UserManager at server start. This enable caching at system level and from this moment caching will be working for any context and any user.

This CL also aligns the existing cache naming to match the required standard.

Bug: 356167673
Change-Id: If34285bcbfbfcdb593c42536226d418eb25836c6
Flag: android.multiuser.caches_not_invalidated_at_start_read_only
Test: N/A
parent d5902b20
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -3763,7 +3763,8 @@ public class UserManager {
    }

    private static final String CACHE_KEY_IS_USER_UNLOCKED_PROPERTY =
            "cache_key.is_user_unlocked";
        PropertyInvalidatedCache.createPropertyName(
            PropertyInvalidatedCache.MODULE_SYSTEM, "is_user_unlocked");

    private final PropertyInvalidatedCache<Integer, Boolean> mIsUserUnlockedCache =
            new PropertyInvalidatedCache<Integer, Boolean>(
@@ -6694,7 +6695,9 @@ public class UserManager {
    }

    /* Cache key for anything that assumes that userIds cannot be re-used without rebooting. */
    private static final String CACHE_KEY_STATIC_USER_PROPERTIES = "cache_key.static_user_props";
    private static final String CACHE_KEY_STATIC_USER_PROPERTIES =
        PropertyInvalidatedCache.createPropertyName(
            PropertyInvalidatedCache.MODULE_SYSTEM, "static_user_props");

    private final PropertyInvalidatedCache<Integer, String> mProfileTypeCache =
            new PropertyInvalidatedCache<Integer, String>(32, CACHE_KEY_STATIC_USER_PROPERTIES) {
@@ -6721,7 +6724,9 @@ public class UserManager {
    }

    /* Cache key for UserProperties object. */
    private static final String CACHE_KEY_USER_PROPERTIES = "cache_key.user_properties";
    private static final String CACHE_KEY_USER_PROPERTIES =
        PropertyInvalidatedCache.createPropertyName(
            PropertyInvalidatedCache.MODULE_SYSTEM, "user_properties");

    // TODO: It would be better to somehow have this as static, so that it can work cross-context.
    private final PropertyInvalidatedCache<Integer, UserProperties> mUserPropertiesCache =
+15 −0
Original line number Diff line number Diff line
@@ -1090,6 +1090,21 @@ public class UserManagerService extends IUserManager.Stub {
        mUser0Allocations = DBG_ALLOCATION ? new AtomicInteger() : null;
        mPrivateSpaceAutoLockSettingsObserver = new SettingsObserver(mHandler);
        emulateSystemUserModeIfNeeded();
        initPropertyInvalidatedCaches();
    }

    /**
     * This method is used to invalidate the caches at server statup,
     * so that caches can start working.
     */
    private static final void initPropertyInvalidatedCaches() {
        if (android.multiuser.Flags.cachesNotInvalidatedAtStartReadOnly()) {
            UserManager.invalidateIsUserUnlockedCache();
            UserManager.invalidateQuietModeEnabledCache();
            UserManager.invalidateStaticUserProperties();
            UserManager.invalidateUserPropertiesCache();
            UserManager.invalidateUserSerialNumberCache();
        }
    }

    private boolean doesDeviceHardwareSupportPrivateSpace() {