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

Commit 134e4291 authored by Vinit Nayak's avatar Vinit Nayak
Browse files

Add logs for launcher user cache

Bug: 243688989
Flag: None
Change-Id: I6f6ea3f3326c1814c2a50863e9bfbcb7e4323ae8
parent 57eaf86f
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.app.admin.DevicePolicyManager.ACTION_DEVICE_POLICY_RESOURC
import static com.android.launcher3.LauncherAppState.ACTION_FORCE_ROLOAD;
import static com.android.launcher3.config.FeatureFlags.IS_STUDIO_BUILD;
import static com.android.launcher3.testing.shared.TestProtocol.WORK_TAB_MISSING;
import static com.android.launcher3.testing.shared.TestProtocol.sDebugTracing;
import static com.android.launcher3.testing.shared.TestProtocol.testLogD;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
@@ -295,7 +296,7 @@ public class LauncherModel extends LauncherApps.Callback implements InstallSessi
    }

    public void onBroadcastIntent(@NonNull final Intent intent) {
        if (DEBUG_RECEIVER) Log.d(TAG, "onReceive intent=" + intent);
        if (DEBUG_RECEIVER || sDebugTracing) Log.d(TAG, "onReceive intent=" + intent);
        final String action = intent.getAction();
        if (Intent.ACTION_LOCALE_CHANGED.equals(action)) {
            // If we have changed locale we need to clear out the labels in all apps/workspace.
+3 −0
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ import static com.android.launcher3.model.ModelUtils.filterCurrentWorkspaceItems
import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_DISABLED_LOCKED_USER;
import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_DISABLED_SAFEMODE;
import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_DISABLED_SUSPENDED;
import static com.android.launcher3.testing.shared.TestProtocol.WORK_TAB_MISSING;
import static com.android.launcher3.testing.shared.TestProtocol.testLogD;
import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
import static com.android.launcher3.util.PackageManagerHelper.hasShortcutsPermission;
import static com.android.launcher3.util.PackageManagerHelper.isSystemApp;
@@ -949,6 +951,7 @@ public class LoaderTask implements Runnable {
    }

    private List<LauncherActivityInfo> loadAllApps() {
        testLogD(WORK_TAB_MISSING, "loadingAllApps");
        final List<UserHandle> profiles = mUserCache.getUserProfiles();
        List<LauncherActivityInfo> allActivityList = new ArrayList<>();
        // Clear the list of apps
+16 −0
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@

package com.android.launcher3.pm;

import static com.android.launcher3.testing.shared.TestProtocol.WORK_TAB_MISSING;
import static com.android.launcher3.testing.shared.TestProtocol.testLogD;

import android.content.Context;
import android.content.Intent;
import android.os.UserHandle;
@@ -56,6 +59,7 @@ public class UserCache {
    }

    private void onUsersChanged(Intent intent) {
        testLogD(WORK_TAB_MISSING, "onUsersChanged intent: " + intent);
        enableAndResetCache();
        mUserChangeListeners.forEach(Runnable::run);
    }
@@ -84,6 +88,7 @@ public class UserCache {
            List<UserHandle> users = mUserManager.getUserProfiles();
            if (users != null) {
                for (UserHandle user : users) {
                    testLogD(WORK_TAB_MISSING, "caching user: " + user);
                    long serial = mUserManager.getSerialNumberForUser(user);
                    mUsers.put(serial, user);
                    mUserToSerialMap.put(user, serial);
@@ -134,13 +139,24 @@ public class UserCache {
     * @see UserManager#getUserProfiles()
     */
    public List<UserHandle> getUserProfiles() {
        StringBuilder usersToReturn = new StringBuilder();
        synchronized (this) {
            if (mUsers != null) {
                for (UserHandle u : mUserToSerialMap.keySet()) {
                    usersToReturn.append(u).append(" && ");
                }
                testLogD(WORK_TAB_MISSING, "users from cache: " + usersToReturn);
                return new ArrayList<>(mUserToSerialMap.keySet());
            } else {
                testLogD(WORK_TAB_MISSING, "users from cache null");
            }
        }

        List<UserHandle> users = mUserManager.getUserProfiles();
        for (UserHandle u : users) {
            usersToReturn.append(u).append(" && ");
        }
        testLogD(WORK_TAB_MISSING, "users from userManager: " + usersToReturn);
        return users == null ? Collections.emptyList() : users;
    }
}
+1 −10
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.launcher3.util;

import android.content.ComponentName;
import android.os.UserHandle;
import android.util.Log;

import androidx.annotation.NonNull;

@@ -26,7 +25,6 @@ import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.model.data.FolderInfo;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.shortcuts.ShortcutKey;
import com.android.launcher3.testing.shared.TestProtocol;

import java.util.Collection;
import java.util.HashSet;
@@ -44,14 +42,7 @@ public abstract class ItemInfoMatcher {
    private static final ComponentName EMPTY_COMPONENT = new ComponentName("", "");

    public static Predicate<ItemInfo> ofUser(UserHandle user) {
        return info -> {
            if (TestProtocol.sDebugTracing) {
                Log.d(TestProtocol.WORK_TAB_MISSING, "userHandle: " + user
                        + ", itemUserHandle: " + info.user
                        + " package: " + info.getTargetPackage());
            }
            return info != null && info.user.equals(user);
        };
        return info -> info != null && info.user.equals(user);
    }

    public static Predicate<ItemInfo> ofComponents(