Search in sources :

Example 1 with PromiseAppInfo

use of com.android.launcher3.PromiseAppInfo 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 2 with PromiseAppInfo

use of com.android.launcher3.PromiseAppInfo in project android_packages_apps_Trebuchet by LineageOS.

the class SecondaryDisplayLauncher method onIconClicked.

private void onIconClicked(View v) {
    // view has detached (it's possible for this to happen if the view is removed mid touch).
    if (v.getWindowToken() == null)
        return;
    Object tag = v.getTag();
    if (tag instanceof ItemInfo) {
        ItemInfo item = (ItemInfo) tag;
        Intent intent;
        if (item instanceof PromiseAppInfo) {
            PromiseAppInfo promiseAppInfo = (PromiseAppInfo) item;
            intent = promiseAppInfo.getMarketIntent(this);
        } else {
            intent = item.getIntent();
        }
        if (intent == null) {
            throw new IllegalArgumentException("Input must have a valid intent");
        }
        startActivitySafely(v, intent, item, CONTAINER_ALL_APPS);
    }
}
Also used : ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) PromiseAppInfo(com.android.launcher3.model.data.PromiseAppInfo) Intent(android.content.Intent)

Example 3 with PromiseAppInfo

use of com.android.launcher3.PromiseAppInfo in project android_packages_apps_Trebuchet by LineageOS.

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) {
        PromiseAppInfo updated = apps.updatePromiseInstallInfo(mInstallInfo);
        if (updated != null) {
            scheduleCallbackTask(c -> c.bindPromiseAppProgressUpdated(updated));
        }
        bindApplicationsIfNeeded();
    }
    synchronized (dataModel) {
        final HashSet<ItemInfo> updates = new HashSet<>();
        for (ItemInfo info : dataModel.itemsIdMap) {
            if (info instanceof WorkspaceItemInfo) {
                WorkspaceItemInfo si = (WorkspaceItemInfo) info;
                ComponentName cn = si.getTargetComponent();
                if (si.hasPromiseIconUi() && (cn != null) && mInstallInfo.packageName.equals(cn.getPackageName())) {
                    si.setInstallProgress(mInstallInfo.progress);
                    if (mInstallInfo.state == PackageInstallInfo.STATUS_FAILED) {
                        // Mark this info as broken.
                        si.status &= ~WorkspaceItemInfo.FLAG_INSTALL_SESSION_ACTIVE;
                    }
                    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(new CallbackTask() {

                @Override
                public void execute(Callbacks callbacks) {
                    callbacks.bindRestoreItemsChange(updates);
                }
            });
        }
    }
}
Also used : CallbackTask(com.android.launcher3.LauncherModel.CallbackTask) ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) ApplicationInfo(android.content.pm.ApplicationInfo) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) PackageManager(android.content.pm.PackageManager) Callbacks(com.android.launcher3.model.BgDataModel.Callbacks) PromiseAppInfo(com.android.launcher3.model.data.PromiseAppInfo) ComponentName(android.content.ComponentName) HashSet(java.util.HashSet) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 4 with PromiseAppInfo

use of com.android.launcher3.PromiseAppInfo in project android_packages_apps_Trebuchet by LineageOS.

the class AllAppsList method updatePromiseInstallInfo.

public PromiseAppInfo updatePromiseInstallInfo(PackageInstallInfo installInfo) {
    UserHandle user = Process.myUserHandle();
    for (int i = 0; i < data.size(); i++) {
        final AppInfo appInfo = data.get(i);
        final ComponentName tgtComp = appInfo.getTargetComponent();
        if (tgtComp != null && tgtComp.getPackageName().equals(installInfo.packageName) && appInfo.user.equals(user) && appInfo instanceof PromiseAppInfo) {
            final PromiseAppInfo promiseAppInfo = (PromiseAppInfo) appInfo;
            if (installInfo.state == PackageInstallInfo.STATUS_INSTALLING) {
                promiseAppInfo.level = installInfo.progress;
                return promiseAppInfo;
            } else if (installInfo.state == PackageInstallInfo.STATUS_FAILED) {
                removeApp(i);
            }
        }
    }
    return null;
}
Also used : UserHandle(android.os.UserHandle) PromiseAppInfo(com.android.launcher3.model.data.PromiseAppInfo) ComponentName(android.content.ComponentName) AppInfo(com.android.launcher3.model.data.AppInfo) PromiseAppInfo(com.android.launcher3.model.data.PromiseAppInfo)

Example 5 with PromiseAppInfo

use of com.android.launcher3.PromiseAppInfo in project android_packages_apps_Trebuchet by LineageOS.

the class AllAppsList method addPromiseApp.

public void addPromiseApp(Context context, PackageInstallInfo installInfo) {
    ApplicationInfo applicationInfo = new PackageManagerHelper(context).getApplicationInfo(installInfo.packageName, installInfo.user, 0);
    // only if not yet installed
    if (applicationInfo == null) {
        PromiseAppInfo info = new PromiseAppInfo(installInfo);
        mIconCache.getTitleAndIcon(info, info.usingLowResIcon());
        info.sectionName = mIndex.computeSectionName(info.title);
        data.add(info);
        mDataChanged = true;
    }
}
Also used : PromiseAppInfo(com.android.launcher3.model.data.PromiseAppInfo) ApplicationInfo(android.content.pm.ApplicationInfo) PackageManagerHelper(com.android.launcher3.util.PackageManagerHelper)

Aggregations

AppInfo (com.android.launcher3.model.data.AppInfo)10 ComponentName (android.content.ComponentName)7 PromiseAppInfo (com.android.launcher3.model.data.PromiseAppInfo)7 UserHandle (android.os.UserHandle)6 PromiseAppInfo (com.android.launcher3.PromiseAppInfo)5 PackageManagerHelper (com.android.launcher3.util.PackageManagerHelper)5 SuppressLint (android.annotation.SuppressLint)4 ApplicationInfo (android.content.pm.ApplicationInfo)4 LauncherActivityInfo (android.content.pm.LauncherActivityInfo)4 PackageInstaller (android.content.pm.PackageInstaller)4 SessionInfo (android.content.pm.PackageInstaller.SessionInfo)4 Point (android.graphics.Point)4 Nullable (androidx.annotation.Nullable)4 IconRequestInfo (com.android.launcher3.model.data.IconRequestInfo)4 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)4 ArrayList (java.util.ArrayList)4 Intent (android.content.Intent)3 AppInfo (com.android.launcher3.AppInfo)3 WorkspaceItemInfo (com.android.launcher3.WorkspaceItemInfo)3 ActivityNotFoundException (android.content.ActivityNotFoundException)2