Search in sources :

Example 1 with INSTALL

use of com.android.launcher3.popup.SystemShortcut.INSTALL in project android_packages_apps_Launcher3 by crdroidandroid.

the class SessionCommitReceiver method processIntent.

@WorkerThread
private static void processIntent(Context context, Intent intent) {
    if (!isEnabled(context)) {
        // User has decided to not add icons on homescreen.
        return;
    }
    SessionInfo info = intent.getParcelableExtra(PackageInstaller.EXTRA_SESSION);
    UserHandle user = intent.getParcelableExtra(Intent.EXTRA_USER);
    if (!PackageInstaller.ACTION_SESSION_COMMITTED.equals(intent.getAction()) || info == null || user == null) {
        // Invalid intent.
        return;
    }
    InstallSessionHelper packageInstallerCompat = InstallSessionHelper.INSTANCE.get(context);
    packageInstallerCompat.restoreDbIfApplicable(info);
    if (TextUtils.isEmpty(info.getAppPackageName()) || info.getInstallReason() != PackageManager.INSTALL_REASON_USER || packageInstallerCompat.promiseIconAddedForId(info.getSessionId())) {
        packageInstallerCompat.removePromiseIconId(info.getSessionId());
        return;
    }
    FileLog.d(LOG, "Adding package name to install queue. Package name: " + info.getAppPackageName() + ", has app icon: " + (info.getAppIcon() != null) + ", has app label: " + !TextUtils.isEmpty(info.getAppLabel()));
    ItemInstallQueue.INSTANCE.get(context).queueItem(info.getAppPackageName(), user);
}
Also used : UserHandle(android.os.UserHandle) SessionInfo(android.content.pm.PackageInstaller.SessionInfo) InstallSessionHelper(com.android.launcher3.pm.InstallSessionHelper) WorkerThread(androidx.annotation.WorkerThread)

Example 2 with INSTALL

use of com.android.launcher3.popup.SystemShortcut.INSTALL in project android_packages_apps_Launcher3 by crdroidandroid.

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 3 with INSTALL

use of com.android.launcher3.popup.SystemShortcut.INSTALL in project android_packages_apps_Launcher3 by crdroidandroid.

the class LauncherUIScrollTest method testWidgetsListScroll.

@Test
public void testWidgetsListScroll() throws Exception {
    // Install 100 widgets
    for (int i = 0; i < 100; i++) {
        mModelHelper.installCustomShortcut(TEST_PACKAGE + i, "shortcutProvider");
    }
    // Bind and open widgets
    Launcher launcher = loadLauncher();
    WidgetsFullSheet widgets = WidgetsFullSheet.show(launcher, false);
    doLayout(launcher);
    int currentScroll = widgets.getRecyclerView().getCurrentScrollY();
    launcher.dispatchGenericMotionEvent(createScrollEvent(-1));
    int newScroll = widgets.getRecyclerView().getCurrentScrollY();
    assertNotEquals("Widgets was not scrolled", currentScroll, newScroll);
    assertEquals("Workspace was scrolled", 0, launcher.getWorkspace().getNextPage());
}
Also used : LauncherUIHelper.buildAndBindLauncher(com.android.launcher3.util.LauncherUIHelper.buildAndBindLauncher) Launcher(com.android.launcher3.Launcher) WidgetsFullSheet(com.android.launcher3.widget.picker.WidgetsFullSheet) Test(org.junit.Test)

Example 4 with INSTALL

use of com.android.launcher3.popup.SystemShortcut.INSTALL in project android_packages_apps_Launcher3 by AOSPA.

the class SessionCommitReceiver method processIntent.

@WorkerThread
private static void processIntent(Context context, Intent intent) {
    if (!isEnabled(context)) {
        // User has decided to not add icons on homescreen.
        return;
    }
    SessionInfo info = intent.getParcelableExtra(PackageInstaller.EXTRA_SESSION);
    UserHandle user = intent.getParcelableExtra(Intent.EXTRA_USER);
    if (!PackageInstaller.ACTION_SESSION_COMMITTED.equals(intent.getAction()) || info == null || user == null) {
        // Invalid intent.
        return;
    }
    InstallSessionHelper packageInstallerCompat = InstallSessionHelper.INSTANCE.get(context);
    packageInstallerCompat.restoreDbIfApplicable(info);
    if (TextUtils.isEmpty(info.getAppPackageName()) || info.getInstallReason() != PackageManager.INSTALL_REASON_USER || packageInstallerCompat.promiseIconAddedForId(info.getSessionId())) {
        packageInstallerCompat.removePromiseIconId(info.getSessionId());
        return;
    }
    FileLog.d(LOG, "Adding package name to install queue. Package name: " + info.getAppPackageName() + ", has app icon: " + (info.getAppIcon() != null) + ", has app label: " + !TextUtils.isEmpty(info.getAppLabel()));
    ItemInstallQueue.INSTANCE.get(context).queueItem(info.getAppPackageName(), user);
}
Also used : UserHandle(android.os.UserHandle) SessionInfo(android.content.pm.PackageInstaller.SessionInfo) InstallSessionHelper(com.android.launcher3.pm.InstallSessionHelper) WorkerThread(androidx.annotation.WorkerThread)

Example 5 with INSTALL

use of com.android.launcher3.popup.SystemShortcut.INSTALL 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)

Aggregations

ItemInfo (com.android.launcher3.model.data.ItemInfo)15 HashSet (java.util.HashSet)14 HashMap (java.util.HashMap)13 BitmapInfo (com.android.launcher3.icons.BitmapInfo)12 LauncherIcons (com.android.launcher3.icons.LauncherIcons)12 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)12 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)12 ComponentName (android.content.ComponentName)9 Launcher (com.android.launcher3.Launcher)9 AppInfo (com.android.launcher3.model.data.AppInfo)9 Context (android.content.Context)7 ShortcutInfo (android.content.pm.ShortcutInfo)7 IconCache (com.android.launcher3.icons.IconCache)7 FlagOp (com.android.launcher3.util.FlagOp)7 ItemInfoMatcher (com.android.launcher3.util.ItemInfoMatcher)7 PackageUserKey (com.android.launcher3.util.PackageUserKey)7 SafeCloseable (com.android.launcher3.util.SafeCloseable)7 ArrayList (java.util.ArrayList)7 ApplicationInfo (android.content.pm.ApplicationInfo)6 LauncherApps (android.content.pm.LauncherApps)6