summaryrefslogtreecommitdiff
path: root/src/com/android
diff options
context:
space:
mode:
authorVinit Nayak <peanutbutter@google.com>2023-06-01 17:09:43 -0700
committerVinit Nayak <peanutbutter@google.com>2023-06-01 17:11:42 -0700
commit134e429189d591707307df164beca920fec54b72 (patch)
tree232221d42c3cd68162da4043376bd32754ce88b6 /src/com/android
parent57eaf86f8ded70c9bb448459e33621c4696a8755 (diff)
downloadLauncher3-134e429189d591707307df164beca920fec54b72.tar.gz
Add logs for launcher user cache
Bug: 243688989 Flag: None Change-Id: I6f6ea3f3326c1814c2a50863e9bfbcb7e4323ae8
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/launcher3/LauncherModel.java3
-rw-r--r--src/com/android/launcher3/model/LoaderTask.java3
-rw-r--r--src/com/android/launcher3/pm/UserCache.java16
-rw-r--r--src/com/android/launcher3/util/ItemInfoMatcher.java11
4 files changed, 22 insertions, 11 deletions
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index c20494d604..4e066b0985 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -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.
diff --git a/src/com/android/launcher3/model/LoaderTask.java b/src/com/android/launcher3/model/LoaderTask.java
index 1a8cf2491c..ca356b08b5 100644
--- a/src/com/android/launcher3/model/LoaderTask.java
+++ b/src/com/android/launcher3/model/LoaderTask.java
@@ -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
diff --git a/src/com/android/launcher3/pm/UserCache.java b/src/com/android/launcher3/pm/UserCache.java
index 5aab41a8a2..5ebcf42d27 100644
--- a/src/com/android/launcher3/pm/UserCache.java
+++ b/src/com/android/launcher3/pm/UserCache.java
@@ -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;
}
}
diff --git a/src/com/android/launcher3/util/ItemInfoMatcher.java b/src/com/android/launcher3/util/ItemInfoMatcher.java
index 8a27381a0b..b6af3140fa 100644
--- a/src/com/android/launcher3/util/ItemInfoMatcher.java
+++ b/src/com/android/launcher3/util/ItemInfoMatcher.java
@@ -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(