Merge changes from topic "cherrypick-UdfpsControllerGoogle-vyfd7ux7f2" into sc-dev
* changes: Turn UdfpView into a SurfaceView Allow UdfpsController to be extended
This commit is contained in:
committed by
Android (Google) Code Review
commit
97b65d577c
@@ -47,6 +47,7 @@ import androidx.annotation.Nullable;
|
||||
import com.android.internal.BrightnessSynchronizer;
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.dagger.SysUISingleton;
|
||||
import com.android.systemui.dagger.qualifiers.Main;
|
||||
import com.android.systemui.doze.DozeReceiver;
|
||||
import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
||||
@@ -71,7 +72,8 @@ import javax.inject.Inject;
|
||||
* {@code sensorId} parameters.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
class UdfpsController implements DozeReceiver {
|
||||
@SysUISingleton
|
||||
public class UdfpsController implements DozeReceiver {
|
||||
private static final String TAG = "UdfpsController";
|
||||
// Gamma approximation for the sRGB color space.
|
||||
private static final float DISPLAY_GAMMA = 2.2f;
|
||||
@@ -177,7 +179,7 @@ class UdfpsController implements DozeReceiver {
|
||||
};
|
||||
|
||||
@Inject
|
||||
UdfpsController(@NonNull Context context,
|
||||
public UdfpsController(@NonNull Context context,
|
||||
@Main Resources resources,
|
||||
LayoutInflater inflater,
|
||||
@Nullable FingerprintManager fingerprintManager,
|
||||
@@ -464,7 +466,7 @@ class UdfpsController implements DozeReceiver {
|
||||
onFingerUp();
|
||||
}
|
||||
|
||||
private void onFingerDown(int x, int y, float minor, float major) {
|
||||
protected void onFingerDown(int x, int y, float minor, float major) {
|
||||
if (mHbmSupported) {
|
||||
try {
|
||||
FileWriter fw = new FileWriter(mHbmPath);
|
||||
@@ -482,7 +484,7 @@ class UdfpsController implements DozeReceiver {
|
||||
mView.showScrimAndDot();
|
||||
}
|
||||
|
||||
private void onFingerUp() {
|
||||
protected void onFingerUp() {
|
||||
mFingerprintManager.onPointerUp(mSensorProps.sensorId);
|
||||
// Hiding the scrim before disabling HBM results in less noticeable flicker.
|
||||
mView.hideScrimAndDot();
|
||||
@@ -521,4 +523,8 @@ class UdfpsController implements DozeReceiver {
|
||||
}
|
||||
return normalizedBacklight;
|
||||
}
|
||||
|
||||
protected UdfpsView getView() {
|
||||
return mView;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
|
||||
@@ -34,20 +35,20 @@ import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.Surface;
|
||||
import android.view.View;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.ViewTreeObserver;
|
||||
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.doze.DozeReceiver;
|
||||
import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
||||
import com.android.systemui.statusbar.StatusBarState;
|
||||
import com.android.systemui.statusbar.phone.ScrimController;
|
||||
|
||||
/**
|
||||
* A full screen view with a configurable illumination dot and scrim.
|
||||
*/
|
||||
public class UdfpsView extends View implements DozeReceiver,
|
||||
StatusBarStateController.StateListener, ScrimController.ScrimChangedListener{
|
||||
public class UdfpsView extends SurfaceView implements DozeReceiver,
|
||||
StatusBarStateController.StateListener, ScrimController.ScrimChangedListener {
|
||||
private static final String TAG = "UdfpsView";
|
||||
|
||||
// Values in pixels.
|
||||
@@ -86,6 +87,29 @@ public class UdfpsView extends View implements DozeReceiver,
|
||||
// The runnable is reset to null after it's executed once.
|
||||
@Nullable private Runnable mRunAfterShowingScrimAndDot;
|
||||
|
||||
@NonNull private final SurfaceHolder.Callback mSurfaceCallback = new SurfaceHolder.Callback() {
|
||||
@Override
|
||||
public void surfaceCreated(@NonNull SurfaceHolder holder) {
|
||||
Log.d(TAG, "Surface created");
|
||||
// SurfaceView sets this to true by default. We must set it to false to allow
|
||||
// onDraw to be called
|
||||
setWillNotDraw(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceChanged(@NonNull SurfaceHolder holder, int format,
|
||||
int width, int height) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceDestroyed(@NonNull SurfaceHolder holder) {
|
||||
Log.d(TAG, "Surface destroyed");
|
||||
// Must not draw when the surface is destroyed
|
||||
setWillNotDraw(true);
|
||||
}
|
||||
};
|
||||
|
||||
public UdfpsView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
@@ -102,6 +126,8 @@ public class UdfpsView extends View implements DozeReceiver,
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
getHolder().addCallback(mSurfaceCallback);
|
||||
getHolder().setFormat(PixelFormat.TRANSLUCENT);
|
||||
|
||||
mScrimRect = new Rect();
|
||||
mScrimPaint = new Paint(0 /* flags */);
|
||||
|
||||
Reference in New Issue
Block a user