Skip to content
This repository was archived by the owner on Dec 12, 2023. It is now read-only.

Commit fcbc8a8

Browse files
committed
Fix LOS FOD revert patch once again
1 parent 66a1cf4 commit fcbc8a8

File tree

1 file changed

+89
-22
lines changed

1 file changed

+89
-22
lines changed

patches/0001-Squashed-revert-of-LOS-FOD-implementation.patch

+89-22
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,10 @@ index cc03b4f816a..1db2e32b8cd 100644
280280

281281
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/FODCircleView.java b/packages/SystemUI/src/com/android/systemui/biometrics/FODCircleView.java
282282
deleted file mode 100644
283-
index 506a25fcc08..00000000000
283+
index 7e7c85578fc..00000000000
284284
--- a/packages/SystemUI/src/com/android/systemui/biometrics/FODCircleView.java
285285
+++ /dev/null
286-
@@ -1,760 +0,0 @@
286+
@@ -1,834 +0,0 @@
287287
-/**
288288
- * Copyright (C) 2019-2020 The LineageOS Project
289289
- *
@@ -308,6 +308,7 @@ index 506a25fcc08..00000000000
308308
-import android.app.admin.DevicePolicyManager;
309309
-import android.content.ContentResolver;
310310
-import android.content.Context;
311+
-import android.content.Intent;
311312
-import android.content.res.Configuration;
312313
-import android.content.res.Resources;
313314
-import android.database.ContentObserver;
@@ -321,11 +322,14 @@ index 506a25fcc08..00000000000
321322
-import android.net.Uri;
322323
-import android.os.Handler;
323324
-import android.os.Looper;
325+
-import android.os.PowerManager;
324326
-import android.os.RemoteException;
327+
-import android.os.SystemClock;
325328
-import android.os.UserHandle;
326329
-import android.pocket.IPocketCallback;
327330
-import android.pocket.PocketManager;
328331
-import android.provider.Settings;
332+
-import android.net.Uri;
329333
-import android.view.Display;
330334
-import android.view.Gravity;
331335
-import android.view.MotionEvent;
@@ -353,6 +357,7 @@ index 506a25fcc08..00000000000
353357
-
354358
-public class FODCircleView extends ImageView implements ConfigurationListener {
355359
- private static final int FADE_ANIM_DURATION = 125;
360+
- private static final String DOZE_INTENT = "com.android.systemui.doze.pulse";
356361
- private final String SCREEN_BRIGHTNESS = Settings.System.SCREEN_BRIGHTNESS;
357362
- private final int[][] BRIGHTNESS_ALPHA_ARRAY = {
358363
- new int[]{0, 255},
@@ -403,6 +408,14 @@ index 506a25fcc08..00000000000
403408
- private boolean mTouchedOutside;
404409
- private boolean mIsAnimating = false;
405410
-
411+
- private boolean mDozeEnabled;
412+
- private boolean mFodGestureEnable;
413+
- private boolean mPressPending;
414+
- private boolean mScreenTurnedOn;
415+
-
416+
- private PowerManager mPowerManager;
417+
- private PowerManager.WakeLock mWakeLock;
418+
-
406419
- private Handler mHandler;
407420
-
408421
- private final ImageView mPressedView;
@@ -420,12 +433,26 @@ index 506a25fcc08..00000000000
420433
- return;
421434
- }
422435
-
423-
- mHandler.post(() -> showCircle());
436+
- if (mFodGestureEnable && !mScreenTurnedOn) {
437+
- if (mDozeEnabled) {
438+
- mHandler.post(() -> mContext.sendBroadcast(new Intent(DOZE_INTENT)));
439+
- } else {
440+
- mWakeLock.acquire(3000);
441+
- mHandler.post(() -> mPowerManager.wakeUp(SystemClock.uptimeMillis(),
442+
- PowerManager.WAKE_REASON_GESTURE, FODCircleView.class.getSimpleName()));
443+
- }
444+
- mPressPending = true;
445+
- } else {
446+
- mHandler.post(() -> showCircle());
447+
- }
424448
- }
425449
-
426450
- @Override
427451
- public void onFingerUp() {
428452
- mHandler.post(() -> hideCircle());
453+
- if (mFodGestureEnable && mPressPending) {
454+
- mPressPending = false;
455+
- }
429456
- }
430457
- };
431458
-
@@ -506,25 +533,61 @@ index 506a25fcc08..00000000000
506533
-
507534
- @Override
508535
- public void onScreenTurnedOff() {
509-
- if (!mHideFodCircleGoingToSleep) {
536+
- mScreenTurnedOn = false;
537+
- if (mFodGestureEnable){
538+
- hideCircle();
539+
- }else if (!mHideFodCircleGoingToSleep) {
510540
- hide();
511541
- }
512542
- }
513543
-
514544
- @Override
515-
- public void onStartedWakingUp() {
516-
- if (mUpdateMonitor.isFingerprintDetectionRunning()) {
545+
- public void onScreenTurnedOn() {
546+
- if (!mFodGestureEnable && mUpdateMonitor.isFingerprintDetectionRunning()) {
517547
- show();
518548
- }
549+
- if (mFodGestureEnable && mPressPending) {
550+
- mHandler.post(() -> showCircle());
551+
- mPressPending = false;
552+
- }
553+
- mScreenTurnedOn = true;
554+
- }
555+
- };
556+
-
557+
- private class FodGestureSettingsObserver extends ContentObserver {
558+
- FodGestureSettingsObserver(Context context, Handler handler) {
559+
- super(handler);
560+
- }
561+
-
562+
- void registerListener() {
563+
- mContext.getContentResolver().registerContentObserver(
564+
- Settings.Secure.getUriFor(
565+
- Settings.Secure.DOZE_ENABLED),
566+
- false, this, UserHandle.USER_ALL);
567+
- mContext.getContentResolver().registerContentObserver(
568+
- Settings.System.getUriFor(
569+
- Settings.System.FOD_GESTURE),
570+
- false, this, UserHandle.USER_ALL);
571+
- updateSettings();
519572
- }
520573
-
521574
- @Override
522-
- public void onScreenTurnedOn() {
523-
- if (mUpdateMonitor.isFingerprintDetectionRunning()) {
524-
- show();
525-
- }
575+
- public void onChange(boolean selfChange, Uri uri) {
576+
- super.onChange(selfChange, uri);
577+
- updateSettings();
526578
- }
527-
- };
579+
-
580+
- public void updateSettings() {
581+
- mDozeEnabled = Settings.Secure.getIntForUser(
582+
- mContext.getContentResolver(),
583+
- Settings.Secure.DOZE_ENABLED, 1,
584+
- UserHandle.USER_CURRENT) == 1;
585+
- mFodGestureEnable = Settings.System.getIntForUser(
586+
- mContext.getContentResolver(),
587+
- Settings.System.FOD_GESTURE, 1,
588+
- UserHandle.USER_CURRENT) == 1;
589+
- }
590+
- }
528591
-
529592
- private void handlePocketManagerCallback(boolean keyguardShowing){
530593
- if (!keyguardShowing){
@@ -542,6 +605,7 @@ index 506a25fcc08..00000000000
542605
-
543606
- private boolean mCutoutMasked;
544607
- private int mStatusbarHeight;
608+
- private FodGestureSettingsObserver mFodGestureSettingsObserver;
545609
- private class CustomSettingsObserver extends ContentObserver {
546610
- CustomSettingsObserver(Handler handler) {
547611
- super(handler);
@@ -621,6 +685,10 @@ index 506a25fcc08..00000000000
621685
- mPaintFingerprintBackground.setColor(res.getColor(R.color.config_fodColorBackground));
622686
- mPaintFingerprintBackground.setAntiAlias(true);
623687
-
688+
- mPowerManager = context.getSystemService(PowerManager.class);
689+
- mWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
690+
- FODCircleView.class.getSimpleName());
691+
-
624692
- mTargetUsesInKernelDimming = res.getBoolean(com.android.internal.R.bool.config_targetUsesInKernelDimming);
625693
-
626694
- mHideFodCircleGoingToSleep = mContext.getResources().getBoolean(
@@ -676,7 +744,13 @@ index 506a25fcc08..00000000000
676744
-
677745
- mUpdateMonitor = Dependency.get(KeyguardUpdateMonitor.class);
678746
- mUpdateMonitor.registerCallback(mMonitorCallback);
679-
-
747+
-
748+
- if (context.getResources().getBoolean(
749+
- com.android.internal.R.bool.config_supportsScreenOffInDisplayFingerprint)){
750+
- mFodGestureSettingsObserver = new FodGestureSettingsObserver(context, mHandler);
751+
- mFodGestureSettingsObserver.registerListener();
752+
- }
753+
-
680754
- updateCutoutFlags();
681755
- Dependency.get(ConfigurationController.class).addCallback(this);
682756
-
@@ -872,7 +946,7 @@ index 506a25fcc08..00000000000
872946
- return;
873947
- }
874948
-
875-
- if (!mUpdateMonitor.isScreenOn()) {
949+
- if (!mFodGestureEnable && !mUpdateMonitor.isScreenOn()) {
876950
- // Keyguard is shown just after screen turning off
877951
- return;
878952
- }
@@ -1046,10 +1120,10 @@ index 506a25fcc08..00000000000
10461120
-}
10471121
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/FODCircleViewImpl.java b/packages/SystemUI/src/com/android/systemui/biometrics/FODCircleViewImpl.java
10481122
deleted file mode 100644
1049-
index 86baa4cab71..00000000000
1123+
index 12e4cbaf8d5..00000000000
10501124
--- a/packages/SystemUI/src/com/android/systemui/biometrics/FODCircleViewImpl.java
10511125
+++ /dev/null
1052-
@@ -1,135 +0,0 @@
1126+
@@ -1,128 +0,0 @@
10531127
-/**
10541128
- * Copyright (C) 2019 The Android Open Source Project
10551129
- *
@@ -1070,8 +1144,6 @@ index 86baa4cab71..00000000000
10701144
-
10711145
-import android.content.Context;
10721146
-import android.content.pm.PackageManager;
1073-
-import android.os.Handler;
1074-
-import android.os.Looper;
10751147
-import android.util.Slog;
10761148
-import android.view.View;
10771149
-
@@ -1096,16 +1168,13 @@ index 86baa4cab71..00000000000
10961168
- private final ArrayList<WeakReference<FODCircleViewImplCallback>>
10971169
- mCallbacks = new ArrayList<>();
10981170
- private final CommandQueue mCommandQueue;
1099-
- private Handler mHandler;
1100-
- private Runnable mHideFodViewRunnable = () -> mFodCircleView.hide();
11011171
-
11021172
- private boolean mIsFODVisible;
11031173
-
11041174
- @Inject
11051175
- public FODCircleViewImpl(Context context, CommandQueue commandQueue) {
11061176
- super(context);
11071177
- mCommandQueue = commandQueue;
1108-
- mHandler = new Handler(Looper.getMainLooper());
11091178
- }
11101179
-
11111180
- @Override
@@ -1139,7 +1208,6 @@ index 86baa4cab71..00000000000
11391208
- }
11401209
- }
11411210
- mIsFODVisible = true;
1142-
- mHandler.removeCallbacks(mHideFodViewRunnable);
11431211
- mFodCircleView.show();
11441212
- }
11451213
- }
@@ -1155,7 +1223,6 @@ index 86baa4cab71..00000000000
11551223
- }
11561224
- mIsFODVisible = false;
11571225
- mFodCircleView.hide();
1158-
- mHandler.postDelayed(mHideFodViewRunnable, 500);
11591226
- }
11601227
- }
11611228
-

0 commit comments

Comments
 (0)