Search in sources :

Example 51 with IGNORE

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

the class LauncherAppsCompatVO 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
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 and fetch the actual icon asynchronously.
        LauncherIcons li = LauncherIcons.obtain(context);
        info.applyFrom(li.createShortcutIcon(si, false));
        li.recycle();
        LauncherAppState.getInstance(context).getModel().updateAndBindWorkspaceItem(info, si);
        return info;
    } else {
        return null;
    }
}
Also used : ShortcutInfo(android.content.pm.ShortcutInfo) LauncherIcons(com.android.launcher3.icons.LauncherIcons) WorkspaceItemInfo(com.android.launcher3.WorkspaceItemInfo) Nullable(androidx.annotation.Nullable)

Example 52 with IGNORE

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

the class Utilities method getDescendantCoordRelativeToAncestor.

/**
 * Given a coordinate relative to the descendant, find the coordinate in a parent view's
 * coordinates.
 *
 * @param descendant The descendant to which the passed coordinate is relative.
 * @param ancestor The root view to make the coordinates relative to.
 * @param coord The coordinate that we want mapped.
 * @param includeRootScroll Whether or not to account for the scroll of the descendant:
 *          sometimes this is relevant as in a child's coordinates within the descendant.
 * @param ignoreTransform If true, view transform is ignored
 * @param outRotation If not null, and {@param ignoreTransform} is true, this is set to the
 *                   overall rotation of the view in degrees.
 * @return The factor by which this descendant is scaled relative to this DragLayer. Caution
 *         this scale factor is assumed to be equal in X and Y, and so if at any point this
 *         assumption fails, we will need to return a pair of scale factors.
 */
public static float getDescendantCoordRelativeToAncestor(View descendant, View ancestor, float[] coord, boolean includeRootScroll, boolean ignoreTransform, float[] outRotation) {
    float scale = 1.0f;
    View v = descendant;
    while (v != ancestor && v != null) {
        // which is very strange... ignore the scroll.
        if (v != descendant || includeRootScroll) {
            offsetPoints(coord, -v.getScrollX(), -v.getScrollY());
        }
        if (ignoreTransform) {
            if (v instanceof Transposable) {
                RotationMode m = ((Transposable) v).getRotationMode();
                if (m.isTransposed) {
                    sMatrix.setRotate(m.surfaceRotation, v.getPivotX(), v.getPivotY());
                    sMatrix.mapPoints(coord);
                    if (outRotation != null) {
                        outRotation[0] += m.surfaceRotation;
                    }
                }
            }
        } else {
            v.getMatrix().mapPoints(coord);
        }
        offsetPoints(coord, v.getLeft(), v.getTop());
        scale *= v.getScaleX();
        v = (View) v.getParent();
    }
    return scale;
}
Also used : RotationMode(com.android.launcher3.graphics.RotationMode) Transposable(com.android.launcher3.views.Transposable) View(android.view.View)

Example 53 with IGNORE

use of com.android.launcher3.logging.StatsLogManager.LauncherEvent.IGNORE in project android_packages_apps_Trebuchet by LineageOS.

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");
    try (LauncherModel.LoaderTransaction transaction = mApp.getModel().beginLoader(this)) {
        List<ShortcutInfo> allShortcuts = new ArrayList<>();
        loadWorkspace(allShortcuts);
        loadCachedPredictions();
        logger.addSplit("loadWorkspace");
        verifyNotStopped();
        mResults.bindWorkspace();
        logger.addSplit("bindWorkspace");
        // Notify the installer packages of packages with active installs on the first screen.
        sendFirstScreenActiveInstallsBroadcast();
        logger.addSplit("sendFirstScreenActiveInstallsBroadcast");
        // Take a break
        waitForIdle();
        logger.addSplit("step 1 complete");
        verifyNotStopped();
        // second step
        List<LauncherActivityInfo> allActivityList = loadAllApps();
        logger.addSplit("loadAllApps");
        verifyNotStopped();
        mResults.bindAllApps();
        logger.addSplit("bindAllApps");
        verifyNotStopped();
        IconCacheUpdateHandler updateHandler = mIconCache.getUpdateHandler();
        setIgnorePackages(updateHandler);
        updateHandler.updateIcons(allActivityList, LauncherActivityCachingLogic.newInstance(mApp.getContext()), mApp.getModel()::onPackageIconsUpdated);
        logger.addSplit("update icon cache");
        if (FeatureFlags.ENABLE_DEEP_SHORTCUT_ICON_CACHE.get()) {
            verifyNotStopped();
            logger.addSplit("save shortcuts in icon cache");
            updateHandler.updateIcons(allShortcuts, new ShortcutCachingLogic(), mApp.getModel()::onPackageIconsUpdated);
        }
        // Take a break
        waitForIdle();
        logger.addSplit("step 2 complete");
        verifyNotStopped();
        // third step
        List<ShortcutInfo> allDeepShortcuts = loadDeepShortcuts();
        logger.addSplit("loadDeepShortcuts");
        verifyNotStopped();
        mResults.bindDeepShortcuts();
        logger.addSplit("bindDeepShortcuts");
        if (FeatureFlags.ENABLE_DEEP_SHORTCUT_ICON_CACHE.get()) {
            verifyNotStopped();
            logger.addSplit("save deep shortcuts in icon cache");
            updateHandler.updateIcons(allDeepShortcuts, new ShortcutCachingLogic(), (pkgs, user) -> {
            });
        }
        // Take a break
        waitForIdle();
        logger.addSplit("step 3 complete");
        verifyNotStopped();
        // fourth step
        List<ComponentWithLabelAndIcon> allWidgetsList = mBgDataModel.widgetsModel.update(mApp, null);
        logger.addSplit("load widgets");
        verifyNotStopped();
        mResults.bindWidgets();
        logger.addSplit("bindWidgets");
        verifyNotStopped();
        updateHandler.updateIcons(allWidgetsList, new ComponentWithIconCachingLogic(mApp.getContext(), true), mApp.getModel()::onWidgetLabelsUpdated);
        logger.addSplit("save widgets in icon cache");
        // fifth step
        if (FeatureFlags.FOLDER_NAME_SUGGEST.get()) {
            loadFolderNames();
        }
        verifyNotStopped();
        updateHandler.finish();
        logger.addSplit("finish icon update");
        transaction.commit();
    } catch (CancellationException e) {
        // Loader stopped, ignore
        logger.addSplit("Cancelled");
    } 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) 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 54 with IGNORE

use of com.android.launcher3.logging.StatsLogManager.LauncherEvent.IGNORE in project android_packages_apps_Trebuchet by LineageOS.

the class BaseSwipeUpHandlerV2 method doLogGesture.

private void doLogGesture(GestureEndTarget endTarget) {
    DeviceProfile dp = mDp;
    if (dp == null || mDownPos == null) {
        // We probably never received an animation controller, skip logging.
        return;
    }
    int pageIndex = endTarget == LAST_TASK ? LOG_NO_OP_PAGE_INDEX : mRecentsView.getNextPage();
    UserEventDispatcher.newInstance(mContext).logStateChangeAction(mLogAction, mLogDirection, (int) mDownPos.x, (int) mDownPos.y, ContainerType.NAVBAR, ContainerType.APP, endTarget.containerType, pageIndex);
    StatsLogManager.EventEnum event;
    switch(endTarget) {
        case HOME:
            event = LAUNCHER_HOME_GESTURE;
            break;
        case RECENTS:
            event = LAUNCHER_OVERVIEW_GESTURE;
            break;
        case LAST_TASK:
        case NEW_TASK:
            event = (mLogDirection == Direction.LEFT) ? LAUNCHER_QUICKSWITCH_LEFT : LAUNCHER_QUICKSWITCH_RIGHT;
            break;
        default:
            event = IGNORE;
    }
    ComponentName componentName = mGestureState.getRunningTask().baseActivity;
    StatsLogManager.newInstance(mContext).logger().withSrcState(LAUNCHER_STATE_BACKGROUND).withDstState(StatsLogManager.containerTypeToAtomState(endTarget.containerType)).withItemInfo(getItemInfo(componentName)).log(event);
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) ComponentName(android.content.ComponentName) StatsLogManager(com.android.launcher3.logging.StatsLogManager)

Example 55 with IGNORE

use of com.android.launcher3.logging.StatsLogManager.LauncherEvent.IGNORE in project android_packages_apps_Trebuchet by LineageOS.

the class Launcher method dump.

/**
 * $ adb shell dumpsys activity com.android.launcher3.Launcher [--all]
 */
@Override
public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) {
    super.dump(prefix, fd, writer, args);
    if (args.length > 0 && TextUtils.equals(args[0], "--all")) {
        writer.println(prefix + "Workspace Items");
        for (int i = 0; i < mWorkspace.getPageCount(); i++) {
            writer.println(prefix + "  Homescreen " + i);
            ViewGroup layout = ((CellLayout) mWorkspace.getPageAt(i)).getShortcutsAndWidgets();
            for (int j = 0; j < layout.getChildCount(); j++) {
                Object tag = layout.getChildAt(j).getTag();
                if (tag != null) {
                    writer.println(prefix + "    " + tag.toString());
                }
            }
        }
        writer.println(prefix + "  Hotseat");
        ViewGroup layout = mHotseat.getShortcutsAndWidgets();
        for (int j = 0; j < layout.getChildCount(); j++) {
            Object tag = layout.getChildAt(j).getTag();
            if (tag != null) {
                writer.println(prefix + "    " + tag.toString());
            }
        }
    }
    writer.println(prefix + "Misc:");
    dumpMisc(prefix + "\t", writer);
    writer.println(prefix + "\tmWorkspaceLoading=" + mWorkspaceLoading);
    writer.println(prefix + "\tmPendingRequestArgs=" + mPendingRequestArgs + " mPendingActivityResult=" + mPendingActivityResult);
    writer.println(prefix + "\tmRotationHelper: " + mRotationHelper);
    writer.println(prefix + "\tmAppWidgetHost.isListening: " + mAppWidgetHost.isListening());
    // Extra logging for general debugging
    mDragLayer.dump(prefix, writer);
    mStateManager.dump(prefix, writer);
    mPopupDataProvider.dump(prefix, writer);
    try {
        FileLog.flushAll(writer);
    } catch (Exception e) {
    // Ignore
    }
    mModel.dumpState(prefix, fd, writer, args);
    if (mLauncherCallbacks != null) {
        mLauncherCallbacks.dump(prefix, fd, writer, args);
    }
    mOverlayManager.dump(prefix, writer);
}
Also used : ViewGroup(android.view.ViewGroup) DragObject(com.android.launcher3.DropTarget.DragObject) ActivityNotFoundException(android.content.ActivityNotFoundException)

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