Add user_type field and log it in Launcher
Add new field user_type to decouple
work_profile and private_space users.
Deprecate is_work boolean field.
Bug: 312200869
Test: statsd_testdrive 19, output: https://paste.googleplex.com/5912695996416000
Flag: NA
Change-Id: Idc25f341b4353a85b8a93eab97c88195895baedc
diff --git a/Android.bp b/Android.bp
index e658949..010ea45 100644
--- a/Android.bp
+++ b/Android.bp
@@ -171,6 +171,7 @@
name: "Launcher3CommonDepsLib",
srcs: ["src_build_config/**/*.java"],
static_libs: [
+ "SystemUI-statsd",
"Launcher3ResLib",
"launcher-testing-shared",
"animationlib",
diff --git a/protos/launcher_atom.proto b/protos/launcher_atom.proto
index dde69e3..a840eb4 100644
--- a/protos/launcher_atom.proto
+++ b/protos/launcher_atom.proto
@@ -38,7 +38,7 @@
optional int32 rank = 5;
// Stores whether the Item belows to non primary user
- optional bool is_work = 6;
+ optional bool is_work = 6 [deprecated = true];
// Item can be child node to parent container or parent containers (nested)
optional ContainerInfo container_info = 7;
@@ -48,6 +48,9 @@
// Stores whether the navigation bar is in kids mode.
optional bool is_kids_mode = 13;
+
+ // Stores type of the user the Item belong to
+ optional int32 user_type = 14;
}
message LauncherAttributes{
diff --git a/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java b/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java
index ac6c274..fa4a248 100644
--- a/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java
+++ b/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java
@@ -481,7 +481,7 @@
getGridY(atomInfo, true) /* grid_y_parent */,
getParentPageId(atomInfo) /* page_id_parent */,
getHierarchy(atomInfo) /* hierarchy */,
- atomInfo.getIsWork() /* is_work_profile */,
+ false /* is_work_profile, deprecated */,
atomInfo.getRank() /* rank */,
atomInfo.getFolderIcon().getFromLabelState().getNumber() /* fromState */,
atomInfo.getFolderIcon().getToLabelState().getNumber() /* toState */,
@@ -490,8 +490,8 @@
features /* features */,
getSearchAttributes(atomInfo) /* searchAttributes */,
getAttributes(atomInfo) /* attributes */,
- inputType /* input_type */
- );
+ inputType /* input_type */,
+ atomInfo.getUserType() /* user_type */);
}
}
diff --git a/src/com/android/launcher3/model/data/ItemInfo.java b/src/com/android/launcher3/model/data/ItemInfo.java
index 9afa459..86393a0 100644
--- a/src/com/android/launcher3/model/data/ItemInfo.java
+++ b/src/com/android/launcher3/model/data/ItemInfo.java
@@ -60,9 +60,12 @@
import com.android.launcher3.logger.LauncherAtom.WallpapersContainer;
import com.android.launcher3.logger.LauncherAtomExtensions.ExtendedContainers;
import com.android.launcher3.model.ModelWriter;
+import com.android.launcher3.pm.UserCache;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.ContentWriter;
import com.android.launcher3.util.SettingsCache;
+import com.android.launcher3.util.UserIconInfo;
+import com.android.systemui.shared.system.SysUiStatsLog;
import java.util.Optional;
@@ -414,7 +417,9 @@
@NonNull
protected LauncherAtom.ItemInfo.Builder getDefaultItemInfoBuilder() {
LauncherAtom.ItemInfo.Builder itemBuilder = LauncherAtom.ItemInfo.newBuilder();
- itemBuilder.setIsWork(!Process.myUserHandle().equals(user));
+ UserIconInfo info = getUserInfo();
+ itemBuilder.setIsWork(info != null && info.isWork());
+ itemBuilder.setUserType(getUserType(info));
SettingsCache settingsCache = SettingsCache.INSTANCE.getNoCreate();
boolean isKidsMode = settingsCache != null && settingsCache.getValue(NAV_BAR_KIDS_MODE, 0);
itemBuilder.setIsKidsMode(isKidsMode);
@@ -510,4 +515,29 @@
@Nullable final ModelWriter modelWriter) {
this.title = title;
}
+
+ private UserIconInfo getUserInfo() {
+ UserCache userCache = UserCache.INSTANCE.getNoCreate();
+ if (userCache == null) {
+ return null;
+ }
+
+ return userCache.getUserInfo(user);
+ }
+
+ private int getUserType(UserIconInfo info) {
+ if (info == null) {
+ return SysUiStatsLog.LAUNCHER_UICHANGED__USER_TYPE__TYPE_UNKNOWN;
+ } else if (info.isMain()) {
+ return SysUiStatsLog.LAUNCHER_UICHANGED__USER_TYPE__TYPE_MAIN;
+ } else if (info.isPrivate()) {
+ return SysUiStatsLog.LAUNCHER_UICHANGED__USER_TYPE__TYPE_PRIVATE;
+ } else if (info.isWork()) {
+ return SysUiStatsLog.LAUNCHER_UICHANGED__USER_TYPE__TYPE_WORK;
+ } else if (info.isCloned()) {
+ return SysUiStatsLog.LAUNCHER_UICHANGED__USER_TYPE__TYPE_CLONED;
+ } else {
+ return SysUiStatsLog.LAUNCHER_UICHANGED__USER_TYPE__TYPE_UNKNOWN;
+ }
+ }
}