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
This commit is contained in:
Anna Zhuravleva
2023-11-20 18:30:35 +00:00
parent 4a6d4994c3
commit 9c20381231
4 changed files with 39 additions and 5 deletions

View File

@@ -171,6 +171,7 @@ android_library {
name: "Launcher3CommonDepsLib",
srcs: ["src_build_config/**/*.java"],
static_libs: [
"SystemUI-statsd",
"Launcher3ResLib",
"launcher-testing-shared",
"animationlib",

View File

@@ -38,7 +38,7 @@ message ItemInfo {
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 @@ message ItemInfo {
// 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{

View File

@@ -481,7 +481,7 @@ public class StatsLogCompatManager extends StatsLogManager {
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 @@ public class StatsLogCompatManager extends StatsLogManager {
features /* features */,
getSearchAttributes(atomInfo) /* searchAttributes */,
getAttributes(atomInfo) /* attributes */,
inputType /* input_type */
);
inputType /* input_type */,
atomInfo.getUserType() /* user_type */);
}
}

View File

@@ -60,9 +60,12 @@ import com.android.launcher3.logger.LauncherAtom.TaskSwitcherContainer;
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 @@ public class ItemInfo {
@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 @@ public class ItemInfo {
@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;
}
}
}