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

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

Merge changes from topic "b-68279369" into oc-dr1-dev

* changes:
  Auto-dim refinements
  Refinement of auto-dimming nav
  Don't touch auto dim on app change
  Auto dim the nav bar to help prevent diff aging
parents af5e1124 06bba683
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@ import android.os.HandlerThread;
import android.os.Looper;
import android.os.Process;
import android.util.ArrayMap;
import android.view.IWindowManager;
import android.view.WindowManagerGlobal;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.app.NightDisplayController;
@@ -300,6 +302,8 @@ public class Dependency extends SystemUI {

        mProviders.put(PowerUI.WarningsUI.class, () -> new PowerNotificationWarnings(mContext));

        mProviders.put(IWindowManager.class, () -> WindowManagerGlobal.getWindowManagerService());

        // Put all dependencies above here so the factory can override them if it wants.
        SystemUIFactory.getInstance().injectDependencies(mProviders, mContext);
    }
+5 −1
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ public class BarTransitions {
    public static final int MODE_LIGHTS_OUT_TRANSPARENT = 6;

    public static final int LIGHTS_IN_DURATION = 250;
    public static final int LIGHTS_OUT_DURATION = 750;
    public static final int LIGHTS_OUT_DURATION = 1500;
    public static final int BACKGROUND_DURATION = 200;

    private final String mTag;
@@ -75,6 +75,10 @@ public class BarTransitions {
        return mMode;
    }

    public void setAutoDim(boolean autoDim) {
        // Default is don't care.
    }

    /**
     * @param alwaysOpaque if {@code true}, the bar's background will always be opaque, regardless
     *         of what mode it is currently set to.
+41 −7
Original line number Diff line number Diff line
@@ -17,12 +17,19 @@
package com.android.systemui.statusbar.phone;

import android.content.Context;
import android.os.Handler;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.SparseArray;
import android.view.Display;
import android.view.IWallpaperVisibilityListener;
import android.view.IWindowManager;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManagerGlobal;

import com.android.internal.statusbar.IStatusBarService;
import com.android.systemui.Dependency;
import com.android.systemui.R;

public final class NavigationBarTransitions extends BarTransitions {
@@ -30,8 +37,10 @@ public final class NavigationBarTransitions extends BarTransitions {
    private final NavigationBarView mView;
    private final IStatusBarService mBarService;
    private final LightBarTransitionsController mLightTransitionsController;
    private boolean mWallpaperVisible;

    private boolean mLightsOut;
    private boolean mAutoDim;

    public NavigationBarTransitions(NavigationBarView view) {
        super(view, R.drawable.nav_background);
@@ -40,11 +49,38 @@ public final class NavigationBarTransitions extends BarTransitions {
                ServiceManager.getService(Context.STATUS_BAR_SERVICE));
        mLightTransitionsController = new LightBarTransitionsController(view.getContext(),
                this::applyDarkIntensity);

        IWindowManager windowManagerService = Dependency.get(IWindowManager.class);
        Handler handler = Handler.getMain();
        try {
            mWallpaperVisible = windowManagerService.registerWallpaperVisibilityListener(
                new IWallpaperVisibilityListener.Stub() {
                    @Override
                    public void onWallpaperVisibilityChanged(boolean newVisibility,
                            int displayId) throws RemoteException {
                        mWallpaperVisible = newVisibility;
                        handler.post(() -> applyLightsOut(true, false));
                    }
                }, Display.DEFAULT_DISPLAY);
        } catch (RemoteException e) {
        }
    }

    public void init() {
        applyModeBackground(-1, getMode(), false /*animate*/);
        applyMode(getMode(), false /*animate*/, true /*force*/);
        applyLightsOut(false /*animate*/, true /*force*/);
    }

    @Override
    public void setAutoDim(boolean autoDim) {
        if (mAutoDim == autoDim) return;
        mAutoDim = autoDim;
        applyLightsOut(true, false);
    }

    @Override
    protected boolean isLightsOut(int mode) {
        return super.isLightsOut(mode) || (mAutoDim && !mWallpaperVisible);
    }

    public LightBarTransitionsController getLightTransitionsController() {
@@ -54,13 +90,12 @@ public final class NavigationBarTransitions extends BarTransitions {
    @Override
    protected void onTransition(int oldMode, int newMode, boolean animate) {
        super.onTransition(oldMode, newMode, animate);
        applyMode(newMode, animate, false /*force*/);
        applyLightsOut(animate, false /*force*/);
    }

    private void applyMode(int mode, boolean animate, boolean force) {

    private void applyLightsOut(boolean animate, boolean force) {
        // apply to lights out
        applyLightsOut(isLightsOut(mode), animate, force);
        applyLightsOut(isLightsOut(getMode()), animate, force);
    }

    private void applyLightsOut(boolean lightsOut, boolean animate, boolean force) {
@@ -73,7 +108,7 @@ public final class NavigationBarTransitions extends BarTransitions {
        // ok, everyone, stop it right there
        navButtons.animate().cancel();

        final float navButtonsAlpha = lightsOut ? 0.5f : 1f;
        final float navButtonsAlpha = lightsOut ? 0.6f : 1f;

        if (!animate) {
            navButtons.setAlpha(navButtonsAlpha);
@@ -86,7 +121,6 @@ public final class NavigationBarTransitions extends BarTransitions {
        }
    }


    public void reapplyDarkIntensity() {
        applyDarkIntensity(mLightTransitionsController.getCurrentDarkIntensity());
    }
+25 −9
Original line number Diff line number Diff line
@@ -340,7 +340,7 @@ public class StatusBar extends SystemUI implements DemoMode,

    private static final int STATUS_OR_NAV_TRANSIENT =
            View.STATUS_BAR_TRANSIENT | View.NAVIGATION_BAR_TRANSIENT;
    private static final long AUTOHIDE_TIMEOUT_MS = 3000;
    private static final long AUTOHIDE_TIMEOUT_MS = 2250;

    /** The minimum delay in ms between reports of notification visibility. */
    private static final int VISIBILITY_REPORT_MIN_DELAY_MS = 500;
@@ -560,14 +560,12 @@ public class StatusBar extends SystemUI implements DemoMode,
    protected DozeScrimController mDozeScrimController;
    private final UiOffloadThread mUiOffloadThread = Dependency.get(UiOffloadThread.class);

    private final Runnable mAutohide = new Runnable() {
        @Override
        public void run() {
    private final Runnable mAutohide = () -> {
        int requested = mSystemUiVisibility & ~STATUS_OR_NAV_TRANSIENT;
        if (mSystemUiVisibility != requested) {
            notifyUiVisibilityChanged(requested);
        }
        }};
    };

    private boolean mWaitingForKeyguardExit;
    protected boolean mDozing;
@@ -3351,6 +3349,7 @@ public class StatusBar extends SystemUI implements DemoMode,
        }
        // manually dismiss the volume panel when interacting with the nav bar
        if (changing && interacting && barWindow == StatusBarManager.WINDOW_NAVIGATION_BAR) {
            touchAutoDim();
            dismissVolumeDialog();
        }
        checkBarModes();
@@ -3385,6 +3384,16 @@ public class StatusBar extends SystemUI implements DemoMode,
        mHandler.postDelayed(mAutohide, AUTOHIDE_TIMEOUT_MS);
    }

    public void touchAutoDim() {
        if (mNavigationBar != null) {
            mNavigationBar.getBarTransitions().setAutoDim(false);
        }
        mHandler.removeCallbacks(mAutoDim);
        if (mState != StatusBarState.KEYGUARD && mState != StatusBarState.SHADE_LOCKED) {
            mHandler.postDelayed(mAutoDim, AUTOHIDE_TIMEOUT_MS);
        }
    }

    void checkUserAutohide(View v, MotionEvent event) {
        if ((mSystemUiVisibility & STATUS_OR_NAV_TRANSIENT) != 0  // a transient bar is revealed
                && event.getAction() == MotionEvent.ACTION_OUTSIDE // touch outside the source bar
@@ -4791,6 +4800,7 @@ public class StatusBar extends SystemUI implements DemoMode,
        updateReportRejectedTouchVisibility();
        updateDozing();
        updateTheme();
        touchAutoDim();
        mNotificationShelf.setStatusBarState(state);
    }

@@ -7466,4 +7476,10 @@ public class StatusBar extends SystemUI implements DemoMode,
        }
    }
    // End Extra BaseStatusBarMethods.

    private final Runnable mAutoDim = () -> {
        if (mNavigationBar != null) {
            mNavigationBar.getBarTransitions().setAutoDim(true);
        }
    };
}
+5 −0
Original line number Diff line number Diff line
@@ -28,6 +28,8 @@ import android.view.Surface;
import android.view.View;

import com.android.systemui.R;
import com.android.systemui.SysUiServiceProvider;
import com.android.systemui.statusbar.phone.StatusBar;

/**
 * The "dead zone" consumes unintentional taps along the top edge of the navigation bar.
@@ -44,6 +46,7 @@ public class DeadZone extends View {
    public static final int VERTICAL = 1;  // Consume taps along the left edge.

    private static final boolean CHATTY = true; // print to logcat when we eat a click
    private final StatusBar mStatusBar;

    private boolean mShouldFlash;
    private float mFlashFrac = 0f;
@@ -88,6 +91,7 @@ public class DeadZone extends View {
                    + (mVertical ? " vertical" : " horizontal"));

        setFlashOnTouchCapture(context.getResources().getBoolean(R.bool.config_dead_zone_flash));
        mStatusBar = SysUiServiceProvider.getComponent(context, StatusBar.class);
    }

    static float lerp(float a, float b, float f) {
@@ -132,6 +136,7 @@ public class DeadZone extends View {
            if (DEBUG) {
                Slog.v(TAG, this + " ACTION_DOWN: " + event.getX() + "," + event.getY());
            }
            if (mStatusBar != null) mStatusBar.touchAutoDim();
            int size = (int) getSize(event.getEventTime());
            // In the vertical orientation consume taps along the left edge.
            // In horizontal orientation consume taps along the top edge.
Loading