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

Commit b7b70ace authored by Kevin Chyn's avatar Kevin Chyn
Browse files

Hide Udfps icon when shade is expanded

1) Adds interface for ScrimController to notify listeners of new
   alpha
2) For SysUI modules such as UdfpsView that have views in layers
   ABOVE the notification shade (such as during lockscreen auth),
   yet need to pretend to be behind the shade (such as during
   enrollment), this allows UdfpsView to set its alpha and color
   to the right level

Bug: 177931181
Test: atest com.android.systemui.biometrics

Change-Id: I9b7bd5d72acee8ccbba9aef5b1c935bbf1da815f
parent 77bb0b72
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -47,4 +47,9 @@ public abstract class UdfpsAnimation extends Drawable {
                (int) sensorRect.right - margin,
                (int) sensorRect.bottom - margin);
    }

    @Override
    public void setAlpha(int alpha) {
        mFingerprintDrawable.setAlpha(alpha);
    }
}
+17 −2
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ import android.graphics.RectF;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.android.internal.graphics.ColorUtils;
import com.android.settingslib.Utils;
import com.android.systemui.R;

/**
@@ -35,8 +37,11 @@ import com.android.systemui.R;
public class UdfpsAnimationEnroll extends UdfpsAnimation {
    private static final String TAG = "UdfpsAnimationEnroll";

    private static final float SHADOW_RADIUS = 5.f;

    @Nullable private RectF mSensorRect;
    @NonNull private final Paint mSensorPaint;
    private final int mNotificationShadeColor;

    UdfpsAnimationEnroll(@NonNull Context context) {
        super(context);
@@ -44,8 +49,11 @@ public class UdfpsAnimationEnroll extends UdfpsAnimation {
        mSensorPaint = new Paint(0 /* flags */);
        mSensorPaint.setAntiAlias(true);
        mSensorPaint.setColor(Color.WHITE);
        mSensorPaint.setShadowLayer(UdfpsView.SENSOR_SHADOW_RADIUS, 0, 0, Color.BLACK);
        mSensorPaint.setShadowLayer(SHADOW_RADIUS, 0, 0, Color.BLACK);
        mSensorPaint.setStyle(Paint.Style.FILL);

        mNotificationShadeColor = Utils.getColorAttr(context,
                android.R.attr.colorBackgroundFloating).getDefaultColor();
    }

    @Override
@@ -73,7 +81,14 @@ public class UdfpsAnimationEnroll extends UdfpsAnimation {

    @Override
    public void setAlpha(int alpha) {

        super.setAlpha(alpha);

        // Gradually fade into the notification shade color. This needs to be done because the
        // UDFPS view is drawn on a layer on top of the notification shade
        final float percent = alpha / 255.f;
        mSensorPaint.setColor(ColorUtils.blendARGB(mNotificationShadeColor, Color.WHITE, percent));
        mSensorPaint.setShadowLayer(SHADOW_RADIUS, 0, 0,
                ColorUtils.blendARGB(mNotificationShadeColor, Color.BLACK, percent));
    }

    @Override
+0 −5
Original line number Diff line number Diff line
@@ -43,11 +43,6 @@ public class UdfpsAnimationFpmOther extends UdfpsAnimation {
        mFingerprintDrawable.draw(canvas);
    }

    @Override
    public void setAlpha(int alpha) {

    }

    @Override
    public void setColorFilter(@Nullable ColorFilter colorFilter) {

+0 −5
Original line number Diff line number Diff line
@@ -98,11 +98,6 @@ public class UdfpsAnimationKeyguard extends UdfpsAnimation implements DozeReceiv
        canvas.restore();
    }

    @Override
    public void setAlpha(int alpha) {

    }

    @Override
    public void setColorFilter(@Nullable ColorFilter colorFilter) {

+5 −1
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ import com.android.systemui.R;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.doze.DozeReceiver;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.phone.ScrimController;
import com.android.systemui.util.concurrency.DelayableExecutor;
import com.android.systemui.util.settings.SystemSettings;

@@ -174,7 +175,8 @@ class UdfpsController implements DozeReceiver {
            WindowManager windowManager,
            SystemSettings systemSettings,
            @NonNull StatusBarStateController statusBarStateController,
            @Main DelayableExecutor fgExecutor) {
            @Main DelayableExecutor fgExecutor,
            @NonNull ScrimController scrimController) {
        mContext = context;
        // The fingerprint manager is queried for UDFPS before this class is constructed, so the
        // fingerprint manager should never be null.
@@ -210,6 +212,8 @@ class UdfpsController implements DozeReceiver {

        mHbmSupported = !TextUtils.isEmpty(mHbmPath);
        mView.setHbmSupported(mHbmSupported);
        scrimController.addScrimChangedListener(mView);
        statusBarStateController.addCallback(mView);

        // This range only consists of the minimum and maximum values, which only cover
        // non-high-brightness mode.
Loading