Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e69db0d5 authored by Shuming Hao's avatar Shuming Hao
Browse files

Revert "Load the split divider veil icons on a boosted background thread"

This reverts commit b3dee02f.

Reason for revert: b/383672263
Test: manual
Flag: EXEMPT bugfix

Change-Id: I61e5a94cc1e9406cb65628a920af64332e3e42d3
parent 2ff94617
Loading
Loading
Loading
Loading
+10 −60
Original line number Diff line number Diff line
@@ -33,14 +33,12 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.graphics.Color;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Binder;
import android.os.Trace;
import android.view.IWindow;
import android.view.LayoutInflater;
import android.view.SurfaceControl;
@@ -52,12 +50,10 @@ import android.widget.FrameLayout;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.android.launcher3.icons.IconProvider;
import com.android.wm.shell.R;
import com.android.wm.shell.common.ScreenshotUtils;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.common.SurfaceUtils;

import java.util.function.Consumer;
@@ -83,19 +79,9 @@ public class SplitDecorManager extends WindowlessWindowManager {
    private static final String RESIZING_BACKGROUND_SURFACE_NAME = "ResizingBackground";
    private static final String GAP_BACKGROUND_SURFACE_NAME = "GapBackground";

    // Indicates the loading state of mIcon
    enum IconLoadState {
        NOT_LOADED,
        LOADING,
        LOADED
    }

    private final IconProvider mIconProvider;
    private final ShellExecutor mMainExecutor;
    private final ShellExecutor mBgExecutor;

    private Drawable mIcon;
    private IconLoadState mIconLoadState = IconLoadState.NOT_LOADED;
    private ImageView mVeilIconView;
    private SurfaceControlViewHost mViewHost;
    /** The parent surface that this is attached to. Should be the stage root. */
@@ -123,14 +109,9 @@ public class SplitDecorManager extends WindowlessWindowManager {
    private int mOffsetY;
    private int mRunningAnimationCount = 0;

    public SplitDecorManager(Configuration configuration,
            IconProvider iconProvider,
            ShellExecutor mainExecutor,
            ShellExecutor bgExecutor) {
    public SplitDecorManager(Configuration configuration, IconProvider iconProvider) {
        super(configuration, null /* rootSurface */, null /* hostInputToken */);
        mIconProvider = iconProvider;
        mMainExecutor = mainExecutor;
        mBgExecutor = bgExecutor;
    }

    @Override
@@ -218,7 +199,6 @@ public class SplitDecorManager extends WindowlessWindowManager {
        }
        mHostLeash = null;
        mIcon = null;
        mIconLoadState = IconLoadState.NOT_LOADED;
        mVeilIconView = null;
        mIsCurrentlyChanging = false;
        mShown = false;
@@ -280,11 +260,10 @@ public class SplitDecorManager extends WindowlessWindowManager {
                    .setWindowCrop(mGapBackgroundLeash, sideBounds.width(), sideBounds.height());
        }

        if (mIconLoadState == IconLoadState.NOT_LOADED && resizingTask.topActivityInfo != null) {
            loadIconInBackground(resizingTask.topActivityInfo, () -> {
        if (mIcon == null && resizingTask.topActivityInfo != null) {
            mIcon = mIconProvider.getIcon(resizingTask.topActivityInfo);
            mVeilIconView.setImageDrawable(mIcon);
            mVeilIconView.setVisibility(View.VISIBLE);
            });

            WindowManager.LayoutParams lp =
                    (WindowManager.LayoutParams) mViewHost.getView().getLayoutParams();
@@ -438,10 +417,10 @@ public class SplitDecorManager extends WindowlessWindowManager {
        }

        if (mIcon == null && resizingTask.topActivityInfo != null) {
            loadIconInBackground(resizingTask.topActivityInfo, () -> {
            // Initialize icon
            mIcon = mIconProvider.getIcon(resizingTask.topActivityInfo);
            mVeilIconView.setImageDrawable(mIcon);
            mVeilIconView.setVisibility(View.VISIBLE);
            });

            WindowManager.LayoutParams lp =
                    (WindowManager.LayoutParams) mViewHost.getView().getLayoutParams();
@@ -474,7 +453,7 @@ public class SplitDecorManager extends WindowlessWindowManager {
            return;
        }

        // Re-center icon
        // Recenter icon
        t.setPosition(mIconLeash,
                mInstantaneousBounds.width() / 2f - mIconSize / 2f,
                mInstantaneousBounds.height() / 2f - mIconSize / 2f);
@@ -617,36 +596,7 @@ public class SplitDecorManager extends WindowlessWindowManager {
            mVeilIconView.setImageDrawable(null);
            t.hide(mIconLeash);
            mIcon = null;
            mIconLoadState = IconLoadState.NOT_LOADED;
        }
    }

    /**
     * Loads the icon for the given {@param info}, calling {@param postLoadCb} on the main thread
     * if provided.
     */
    private void loadIconInBackground(@NonNull ActivityInfo info, @Nullable Runnable postLoadCb) {
        mIconLoadState = IconLoadState.LOADING;
        mBgExecutor.setBoost();
        mBgExecutor.execute(() -> {
            Trace.beginSection("SplitDecorManager.loadIconInBackground("
                    + info.applicationInfo.packageName + ")");
            final Drawable icon = mIconProvider.getIcon(info);
            Trace.endSection();
            mMainExecutor.execute(() -> {
                if (mIconLoadState != IconLoadState.LOADING) {
                    // The request was canceled while loading in the background, just drop the
                    // result
                    return;
        }
                mIcon = icon;
                mIconLoadState = IconLoadState.LOADED;
                if (postLoadCb != null) {
                    postLoadCb.run();
                }
            });
            mBgExecutor.resetBoost();
        });
    }

    private static float[] getResizingBackgroundColor(ActivityManager.RunningTaskInfo taskInfo) {
+0 −4
Original line number Diff line number Diff line
@@ -794,10 +794,6 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
    }

    void onStartDragging() {
        // This triggers initialization of things like the resize veil in preparation for
        // showing it when the user moves the divider past the slop
        updateDividerBounds(getDividerPosition(), false /* shouldUseParallaxEffect */);

        mInteractionJankMonitor.begin(getDividerLeash(), mContext, mHandler,
                CUJ_SPLIT_SCREEN_RESIZE);
    }
+1 −3
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@ import com.android.wm.shell.common.split.SplitState;
import com.android.wm.shell.dagger.pip.TvPipModule;
import com.android.wm.shell.recents.RecentTasksController;
import com.android.wm.shell.shared.TransactionPool;
import com.android.wm.shell.shared.annotations.ShellBackgroundThread;
import com.android.wm.shell.shared.annotations.ShellMainThread;
import com.android.wm.shell.splitscreen.SplitScreenController;
import com.android.wm.shell.splitscreen.tv.TvSplitScreenController;
@@ -94,12 +93,11 @@ public class TvWMShellModule {
            SplitState splitState,
            @ShellMainThread ShellExecutor mainExecutor,
            Handler mainHandler,
            @ShellBackgroundThread ShellExecutor bgExecutor,
            SystemWindows systemWindows) {
        return new TvSplitScreenController(context, shellInit, shellCommandHandler, shellController,
                shellTaskOrganizer, syncQueue, rootTDAOrganizer, displayController,
                displayImeController, displayInsetsController, transitions, transactionPool,
                iconProvider, recentTasks, launchAdjacentController, multiInstanceHelper,
                splitState, mainExecutor, mainHandler, bgExecutor, systemWindows);
                splitState, mainExecutor, mainHandler, systemWindows);
    }
}
+2 −4
Original line number Diff line number Diff line
@@ -520,8 +520,7 @@ public abstract class WMShellModule {
            MultiInstanceHelper multiInstanceHelper,
            SplitState splitState,
            @ShellMainThread ShellExecutor mainExecutor,
            @ShellMainThread Handler mainHandler,
            @ShellBackgroundThread ShellExecutor bgExecutor) {
            @ShellMainThread Handler mainHandler) {
        return new SplitScreenController(
                context,
                shellInit,
@@ -545,8 +544,7 @@ public abstract class WMShellModule {
                multiInstanceHelper,
                splitState,
                mainExecutor,
                mainHandler,
                bgExecutor);
                mainHandler);
    }

    //
+3 −7
Original line number Diff line number Diff line
@@ -185,7 +185,6 @@ public class SplitScreenController implements SplitDragPolicy.Starter,
    private final LauncherApps mLauncherApps;
    private final RootTaskDisplayAreaOrganizer mRootTDAOrganizer;
    private final ShellExecutor mMainExecutor;
    private final ShellExecutor mBgExecutor;
    private final Handler mMainHandler;
    private final SplitScreenImpl mImpl = new SplitScreenImpl();
    private final DisplayController mDisplayController;
@@ -232,8 +231,7 @@ public class SplitScreenController implements SplitDragPolicy.Starter,
            MultiInstanceHelper multiInstanceHelper,
            SplitState splitState,
            ShellExecutor mainExecutor,
            Handler mainHandler,
            ShellExecutor bgExecutor) {
            Handler mainHandler) {
        mShellCommandHandler = shellCommandHandler;
        mShellController = shellController;
        mTaskOrganizer = shellTaskOrganizer;
@@ -243,7 +241,6 @@ public class SplitScreenController implements SplitDragPolicy.Starter,
        mRootTDAOrganizer = rootTDAOrganizer;
        mMainExecutor = mainExecutor;
        mMainHandler = mainHandler;
        mBgExecutor = bgExecutor;
        mDisplayController = displayController;
        mDisplayImeController = displayImeController;
        mDisplayInsetsController = displayInsetsController;
@@ -301,9 +298,8 @@ public class SplitScreenController implements SplitDragPolicy.Starter,
        return new StageCoordinator(mContext, DEFAULT_DISPLAY, mSyncQueue,
                mTaskOrganizer, mDisplayController, mDisplayImeController,
                mDisplayInsetsController, mTransitions, mTransactionPool, mIconProvider,
                mMainExecutor, mMainHandler, mBgExecutor, mRecentTasksOptional,
                mLaunchAdjacentController, mWindowDecorViewModel, mSplitState,
                mDesktopTasksController);
                mMainExecutor, mMainHandler, mRecentTasksOptional, mLaunchAdjacentController,
                mWindowDecorViewModel, mSplitState, mDesktopTasksController);
    }

    @Override
Loading