Search in sources :

Example 11 with IGNORE

use of com.android.launcher3.logging.StatsLogManager.LauncherEvent.IGNORE in project android_packages_apps_Launcher3 by AOSPA.

the class LoaderTask method run.

public void run() {
    synchronized (this) {
        // Skip fast if we are already stopped.
        if (mStopped) {
            return;
        }
    }
    Object traceToken = TraceHelper.INSTANCE.beginSection(TAG);
    TimingLogger logger = new TimingLogger(TAG, "run");
    LoaderMemoryLogger memoryLogger = new LoaderMemoryLogger();
    try (LauncherModel.LoaderTransaction transaction = mApp.getModel().beginLoader(this)) {
        List<ShortcutInfo> allShortcuts = new ArrayList<>();
        Trace.beginSection("LoadWorkspace");
        try {
            loadWorkspace(allShortcuts, memoryLogger);
        } finally {
            Trace.endSection();
        }
        logASplit(logger, "loadWorkspace");
        // (e.g. both grid preview and minimal device mode uses a different db)
        if (mApp.getInvariantDeviceProfile().dbFile.equals(mDbName)) {
            verifyNotStopped();
            sanitizeData();
            logASplit(logger, "sanitizeData");
        }
        verifyNotStopped();
        mResults.bindWorkspace(true);
        logASplit(logger, "bindWorkspace");
        mModelDelegate.workspaceLoadComplete();
        // Notify the installer packages of packages with active installs on the first screen.
        sendFirstScreenActiveInstallsBroadcast();
        logASplit(logger, "sendFirstScreenActiveInstallsBroadcast");
        // Take a break
        waitForIdle();
        logASplit(logger, "step 1 complete");
        verifyNotStopped();
        // second step
        Trace.beginSection("LoadAllApps");
        List<LauncherActivityInfo> allActivityList;
        try {
            allActivityList = loadAllApps();
        } finally {
            Trace.endSection();
        }
        logASplit(logger, "loadAllApps");
        verifyNotStopped();
        mResults.bindAllApps();
        logASplit(logger, "bindAllApps");
        verifyNotStopped();
        IconCacheUpdateHandler updateHandler = mIconCache.getUpdateHandler();
        setIgnorePackages(updateHandler);
        updateHandler.updateIcons(allActivityList, LauncherActivityCachingLogic.newInstance(mApp.getContext()), mApp.getModel()::onPackageIconsUpdated);
        logASplit(logger, "update icon cache");
        if (FeatureFlags.ENABLE_DEEP_SHORTCUT_ICON_CACHE.get()) {
            verifyNotStopped();
            logASplit(logger, "save shortcuts in icon cache");
            updateHandler.updateIcons(allShortcuts, new ShortcutCachingLogic(), mApp.getModel()::onPackageIconsUpdated);
        }
        // Take a break
        waitForIdle();
        logASplit(logger, "step 2 complete");
        verifyNotStopped();
        // third step
        List<ShortcutInfo> allDeepShortcuts = loadDeepShortcuts();
        logASplit(logger, "loadDeepShortcuts");
        verifyNotStopped();
        mResults.bindDeepShortcuts();
        logASplit(logger, "bindDeepShortcuts");
        if (FeatureFlags.ENABLE_DEEP_SHORTCUT_ICON_CACHE.get()) {
            verifyNotStopped();
            logASplit(logger, "save deep shortcuts in icon cache");
            updateHandler.updateIcons(allDeepShortcuts, new ShortcutCachingLogic(), (pkgs, user) -> {
            });
        }
        // Take a break
        waitForIdle();
        logASplit(logger, "step 3 complete");
        verifyNotStopped();
        // fourth step
        List<ComponentWithLabelAndIcon> allWidgetsList = mBgDataModel.widgetsModel.update(mApp, null);
        logASplit(logger, "load widgets");
        verifyNotStopped();
        mResults.bindWidgets();
        logASplit(logger, "bindWidgets");
        verifyNotStopped();
        updateHandler.updateIcons(allWidgetsList, new ComponentWithIconCachingLogic(mApp.getContext(), true), mApp.getModel()::onWidgetLabelsUpdated);
        logASplit(logger, "save widgets in icon cache");
        // fifth step
        if (FeatureFlags.FOLDER_NAME_SUGGEST.get()) {
            loadFolderNames();
        }
        verifyNotStopped();
        updateHandler.finish();
        logASplit(logger, "finish icon update");
        mModelDelegate.modelLoadComplete();
        transaction.commit();
        memoryLogger.clearLogs();
    } catch (CancellationException e) {
        // Loader stopped, ignore
        logASplit(logger, "Cancelled");
    } catch (Exception e) {
        memoryLogger.printLogs();
        throw e;
    } finally {
        logger.dumpToLog();
    }
    TraceHelper.INSTANCE.endSection(traceToken);
}
Also used : LauncherModel(com.android.launcher3.LauncherModel) ShortcutInfo(android.content.pm.ShortcutInfo) ArrayList(java.util.ArrayList) ShortcutCachingLogic(com.android.launcher3.icons.ShortcutCachingLogic) CancellationException(java.util.concurrent.CancellationException) ComponentWithIconCachingLogic(com.android.launcher3.icons.ComponentWithLabelAndIcon.ComponentWithIconCachingLogic) TimingLogger(android.util.TimingLogger) CancellationException(java.util.concurrent.CancellationException) LauncherActivityInfo(android.content.pm.LauncherActivityInfo) ComponentWithLabelAndIcon(com.android.launcher3.icons.ComponentWithLabelAndIcon) IconCacheUpdateHandler(com.android.launcher3.icons.cache.IconCacheUpdateHandler)

Example 12 with IGNORE

use of com.android.launcher3.logging.StatsLogManager.LauncherEvent.IGNORE 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)

Example 13 with IGNORE

use of com.android.launcher3.logging.StatsLogManager.LauncherEvent.IGNORE in project android_packages_apps_Launcher3 by AOSPA.

the class PinRequestHelper method createWorkspaceItemFromPinItemRequest.

/**
 * request.accept() will initiate the following flow:
 *      -> go-to-system-process for actual processing (a)
 *      -> callback-to-launcher on UI thread (b)
 *      -> post callback on the worker thread (c)
 *      -> Update model and unpin (in system) any shortcut not in out model. (d)
 *
 * Note that (b) will take at-least one frame as it involves posting callback from binder
 * thread to UI thread.
 * If (d) happens before we add this shortcut to our model, we will end up unpinning
 * the shortcut in the system.
 * Here its the caller's responsibility to add the newly created WorkspaceItemInfo immediately
 * to the model (which may involves a single post-to-worker-thread). That will guarantee
 * that (d) happens after model is updated.
 */
@Nullable
@TargetApi(Build.VERSION_CODES.O)
public static WorkspaceItemInfo createWorkspaceItemFromPinItemRequest(Context context, final PinItemRequest request, final long acceptDelay) {
    if (request != null && request.getRequestType() == PinItemRequest.REQUEST_TYPE_SHORTCUT && request.isValid()) {
        if (acceptDelay <= 0) {
            if (!request.accept()) {
                return null;
            }
        } else {
            // Block the worker thread until the accept() is called.
            MODEL_EXECUTOR.execute(new Runnable() {

                @Override
                public void run() {
                    try {
                        Thread.sleep(acceptDelay);
                    } catch (InterruptedException e) {
                    // Ignore
                    }
                    if (request.isValid()) {
                        request.accept();
                    }
                }
            });
        }
        ShortcutInfo si = request.getShortcutInfo();
        WorkspaceItemInfo info = new WorkspaceItemInfo(si, context);
        // Apply the unbadged icon synchronously using the caching logic directly and
        // fetch the actual icon asynchronously.
        info.bitmap = new ShortcutCachingLogic().loadIcon(context, si);
        LauncherAppState.getInstance(context).getModel().updateAndBindWorkspaceItem(info, si);
        return info;
    } else {
        return null;
    }
}
Also used : ShortcutInfo(android.content.pm.ShortcutInfo) ShortcutCachingLogic(com.android.launcher3.icons.ShortcutCachingLogic) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) TargetApi(android.annotation.TargetApi) Nullable(androidx.annotation.Nullable)

Example 14 with IGNORE

use of com.android.launcher3.logging.StatsLogManager.LauncherEvent.IGNORE 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 15 with IGNORE

use of com.android.launcher3.logging.StatsLogManager.LauncherEvent.IGNORE in project Neo-Launcher by NeoApplications.

the class OverviewWithoutFocusInputConsumer method finishTouchTracking.

private void finishTouchTracking(MotionEvent ev) {
    mVelocityTracker.computeCurrentVelocity(100);
    float velocityX = mVelocityTracker.getXVelocity();
    float velocityY = mVelocityTracker.getYVelocity();
    float velocity = mNavBarPosition.isRightEdge() ? -velocityX : (mNavBarPosition.isLeftEdge() ? velocityX : -velocityY);
    final boolean triggerQuickstep;
    int touch = Touch.FLING;
    if (Math.abs(velocity) >= ViewConfiguration.get(mContext).getScaledMinimumFlingVelocity()) {
        triggerQuickstep = velocity > 0;
    } else {
        float displacementX = mDisableHorizontalSwipe ? 0 : (ev.getX() - mDownPos.x);
        float displacementY = ev.getY() - mDownPos.y;
        triggerQuickstep = squaredHypot(displacementX, displacementY) >= mSquaredTouchSlop;
        touch = Touch.SWIPE;
    }
    if (triggerQuickstep) {
        mContext.startActivity(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
        TOUCH_INTERACTION_LOG.addLog("startQuickstep");
        BaseActivity activity = BaseDraggingActivity.fromContext(mContext);
        // This number doesn't reflect workspace page index.
        int pageIndex = -1;
        // It only indicates that launcher client screen was shown.
        int containerType = StatsLogUtils.getContainerTypeFromState(activity.getCurrentState());
        activity.getUserEventDispatcher().logActionOnContainer(touch, Direction.UP, containerType, pageIndex);
        activity.getUserEventDispatcher().setPreviousHomeGesture(true);
    } else {
    // ignore
    }
}
Also used : BaseActivity(com.android.launcher3.BaseActivity) Intent(android.content.Intent)

Aggregations

Ignore (org.junit.Ignore)17 Test (org.junit.Test)17 LargeTest (androidx.test.filters.LargeTest)16 ShortcutInfo (android.content.pm.ShortcutInfo)13 Point (android.graphics.Point)12 DragObject (com.android.launcher3.DropTarget.DragObject)12 ShortcutCachingLogic (com.android.launcher3.icons.ShortcutCachingLogic)12 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)12 Rect (android.graphics.Rect)11 DeviceProfile (com.android.launcher3.DeviceProfile)11 ItemInfo (com.android.launcher3.model.data.ItemInfo)11 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)11 ArrayList (java.util.ArrayList)11 AppInfo (com.android.launcher3.model.data.AppInfo)10 View (android.view.View)8 ActivityNotFoundException (android.content.ActivityNotFoundException)7 LauncherActivityInfo (android.content.pm.LauncherActivityInfo)7 ViewGroup (android.view.ViewGroup)7 AllApps (com.android.launcher3.tapl.AllApps)7 TargetApi (android.annotation.TargetApi)6