Skip to content

Commit c65f822

Browse files
TheScarasticGenkzsz11
authored andcommitted
fwb: Add screen off fod [1/2]
Also revert "FODCircleView: disable touch detection on screen off" 6a5b556. jhenrique09 - adapt to PE Change-Id: I2aba41f6669291ce65880df3fc7f3ed77cd45bed
1 parent 1376ea9 commit c65f822

5 files changed

Lines changed: 109 additions & 4 deletions

File tree

core/java/android/provider/Settings.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5848,6 +5848,12 @@ public static void setShowGTalkServiceStatusForUser(ContentResolver cr, boolean
58485848
*/
58495849
public static final String CATEGORY_NUSANTARA = "cat_nusantara";
58505850

5851+
/**
5852+
* Screen off fod
5853+
* @hide
5854+
*/
5855+
public static final String FOD_GESTURE = "fod_gesture";
5856+
58515857
/**
58525858
* Keys we no longer back up under the current schema, but want to continue to
58535859
* process when restoring historical backup datasets.
@@ -6013,6 +6019,7 @@ public static void setShowGTalkServiceStatusForUser(ContentResolver cr, boolean
60136019
PRIVATE_SETTINGS.add(HEADS_UP_BLACKLIST_VALUES);
60146020
PRIVATE_SETTINGS.add(SCREEN_OFF_ANIMATION);
60156021
PRIVATE_SETTINGS.add(SYSTEMUI_PLUGIN_VOLUME);
6022+
PRIVATE_SETTINGS.add(FOD_GESTURE);
60166023
}
60176024

60186025
/**

core/res/res/values/nad_config.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,7 @@
121121

122122
<!-- Shows the required view for in-display fingerprint -->
123123
<bool name="config_supportsInDisplayFingerprint">false</bool>
124+
125+
<!-- Whether device supports in-display fingerprint when screen is turned off -->
126+
<bool name="config_supportsScreenOffInDisplayFingerprint">false</bool>
124127
</resources>

core/res/res/values/nad_symbols.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,7 @@
8989

9090
<!-- In-display Fingerprint -->
9191
<java-symbol type="bool" name="config_supportsInDisplayFingerprint" />
92+
93+
<!-- Whether device supports in-display fingerprint when screen is turned off -->
94+
<java-symbol type="bool" name="config_supportsScreenOffInDisplayFingerprint" />
9295
</resources>

packages/SettingsProvider/src/android/provider/settings/validators/SystemSettingsValidators.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,5 +246,6 @@ public boolean validate(@Nullable String value) {
246246
VALIDATORS.put(System.STATUSBAR_CLOCK_DATE_STYLE, new InclusiveIntegerRangeValidator(0, 2));
247247
VALIDATORS.put(System.STATUSBAR_CLOCK_DATE_FORMAT, ANY_STRING_VALIDATOR);
248248
VALIDATORS.put(System.STATUSBAR_CLOCK_DATE_POSITION, BOOLEAN_VALIDATOR);
249+
VALIDATORS.put(System.FOD_GESTURE, BOOLEAN_VALIDATOR);
249250
}
250251
}

packages/SystemUI/src/com/android/systemui/biometrics/FODCircleView.java

Lines changed: 95 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,23 @@
1818

1919
import android.app.admin.DevicePolicyManager;
2020
import android.content.Context;
21+
import android.content.Intent;
2122
import android.content.res.Configuration;
2223
import android.content.res.Resources;
24+
import android.database.ContentObserver;
2325
import android.graphics.Canvas;
2426
import android.graphics.Color;
2527
import android.graphics.Paint;
2628
import android.graphics.PixelFormat;
2729
import android.graphics.Point;
2830
import android.os.Handler;
2931
import android.os.Looper;
32+
import android.os.PowerManager;
3033
import android.os.RemoteException;
34+
import android.os.SystemClock;
35+
import android.os.UserHandle;
3136
import android.provider.Settings;
37+
import android.net.Uri;
3238
import android.view.Display;
3339
import android.view.Gravity;
3440
import android.view.MotionEvent;
@@ -54,6 +60,8 @@
5460
import java.util.TimerTask;
5561

5662
public class FODCircleView extends ImageView implements ConfigurationListener {
63+
private static final String DOZE_INTENT = "com.android.systemui.doze.pulse";
64+
5765
private final int mPositionX;
5866
private final int mPositionY;
5967
private final int mSize;
@@ -75,6 +83,14 @@ public class FODCircleView extends ImageView implements ConfigurationListener {
7583
private boolean mIsDreaming;
7684
private boolean mIsCircleShowing;
7785

86+
private boolean mDozeEnabled;
87+
private boolean mFodGestureEnable;
88+
private boolean mPressPending;
89+
private boolean mScreenTurnedOn;
90+
91+
private PowerManager mPowerManager;
92+
private PowerManager.WakeLock mWakeLock;
93+
7894
private Handler mHandler;
7995

8096
private final ImageView mPressedView;
@@ -87,12 +103,26 @@ public class FODCircleView extends ImageView implements ConfigurationListener {
87103
new IFingerprintInscreenCallback.Stub() {
88104
@Override
89105
public void onFingerDown() {
90-
mHandler.post(() -> showCircle());
106+
if (mFodGestureEnable && !mScreenTurnedOn) {
107+
if (mDozeEnabled) {
108+
mHandler.post(() -> mContext.sendBroadcast(new Intent(DOZE_INTENT)));
109+
} else {
110+
mWakeLock.acquire(3000);
111+
mHandler.post(() -> mPowerManager.wakeUp(SystemClock.uptimeMillis(),
112+
PowerManager.WAKE_REASON_GESTURE, FODCircleView.class.getSimpleName()));
113+
}
114+
mPressPending = true;
115+
} else {
116+
mHandler.post(() -> showCircle());
117+
}
91118
}
92119

93120
@Override
94121
public void onFingerUp() {
95122
mHandler.post(() -> hideCircle());
123+
if (mFodGestureEnable && mPressPending) {
124+
mPressPending = false;
125+
}
96126
}
97127
};
98128

@@ -131,16 +161,67 @@ public void onStartedGoingToSleep(int why) {
131161
hide();
132162
}
133163

164+
@Override
165+
public void onScreenTurnedOff() {
166+
mScreenTurnedOn = false;
167+
if (mFodGestureEnable){
168+
hideCircle();
169+
}else{
170+
hide();
171+
}
172+
}
173+
134174
@Override
135175
public void onScreenTurnedOn() {
136-
if (mUpdateMonitor.isFingerprintDetectionRunning()) {
176+
if (!mFodGestureEnable && mUpdateMonitor.isFingerprintDetectionRunning()) {
137177
show();
138178
}
179+
if (mFodGestureEnable && mPressPending) {
180+
mHandler.post(() -> showCircle());
181+
mPressPending = false;
182+
}
183+
mScreenTurnedOn = true;
139184
}
140185
};
141186

187+
private class FodGestureSettingsObserver extends ContentObserver {
188+
FodGestureSettingsObserver(Context context, Handler handler) {
189+
super(handler);
190+
}
191+
192+
void registerListener() {
193+
mContext.getContentResolver().registerContentObserver(
194+
Settings.Secure.getUriFor(
195+
Settings.Secure.DOZE_ENABLED),
196+
false, this, UserHandle.USER_ALL);
197+
mContext.getContentResolver().registerContentObserver(
198+
Settings.System.getUriFor(
199+
Settings.System.FOD_GESTURE),
200+
false, this, UserHandle.USER_ALL);
201+
updateSettings();
202+
}
203+
204+
@Override
205+
public void onChange(boolean selfChange, Uri uri) {
206+
super.onChange(selfChange, uri);
207+
updateSettings();
208+
}
209+
210+
public void updateSettings() {
211+
mDozeEnabled = Settings.Secure.getIntForUser(
212+
mContext.getContentResolver(),
213+
Settings.Secure.DOZE_ENABLED, 1,
214+
UserHandle.USER_CURRENT) == 1;
215+
mFodGestureEnable = Settings.System.getIntForUser(
216+
mContext.getContentResolver(),
217+
Settings.System.FOD_GESTURE, 1,
218+
UserHandle.USER_CURRENT) == 1;
219+
}
220+
}
221+
142222
private boolean mCutoutMasked;
143223
private int mStatusbarHeight;
224+
private FodGestureSettingsObserver mFodGestureSettingsObserver;
144225

145226
public FODCircleView(Context context) {
146227
super(context);
@@ -169,6 +250,10 @@ public FODCircleView(Context context) {
169250
mPaintFingerprintBackground.setColor(res.getColor(R.color.config_fodColorBackground));
170251
mPaintFingerprintBackground.setAntiAlias(true);
171252

253+
mPowerManager = context.getSystemService(PowerManager.class);
254+
mWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
255+
FODCircleView.class.getSimpleName());
256+
172257
mWindowManager = context.getSystemService(WindowManager.class);
173258

174259
mNavigationBarSize = res.getDimensionPixelSize(R.dimen.navigation_bar_size);
@@ -213,7 +298,13 @@ protected void onDraw(Canvas canvas) {
213298

214299
mUpdateMonitor = Dependency.get(KeyguardUpdateMonitor.class);
215300
mUpdateMonitor.registerCallback(mMonitorCallback);
216-
301+
302+
if (context.getResources().getBoolean(
303+
com.android.internal.R.bool.config_supportsScreenOffInDisplayFingerprint)){
304+
mFodGestureSettingsObserver = new FodGestureSettingsObserver(context, mHandler);
305+
mFodGestureSettingsObserver.registerListener();
306+
}
307+
217308
updateCutoutFlags();
218309
Dependency.get(ConfigurationController.class).addCallback(this);
219310
}
@@ -329,7 +420,7 @@ public void hideCircle() {
329420
}
330421

331422
public void show() {
332-
if (!mUpdateMonitor.isScreenOn()) {
423+
if (!mFodGestureEnable && !mUpdateMonitor.isScreenOn()) {
333424
// Keyguard is shown just after screen turning off
334425
return;
335426
}

0 commit comments

Comments
 (0)