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

Commit 8902bbe4 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I7b5504d0,I10c263dc into oc-dev

* changes:
  Get rid of a lot of binder calls
  Fix recents entry delay
parents 605351c5 ddb449ef
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ import android.view.View;
public interface RecentsComponent {
    void showRecentApps(boolean triggeredFromAltTab, boolean fromHome);
    void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey);
    void toggleRecents(Display display);
    void toggleRecents();
    void preloadRecents();
    void showNextAffiliatedTask();
    void showPrevAffiliatedTask();
+2 −2
Original line number Diff line number Diff line
@@ -324,14 +324,14 @@ public class Recents extends SystemUI

    @Override
    public void toggleRecentApps() {
        toggleRecents(mContext.getSystemService(WindowManager.class).getDefaultDisplay());
        toggleRecents();
    }

    /**
     * Toggles the Recents activity.
     */
    @Override
    public void toggleRecents(Display display) {
    public void toggleRecents() {
        // Ensure the device has been provisioned before allowing the user to interact with
        // recents
        if (!isUserSetup()) {
+4 −2
Original line number Diff line number Diff line
@@ -222,6 +222,10 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
                                getApplicationContext()).onActionEnd(
                                LatencyTracker.ACTION_TOGGLE_RECENTS));
                    }
                    DejankUtils.postAfterTraversal(() -> {
                        Recents.getTaskLoader().startLoader(RecentsActivity.this);
                        Recents.getTaskLoader().getHighResThumbnailLoader().setVisible(true);
                    });
                    return true;
                }
            };
@@ -376,8 +380,6 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD

        // Notify of the next draw
        mRecentsView.getViewTreeObserver().addOnPreDrawListener(mRecentsDrawnEventListener);

        Recents.getTaskLoader().getHighResThumbnailLoader().setVisible(true);
    }

    @Override
+25 −14
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import static android.provider.Settings.Global.DEVELOPMENT_ENABLE_FREEFORM_WINDO

import android.annotation.NonNull;
import android.app.ActivityManager;
import android.app.ActivityManager.StackInfo;
import android.app.ActivityManager.TaskSnapshot;
import android.app.ActivityOptions;
import android.app.AppGlobals;
@@ -95,6 +96,8 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Acts as a shim around the real system services that we need to access data from, and provides
@@ -143,6 +146,7 @@ public class SystemServicesProxy {
    Canvas mBgProtectionCanvas;

    private final Handler mHandler = new H();
    private final ExecutorService mOnewayExecutor = Executors.newSingleThreadExecutor();

    /**
     * An abstract class to track task stack changes.
@@ -466,13 +470,20 @@ public class SystemServicesProxy {
        if (mIam == null) return false;

        try {
            ActivityManager.StackInfo homeStackInfo = mIam.getStackInfo(
                    ActivityManager.StackId.HOME_STACK_ID);
            ActivityManager.StackInfo fullscreenStackInfo = mIam.getStackInfo(
                    ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID);
            ActivityManager.StackInfo recentsStackInfo = mIam.getStackInfo(
                    ActivityManager.StackId.RECENTS_STACK_ID);

            List<StackInfo> stackInfos = mIam.getAllStackInfos();
            ActivityManager.StackInfo homeStackInfo = null;
            ActivityManager.StackInfo fullscreenStackInfo = null;
            ActivityManager.StackInfo recentsStackInfo = null;
            for (int i = 0; i < stackInfos.size(); i++) {
                StackInfo stackInfo = stackInfos.get(i);
                if (stackInfo.stackId == HOME_STACK_ID) {
                    homeStackInfo = stackInfo;
                } else if (stackInfo.stackId == FULLSCREEN_WORKSPACE_STACK_ID) {
                    fullscreenStackInfo = stackInfo;
                } else if (stackInfo.stackId == RECENTS_STACK_ID) {
                    recentsStackInfo = stackInfo;
                }
            }
            boolean homeStackVisibleNotOccluded = isStackNotOccluded(homeStackInfo,
                    fullscreenStackInfo);
            boolean recentsStackVisibleNotOccluded = isStackNotOccluded(recentsStackInfo,
@@ -755,10 +766,12 @@ public class SystemServicesProxy {
     * Sends a message to close other system windows.
     */
    public void sendCloseSystemWindows(String reason) {
        mOnewayExecutor.submit(() -> {
            try {
                mIam.closeSystemDialogs(reason);
            } catch (RemoteException e) {
            }
        });
    }

    /**
@@ -998,9 +1011,7 @@ public class SystemServicesProxy {
     * Returns the current user id.
     */
    public int getCurrentUser() {
        if (mAm == null) return 0;

        return mAm.getCurrentUser();
        return KeyguardUpdateMonitor.getCurrentUser();
    }

    /**
+11 −1
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ public class HighResThumbnailLoader implements TaskCallbacks {
    private boolean mLoading;
    private boolean mVisible;
    private boolean mFlingingFast;
    private boolean mTaskLoadQueueIdle;

    public HighResThumbnailLoader(SystemServicesProxy ssp, Looper looper) {
        mMainThreadHandler = new Handler(looper);
@@ -71,13 +72,22 @@ public class HighResThumbnailLoader implements TaskCallbacks {
        updateLoading();
    }

    /**
     * Sets whether the other task load queue is idling. Avoid double-loading bitmaps by not
     * starting this queue until the other queue is idling.
     */
    public void setTaskLoadQueueIdle(boolean idle) {
        mTaskLoadQueueIdle = idle;
        updateLoading();
    }

    @VisibleForTesting
    boolean isLoading() {
        return mLoading;
    }

    private void updateLoading() {
        setLoading(mVisible && !mFlingingFast);
        setLoading(mVisible && !mFlingingFast && mTaskLoadQueueIdle);
    }

    private void setLoading(boolean loading) {
Loading