use of com.android.launcher3.util.ComponentKey in project android_packages_apps_Trebuchet by LineageOS.
the class HotseatPredictionController method logLaunchedAppRankingInfo.
/**
* Logs rank info based on current list of predicted items
*/
public void logLaunchedAppRankingInfo(@NonNull ItemInfo itemInfo, InstanceId instanceId) {
if (Utilities.IS_DEBUG_DEVICE) {
final String pkg = itemInfo.getTargetComponent() != null ? itemInfo.getTargetComponent().getPackageName() : "unknown";
HotseatFileLog.INSTANCE.get(mLauncher).log("UserEvent", "appLaunch: packageName:" + pkg + ",isWorkApp:" + (itemInfo.user != null && !Process.myUserHandle().equals(itemInfo.user)) + ",launchLocation:" + itemInfo.container);
}
if (itemInfo.getTargetComponent() == null || itemInfo.user == null) {
return;
}
final ComponentKey key = new ComponentKey(itemInfo.getTargetComponent(), itemInfo.user);
final List<ComponentKeyMapper> predictedApps = new ArrayList<>(mComponentKeyMappers);
OptionalInt rank = IntStream.range(0, predictedApps.size()).filter(index -> key.equals(predictedApps.get(index).getComponentKey())).findFirst();
if (!rank.isPresent()) {
return;
}
int cardinality = 0;
for (PredictedAppIcon icon : getPredictedIcons()) {
ItemInfo info = (ItemInfo) icon.getTag();
cardinality |= 1 << info.screenId;
}
PredictedHotseatContainer.Builder containerBuilder = PredictedHotseatContainer.newBuilder();
containerBuilder.setCardinality(cardinality);
if (itemInfo.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION) {
containerBuilder.setIndex(rank.getAsInt());
}
mLauncher.getStatsLogManager().logger().withInstanceId(instanceId).withRank(rank.getAsInt()).withContainerInfo(ContainerInfo.newBuilder().setPredictedHotseatContainer(containerBuilder).build()).log(LAUNCHER_HOTSEAT_RANKED);
}
use of com.android.launcher3.util.ComponentKey in project android_packages_apps_Trebuchet by LineageOS.
the class PredictionModel method getComponentKeyFromSerializedString.
private ComponentKey getComponentKeyFromSerializedString(String str) {
int sep = str.indexOf('#');
if (sep < 0 || (sep + 1) >= str.length()) {
return null;
}
ComponentName componentName = ComponentName.unflattenFromString(str.substring(0, sep));
if (componentName == null) {
return null;
}
try {
long serialNumber = Long.parseLong(str.substring(sep + 1));
UserHandle userHandle = mUserCache.getUserForSerialNumber(serialNumber);
return userHandle != null ? new ComponentKey(componentName, userHandle) : null;
} catch (NumberFormatException ex) {
return null;
}
}
use of com.android.launcher3.util.ComponentKey in project android_packages_apps_Trebuchet by LineageOS.
the class PredictionModel method getPredictionComponentKeys.
/**
* parses and returns ComponentKeys saved by
* {@link PredictionModel#cachePredictionComponentKeys(List)}
*/
@WorkerThread
public List<ComponentKey> getPredictionComponentKeys() {
Preconditions.assertWorkerThread();
ArrayList<ComponentKey> items = new ArrayList<>();
String cachedBlob = mDevicePrefs.getString(CACHED_ITEMS_KEY, "");
for (String line : cachedBlob.split("\n")) {
ComponentKey key = getComponentKeyFromSerializedString(line);
if (key != null) {
items.add(key);
}
}
return items;
}
use of com.android.launcher3.util.ComponentKey in project android_packages_apps_Trebuchet by LineageOS.
the class UserEventDispatcher method logTaskLaunchOrDismiss.
@Deprecated
public void logTaskLaunchOrDismiss(int action, int direction, int taskIndex, ComponentKey componentKey) {
LauncherEvent event = newLauncherEvent(// TAP or SWIPE or FLING
newTouchAction(action), newTarget(Target.Type.ITEM));
if (action == Action.Touch.SWIPE || action == Action.Touch.FLING) {
// Direction DOWN means the task was launched, UP means it was dismissed.
event.action.dir = direction;
}
event.srcTarget[0].itemType = ItemType.TASK;
event.srcTarget[0].pageIndex = taskIndex;
fillComponentInfo(event.srcTarget[0], componentKey.componentName);
dispatchUserEvent(event, null);
mAppOrTaskLaunch = true;
}
use of com.android.launcher3.util.ComponentKey in project android_packages_apps_Trebuchet by LineageOS.
the class PinnedAppsAdapter method update.
private void update(ItemInfo info, Function<ComponentKey, Boolean> op) {
ComponentKey key = new ComponentKey(info.getTargetComponent(), info.user);
if (op.apply(key)) {
createFilteredAppsList();
Set<ComponentKey> copy = new HashSet<>(mPinnedApps);
Executors.MODEL_EXECUTOR.submit(() -> mPrefs.edit().putStringSet(PINNED_APPS_KEY, copy.stream().map(this::encode).collect(Collectors.toSet())).apply());
}
}
Aggregations