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

Commit 13c1c2cd authored by Winson Chung's avatar Winson Chung
Browse files

Migrate to using DefaultDisplay

- Remove extra binder calls to get the default display

Bug: 140633033
Change-Id: I532645deac101a6065d90484b87a67b67aa717f5
parent 72fddba8
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -44,7 +44,6 @@ import android.os.Vibrator;
import android.provider.Settings;
import android.provider.Settings;
import android.view.MotionEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.View;
import android.view.WindowManager;
import android.view.animation.Interpolator;
import android.view.animation.Interpolator;


import androidx.annotation.UiThread;
import androidx.annotation.UiThread;
@@ -274,7 +273,7 @@ public abstract class BaseSwipeUpHandler<T extends BaseDraggingActivity, Q exten
            overviewStackBounds = getStackBounds(dp);
            overviewStackBounds = getStackBounds(dp);
        }
        }
        dp.updateInsets(targetSet.homeContentInsets);
        dp.updateInsets(targetSet.homeContentInsets);
        dp.updateIsSeascape(mContext.getSystemService(WindowManager.class));
        dp.updateIsSeascape(mContext);
        if (runningTaskTarget != null) {
        if (runningTaskTarget != null) {
            mClipAnimationHelper.updateSource(overviewStackBounds, runningTaskTarget);
            mClipAnimationHelper.updateSource(overviewStackBounds, runningTaskTarget);
        }
        }
+14 −23
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@
package com.android.quickstep;
package com.android.quickstep;


import static android.view.MotionEvent.ACTION_DOWN;
import static android.view.MotionEvent.ACTION_DOWN;

import static com.android.launcher3.config.FeatureFlags.ADAPTIVE_ICON_WINDOW_ANIM;
import static com.android.launcher3.config.FeatureFlags.ADAPTIVE_ICON_WINDOW_ANIM;
import static com.android.launcher3.config.FeatureFlags.APPLY_CONFIG_AT_RUNTIME;
import static com.android.launcher3.config.FeatureFlags.APPLY_CONFIG_AT_RUNTIME;
import static com.android.launcher3.config.FeatureFlags.ENABLE_HINTS_IN_OVERVIEW;
import static com.android.launcher3.config.FeatureFlags.ENABLE_HINTS_IN_OVERVIEW;
@@ -51,8 +52,6 @@ import android.content.res.Configuration;
import android.graphics.Point;
import android.graphics.Point;
import android.graphics.RectF;
import android.graphics.RectF;
import android.graphics.Region;
import android.graphics.Region;
import android.hardware.display.DisplayManager;
import android.hardware.display.DisplayManager.DisplayListener;
import android.os.Build;
import android.os.Build;
import android.os.Bundle;
import android.os.Bundle;
import android.os.IBinder;
import android.os.IBinder;
@@ -62,14 +61,14 @@ import android.os.RemoteException;
import android.text.TextUtils;
import android.text.TextUtils;
import android.util.Log;
import android.util.Log;
import android.view.Choreographer;
import android.view.Choreographer;
import android.view.Display;
import android.view.InputEvent;
import android.view.InputEvent;
import android.view.MotionEvent;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.Surface;
import android.view.WindowManager;

import androidx.annotation.BinderThread;
import androidx.annotation.BinderThread;
import androidx.annotation.UiThread;
import androidx.annotation.UiThread;
import androidx.annotation.WorkerThread;
import androidx.annotation.WorkerThread;

import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.R;
import com.android.launcher3.R;
import com.android.launcher3.ResourceUtils;
import com.android.launcher3.ResourceUtils;
@@ -80,6 +79,7 @@ import com.android.launcher3.logging.UserEventDispatcher;
import com.android.launcher3.model.AppLaunchTracker;
import com.android.launcher3.model.AppLaunchTracker;
import com.android.launcher3.provider.RestoreDbTask;
import com.android.launcher3.provider.RestoreDbTask;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.util.DefaultDisplay;
import com.android.quickstep.SysUINavigationMode.Mode;
import com.android.quickstep.SysUINavigationMode.Mode;
import com.android.quickstep.SysUINavigationMode.NavigationModeChangeListener;
import com.android.quickstep.SysUINavigationMode.NavigationModeChangeListener;
import com.android.quickstep.inputconsumers.AccessibilityInputConsumer;
import com.android.quickstep.inputconsumers.AccessibilityInputConsumer;
@@ -132,7 +132,7 @@ class ArgList extends LinkedList<String> {
 */
 */
@TargetApi(Build.VERSION_CODES.Q)
@TargetApi(Build.VERSION_CODES.Q)
public class TouchInteractionService extends Service implements
public class TouchInteractionService extends Service implements
        NavigationModeChangeListener, DisplayListener {
        NavigationModeChangeListener, DefaultDisplay.DisplayInfoChangeListener {


    /**
    /**
     * NOTE: This value should be kept same as
     * NOTE: This value should be kept same as
@@ -323,8 +323,7 @@ public class TouchInteractionService extends Service implements
            registerReceiver(mUserUnlockedReceiver, new IntentFilter(Intent.ACTION_USER_UNLOCKED));
            registerReceiver(mUserUnlockedReceiver, new IntentFilter(Intent.ACTION_USER_UNLOCKED));
        }
        }


        mDefaultDisplayId = getSystemService(WindowManager.class).getDefaultDisplay()
        mDefaultDisplayId = DefaultDisplay.INSTANCE.get(this).getInfo().id;
                .getDisplayId();
        String blockingActivity = getString(R.string.gesture_blocking_activity);
        String blockingActivity = getString(R.string.gesture_blocking_activity);
        mGestureBlockingActivity = TextUtils.isEmpty(blockingActivity) ? null :
        mGestureBlockingActivity = TextUtils.isEmpty(blockingActivity) ? null :
                ComponentName.unflattenFromString(blockingActivity);
                ComponentName.unflattenFromString(blockingActivity);
@@ -391,9 +390,8 @@ public class TouchInteractionService extends Service implements
            return;
            return;
        }
        }


        Display defaultDisplay = getSystemService(WindowManager.class).getDefaultDisplay();
        DefaultDisplay.Info displayInfo = DefaultDisplay.INSTANCE.get(this).getInfo();
        Point realSize = new Point();
        Point realSize = new Point(displayInfo.realSize);
        defaultDisplay.getRealSize(realSize);
        mSwipeTouchRegion.set(0, 0, realSize.x, realSize.y);
        mSwipeTouchRegion.set(0, 0, realSize.x, realSize.y);
        if (mMode == Mode.NO_BUTTON) {
        if (mMode == Mode.NO_BUTTON) {
            int touchHeight = getNavbarSize(ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE);
            int touchHeight = getNavbarSize(ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE);
@@ -415,7 +413,7 @@ public class TouchInteractionService extends Service implements
        } else {
        } else {
            mAssistantLeftRegion.setEmpty();
            mAssistantLeftRegion.setEmpty();
            mAssistantRightRegion.setEmpty();
            mAssistantRightRegion.setEmpty();
            switch (defaultDisplay.getRotation()) {
            switch (displayInfo.rotation) {
                case Surface.ROTATION_90:
                case Surface.ROTATION_90:
                    mSwipeTouchRegion.left = mSwipeTouchRegion.right
                    mSwipeTouchRegion.left = mSwipeTouchRegion.right
                            - getNavbarSize(ResourceUtils.NAVBAR_LANDSCAPE_LEFT_RIGHT_SIZE);
                            - getNavbarSize(ResourceUtils.NAVBAR_LANDSCAPE_LEFT_RIGHT_SIZE);
@@ -438,10 +436,9 @@ public class TouchInteractionService extends Service implements
        }
        }
        if (mMode.hasGestures != newMode.hasGestures) {
        if (mMode.hasGestures != newMode.hasGestures) {
            if (newMode.hasGestures) {
            if (newMode.hasGestures) {
                getSystemService(DisplayManager.class).registerDisplayListener(
                DefaultDisplay.INSTANCE.get(this).addChangeListener(this);
                        this, MAIN_EXECUTOR.getHandler());
            } else {
            } else {
                getSystemService(DisplayManager.class).unregisterDisplayListener(this);
                DefaultDisplay.INSTANCE.get(this).removeChangeListener(this);
            }
            }
        }
        }
        mMode = newMode;
        mMode = newMode;
@@ -457,14 +454,8 @@ public class TouchInteractionService extends Service implements
    }
    }


    @Override
    @Override
    public void onDisplayAdded(int i) { }
    public void onDisplayInfoChanged(DefaultDisplay.Info info, int flags) {

        if (info.id != mDefaultDisplayId) {
    @Override
    public void onDisplayRemoved(int i) { }

    @Override
    public void onDisplayChanged(int displayId) {
        if (displayId != mDefaultDisplayId) {
            return;
            return;
        }
        }


@@ -529,7 +520,7 @@ public class TouchInteractionService extends Service implements
        }
        }
        disposeEventHandlers();
        disposeEventHandlers();
        if (mMode.hasGestures) {
        if (mMode.hasGestures) {
            getSystemService(DisplayManager.class).unregisterDisplayListener(this);
            DefaultDisplay.INSTANCE.get(this).removeChangeListener(this);
        }
        }


        sConnected = false;
        sConnected = false;
+4 −3
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.quickstep.inputconsumers;
import static android.view.MotionEvent.ACTION_CANCEL;
import static android.view.MotionEvent.ACTION_CANCEL;
import static android.view.MotionEvent.ACTION_POINTER_DOWN;
import static android.view.MotionEvent.ACTION_POINTER_DOWN;
import static android.view.MotionEvent.ACTION_UP;
import static android.view.MotionEvent.ACTION_UP;

import static com.android.launcher3.Utilities.squaredHypot;
import static com.android.launcher3.Utilities.squaredHypot;
import static com.android.launcher3.Utilities.squaredTouchSlop;
import static com.android.launcher3.Utilities.squaredTouchSlop;
import static com.android.quickstep.MultiStateCallback.DEBUG_STATES;
import static com.android.quickstep.MultiStateCallback.DEBUG_STATES;
@@ -35,9 +36,10 @@ import android.graphics.RectF;
import android.view.MotionEvent;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.VelocityTracker;
import android.view.ViewConfiguration;
import android.view.ViewConfiguration;
import android.view.WindowManager;

import com.android.launcher3.R;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.Utilities;
import com.android.launcher3.util.DefaultDisplay;
import com.android.quickstep.LockScreenRecentsActivity;
import com.android.quickstep.LockScreenRecentsActivity;
import com.android.quickstep.MultiStateCallback;
import com.android.quickstep.MultiStateCallback;
import com.android.quickstep.SwipeSharedState;
import com.android.quickstep.SwipeSharedState;
@@ -103,8 +105,7 @@ public class DeviceLockedInputConsumer implements InputConsumer,
        mRunningTaskId = runningTaskId;
        mRunningTaskId = runningTaskId;


        // Do not use DeviceProfile as the user data might be locked
        // Do not use DeviceProfile as the user data might be locked
        mDisplaySize = new Point();
        mDisplaySize = DefaultDisplay.INSTANCE.get(context).getInfo().realSize;
        context.getSystemService(WindowManager.class).getDefaultDisplay().getRealSize(mDisplaySize);


        // Init states
        // Init states
        mStateCallback = new MultiStateCallback(STATE_NAMES);
        mStateCallback = new MultiStateCallback(STATE_NAMES);
+2 −3
Original line number Original line Diff line number Diff line
@@ -21,9 +21,9 @@ import static com.android.quickstep.SysUINavigationMode.Mode.NO_BUTTON;


import android.content.Context;
import android.content.Context;
import android.view.Surface;
import android.view.Surface;
import android.view.WindowManager;


import com.android.launcher3.graphics.RotationMode;
import com.android.launcher3.graphics.RotationMode;
import com.android.launcher3.util.DefaultDisplay;
import com.android.quickstep.SysUINavigationMode;
import com.android.quickstep.SysUINavigationMode;


/**
/**
@@ -36,8 +36,7 @@ public class NavBarPosition {


    public NavBarPosition(Context context) {
    public NavBarPosition(Context context) {
        mMode = SysUINavigationMode.getMode(context);
        mMode = SysUINavigationMode.getMode(context);
        mDisplayRotation = context.getSystemService(WindowManager.class)
        mDisplayRotation = DefaultDisplay.INSTANCE.get(context).getInfo().rotation;
                .getDefaultDisplay().getRotation();
    }
    }


    public boolean isRightEdge() {
    public boolean isRightEdge() {
+4 −4
Original line number Original line Diff line number Diff line
@@ -30,6 +30,8 @@ import android.view.ActionMode;
import android.view.View;
import android.view.View;
import android.widget.Toast;
import android.widget.Toast;


import androidx.annotation.Nullable;

import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.model.AppLaunchTracker;
import com.android.launcher3.model.AppLaunchTracker;
@@ -39,8 +41,6 @@ import com.android.launcher3.uioverrides.WallpaperColorInfo;
import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.util.Themes;
import com.android.launcher3.util.Themes;


import androidx.annotation.Nullable;

/**
/**
 * Extension of BaseActivity allowing support for drag-n-drop
 * Extension of BaseActivity allowing support for drag-n-drop
 */
 */
@@ -241,14 +241,14 @@ public abstract class BaseDraggingActivity extends BaseActivity
    protected void onDeviceProfileInitiated() {
    protected void onDeviceProfileInitiated() {
        if (mDeviceProfile.isVerticalBarLayout()) {
        if (mDeviceProfile.isVerticalBarLayout()) {
            mRotationListener.enable();
            mRotationListener.enable();
            mDeviceProfile.updateIsSeascape(getWindowManager());
            mDeviceProfile.updateIsSeascape(this);
        } else {
        } else {
            mRotationListener.disable();
            mRotationListener.disable();
        }
        }
    }
    }


    private void onDeviceRotationChanged() {
    private void onDeviceRotationChanged() {
        if (mDeviceProfile.updateIsSeascape(getWindowManager())) {
        if (mDeviceProfile.updateIsSeascape(this)) {
            reapplyUi();
            reapplyUi();
        }
        }
    }
    }
Loading