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

Commit e108b677 authored by Winson Chung's avatar Winson Chung
Browse files

Check the overlay state for updating sysui

Bug: 127366543
Test: Change the system navigation gesture setting, ensure SystemUI updates
Change-Id: I448ea554b0bea2e3742291fc9ce12ab87c9fdbd5
parent 6afd0400
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -21,12 +21,8 @@ import android.annotation.IntDef;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 * TODO: Remove this class
 */
public class NavigationBarCompat extends QuickStepContract {


    @Retention(RetentionPolicy.SOURCE)
    @IntDef({HIT_TARGET_NONE, HIT_TARGET_BACK, HIT_TARGET_HOME, HIT_TARGET_OVERVIEW})
    public @interface HitTarget{}
@@ -59,4 +55,6 @@ public class NavigationBarCompat extends QuickStepContract {
     * Interaction type: show/hide the overview button while this service is connected to launcher
     */
    public static final int FLAG_SHOW_OVERVIEW_BUTTON = 0x4;


}
+63 −0
Original line number Diff line number Diff line
@@ -16,7 +16,13 @@

package com.android.systemui.shared.system;

import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;

import android.content.Context;
import android.content.res.Resources;
import android.view.WindowManagerPolicyConstants;

/**
 * Various shared constants between Launcher and SysUI as part of quickstep
@@ -28,6 +34,13 @@ public class QuickStepContract {
    public static final String KEY_EXTRA_WINDOW_CORNER_RADIUS = "extra_window_corner_radius";
    public static final String KEY_EXTRA_SUPPORTS_WINDOW_CORNERS = "extra_supports_window_corners";

    public static final String NAV_BAR_MODE_2BUTTON_OVERLAY =
            WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON_OVERLAY;
    public static final String NAV_BAR_MODE_3BUTTON_OVERLAY =
            WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON_OVERLAY;
    public static final String NAV_BAR_MODE_GESTURAL_OVERLAY =
            WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY;

    /**
     * Touch slopes and thresholds for quick step operations. Drag slop is the point where the
     * home button press/long press over are ignored and will start to drag when exceeded and the
@@ -49,4 +62,54 @@ public class QuickStepContract {
    private static int convertDpToPixel(float dp) {
        return (int) (dp * Resources.getSystem().getDisplayMetrics().density);
    }

    /**
     * @return whether this nav bar mode is edge to edge
     */
    public static boolean isGesturalMode(int mode) {
        return mode == NAV_BAR_MODE_GESTURAL;
    }

    /**
     * @return whether the current nav bar mode is gestural
     */
    public static boolean isGesturalMode(Context context) {
        return isGesturalMode(getCurrentInteractionMode(context));
    }

    /**
     * @return whether this nav bar mode is swipe up
     */
    public static boolean isSwipeUpMode(int mode) {
        return mode == NAV_BAR_MODE_2BUTTON;
    }

    /**
     * @return whether the current nav bar mode is swipe up
     */
    public static boolean isSwipeUpMode(Context context) {
        return isSwipeUpMode(getCurrentInteractionMode(context));
    }

    /**
     * @return whether this nav bar mode is 3 button
     */
    public static boolean isLegacyMode(int mode) {
        return mode == NAV_BAR_MODE_3BUTTON;
    }

    /**
     * @return whether this nav bar mode is 3 button
     */
    public static boolean isLegacyMode(Context context) {
        return isLegacyMode(getCurrentInteractionMode(context));
    }

    /**
     * @return the current nav bar interaction mode
     */
    public static int getCurrentInteractionMode(Context context) {
        return context.getResources().getInteger(
                com.android.internal.R.integer.config_navBarInteractionMode);
    }
}
+4 −9
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import static android.content.pm.PackageManager.MATCH_SYSTEM_ONLY;
import static android.view.MotionEvent.ACTION_CANCEL;
import static android.view.MotionEvent.ACTION_DOWN;
import static android.view.MotionEvent.ACTION_UP;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;

import static com.android.systemui.shared.system.NavigationBarCompat.FLAG_DISABLE_SWIPE_UP;
import static com.android.systemui.shared.system.NavigationBarCompat.FLAG_SHOW_OVERVIEW_BUTTON;
@@ -37,7 +36,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.res.Resources;
import android.graphics.Rect;
import android.graphics.Region;
import android.os.Binder;
@@ -61,6 +59,7 @@ import com.android.systemui.shared.recents.IOverviewProxy;
import com.android.systemui.shared.recents.ISystemUiProxy;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.InputChannelCompat.InputEventDispatcher;
import com.android.systemui.shared.system.QuickStepContract;
import com.android.systemui.stackdivider.Divider;
import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.policy.CallbackController;
@@ -590,9 +589,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis

    private int getDefaultInteractionFlags() {
        // If there is no settings available use device default or get it from settings
        int navBarMode = Resources.getSystem().getInteger(
                com.android.internal.R.integer.config_navBarInteractionMode);
        return navBarMode == NAV_BAR_MODE_3BUTTON
        return QuickStepContract.isLegacyMode(mContext)
                ? DEFAULT_DISABLE_SWIPE_UP_STATE
                : 0;
    }
@@ -651,10 +648,8 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis

        pw.print("  quickStepIntent="); pw.println(mQuickStepIntent);
        pw.print("  quickStepIntentResolved="); pw.println(isEnabled());

        int navBarMode = Resources.getSystem().getInteger(
                com.android.internal.R.integer.config_navBarInteractionMode);
        pw.print("  navBarMode="); pw.println(navBarMode);
        pw.print("  navBarMode=");
        pw.println(QuickStepContract.getCurrentInteractionMode(mContext));
    }

    public interface OverviewProxyListener {
+3 −5
Original line number Diff line number Diff line
@@ -21,10 +21,11 @@ import static android.view.Display.DEFAULT_DISPLAY;
import android.content.Context;
import android.graphics.Rect;
import android.os.Handler;
import android.provider.Settings;
import android.view.CompositionSamplingListener;
import android.view.View;

import com.android.systemui.shared.system.QuickStepContract;

import java.io.PrintWriter;

/**
@@ -166,9 +167,6 @@ public class NavBarTintController implements View.OnAttachStateChangeListener,

    public static boolean isEnabled(Context context) {
        return context.getDisplayId() == DEFAULT_DISPLAY
                && Settings.Global.getInt(context.getContentResolver(),
                        NavigationPrototypeController.NAV_COLOR_ADAPT_ENABLE_SETTING, 0) == 1
                && Settings.Global.getInt(context.getContentResolver(),
                        NavigationPrototypeController.SHOW_HOME_HANDLE_SETTING, 0) == 1;
                && QuickStepContract.isGesturalMode(context);
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ public class NavigationBackAction extends NavigationGestureAction {

    @Override
    protected void onGestureStart(MotionEvent event) {
        if (!QuickStepController.shouldhideBackButton(getContext())) {
        if (!QuickStepController.shouldHideBackButton(getContext())) {
            mNavigationBarView.getBackButton().setAlpha(0 /* alpha */, true /* animate */,
                    BACK_BUTTON_FADE_OUT_ALPHA);
        }
@@ -85,7 +85,7 @@ public class NavigationBackAction extends NavigationGestureAction {
    @Override
    protected void onGestureEnd() {
        mHandler.removeCallbacks(mExecuteBackRunnable);
        if (!QuickStepController.shouldhideBackButton(getContext())) {
        if (!QuickStepController.shouldHideBackButton(getContext())) {
            mNavigationBarView.getBackButton().setAlpha(
                    mProxySender.getBackButtonAlpha(), true /* animate */);
        }
Loading