Search in sources :

Example 21 with PackageInstallInfo

use of com.android.launcher3.compat.PackageInstallerCompat.PackageInstallInfo in project Neo-Launcher by NeoApplications.

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 == PackageInstallerCompat.STATUS_INSTALLING) {
                promiseAppInfo.level = installInfo.progress;
                return promiseAppInfo;
            } else if (installInfo.state == PackageInstallerCompat.STATUS_FAILED) {
                removeApp(i);
            }
        }
    }
    return null;
}
Also used : UserHandle(android.os.UserHandle) PromiseAppInfo(com.android.launcher3.PromiseAppInfo) ComponentName(android.content.ComponentName) AppInfo(com.android.launcher3.AppInfo) PromiseAppInfo(com.android.launcher3.PromiseAppInfo)

Example 22 with PackageInstallInfo

use of com.android.launcher3.compat.PackageInstallerCompat.PackageInstallInfo in project android_packages_apps_Launcher3 by AOSPA.

the class InstallSessionTracker method onFinished.

@Override
public void onFinished(int sessionId, boolean success) {
    InstallSessionHelper helper = mWeakHelper.get();
    Callback callback = mWeakCallback.get();
    if (callback == null || helper == null) {
        return;
    }
    // For a finished session, we can't get the session info. So use the
    // packageName from our local cache.
    SparseArray<PackageUserKey> activeSessions = getActiveSessionMap(helper);
    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);
        callback.onPackageStateChanged(info);
        if (!success && helper.promiseIconAddedForId(sessionId)) {
            callback.onSessionFailure(packageName, key.mUser);
            // If it is successful, the id is removed in the the package added flow.
            helper.removePromiseIconId(sessionId);
        }
    }
}
Also used : PackageUserKey(com.android.launcher3.util.PackageUserKey)

Example 23 with PackageInstallInfo

use of com.android.launcher3.compat.PackageInstallerCompat.PackageInstallInfo in project android_packages_apps_Launcher3 by AOSPA.

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

use of com.android.launcher3.compat.PackageInstallerCompat.PackageInstallInfo in project android_packages_apps_Launcher3 by ArrowOS.

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

use of com.android.launcher3.compat.PackageInstallerCompat.PackageInstallInfo in project android_packages_apps_Launcher3 by ArrowOS.

the class PackageIncrementalDownloadUpdatedTask method execute.

@Override
public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList appsList) {
    PackageInstallInfo downloadInfo = new PackageInstallInfo(mPackageName, PackageInstallInfo.STATUS_INSTALLED_DOWNLOADING, mProgress, mUser);
    synchronized (appsList) {
        List<AppInfo> updatedAppInfos = appsList.updatePromiseInstallInfo(downloadInfo);
        if (!updatedAppInfos.isEmpty()) {
            for (AppInfo appInfo : updatedAppInfos) {
                appInfo.runtimeStatusFlags &= ~ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE;
                scheduleCallbackTask(c -> c.bindIncrementalDownloadProgressUpdated(appInfo));
            }
        }
        bindApplicationsIfNeeded();
    }
    final ArrayList<WorkspaceItemInfo> updatedWorkspaceItems = new ArrayList<>();
    synchronized (dataModel) {
        dataModel.forAllWorkspaceItemInfos(mUser, si -> {
            if (mPackageName.equals(si.getTargetPackage())) {
                si.runtimeStatusFlags &= ~ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE;
                si.setProgressLevel(downloadInfo);
                updatedWorkspaceItems.add(si);
            }
        });
    }
    bindUpdatedWorkspaceItems(updatedWorkspaceItems);
}
Also used : PackageInstallInfo(com.android.launcher3.pm.PackageInstallInfo) ArrayList(java.util.ArrayList) AppInfo(com.android.launcher3.model.data.AppInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

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