Search in sources :

Example 6 with PromiseAppInfo

use of com.android.launcher3.PromiseAppInfo in project Neo-Launcher by NeoApplications.

the class AllAppsList method addPromiseApp.

public void addPromiseApp(Context context, PackageInstallerCompat.PackageInstallInfo installInfo) {
    ApplicationInfo applicationInfo = LauncherAppsCompat.getInstance(context).getApplicationInfo(installInfo.packageName, 0, installInfo.user);
    // 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.PromiseAppInfo) ApplicationInfo(android.content.pm.ApplicationInfo)

Example 7 with PromiseAppInfo

use of com.android.launcher3.PromiseAppInfo in project Neo-Launcher by NeoApplications.

the class PackageInstallStateChangedTask method execute.

@Override
public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList apps) {
    if (mInstallInfo.state == PackageInstallerCompat.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 == PackageInstallerCompat.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.ItemInfo) WorkspaceItemInfo(com.android.launcher3.WorkspaceItemInfo) ApplicationInfo(android.content.pm.ApplicationInfo) LauncherAppWidgetInfo(com.android.launcher3.LauncherAppWidgetInfo) PackageManager(android.content.pm.PackageManager) Callbacks(com.android.launcher3.model.BgDataModel.Callbacks) PromiseAppInfo(com.android.launcher3.PromiseAppInfo) ComponentName(android.content.ComponentName) HashSet(java.util.HashSet) WorkspaceItemInfo(com.android.launcher3.WorkspaceItemInfo)

Example 8 with PromiseAppInfo

use of com.android.launcher3.PromiseAppInfo in project Neo-Launcher by NeoApplications.

the class ItemClickHandler method startAppShortcutOrInfoActivity.

private static void startAppShortcutOrInfoActivity(View v, ItemInfo item, Launcher launcher, @Nullable String sourceContainer) {
    Intent intent;
    if (item instanceof PromiseAppInfo) {
        PromiseAppInfo promiseAppInfo = (PromiseAppInfo) item;
        intent = promiseAppInfo.getMarketIntent(launcher);
    } else {
        intent = item.getIntent();
    }
    if (intent == null) {
        throw new IllegalArgumentException("Input must have a valid intent");
    }
    if (item instanceof WorkspaceItemInfo) {
        WorkspaceItemInfo si = (WorkspaceItemInfo) item;
        if (si.hasStatusFlag(WorkspaceItemInfo.FLAG_SUPPORTS_WEB_UI) && Intent.ACTION_VIEW.equals(intent.getAction())) {
            // make a copy of the intent that has the package set to null
            // we do this because the platform sometimes disables instant
            // apps temporarily (triggered by the user) and fallbacks to the
            // web ui. This only works though if the package isn't set
            intent = new Intent(intent);
            intent.setPackage(null);
        }
    }
    if (v != null && launcher.getAppTransitionManager().supportsAdaptiveIconAnimation()) {
        // Preload the icon to reduce latency b/w swapping the floating view with the original.
        FloatingIconView.fetchIcon(launcher, v, item, true);
    }
    if (item instanceof AppInfo) {
        Log.i(TAG, "Clicking App " + item.title);
        DbHelper db = new DbHelper(launcher.getApplicationContext());
        db.updateAppCount(((AppInfo) item).componentName.getPackageName());
        db.close();
    }
    launcher.startActivitySafely(v, intent, item, sourceContainer);
    launcher.getUserEventDispatcher().logAppLaunch(v, intent, item.user);
}
Also used : PromiseAppInfo(com.android.launcher3.PromiseAppInfo) Intent(android.content.Intent) DbHelper(com.saggitt.omega.util.DbHelper) WorkspaceItemInfo(com.android.launcher3.WorkspaceItemInfo) AppInfo(com.android.launcher3.AppInfo) PromiseAppInfo(com.android.launcher3.PromiseAppInfo)

Example 9 with PromiseAppInfo

use of com.android.launcher3.PromiseAppInfo in project android_packages_apps_Launcher3 by ArrowOS.

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 10 with PromiseAppInfo

use of com.android.launcher3.PromiseAppInfo in project android_packages_apps_Launcher3 by ProtonAOSP.

the class LoaderTask method loadAllApps.

private List<LauncherActivityInfo> loadAllApps() {
    final List<UserHandle> profiles = mUserCache.getUserProfiles();
    List<LauncherActivityInfo> allActivityList = new ArrayList<>();
    // Clear the list of apps
    mBgAllAppsList.clear();
    List<IconRequestInfo<AppInfo>> iconRequestInfos = new ArrayList<>();
    for (UserHandle user : profiles) {
        // Query for the set of apps
        final List<LauncherActivityInfo> apps = mLauncherApps.getActivityList(null, user);
        // TODO: Fix this. Only fail for the current user.
        if (apps == null || apps.isEmpty()) {
            return allActivityList;
        }
        boolean quietMode = mUserManagerState.isUserQuiet(user);
        // Create the ApplicationInfos
        for (int i = 0; i < apps.size(); i++) {
            LauncherActivityInfo app = apps.get(i);
            AppInfo appInfo = new AppInfo(app, user, quietMode);
            iconRequestInfos.add(new IconRequestInfo<>(appInfo, app, /* useLowResIcon= */
            false));
            mBgAllAppsList.add(appInfo, app, !FeatureFlags.ENABLE_BULK_ALL_APPS_ICON_LOADING.get());
        }
        allActivityList.addAll(apps);
    }
    if (FeatureFlags.PROMISE_APPS_IN_ALL_APPS.get()) {
        // get all active sessions and add them to the all apps list
        for (PackageInstaller.SessionInfo info : mSessionHelper.getAllVerifiedSessions()) {
            AppInfo promiseAppInfo = mBgAllAppsList.addPromiseApp(mApp.getContext(), PackageInstallInfo.fromInstallingState(info), !FeatureFlags.ENABLE_BULK_ALL_APPS_ICON_LOADING.get());
            if (promiseAppInfo != null) {
                iconRequestInfos.add(new IconRequestInfo<>(promiseAppInfo, /* launcherActivityInfo= */
                null, promiseAppInfo.usingLowResIcon()));
            }
        }
    }
    if (FeatureFlags.ENABLE_BULK_ALL_APPS_ICON_LOADING.get()) {
        Trace.beginSection("LoadAllAppsIconsInBulk");
        try {
            mIconCache.getTitlesAndIconsInBulk(iconRequestInfos);
            iconRequestInfos.forEach(iconRequestInfo -> mBgAllAppsList.updateSectionName(iconRequestInfo.itemInfo));
        } finally {
            Trace.endSection();
        }
    }
    mBgAllAppsList.setFlags(FLAG_QUIET_MODE_ENABLED, mUserManagerState.isAnyProfileQuietModeEnabled());
    mBgAllAppsList.setFlags(FLAG_HAS_SHORTCUT_PERMISSION, hasShortcutsPermission(mApp.getContext()));
    mBgAllAppsList.setFlags(FLAG_QUIET_MODE_CHANGE_PERMISSION, mApp.getContext().checkSelfPermission("android.permission.MODIFY_QUIET_MODE") == PackageManager.PERMISSION_GRANTED);
    mBgAllAppsList.getAndResetChangeFlag();
    return allActivityList;
}
Also used : ArrayList(java.util.ArrayList) IconRequestInfo(com.android.launcher3.model.data.IconRequestInfo) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point) AppInfo(com.android.launcher3.model.data.AppInfo) SessionInfo(android.content.pm.PackageInstaller.SessionInfo) UserHandle(android.os.UserHandle) LauncherActivityInfo(android.content.pm.LauncherActivityInfo) PackageInstaller(android.content.pm.PackageInstaller)

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