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

Commit ddb449ef authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Get rid of a lot of binder calls

Lead to delays when entering recents.

Test: Open recents
Bug: 32668632
Change-Id: I7b5504d0c11208d9c4d55de2eace6407d186f25c
parent 44f4bcb8
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()) {
+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();
    }

    /**
+2 −1
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.util.SparseArray;
import android.util.SparseBooleanArray;
import android.util.SparseIntArray;

import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.Prefs;
import com.android.systemui.R;
import com.android.systemui.recents.Recents;
@@ -86,7 +87,7 @@ public class RecentsTaskLoadPlan {
        mCurrentQuietProfiles.clear();

        if (currentUserId == UserHandle.USER_CURRENT) {
            currentUserId = ActivityManager.getCurrentUser();
            currentUserId = KeyguardUpdateMonitor.getCurrentUser();
        }
        UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
        List<UserInfo> profiles = userManager.getProfiles(currentUserId);
+1 −1
Original line number Diff line number Diff line
@@ -1151,7 +1151,7 @@ public class DividerView extends FrameLayout implements OnTouchListener,
     */
    public int growsRecents() {
        boolean result = mGrowRecents
                && mWindowManagerProxy.getDockSide() == WindowManager.DOCKED_TOP
                && mDockSide == WindowManager.DOCKED_TOP
                && getCurrentPosition() == getSnapAlgorithm().getLastSplitTarget().position;
        if (result) {
            return getSnapAlgorithm().getMiddleTarget().position;