Search in sources :

Example 1 with LAST_PREDICTION_ENABLED_STATE

use of com.android.launcher3.model.QuickstepModelDelegate.LAST_PREDICTION_ENABLED_STATE in project android_packages_apps_Launcher3 by ArrowOS.

the class PredictionUpdateTask method execute.

@Override
public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList apps) {
    Context context = app.getContext();
    // TODO: remove this
    Utilities.getDevicePrefs(context).edit().putBoolean(LAST_PREDICTION_ENABLED_STATE, !mTargets.isEmpty()).apply();
    FixedContainerItems fci = mPredictorState.items;
    Set<UserHandle> usersForChangedShortcuts = new HashSet<>(fci.items.stream().filter(info -> info.itemType == ITEM_TYPE_DEEP_SHORTCUT).map(info -> info.user).collect(Collectors.toSet()));
    fci.items.clear();
    for (AppTarget target : mTargets) {
        WorkspaceItemInfo itemInfo;
        ShortcutInfo si = target.getShortcutInfo();
        if (si != null) {
            usersForChangedShortcuts.add(si.getUserHandle());
            itemInfo = new WorkspaceItemInfo(si, context);
            app.getIconCache().getShortcutIcon(itemInfo, si);
        } else {
            String className = target.getClassName();
            if (COMPONENT_CLASS_MARKER.equals(className)) {
                // TODO: Implement this
                continue;
            }
            ComponentName cn = new ComponentName(target.getPackageName(), className);
            UserHandle user = target.getUser();
            itemInfo = apps.data.stream().filter(info -> user.equals(info.user) && cn.equals(info.componentName)).map(ai -> {
                app.getIconCache().getTitleAndIcon(ai, false);
                return ai.makeWorkspaceItem();
            }).findAny().orElseGet(() -> {
                LauncherActivityInfo lai = context.getSystemService(LauncherApps.class).resolveActivity(AppInfo.makeLaunchIntent(cn), user);
                if (lai == null) {
                    return null;
                }
                AppInfo ai = new AppInfo(context, lai, user);
                app.getIconCache().getTitleAndIcon(ai, lai, false);
                return ai.makeWorkspaceItem();
            });
            if (itemInfo == null) {
                continue;
            }
        }
        itemInfo.container = fci.containerId;
        fci.items.add(itemInfo);
    }
    bindExtraContainerItems(fci);
    usersForChangedShortcuts.forEach(u -> dataModel.updateShortcutPinnedState(app.getContext(), u));
    // Save to disk
    mPredictorState.storage.write(context, fci.items);
}
Also used : Context(android.content.Context) Utilities(com.android.launcher3.Utilities) Context(android.content.Context) AppInfo(com.android.launcher3.model.data.AppInfo) ComponentName(android.content.ComponentName) ShortcutInfo(android.content.pm.ShortcutInfo) ITEM_TYPE_DEEP_SHORTCUT(com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) LauncherAppState(com.android.launcher3.LauncherAppState) Set(java.util.Set) Collectors(java.util.stream.Collectors) AppTarget(android.app.prediction.AppTarget) LauncherApps(android.content.pm.LauncherApps) HashSet(java.util.HashSet) List(java.util.List) COMPONENT_CLASS_MARKER(com.android.quickstep.InstantAppResolverImpl.COMPONENT_CLASS_MARKER) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) UserHandle(android.os.UserHandle) LauncherActivityInfo(android.content.pm.LauncherActivityInfo) FixedContainerItems(com.android.launcher3.model.BgDataModel.FixedContainerItems) LAST_PREDICTION_ENABLED_STATE(com.android.launcher3.model.QuickstepModelDelegate.LAST_PREDICTION_ENABLED_STATE) PredictorState(com.android.launcher3.model.QuickstepModelDelegate.PredictorState) ShortcutInfo(android.content.pm.ShortcutInfo) FixedContainerItems(com.android.launcher3.model.BgDataModel.FixedContainerItems) AppInfo(com.android.launcher3.model.data.AppInfo) AppTarget(android.app.prediction.AppTarget) UserHandle(android.os.UserHandle) LauncherActivityInfo(android.content.pm.LauncherActivityInfo) ComponentName(android.content.ComponentName) HashSet(java.util.HashSet) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 2 with LAST_PREDICTION_ENABLED_STATE

use of com.android.launcher3.model.QuickstepModelDelegate.LAST_PREDICTION_ENABLED_STATE in project android_packages_apps_404Launcher by P-404.

the class PredictionUpdateTask method execute.

@Override
public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList apps) {
    Context context = app.getContext();
    // TODO: remove this
    Utilities.getDevicePrefs(context).edit().putBoolean(LAST_PREDICTION_ENABLED_STATE, !mTargets.isEmpty()).apply();
    FixedContainerItems fci = mPredictorState.items;
    Set<UserHandle> usersForChangedShortcuts = new HashSet<>(fci.items.stream().filter(info -> info.itemType == ITEM_TYPE_DEEP_SHORTCUT).map(info -> info.user).collect(Collectors.toSet()));
    fci.items.clear();
    for (AppTarget target : mTargets) {
        WorkspaceItemInfo itemInfo;
        ShortcutInfo si = target.getShortcutInfo();
        if (si != null) {
            usersForChangedShortcuts.add(si.getUserHandle());
            itemInfo = new WorkspaceItemInfo(si, context);
            app.getIconCache().getShortcutIcon(itemInfo, si);
        } else {
            String className = target.getClassName();
            if (COMPONENT_CLASS_MARKER.equals(className)) {
                // TODO: Implement this
                continue;
            }
            ComponentName cn = new ComponentName(target.getPackageName(), className);
            UserHandle user = target.getUser();
            itemInfo = apps.data.stream().filter(info -> user.equals(info.user) && cn.equals(info.componentName)).map(ai -> {
                app.getIconCache().getTitleAndIcon(ai, false);
                return ai.makeWorkspaceItem();
            }).findAny().orElseGet(() -> {
                LauncherActivityInfo lai = context.getSystemService(LauncherApps.class).resolveActivity(AppInfo.makeLaunchIntent(cn), user);
                if (lai == null) {
                    return null;
                }
                AppInfo ai = new AppInfo(context, lai, user);
                app.getIconCache().getTitleAndIcon(ai, lai, false);
                return ai.makeWorkspaceItem();
            });
            if (itemInfo == null) {
                continue;
            }
        }
        itemInfo.container = fci.containerId;
        fci.items.add(itemInfo);
    }
    bindExtraContainerItems(fci);
    usersForChangedShortcuts.forEach(u -> dataModel.updateShortcutPinnedState(app.getContext(), u));
    // Save to disk
    mPredictorState.storage.write(context, fci.items);
}
Also used : Context(android.content.Context) Utilities(com.android.launcher3.Utilities) Context(android.content.Context) AppInfo(com.android.launcher3.model.data.AppInfo) ComponentName(android.content.ComponentName) ShortcutInfo(android.content.pm.ShortcutInfo) ITEM_TYPE_DEEP_SHORTCUT(com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) LauncherAppState(com.android.launcher3.LauncherAppState) Set(java.util.Set) Collectors(java.util.stream.Collectors) AppTarget(android.app.prediction.AppTarget) LauncherApps(android.content.pm.LauncherApps) HashSet(java.util.HashSet) List(java.util.List) COMPONENT_CLASS_MARKER(com.android.quickstep.InstantAppResolverImpl.COMPONENT_CLASS_MARKER) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) UserHandle(android.os.UserHandle) LauncherActivityInfo(android.content.pm.LauncherActivityInfo) FixedContainerItems(com.android.launcher3.model.BgDataModel.FixedContainerItems) LAST_PREDICTION_ENABLED_STATE(com.android.launcher3.model.QuickstepModelDelegate.LAST_PREDICTION_ENABLED_STATE) PredictorState(com.android.launcher3.model.QuickstepModelDelegate.PredictorState) ShortcutInfo(android.content.pm.ShortcutInfo) FixedContainerItems(com.android.launcher3.model.BgDataModel.FixedContainerItems) AppInfo(com.android.launcher3.model.data.AppInfo) AppTarget(android.app.prediction.AppTarget) UserHandle(android.os.UserHandle) LauncherActivityInfo(android.content.pm.LauncherActivityInfo) ComponentName(android.content.ComponentName) HashSet(java.util.HashSet) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 3 with LAST_PREDICTION_ENABLED_STATE

use of com.android.launcher3.model.QuickstepModelDelegate.LAST_PREDICTION_ENABLED_STATE in project android_packages_apps_Launcher3 by crdroidandroid.

the class PredictionUpdateTask method execute.

@Override
public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList apps) {
    Context context = app.getContext();
    // TODO: remove this
    Utilities.getDevicePrefs(context).edit().putBoolean(LAST_PREDICTION_ENABLED_STATE, !mTargets.isEmpty()).apply();
    FixedContainerItems fci = mPredictorState.items;
    Set<UserHandle> usersForChangedShortcuts = new HashSet<>(fci.items.stream().filter(info -> info.itemType == ITEM_TYPE_DEEP_SHORTCUT).map(info -> info.user).collect(Collectors.toSet()));
    fci.items.clear();
    for (AppTarget target : mTargets) {
        WorkspaceItemInfo itemInfo;
        ShortcutInfo si = target.getShortcutInfo();
        if (si != null) {
            usersForChangedShortcuts.add(si.getUserHandle());
            itemInfo = new WorkspaceItemInfo(si, context);
            app.getIconCache().getShortcutIcon(itemInfo, si);
        } else {
            String className = target.getClassName();
            if (COMPONENT_CLASS_MARKER.equals(className)) {
                // TODO: Implement this
                continue;
            }
            ComponentName cn = new ComponentName(target.getPackageName(), className);
            UserHandle user = target.getUser();
            itemInfo = apps.data.stream().filter(info -> user.equals(info.user) && cn.equals(info.componentName)).map(ai -> {
                app.getIconCache().getTitleAndIcon(ai, false);
                return ai.makeWorkspaceItem();
            }).findAny().orElseGet(() -> {
                LauncherActivityInfo lai = context.getSystemService(LauncherApps.class).resolveActivity(AppInfo.makeLaunchIntent(cn), user);
                if (lai == null) {
                    return null;
                }
                AppInfo ai = new AppInfo(context, lai, user);
                app.getIconCache().getTitleAndIcon(ai, lai, false);
                return ai.makeWorkspaceItem();
            });
            if (itemInfo == null) {
                continue;
            }
        }
        itemInfo.container = fci.containerId;
        fci.items.add(itemInfo);
    }
    bindExtraContainerItems(fci);
    usersForChangedShortcuts.forEach(u -> dataModel.updateShortcutPinnedState(app.getContext(), u));
    // Save to disk
    mPredictorState.storage.write(context, fci.items);
}
Also used : Context(android.content.Context) Utilities(com.android.launcher3.Utilities) Context(android.content.Context) AppInfo(com.android.launcher3.model.data.AppInfo) ComponentName(android.content.ComponentName) ShortcutInfo(android.content.pm.ShortcutInfo) ITEM_TYPE_DEEP_SHORTCUT(com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) LauncherAppState(com.android.launcher3.LauncherAppState) Set(java.util.Set) Collectors(java.util.stream.Collectors) AppTarget(android.app.prediction.AppTarget) LauncherApps(android.content.pm.LauncherApps) HashSet(java.util.HashSet) List(java.util.List) COMPONENT_CLASS_MARKER(com.android.quickstep.InstantAppResolverImpl.COMPONENT_CLASS_MARKER) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) UserHandle(android.os.UserHandle) LauncherActivityInfo(android.content.pm.LauncherActivityInfo) FixedContainerItems(com.android.launcher3.model.BgDataModel.FixedContainerItems) LAST_PREDICTION_ENABLED_STATE(com.android.launcher3.model.QuickstepModelDelegate.LAST_PREDICTION_ENABLED_STATE) PredictorState(com.android.launcher3.model.QuickstepModelDelegate.PredictorState) ShortcutInfo(android.content.pm.ShortcutInfo) FixedContainerItems(com.android.launcher3.model.BgDataModel.FixedContainerItems) AppInfo(com.android.launcher3.model.data.AppInfo) AppTarget(android.app.prediction.AppTarget) UserHandle(android.os.UserHandle) LauncherActivityInfo(android.content.pm.LauncherActivityInfo) ComponentName(android.content.ComponentName) HashSet(java.util.HashSet) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 4 with LAST_PREDICTION_ENABLED_STATE

use of com.android.launcher3.model.QuickstepModelDelegate.LAST_PREDICTION_ENABLED_STATE in project android_packages_apps_Launcher3 by crdroidandroid.

the class SettingsChangeLogger method dispatchUserEvent.

private void dispatchUserEvent() {
    StatsLogger logger = StatsLogManager.newInstance(mContext).logger().withInstanceId(new InstanceIdSequence().newInstanceId());
    logger.log(mNotificationDotsEnabled ? LAUNCHER_NOTIFICATION_DOT_ENABLED : LAUNCHER_NOTIFICATION_DOT_DISABLED);
    logger.log(mNavMode.launcherEvent);
    logger.log(getDevicePrefs(mContext).getBoolean(LAST_PREDICTION_ENABLED_STATE, true) ? LAUNCHER_HOME_SCREEN_SUGGESTIONS_ENABLED : LAUNCHER_HOME_SCREEN_SUGGESTIONS_DISABLED);
    SharedPreferences prefs = getPrefs(mContext);
    StatsLogManager.LauncherEvent gridSizeChangedEvent = null;
    // TODO(b/184981523): This doesn't work for 2-panel grid, which has 6 hotseat icons
    switch(prefs.getInt(KEY_MIGRATION_SRC_HOTSEAT_COUNT, -1)) {
        case 5:
            gridSizeChangedEvent = LAUNCHER_GRID_SIZE_5;
            break;
        case 4:
            gridSizeChangedEvent = LAUNCHER_GRID_SIZE_4;
            break;
        case 3:
            gridSizeChangedEvent = LAUNCHER_GRID_SIZE_3;
            break;
        case 2:
            gridSizeChangedEvent = LAUNCHER_GRID_SIZE_2;
            break;
        default:
            // Ignore illegal input.
            break;
    }
    if (gridSizeChangedEvent != null) {
        logger.log(gridSizeChangedEvent);
    }
    if (FeatureFlags.ENABLE_THEMED_ICONS.get()) {
        logger.log(prefs.getBoolean(KEY_THEMED_ICONS, false) ? LAUNCHER_THEMED_ICON_ENABLED : LAUNCHER_THEMED_ICON_DISABLED);
    }
    mLoggablePrefs.forEach((key, lp) -> logger.log(() -> prefs.getBoolean(key, lp.defaultValue) ? lp.eventIdOn : lp.eventIdOff));
}
Also used : StatsLogger(com.android.launcher3.logging.StatsLogManager.StatsLogger) InstanceIdSequence(com.android.launcher3.logging.InstanceIdSequence) SharedPreferences(android.content.SharedPreferences) StatsLogManager(com.android.launcher3.logging.StatsLogManager)

Example 5 with LAST_PREDICTION_ENABLED_STATE

use of com.android.launcher3.model.QuickstepModelDelegate.LAST_PREDICTION_ENABLED_STATE in project android_packages_apps_Launcher3 by ProtonAOSP.

the class PredictionUpdateTask method execute.

@Override
public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList apps) {
    Context context = app.getContext();
    // TODO: remove this
    Utilities.getDevicePrefs(context).edit().putBoolean(LAST_PREDICTION_ENABLED_STATE, !mTargets.isEmpty()).apply();
    FixedContainerItems fci = mPredictorState.items;
    Set<UserHandle> usersForChangedShortcuts = new HashSet<>(fci.items.stream().filter(info -> info.itemType == ITEM_TYPE_DEEP_SHORTCUT).map(info -> info.user).collect(Collectors.toSet()));
    fci.items.clear();
    for (AppTarget target : mTargets) {
        WorkspaceItemInfo itemInfo;
        ShortcutInfo si = target.getShortcutInfo();
        if (si != null) {
            usersForChangedShortcuts.add(si.getUserHandle());
            itemInfo = new WorkspaceItemInfo(si, context);
            app.getIconCache().getShortcutIcon(itemInfo, si);
        } else {
            String className = target.getClassName();
            if (COMPONENT_CLASS_MARKER.equals(className)) {
                // TODO: Implement this
                continue;
            }
            ComponentName cn = new ComponentName(target.getPackageName(), className);
            UserHandle user = target.getUser();
            itemInfo = apps.data.stream().filter(info -> user.equals(info.user) && cn.equals(info.componentName)).map(ai -> {
                app.getIconCache().getTitleAndIcon(ai, false);
                return ai.makeWorkspaceItem();
            }).findAny().orElseGet(() -> {
                LauncherActivityInfo lai = context.getSystemService(LauncherApps.class).resolveActivity(AppInfo.makeLaunchIntent(cn), user);
                if (lai == null) {
                    return null;
                }
                AppInfo ai = new AppInfo(context, lai, user);
                app.getIconCache().getTitleAndIcon(ai, lai, false);
                return ai.makeWorkspaceItem();
            });
            if (itemInfo == null) {
                continue;
            }
        }
        itemInfo.container = fci.containerId;
        fci.items.add(itemInfo);
    }
    bindExtraContainerItems(fci);
    usersForChangedShortcuts.forEach(u -> dataModel.updateShortcutPinnedState(app.getContext(), u));
    // Save to disk
    mPredictorState.storage.write(context, fci.items);
}
Also used : Context(android.content.Context) Utilities(com.android.launcher3.Utilities) Context(android.content.Context) AppInfo(com.android.launcher3.model.data.AppInfo) ComponentName(android.content.ComponentName) ShortcutInfo(android.content.pm.ShortcutInfo) ITEM_TYPE_DEEP_SHORTCUT(com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) LauncherAppState(com.android.launcher3.LauncherAppState) Set(java.util.Set) Collectors(java.util.stream.Collectors) AppTarget(android.app.prediction.AppTarget) LauncherApps(android.content.pm.LauncherApps) HashSet(java.util.HashSet) List(java.util.List) COMPONENT_CLASS_MARKER(com.android.quickstep.InstantAppResolverImpl.COMPONENT_CLASS_MARKER) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) UserHandle(android.os.UserHandle) LauncherActivityInfo(android.content.pm.LauncherActivityInfo) FixedContainerItems(com.android.launcher3.model.BgDataModel.FixedContainerItems) LAST_PREDICTION_ENABLED_STATE(com.android.launcher3.model.QuickstepModelDelegate.LAST_PREDICTION_ENABLED_STATE) PredictorState(com.android.launcher3.model.QuickstepModelDelegate.PredictorState) ShortcutInfo(android.content.pm.ShortcutInfo) FixedContainerItems(com.android.launcher3.model.BgDataModel.FixedContainerItems) AppInfo(com.android.launcher3.model.data.AppInfo) AppTarget(android.app.prediction.AppTarget) UserHandle(android.os.UserHandle) LauncherActivityInfo(android.content.pm.LauncherActivityInfo) ComponentName(android.content.ComponentName) HashSet(java.util.HashSet) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Aggregations

AppTarget (android.app.prediction.AppTarget)5 ComponentName (android.content.ComponentName)5 Context (android.content.Context)5 LauncherActivityInfo (android.content.pm.LauncherActivityInfo)5 LauncherApps (android.content.pm.LauncherApps)5 ShortcutInfo (android.content.pm.ShortcutInfo)5 UserHandle (android.os.UserHandle)5 LauncherAppState (com.android.launcher3.LauncherAppState)5 ITEM_TYPE_DEEP_SHORTCUT (com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT)5 Utilities (com.android.launcher3.Utilities)5 FixedContainerItems (com.android.launcher3.model.BgDataModel.FixedContainerItems)5 LAST_PREDICTION_ENABLED_STATE (com.android.launcher3.model.QuickstepModelDelegate.LAST_PREDICTION_ENABLED_STATE)5 PredictorState (com.android.launcher3.model.QuickstepModelDelegate.PredictorState)5 AppInfo (com.android.launcher3.model.data.AppInfo)5 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)5 COMPONENT_CLASS_MARKER (com.android.quickstep.InstantAppResolverImpl.COMPONENT_CLASS_MARKER)5 HashSet (java.util.HashSet)5 List (java.util.List)5 Set (java.util.Set)5 Collectors (java.util.stream.Collectors)5