Search in sources :

Example 31 with AppInfo

use of com.android.launcher3.model.data.AppInfo in project android_packages_apps_Launcher3 by AOSPA.

the class PackageInstallStateChangedTask method execute.

@Override
public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList apps) {
    if (mInstallInfo.state == PackageInstallInfo.STATUS_INSTALLED) {
        try {
            // For instant apps we do not get package-add. Use setting events to update
            // any pinned icons.
            ApplicationInfo ai = app.getContext().getPackageManager().getApplicationInfo(mInstallInfo.packageName, 0);
            if (InstantAppResolver.newInstance(app.getContext()).isInstantApp(ai)) {
                app.getModel().onPackageAdded(ai.packageName, mInstallInfo.user);
            }
        } catch (PackageManager.NameNotFoundException e) {
        // Ignore
        }
        // Ignore install success events as they are handled by Package add events.
        return;
    }
    synchronized (apps) {
        List<AppInfo> updatedAppInfos = apps.updatePromiseInstallInfo(mInstallInfo);
        if (!updatedAppInfos.isEmpty()) {
            for (AppInfo appInfo : updatedAppInfos) {
                scheduleCallbackTask(c -> c.bindIncrementalDownloadProgressUpdated(appInfo));
            }
        }
        bindApplicationsIfNeeded();
    }
    synchronized (dataModel) {
        final HashSet<ItemInfo> updates = new HashSet<>();
        dataModel.forAllWorkspaceItemInfos(mInstallInfo.user, si -> {
            if (si.hasPromiseIconUi() && mInstallInfo.packageName.equals(si.getTargetPackage())) {
                si.setProgressLevel(mInstallInfo);
                updates.add(si);
            }
        });
        for (LauncherAppWidgetInfo widget : dataModel.appWidgets) {
            if (widget.providerName.getPackageName().equals(mInstallInfo.packageName)) {
                widget.installProgress = mInstallInfo.progress;
                updates.add(widget);
            }
        }
        if (!updates.isEmpty()) {
            scheduleCallbackTask(callbacks -> callbacks.bindRestoreItemsChange(updates));
        }
    }
}
Also used : PackageManager(android.content.pm.PackageManager) ItemInfo(com.android.launcher3.model.data.ItemInfo) ApplicationInfo(android.content.pm.ApplicationInfo) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) AppInfo(com.android.launcher3.model.data.AppInfo) HashSet(java.util.HashSet)

Example 32 with AppInfo

use of com.android.launcher3.model.data.AppInfo in project android_packages_apps_Launcher3 by AOSPA.

the class AllAppsList method updatePromiseInstallInfo.

/**
 * Updates the given PackageInstallInfo's associated AppInfo's installation info.
 */
public List<AppInfo> updatePromiseInstallInfo(PackageInstallInfo installInfo) {
    List<AppInfo> updatedAppInfos = new ArrayList<>();
    UserHandle user = installInfo.user;
    for (int i = data.size() - 1; i >= 0; i--) {
        final AppInfo appInfo = data.get(i);
        final ComponentName tgtComp = appInfo.getTargetComponent();
        if (tgtComp != null && tgtComp.getPackageName().equals(installInfo.packageName) && appInfo.user.equals(user)) {
            if (installInfo.state == PackageInstallInfo.STATUS_INSTALLED_DOWNLOADING || installInfo.state == PackageInstallInfo.STATUS_INSTALLING) {
                if (appInfo.isAppStartable() && installInfo.state == PackageInstallInfo.STATUS_INSTALLING) {
                    continue;
                }
                appInfo.setProgressLevel(installInfo);
                updatedAppInfos.add(appInfo);
            } else if (installInfo.state == PackageInstallInfo.STATUS_FAILED && !appInfo.isAppStartable()) {
                removeApp(i);
            }
        }
    }
    return updatedAppInfos;
}
Also used : UserHandle(android.os.UserHandle) ArrayList(java.util.ArrayList) ComponentName(android.content.ComponentName) AppInfo(com.android.launcher3.model.data.AppInfo)

Example 33 with AppInfo

use of com.android.launcher3.model.data.AppInfo in project android_packages_apps_Launcher3 by AOSPA.

the class AllAppsList method updatePackage.

/**
 * Add and remove icons for this package which has been updated.
 */
public List<LauncherActivityInfo> updatePackage(Context context, String packageName, UserHandle user) {
    final List<LauncherActivityInfo> matches = context.getSystemService(LauncherApps.class).getActivityList(packageName, user);
    if (matches.size() > 0) {
        // to the removed list.
        for (int i = data.size() - 1; i >= 0; i--) {
            final AppInfo applicationInfo = data.get(i);
            if (user.equals(applicationInfo.user) && packageName.equals(applicationInfo.componentName.getPackageName())) {
                if (!findActivity(matches, applicationInfo.componentName)) {
                    Log.w(TAG, "Changing shortcut target due to app component name change.");
                    removeApp(i);
                }
            }
        }
        // Also updates existing activities with new labels/icons
        for (final LauncherActivityInfo info : matches) {
            AppInfo applicationInfo = findAppInfo(info.getComponentName(), user);
            if (applicationInfo == null) {
                add(new AppInfo(context, info, user), info);
            } else {
                Intent launchIntent = AppInfo.makeLaunchIntent(info);
                mIconCache.getTitleAndIcon(applicationInfo, info, false);
                applicationInfo.sectionName = mIndex.computeSectionName(applicationInfo.title);
                applicationInfo.setProgressLevel(PackageManagerHelper.getLoadingProgress(info), PackageInstallInfo.STATUS_INSTALLED_DOWNLOADING);
                applicationInfo.intent = launchIntent;
                mDataChanged = true;
            }
        }
    } else {
        // Remove all data for this package.
        for (int i = data.size() - 1; i >= 0; i--) {
            final AppInfo applicationInfo = data.get(i);
            if (user.equals(applicationInfo.user) && packageName.equals(applicationInfo.componentName.getPackageName())) {
                mIconCache.remove(applicationInfo.componentName, user);
                removeApp(i);
            }
        }
    }
    return matches;
}
Also used : LauncherActivityInfo(android.content.pm.LauncherActivityInfo) LauncherApps(android.content.pm.LauncherApps) Intent(android.content.Intent) AppInfo(com.android.launcher3.model.data.AppInfo)

Example 34 with AppInfo

use of com.android.launcher3.model.data.AppInfo in project android_packages_apps_Launcher3 by AOSPA.

the class AllAppsList method addPromiseApp.

@Nullable
public AppInfo addPromiseApp(Context context, PackageInstallInfo installInfo, boolean loadIcon) {
    // only if not yet installed
    if (new PackageManagerHelper(context).isAppInstalled(installInfo.packageName, installInfo.user)) {
        return null;
    }
    AppInfo promiseAppInfo = new AppInfo(installInfo);
    if (loadIcon) {
        mIconCache.getTitleAndIcon(promiseAppInfo, promiseAppInfo.usingLowResIcon());
        promiseAppInfo.sectionName = mIndex.computeSectionName(promiseAppInfo.title);
    }
    data.add(promiseAppInfo);
    mDataChanged = true;
    return promiseAppInfo;
}
Also used : PackageManagerHelper(com.android.launcher3.util.PackageManagerHelper) AppInfo(com.android.launcher3.model.data.AppInfo) Nullable(androidx.annotation.Nullable)

Example 35 with AppInfo

use of com.android.launcher3.model.data.AppInfo in project android_packages_apps_Launcher3 by AOSPA.

the class AllAppsList method updateIconsAndLabels.

public void updateIconsAndLabels(HashSet<String> packages, UserHandle user) {
    for (AppInfo info : data) {
        if (info.user.equals(user) && packages.contains(info.componentName.getPackageName())) {
            mIconCache.updateTitleAndIcon(info);
            info.sectionName = mIndex.computeSectionName(info.title);
            mDataChanged = true;
        }
    }
}
Also used : AppInfo(com.android.launcher3.model.data.AppInfo)

Aggregations

AppInfo (com.android.launcher3.model.data.AppInfo)181 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)86 ItemInfo (com.android.launcher3.model.data.ItemInfo)46 ArrayList (java.util.ArrayList)46 ComponentName (android.content.ComponentName)36 AppInfo (com.android.launcher3.AppInfo)33 View (android.view.View)32 LauncherActivityInfo (android.content.pm.LauncherActivityInfo)31 Intent (android.content.Intent)30 FolderInfo (com.android.launcher3.model.data.FolderInfo)30 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)30 UserHandle (android.os.UserHandle)21 PackageItemInfo (com.android.launcher3.model.data.PackageItemInfo)21 PendingAddShortcutInfo (com.android.launcher3.widget.PendingAddShortcutInfo)21 Point (android.graphics.Point)19 BubbleTextView (com.android.launcher3.BubbleTextView)19 LauncherApps (android.content.pm.LauncherApps)17 ItemInfoWithIcon (com.android.launcher3.model.data.ItemInfoWithIcon)17 PendingAddItemInfo (com.android.launcher3.PendingAddItemInfo)15 AppWidgetHostView (android.appwidget.AppWidgetHostView)14