Loading packages/SystemUI/res/layout/udfps_view.xml +0 −6 Original line number Diff line number Diff line Loading @@ -28,10 +28,4 @@ android:layout_width="match_parent" android:layout_height="match_parent"/> <com.android.systemui.biometrics.UdfpsSurfaceView android:id="@+id/hbm_view" android:layout_width="match_parent" android:layout_height="match_parent" android:visibility="invisible"/> </com.android.systemui.biometrics.UdfpsView> packages/SystemUI/src/com/android/systemui/biometrics/UdfpsSurfaceView.javadeleted 100644 → 0 +0 −145 Original line number Diff line number Diff line /* * 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.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; /** * 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 onIlluminatedRunnable a runnable that should be run after GHBM is enabled. */ void enableGhbm(@NonNull Surface surface, @Nullable Runnable onIlluminatedRunnable); } @NonNull private final SurfaceHolder mHolder; @NonNull private final Paint mSensorPaint; @Nullable private GhbmIlluminationListener mGhbmIlluminationListener; @Nullable private Runnable mOnIlluminatedRunnable; boolean mAwaitingSurfaceToStartIllumination; boolean mHasValidSurface; 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.setARGB(255, 255, 255, 255); mSensorPaint.setStyle(Paint.Style.FILL); } @Override public void surfaceCreated(SurfaceHolder holder) { mHasValidSurface = true; if (mAwaitingSurfaceToStartIllumination) { doIlluminate(mOnIlluminatedRunnable); mOnIlluminatedRunnable = 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 onIlluminatedRunnable) { if (mGhbmIlluminationListener == null) { Log.e(TAG, "startIllumination | mGhbmIlluminationListener is null"); return; } if (mHasValidSurface) { doIlluminate(onIlluminatedRunnable); } else { mAwaitingSurfaceToStartIllumination = true; mOnIlluminatedRunnable = onIlluminatedRunnable; } } private void doIlluminate(@Nullable Runnable onIlluminatedRunnable) { if (mGhbmIlluminationListener == null) { Log.e(TAG, "doIlluminate | mGhbmIlluminationListener is null"); return; } mGhbmIlluminationListener.enableGhbm(mHolder.getSurface(), onIlluminatedRunnable); } /** * 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(); canvas.drawOval(sensorRect, mSensorPaint); } finally { // Make sure the surface is never left in a bad state. if (canvas != null) { mHolder.unlockCanvasAndPost(canvas); } } } } packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.kt +2 −26 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -61,9 +60,6 @@ class UdfpsView( com.android.internal.R.integer.config_udfps_illumination_transition_ms ).toLong() // Only used for UdfpsHbmTypes.GLOBAL_HBM. private var ghbmView: UdfpsSurfaceView? = null /** View controller (can be different for enrollment, BiometricPrompt, Keyguard, etc.). */ var animationViewController: UdfpsAnimationViewController<*>? = null Loading Loading @@ -93,10 +89,6 @@ class UdfpsView( return (animationViewController == null || !animationViewController!!.shouldPauseAuth()) } override fun onFinishInflate() { ghbmView = findViewById(R.id.hbm_view) } override fun dozeTimeTick() { animationViewController?.dozeTimeTick() } Loading Loading @@ -161,25 +153,13 @@ class UdfpsView( override fun startIllumination(onIlluminatedRunnable: Runnable?) { isIlluminationRequested = true animationViewController?.onIlluminationStarting() val gView = ghbmView if (gView != null) { gView.setGhbmIlluminationListener(this::doIlluminate) gView.visibility = VISIBLE gView.startGhbmIllumination(onIlluminatedRunnable) } else { doIlluminate(null /* surface */, onIlluminatedRunnable) } } private fun doIlluminate(surface: Surface?, onIlluminatedRunnable: Runnable?) { if (ghbmView != null && surface == null) { Log.e(TAG, "doIlluminate | surface must be non-null for GHBM") doIlluminate(onIlluminatedRunnable) } private fun doIlluminate(onIlluminatedRunnable: Runnable?) { // TODO(b/231335067): enableHbm with halControlsIllumination=true shouldn't make sense. // This only makes sense now because vendor code may rely on the side effects of enableHbm. hbmProvider?.enableHbm(halControlsIllumination) { ghbmView?.drawIlluminationDot(sensorRect) if (onIlluminatedRunnable != null) { if (halControlsIllumination) { onIlluminatedRunnable.run() Loading @@ -197,10 +177,6 @@ class UdfpsView( override fun stopIllumination() { isIlluminationRequested = false animationViewController?.onIlluminationStopped() ghbmView?.let { view -> view.setGhbmIlluminationListener(null) view.visibility = INVISIBLE } hbmProvider?.disableHbm(null /* onHbmDisabled */) } } Loading
packages/SystemUI/res/layout/udfps_view.xml +0 −6 Original line number Diff line number Diff line Loading @@ -28,10 +28,4 @@ android:layout_width="match_parent" android:layout_height="match_parent"/> <com.android.systemui.biometrics.UdfpsSurfaceView android:id="@+id/hbm_view" android:layout_width="match_parent" android:layout_height="match_parent" android:visibility="invisible"/> </com.android.systemui.biometrics.UdfpsView>
packages/SystemUI/src/com/android/systemui/biometrics/UdfpsSurfaceView.javadeleted 100644 → 0 +0 −145 Original line number Diff line number Diff line /* * 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.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; /** * 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 onIlluminatedRunnable a runnable that should be run after GHBM is enabled. */ void enableGhbm(@NonNull Surface surface, @Nullable Runnable onIlluminatedRunnable); } @NonNull private final SurfaceHolder mHolder; @NonNull private final Paint mSensorPaint; @Nullable private GhbmIlluminationListener mGhbmIlluminationListener; @Nullable private Runnable mOnIlluminatedRunnable; boolean mAwaitingSurfaceToStartIllumination; boolean mHasValidSurface; 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.setARGB(255, 255, 255, 255); mSensorPaint.setStyle(Paint.Style.FILL); } @Override public void surfaceCreated(SurfaceHolder holder) { mHasValidSurface = true; if (mAwaitingSurfaceToStartIllumination) { doIlluminate(mOnIlluminatedRunnable); mOnIlluminatedRunnable = 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 onIlluminatedRunnable) { if (mGhbmIlluminationListener == null) { Log.e(TAG, "startIllumination | mGhbmIlluminationListener is null"); return; } if (mHasValidSurface) { doIlluminate(onIlluminatedRunnable); } else { mAwaitingSurfaceToStartIllumination = true; mOnIlluminatedRunnable = onIlluminatedRunnable; } } private void doIlluminate(@Nullable Runnable onIlluminatedRunnable) { if (mGhbmIlluminationListener == null) { Log.e(TAG, "doIlluminate | mGhbmIlluminationListener is null"); return; } mGhbmIlluminationListener.enableGhbm(mHolder.getSurface(), onIlluminatedRunnable); } /** * 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(); canvas.drawOval(sensorRect, mSensorPaint); } finally { // Make sure the surface is never left in a bad state. if (canvas != null) { mHolder.unlockCanvasAndPost(canvas); } } } }
packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.kt +2 −26 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -61,9 +60,6 @@ class UdfpsView( com.android.internal.R.integer.config_udfps_illumination_transition_ms ).toLong() // Only used for UdfpsHbmTypes.GLOBAL_HBM. private var ghbmView: UdfpsSurfaceView? = null /** View controller (can be different for enrollment, BiometricPrompt, Keyguard, etc.). */ var animationViewController: UdfpsAnimationViewController<*>? = null Loading Loading @@ -93,10 +89,6 @@ class UdfpsView( return (animationViewController == null || !animationViewController!!.shouldPauseAuth()) } override fun onFinishInflate() { ghbmView = findViewById(R.id.hbm_view) } override fun dozeTimeTick() { animationViewController?.dozeTimeTick() } Loading Loading @@ -161,25 +153,13 @@ class UdfpsView( override fun startIllumination(onIlluminatedRunnable: Runnable?) { isIlluminationRequested = true animationViewController?.onIlluminationStarting() val gView = ghbmView if (gView != null) { gView.setGhbmIlluminationListener(this::doIlluminate) gView.visibility = VISIBLE gView.startGhbmIllumination(onIlluminatedRunnable) } else { doIlluminate(null /* surface */, onIlluminatedRunnable) } } private fun doIlluminate(surface: Surface?, onIlluminatedRunnable: Runnable?) { if (ghbmView != null && surface == null) { Log.e(TAG, "doIlluminate | surface must be non-null for GHBM") doIlluminate(onIlluminatedRunnable) } private fun doIlluminate(onIlluminatedRunnable: Runnable?) { // TODO(b/231335067): enableHbm with halControlsIllumination=true shouldn't make sense. // This only makes sense now because vendor code may rely on the side effects of enableHbm. hbmProvider?.enableHbm(halControlsIllumination) { ghbmView?.drawIlluminationDot(sensorRect) if (onIlluminatedRunnable != null) { if (halControlsIllumination) { onIlluminatedRunnable.run() Loading @@ -197,10 +177,6 @@ class UdfpsView( override fun stopIllumination() { isIlluminationRequested = false animationViewController?.onIlluminationStopped() ghbmView?.let { view -> view.setGhbmIlluminationListener(null) view.visibility = INVISIBLE } hbmProvider?.disableHbm(null /* onHbmDisabled */) } }