Search in sources :

Example 1 with PackageInstallInfo

use of com.android.launcher3.pm.PackageInstallInfo in project android_packages_apps_Launcher3 by crdroidandroid.

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 2 with PackageInstallInfo

use of com.android.launcher3.pm.PackageInstallInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class AllAppsList method addPromiseApp.

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

Example 3 with PackageInstallInfo

use of com.android.launcher3.pm.PackageInstallInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class InstallSessionTracker method onFinished.

@Override
public void onFinished(int sessionId, boolean success) {
    // For a finished session, we can't get the session info. So use the
    // packageName from our local cache.
    SparseArray<PackageUserKey> activeSessions = getActiveSessionMap();
    PackageUserKey key = activeSessions.get(sessionId);
    activeSessions.remove(sessionId);
    if (key != null && key.mPackageName != null) {
        String packageName = key.mPackageName;
        PackageInstallInfo info = PackageInstallInfo.fromState(success ? STATUS_INSTALLED : STATUS_FAILED, packageName, key.mUser);
        mCallback.onPackageStateChanged(info);
        if (!success && mInstallerCompat.promiseIconAddedForId(sessionId)) {
            mCallback.onSessionFailure(packageName, key.mUser);
            // If it is successful, the id is removed in the the package added flow.
            mInstallerCompat.removePromiseIconId(sessionId);
        }
    }
}
Also used : PackageUserKey(com.android.launcher3.util.PackageUserKey)

Example 4 with PackageInstallInfo

use of com.android.launcher3.pm.PackageInstallInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class PackageInstallStateChangedTaskTest method newTask.

private PackageInstallStateChangedTask newTask(String pkg, int progress) {
    int state = PackageInstallInfo.STATUS_INSTALLING;
    PackageInstallInfo installInfo = new PackageInstallInfo(pkg, state, progress, android.os.Process.myUserHandle());
    return new PackageInstallStateChangedTask(installInfo);
}
Also used : PackageInstallInfo(com.android.launcher3.pm.PackageInstallInfo)

Example 5 with PackageInstallInfo

use of com.android.launcher3.pm.PackageInstallInfo 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)

Aggregations

AppInfo (com.android.launcher3.model.data.AppInfo)16 PackageInstallInfo (com.android.launcher3.pm.PackageInstallInfo)11 ArrayList (java.util.ArrayList)10 ComponentName (android.content.ComponentName)7 UserHandle (android.os.UserHandle)7 PackageManagerHelper (com.android.launcher3.util.PackageManagerHelper)6 PackageUserKey (com.android.launcher3.util.PackageUserKey)6 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)5 Nullable (androidx.annotation.Nullable)4 PromiseAppInfo (com.android.launcher3.model.data.PromiseAppInfo)2 ApplicationInfo (android.content.pm.ApplicationInfo)1 AppInfo (com.android.launcher3.AppInfo)1 PromiseAppInfo (com.android.launcher3.PromiseAppInfo)1 PackageInstallInfo (com.android.launcher3.compat.PackageInstallerCompat.PackageInstallInfo)1