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

Commit 39464839 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 8018982 from cb1f78f0 to sc-v2-release

Change-Id: I459b5c6d2cda559717822f9298917f60b2157761
parents 6049b651 cb1f78f0
Loading
Loading
Loading
Loading
+45 −3
Original line number Diff line number Diff line
@@ -17,8 +17,10 @@
package android.text.style;

import android.annotation.NonNull;
import android.content.res.Configuration;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.graphics.fonts.FontStyle;
import android.os.Parcel;
import android.text.ParcelableSpan;
import android.text.TextPaint;
@@ -45,6 +47,7 @@ import android.text.TextUtils;
public class StyleSpan extends MetricAffectingSpan implements ParcelableSpan {

    private final int mStyle;
    private final int mFontWeightAdjustment;

    /**
     * Creates a {@link StyleSpan} from a style.
@@ -54,7 +57,24 @@ public class StyleSpan extends MetricAffectingSpan implements ParcelableSpan {
     *              in {@link Typeface}.
     */
    public StyleSpan(int style) {
        this(style, Configuration.FONT_WEIGHT_ADJUSTMENT_UNDEFINED);
    }

    /**
     * Creates a {@link StyleSpan} from a style and font weight adjustment.
     *
     * @param style An integer constant describing the style for this span. Examples
     *              include bold, italic, and normal. Values are constants defined
     *              in {@link Typeface}.
     * @param fontWeightAdjustment An integer describing the adjustment to be made to the font
     *              weight.
     * @see Configuration#fontWeightAdjustment This is the adjustment in text font weight
     * that is used to reflect the current user's preference for increasing font weight.
     * @hide
     */
    public StyleSpan(@Typeface.Style int style, int fontWeightAdjustment) {
        mStyle = style;
        mFontWeightAdjustment = fontWeightAdjustment;
    }

    /**
@@ -64,6 +84,7 @@ public class StyleSpan extends MetricAffectingSpan implements ParcelableSpan {
     */
    public StyleSpan(@NonNull Parcel src) {
        mStyle = src.readInt();
        mFontWeightAdjustment = src.readInt();
    }

    @Override
@@ -91,6 +112,7 @@ public class StyleSpan extends MetricAffectingSpan implements ParcelableSpan {
    @Override
    public void writeToParcelInternal(@NonNull Parcel dest, int flags) {
        dest.writeInt(mStyle);
        dest.writeInt(mFontWeightAdjustment);
    }

    /**
@@ -100,17 +122,25 @@ public class StyleSpan extends MetricAffectingSpan implements ParcelableSpan {
        return mStyle;
    }

    /**
     * Returns the font weight adjustment specified by this span.
     * @hide
     */
    public int getFontWeightAdjustment() {
        return mFontWeightAdjustment;
    }

    @Override
    public void updateDrawState(TextPaint ds) {
        apply(ds, mStyle);
        apply(ds, mStyle, mFontWeightAdjustment);
    }

    @Override
    public void updateMeasureState(TextPaint paint) {
        apply(paint, mStyle);
        apply(paint, mStyle, mFontWeightAdjustment);
    }

    private static void apply(Paint paint, int style) {
    private static void apply(Paint paint, int style, int fontWeightAdjustment) {
        int oldStyle;

        Typeface old = paint.getTypeface();
@@ -129,6 +159,18 @@ public class StyleSpan extends MetricAffectingSpan implements ParcelableSpan {
            tf = Typeface.create(old, want);
        }

        // Base typeface may already be bolded by auto bold. Bold further.
        if ((style & Typeface.BOLD) != 0) {
            if (fontWeightAdjustment != 0
                    && fontWeightAdjustment != Configuration.FONT_WEIGHT_ADJUSTMENT_UNDEFINED) {
                int newWeight = Math.min(
                        Math.max(tf.getWeight() + fontWeightAdjustment, FontStyle.FONT_WEIGHT_MIN),
                        FontStyle.FONT_WEIGHT_MAX);
                boolean italic = (want & Typeface.ITALIC) != 0;
                tf = Typeface.create(tf, newWeight, italic);
            }
        }

        int fake = want & ~tf.getStyle();

        if ((fake & Typeface.BOLD) != 0) {
+2 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.app.ActivityTaskManager;
import android.app.TaskInfo;
import android.content.Context;
import android.os.RemoteException;
import android.util.Slog;
import android.util.SparseArray;
import android.util.SparseIntArray;

@@ -316,6 +317,7 @@ public class RecentTasksController implements TaskStackListenerCallback,
                    (controller) -> out[0] = controller.getRecentTasks(maxNum, flags, userId)
                            .toArray(new GroupedRecentTaskInfo[0]),
                    true /* blocking */);
            Slog.d("b/206648922", "getRecentTasks(" + maxNum + "): " + out[0]);
            return out[0];
        }
    }
+79 −56
Original line number Diff line number Diff line
@@ -49,7 +49,6 @@ import android.hardware.fingerprint.IFingerprintAuthenticatorsRegisteredCallback
import android.hardware.fingerprint.IUdfpsHbmListener;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.RemoteException;
import android.util.Log;
import android.util.SparseBooleanArray;
@@ -65,6 +64,7 @@ import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.doze.DozeReceiver;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.util.concurrency.Execution;

import java.util.ArrayList;
import java.util.Arrays;
@@ -92,15 +92,20 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
    private static final boolean DEBUG = true;
    private static final int SENSOR_PRIVACY_DELAY = 500;

    private final Handler mHandler = new Handler(Looper.getMainLooper());
    private final Handler mHandler;
    private final Execution mExecution;
    private final CommandQueue mCommandQueue;
    private final ActivityTaskManager mActivityTaskManager;
    @Nullable private final FingerprintManager mFingerprintManager;
    @Nullable private final FaceManager mFaceManager;
    @Nullable
    private final FingerprintManager mFingerprintManager;
    @Nullable
    private final FaceManager mFaceManager;
    private final Provider<UdfpsController> mUdfpsControllerFactory;
    private final Provider<SidefpsController> mSidefpsControllerFactory;
    @Nullable private final PointF mFaceAuthSensorLocation;
    @Nullable private PointF mFingerprintLocation;
    @Nullable
    private final PointF mFaceAuthSensorLocation;
    @Nullable
    private PointF mFingerprintLocation;
    private final Set<Callback> mCallbacks = new HashSet<>();

    // TODO: These should just be saved from onSaveState
@@ -133,62 +138,27 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
        }
    }

    private final FingerprintStateListener mFingerprintStateListener =
            new FingerprintStateListener() {
        @Override
        public void onEnrollmentsChanged(int userId, int sensorId, boolean hasEnrollments) {
            Log.d(TAG, "onEnrollmentsChanged, userId: " + userId
                    + ", sensorId: " + sensorId
                    + ", hasEnrollments: " + hasEnrollments);
            for (FingerprintSensorPropertiesInternal prop : mUdfpsProps) {
                if (prop.sensorId == sensorId) {
                    mUdfpsEnrolledForUser.put(userId, hasEnrollments);
                }
            }

            for (Callback cb : mCallbacks) {
                cb.onEnrollmentsChanged();
            }
        }
    };

    @NonNull
    private final IFingerprintAuthenticatorsRegisteredCallback
            mFingerprintAuthenticatorsRegisteredCallback =
            new IFingerprintAuthenticatorsRegisteredCallback.Stub() {
                @Override public void onAllAuthenticatorsRegistered(
                @Override
                public void onAllAuthenticatorsRegistered(
                        List<FingerprintSensorPropertiesInternal> sensors) {
                    if (DEBUG) {
                        Log.d(TAG, "onFingerprintProvidersAvailable | sensors: " + Arrays.toString(
                                sensors.toArray()));
                    }
                    mFpProps = sensors;
                    List<FingerprintSensorPropertiesInternal> udfpsProps = new ArrayList<>();
                    List<FingerprintSensorPropertiesInternal> sidefpsProps = new ArrayList<>();
                    for (FingerprintSensorPropertiesInternal props : mFpProps) {
                        if (props.isAnyUdfpsType()) {
                            udfpsProps.add(props);
                        }
                        if (props.isAnySidefpsType()) {
                            sidefpsProps.add(props);
                        }
                    }
                    mUdfpsProps = !udfpsProps.isEmpty() ? udfpsProps : null;
                    if (mUdfpsProps != null) {
                        mUdfpsController = mUdfpsControllerFactory.get();
                    }
                    mSidefpsProps = !sidefpsProps.isEmpty() ? sidefpsProps : null;
                    if (mSidefpsProps != null) {
                        mSidefpsController = mSidefpsControllerFactory.get();
                    mHandler.post(() -> handleAllAuthenticatorsRegistered(sensors));
                }
            };

                    for (Callback cb : mCallbacks) {
                        cb.onAllAuthenticatorsRegistered();
                    }
    private final FingerprintStateListener mFingerprintStateListener =
            new FingerprintStateListener() {
                @Override
                public void onEnrollmentsChanged(int userId, int sensorId, boolean hasEnrollments) {
                    mHandler.post(
                            () -> handleEnrollmentsChanged(userId, sensorId, hasEnrollments));
                }
            };

    @VisibleForTesting final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
    @VisibleForTesting
    final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (mCurrentDialog != null
@@ -212,6 +182,7 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
    };

    private void handleTaskStackChanged() {
        mExecution.assertIsMainThread();
        if (mCurrentDialog != null) {
            try {
                final String clientPackage = mCurrentDialog.getOpPackageName();
@@ -241,6 +212,56 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
        }
    }

    private void handleAllAuthenticatorsRegistered(
            List<FingerprintSensorPropertiesInternal> sensors) {
        mExecution.assertIsMainThread();
        if (DEBUG) {
            Log.d(TAG, "handleAllAuthenticatorsRegistered | sensors: " + Arrays.toString(
                    sensors.toArray()));
        }
        mFpProps = sensors;
        List<FingerprintSensorPropertiesInternal> udfpsProps = new ArrayList<>();
        List<FingerprintSensorPropertiesInternal> sidefpsProps = new ArrayList<>();
        for (FingerprintSensorPropertiesInternal props : mFpProps) {
            if (props.isAnyUdfpsType()) {
                udfpsProps.add(props);
            }
            if (props.isAnySidefpsType()) {
                sidefpsProps.add(props);
            }
        }
        mUdfpsProps = !udfpsProps.isEmpty() ? udfpsProps : null;
        if (mUdfpsProps != null) {
            mUdfpsController = mUdfpsControllerFactory.get();
        }
        mSidefpsProps = !sidefpsProps.isEmpty() ? sidefpsProps : null;
        if (mSidefpsProps != null) {
            mSidefpsController = mSidefpsControllerFactory.get();
        }
        for (Callback cb : mCallbacks) {
            cb.onAllAuthenticatorsRegistered();
        }
        mFingerprintManager.registerFingerprintStateListener(mFingerprintStateListener);
    }

    private void handleEnrollmentsChanged(int userId, int sensorId, boolean hasEnrollments) {
        mExecution.assertIsMainThread();
        Log.d(TAG, "handleEnrollmentsChanged, userId: " + userId + ", sensorId: " + sensorId
                + ", hasEnrollments: " + hasEnrollments);
        if (mUdfpsProps == null) {
            Log.d(TAG, "handleEnrollmentsChanged, mUdfpsProps is null");
        } else {
            for (FingerprintSensorPropertiesInternal prop : mUdfpsProps) {
                if (prop.sensorId == sensorId) {
                    mUdfpsEnrolledForUser.put(userId, hasEnrollments);
                }
            }
        }
        for (Callback cb : mCallbacks) {
            cb.onEnrollmentsChanged();
        }
    }

    /**
     * Adds a callback. See {@link Callback}.
     */
@@ -449,6 +470,7 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,

    @Inject
    public AuthController(Context context,
            Execution execution,
            CommandQueue commandQueue,
            ActivityTaskManager activityTaskManager,
            @NonNull WindowManager windowManager,
@@ -459,6 +481,8 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
            @NonNull DisplayManager displayManager,
            @Main Handler handler) {
        super(context);
        mExecution = execution;
        mHandler = handler;
        mCommandQueue = commandQueue;
        mActivityTaskManager = activityTaskManager;
        mFingerprintManager = fingerprintManager;
@@ -470,7 +494,7 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
        mOrientationListener = new BiometricDisplayListener(
                context,
                displayManager,
                handler,
                mHandler,
                BiometricDisplayListener.SensorType.Generic.INSTANCE,
                () -> {
                    onOrientationChanged();
@@ -521,7 +545,6 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
        if (mFingerprintManager != null) {
            mFingerprintManager.addAuthenticatorsRegisteredCallback(
                    mFingerprintAuthenticatorsRegisteredCallback);
            mFingerprintManager.registerFingerprintStateListener(mFingerprintStateListener);
        }

        mTaskStackListener = new BiometricTaskStackListener();
+9 −42
Original line number Diff line number Diff line
@@ -80,11 +80,6 @@ class AuthRippleController @Inject constructor(
    private var circleReveal: LightRevealEffect? = null

    private var udfpsController: UdfpsController? = null

    private var dwellScale = 2f
    private var expandedDwellScale = 2.5f
    private var aodDwellScale = 1.9f
    private var aodExpandedDwellScale = 2.3f
    private var udfpsRadius: Float = -1f

    override fun onInit() {
@@ -128,7 +123,7 @@ class AuthRippleController @Inject constructor(
        updateSensorLocation()
        if (biometricSourceType == BiometricSourceType.FINGERPRINT &&
            fingerprintSensorLocation != null) {
            mView.setSensorLocation(fingerprintSensorLocation!!)
            mView.setFingerprintSensorLocation(fingerprintSensorLocation!!, udfpsRadius)
            showUnlockedRipple()
        } else if (biometricSourceType == BiometricSourceType.FACE &&
            faceSensorLocation != null) {
@@ -241,24 +236,12 @@ class AuthRippleController @Inject constructor(
    }

    private fun updateRippleColor() {
        mView.setColor(
            Utils.getColorAttr(sysuiContext, android.R.attr.colorAccent).defaultColor)
        mView.setLockScreenColor(Utils.getColorAttrDefaultColor(sysuiContext,
                R.attr.wallpaperTextColorAccent))
    }

    private fun showDwellRipple() {
        if (statusBarStateController.isDozing) {
            mView.startDwellRipple(
                    /* startRadius */ udfpsRadius,
                    /* endRadius */ udfpsRadius * aodDwellScale,
                    /* expandedRadius */ udfpsRadius * aodExpandedDwellScale,
                    /* isDozing */ true)
        } else {
            mView.startDwellRipple(
                    /* startRadius */ udfpsRadius,
                    /* endRadius */ udfpsRadius * dwellScale,
                    /* expandedRadius */ udfpsRadius * expandedDwellScale,
                    /* isDozing */ false)
        }
        mView.startDwellRipple(statusBarStateController.isDozing)
    }

    private val keyguardUpdateMonitorCallback =
@@ -295,7 +278,7 @@ class AuthRippleController @Inject constructor(
                    return
                }

                mView.setSensorLocation(fingerprintSensorLocation!!)
                mView.setFingerprintSensorLocation(fingerprintSensorLocation!!, udfpsRadius)
                showDwellRipple()
            }

@@ -307,8 +290,8 @@ class AuthRippleController @Inject constructor(
    private val authControllerCallback =
        object : AuthController.Callback {
            override fun onAllAuthenticatorsRegistered() {
                updateSensorLocation()
                updateUdfpsDependentParams()
                updateSensorLocation()
            }

            override fun onEnrollmentsChanged() {
@@ -329,20 +312,6 @@ class AuthRippleController @Inject constructor(
    }

    inner class AuthRippleCommand : Command {
        fun printLockScreenDwellInfo(pw: PrintWriter) {
            pw.println("lock screen dwell ripple: " +
                    "\n\tsensorLocation=$fingerprintSensorLocation" +
                    "\n\tdwellScale=$dwellScale" +
                    "\n\tdwellExpand=$expandedDwellScale")
        }

        fun printAodDwellInfo(pw: PrintWriter) {
            pw.println("aod dwell ripple: " +
                    "\n\tsensorLocation=$fingerprintSensorLocation" +
                    "\n\tdwellScale=$aodDwellScale" +
                    "\n\tdwellExpand=$aodExpandedDwellScale")
        }

        override fun execute(pw: PrintWriter, args: List<String>) {
            if (args.isEmpty()) {
                invalidCommand(pw)
@@ -350,11 +319,9 @@ class AuthRippleController @Inject constructor(
                when (args[0]) {
                    "dwell" -> {
                        showDwellRipple()
                        if (statusBarStateController.isDozing) {
                            printAodDwellInfo(pw)
                        } else {
                            printLockScreenDwellInfo(pw)
                        }
                        pw.println("lock screen dwell ripple: " +
                                "\n\tsensorLocation=$fingerprintSensorLocation" +
                                "\n\tudfpsRadius=$udfpsRadius")
                    }
                    "fingerprint" -> {
                        updateSensorLocation()
+90 −97

File changed.

Preview size limit exceeded, changes collapsed.

Loading