From 6ebe8ddd00f9b7bd7aa32e79f7f36e97f60acfa5 Mon Sep 17 00:00:00 2001 From: Andy CrossGate Yan Date: Wed, 11 Jan 2023 11:56:05 +0000 Subject: [PATCH 1/2] Squashed revert of LOS UDFPS changes Way less than FOD, but reverting them nonetheless to keep in line with PHH AOSP - Revert "udfps: Make pressed udfp view configurable" - Revert "udfps: Restore illumination dot for global hbm" - Revert "udfps: Implement default udfps display mode provider" - Revert "udfps: Change window type to TYPE_DISPLAY_OVERLAY" --- packages/SystemUI/proguard.flags | 3 - .../res/drawable-nodpi/udfps_icon_pressed.png | Bin 108 -> 0 bytes packages/SystemUI/res/layout/udfps_view.xml | 6 - .../SystemUI/res/values/lineage_config.xml | 6 - .../biometrics/AuthContainerView.java | 2 +- .../DummyUdfpsDisplayModeProvider.kt | 32 ---- .../systemui/biometrics/UdfpsController.java | 4 +- .../biometrics/UdfpsControllerOverlay.kt | 2 +- .../systemui/biometrics/UdfpsSurfaceView.java | 159 ------------------ .../android/systemui/biometrics/UdfpsView.kt | 31 +--- .../systemui/dagger/SystemUIModule.java | 14 +- 11 files changed, 7 insertions(+), 252 deletions(-) delete mode 100644 packages/SystemUI/res/drawable-nodpi/udfps_icon_pressed.png delete mode 100644 packages/SystemUI/src/com/android/systemui/biometrics/DummyUdfpsDisplayModeProvider.kt delete mode 100644 packages/SystemUI/src/com/android/systemui/biometrics/UdfpsSurfaceView.java diff --git a/packages/SystemUI/proguard.flags b/packages/SystemUI/proguard.flags index b41952b7306b..7538555e1bcd 100644 --- a/packages/SystemUI/proguard.flags +++ b/packages/SystemUI/proguard.flags @@ -10,9 +10,6 @@ } -keep class * extends com.android.systemui.CoreStartable -keep class * implements com.android.systemui.CoreStartable$Injector --keep class * implements com.android.systemui.biometrics.UdfpsDisplayModeProvider { - public (...); -} # Needed for builds to properly initialize KeyFrames from xml scene -keepclassmembers class * extends androidx.constraintlayout.motion.widget.Key { diff --git a/packages/SystemUI/res/drawable-nodpi/udfps_icon_pressed.png b/packages/SystemUI/res/drawable-nodpi/udfps_icon_pressed.png deleted file mode 100644 index 4102e28c1300b49323b50625d8cfaa73b006561f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 108 zcmeAS@N?(olHy`uVBq!ia0vp^j3CUx1|;Q0k8}bl$r9IylHmNblJdl&R0hYC{G?O` z&)mfH)S%SFl*+=BsWw1Ge4Z|jAr-fh5*U~o7?>FtSQ!{^cTTbP0l+XkK D@OB!I diff --git a/packages/SystemUI/res/layout/udfps_view.xml b/packages/SystemUI/res/layout/udfps_view.xml index 0fcbfa161ddf..257d238f5c54 100644 --- a/packages/SystemUI/res/layout/udfps_view.xml +++ b/packages/SystemUI/res/layout/udfps_view.xml @@ -28,10 +28,4 @@ android:layout_width="match_parent" android:layout_height="match_parent"/> - - diff --git a/packages/SystemUI/res/values/lineage_config.xml b/packages/SystemUI/res/values/lineage_config.xml index 7509dfd2dcba..d08c6f19b9a3 100644 --- a/packages/SystemUI/res/values/lineage_config.xml +++ b/packages/SystemUI/res/values/lineage_config.xml @@ -25,12 +25,6 @@ causes a poor experience. --> true - - com.android.systemui.biometrics.DummyUdfpsDisplayModeProvider - - - #ffffffff - false diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java index 2d87da8c2112..8f5cbb76222f 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java @@ -879,7 +879,7 @@ public class AuthContainerView extends LinearLayout final WindowManager.LayoutParams lp = new WindowManager.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, - WindowManager.LayoutParams.TYPE_DISPLAY_OVERLAY, + WindowManager.LayoutParams.TYPE_STATUS_BAR_ADDITIONAL, windowFlags, PixelFormat.TRANSLUCENT); lp.privateFlags |= WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS; diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/DummyUdfpsDisplayModeProvider.kt b/packages/SystemUI/src/com/android/systemui/biometrics/DummyUdfpsDisplayModeProvider.kt deleted file mode 100644 index 380200983114..000000000000 --- a/packages/SystemUI/src/com/android/systemui/biometrics/DummyUdfpsDisplayModeProvider.kt +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2022 The LineageOS Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.biometrics - -import android.content.Context -import android.view.Surface - -class DummyUdfpsDisplayModeProvider constructor( - private val context: Context -): UdfpsDisplayModeProvider { - override fun enable(onEnabled: Runnable?) { - onEnabled?.run() - } - - override fun disable(onDisabled: Runnable?) { - onDisabled?.run() - } -} diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java index 70aa6a3aa06e..412dc0577876 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java @@ -594,7 +594,7 @@ public class UdfpsController implements DozeReceiver { @NonNull VibratorHelper vibrator, @NonNull UdfpsHapticsSimulator udfpsHapticsSimulator, @NonNull UdfpsShell udfpsShell, - @NonNull UdfpsDisplayModeProvider udfpsDisplayMode, + @NonNull Optional udfpsDisplayMode, @NonNull KeyguardStateController keyguardStateController, @NonNull DisplayManager displayManager, @Main Handler mainHandler, @@ -626,7 +626,7 @@ public class UdfpsController implements DozeReceiver { mPowerManager = powerManager; mAccessibilityManager = accessibilityManager; mLockscreenShadeTransitionController = lockscreenShadeTransitionController; - mUdfpsDisplayMode = udfpsDisplayMode; + mUdfpsDisplayMode = udfpsDisplayMode.orElse(null); screenLifecycle.addObserver(mScreenObserver); mScreenOn = screenLifecycle.getScreenState() == ScreenLifecycle.SCREEN_ON; mConfigurationController = configurationController; diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsControllerOverlay.kt b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsControllerOverlay.kt index 09a7fb338553..1c62f8a4e508 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsControllerOverlay.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsControllerOverlay.kt @@ -93,7 +93,7 @@ class UdfpsControllerOverlay( private var overlayTouchListener: TouchExplorationStateChangeListener? = null private val coreLayoutParams = WindowManager.LayoutParams( - WindowManager.LayoutParams.TYPE_DISPLAY_OVERLAY, + WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG, 0 /* flags set in computeLayoutParams() */, PixelFormat.TRANSLUCENT ).apply { diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsSurfaceView.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsSurfaceView.java deleted file mode 100644 index 2488132b508b..000000000000 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsSurfaceView.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (C) 2021 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.biometrics; - -import android.annotation.NonNull; -import android.annotation.Nullable; -import android.content.Context; -import android.graphics.drawable.Drawable; -import android.graphics.Canvas; -import android.graphics.Paint; -import android.graphics.PixelFormat; -import android.graphics.RectF; -import android.util.AttributeSet; -import android.util.Log; -import android.view.Surface; -import android.view.SurfaceHolder; -import android.view.SurfaceView; - -import com.android.systemui.R; - -/** - * Surface View for providing the Global High-Brightness Mode (GHBM) illumination for UDFPS. - */ -public class UdfpsSurfaceView extends SurfaceView implements SurfaceHolder.Callback { - private static final String TAG = "UdfpsSurfaceView"; - - /** - * Notifies {@link UdfpsView} when to enable GHBM illumination. - */ - interface GhbmIlluminationListener { - /** - * @param surface the surface for which GHBM should be enabled. - * @param onDisplayConfigured a runnable that should be run after GHBM is enabled. - */ - void enableGhbm(@NonNull Surface surface, @Nullable Runnable onDisplayConfigured); - } - - @NonNull private final SurfaceHolder mHolder; - @NonNull private final Paint mSensorPaint; - - @Nullable private GhbmIlluminationListener mGhbmIlluminationListener; - @Nullable private Runnable mOnDisplayConfigured; - boolean mAwaitingSurfaceToStartIllumination; - boolean mHasValidSurface; - - private Drawable mUdfpsIconPressed; - - public UdfpsSurfaceView(Context context, AttributeSet attrs) { - super(context, attrs); - - // Make this SurfaceView draw on top of everything else in this window. This allows us to - // 1) Always show the HBM circle on top of everything else, and - // 2) Properly composite this view with any other animations in the same window no matter - // what contents are added in which order to this view hierarchy. - setZOrderOnTop(true); - - mHolder = getHolder(); - mHolder.addCallback(this); - mHolder.setFormat(PixelFormat.RGBA_8888); - - mSensorPaint = new Paint(0 /* flags */); - mSensorPaint.setAntiAlias(true); - mSensorPaint.setColor(context.getColor(R.color.config_udfpsColor)); - mSensorPaint.setStyle(Paint.Style.FILL); - - mUdfpsIconPressed = context.getDrawable(R.drawable.udfps_icon_pressed); - } - - @Override public void surfaceCreated(SurfaceHolder holder) { - mHasValidSurface = true; - if (mAwaitingSurfaceToStartIllumination) { - doIlluminate(mOnDisplayConfigured); - mOnDisplayConfigured = null; - mAwaitingSurfaceToStartIllumination = false; - } - } - - @Override - public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { - // Unused. - } - - @Override public void surfaceDestroyed(SurfaceHolder holder) { - mHasValidSurface = false; - } - - void setGhbmIlluminationListener(@Nullable GhbmIlluminationListener listener) { - mGhbmIlluminationListener = listener; - } - - /** - * Note: there is no corresponding method to stop GHBM illumination. It is expected that - * {@link UdfpsView} will hide this view, which would destroy the surface and remove the - * illumination dot. - */ - void startGhbmIllumination(@Nullable Runnable onDisplayConfigured) { - if (mGhbmIlluminationListener == null) { - Log.e(TAG, "startIllumination | mGhbmIlluminationListener is null"); - return; - } - - if (mHasValidSurface) { - doIlluminate(onDisplayConfigured); - } else { - mAwaitingSurfaceToStartIllumination = true; - mOnDisplayConfigured = onDisplayConfigured; - } - } - - private void doIlluminate(@Nullable Runnable onDisplayConfigured) { - if (mGhbmIlluminationListener == null) { - Log.e(TAG, "doIlluminate | mGhbmIlluminationListener is null"); - return; - } - - mGhbmIlluminationListener.enableGhbm(mHolder.getSurface(), onDisplayConfigured); - } - - /** - * Immediately draws the illumination dot on this SurfaceView's surface. - */ - void drawIlluminationDot(@NonNull RectF sensorRect) { - if (!mHasValidSurface) { - Log.e(TAG, "drawIlluminationDot | the surface is destroyed or was never created."); - return; - } - Canvas canvas = null; - try { - canvas = mHolder.lockCanvas(); - mUdfpsIconPressed.setBounds( - Math.round(sensorRect.left), - Math.round(sensorRect.top), - Math.round(sensorRect.right), - Math.round(sensorRect.bottom) - ); - mUdfpsIconPressed.draw(canvas); - canvas.drawOval(sensorRect, mSensorPaint); - } finally { - // Make sure the surface is never left in a bad state. - if (canvas != null) { - mHolder.unlockCanvasAndPost(canvas); - } - } - } -} diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.kt b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.kt index 9dcd2db4d3b4..a15456d46897 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.kt @@ -24,7 +24,6 @@ import android.graphics.RectF import android.util.AttributeSet import android.util.Log import android.view.MotionEvent -import android.view.Surface import android.widget.FrameLayout import com.android.systemui.R import com.android.systemui.doze.DozeReceiver @@ -57,8 +56,6 @@ class UdfpsView( a.getFloat(R.styleable.UdfpsView_sensorTouchAreaCoefficient, 0f) } - private var ghbmView: UdfpsSurfaceView? = null - /** View controller (can be different for enrollment, BiometricPrompt, Keyguard, etc.). */ var animationViewController: UdfpsAnimationViewController<*>? = null @@ -85,10 +82,6 @@ class UdfpsView( return (animationViewController == null || !animationViewController!!.shouldPauseAuth()) } - override fun onFinishInflate() { - ghbmView = findViewById(R.id.hbm_view) - } - override fun dozeTimeTick() { animationViewController?.dozeTimeTick() } @@ -150,34 +143,12 @@ class UdfpsView( fun configureDisplay(onDisplayConfigured: Runnable) { isDisplayConfigured = true animationViewController?.onDisplayConfiguring() - val gView = ghbmView - if (gView != null) { - gView.setGhbmIlluminationListener(this::doIlluminate) - gView.visibility = VISIBLE - gView.startGhbmIllumination(onDisplayConfigured) - } else { - doIlluminate(null /* surface */, onDisplayConfigured) - } - } - - private fun doIlluminate(surface: Surface?, onDisplayConfigured: Runnable?) { - if (ghbmView != null && surface == null) { - Log.e(TAG, "doIlluminate | surface must be non-null for GHBM") - } - - mUdfpsDisplayMode?.enable { - onDisplayConfigured?.run() - ghbmView?.drawIlluminationDot(sensorRect) - } + mUdfpsDisplayMode?.enable(onDisplayConfigured) } fun unconfigureDisplay() { isDisplayConfigured = false animationViewController?.onDisplayUnconfigured() - ghbmView?.let { view -> - view.setGhbmIlluminationListener(null) - view.visibility = INVISIBLE - } mUdfpsDisplayMode?.disable(null /* onDisabled */) } } diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java index bc130894ced1..443d2774f0e0 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java @@ -93,7 +93,6 @@ import com.android.systemui.util.time.SystemClock; import com.android.systemui.util.time.SystemClockImpl; import com.android.systemui.wallet.dagger.WalletModule; import com.android.systemui.wmshell.BubblesManager; -import com.android.systemui.R; import com.android.wm.shell.bubbles.Bubbles; import java.util.Optional; @@ -199,17 +198,8 @@ public abstract class SystemUIModule { @BindsOptionalOf abstract CentralSurfaces optionalCentralSurfaces(); - @Provides - static UdfpsDisplayModeProvider getUdfpsDisplayModeProvider(Context context) { - String className = context.getString(R.string.config_udfpsDisplayModeProviderComponent); - try { - Class clazz = context.getClassLoader().loadClass(className); - return (UdfpsDisplayModeProvider) clazz.getDeclaredConstructor( - new Class[] { Context.class }).newInstance(context); - } catch (Throwable t) { - throw new RuntimeException("Error loading UdfpsDisplayModeProvider " + className, t); - } - } + @BindsOptionalOf + abstract UdfpsDisplayModeProvider optionalUdfpsDisplayModeProvider(); @BindsOptionalOf abstract AlternateUdfpsTouchProvider optionalUdfpsTouchProvider(); -- 2.25.1