Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Commit

Permalink
base: Allow toggling screen off FOD [1/2]
Browse files Browse the repository at this point in the history
Signed-off-by: jhonboy121 <alfredmathew05@gmail.com>
Change-Id: I1feece846e4dbddb276ad6ed0efac77e5b7986d8
Signed-off-by: Chenyang Zhong <zhongcy95@gmail.com>
  • Loading branch information
jhonboy121 authored and jjpprrrr committed May 17, 2022
1 parent ec908ad commit 7d11663
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ && pickupGestureEnabled(user)
/** {@hide} */
public boolean screenOffUdfpsEnabled(int user) {
return !TextUtils.isEmpty(udfpsLongPressSensorType())
&& boolSettingDefaultOff("screen_off_udfps_enabled", user);
&& boolSettingDefaultOff("screen_off_udfps_enabled", user)
&& mContext.getResources().getBoolean(R.bool.config_supportsScreenOffUdfps);
}

/** {@hide} */
Expand Down
8 changes: 8 additions & 0 deletions core/java/android/provider/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -10511,6 +10511,14 @@ public static boolean putFloatForUser(ContentResolver cr, String name, float val
*/
public static final String FACE_UNLOCK_METHOD = "face_unlock_method";

/**
* Enable udfps detection even when screen is off
* Default value is 0
* @hide
*/
@Readable
public static final String SCREEN_OFF_UDFPS_ENABLED = "screen_off_udfps_enabled";

/**
* These entries are considered common between the personal and the managed profile,
* since the managed profile doesn't get to change them.
Expand Down
3 changes: 3 additions & 0 deletions core/res/res/values/custom_config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,7 @@
<!-- Enable face auth only when swiping security view -->
<bool name="config_faceAuthOnlyOnSecurityView">false</bool>

<!-- Whether devices suports in-display fingerprint when screen is off -->
<bool name="config_supportsScreenOffUdfps">true</bool>

</resources>
3 changes: 3 additions & 0 deletions core/res/res/values/custom_symbols.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,7 @@
<!-- Enable face auth only when swiping security view -->
<java-symbol type="bool" name="config_faceAuthOnlyOnSecurityView" />

<!-- Whether devices suports in-display fingerprint when screen is off -->
<java-symbol type="bool" name="config_supportsScreenOffUdfps" />

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -323,5 +323,6 @@ public class SecureSettingsValidators {
VALIDATORS.put(Secure.FEATURE_TOUCH_HOVERING, BOOLEAN_VALIDATOR);
VALIDATORS.put(Secure.SWAP_CAPACITIVE_KEYS, BOOLEAN_VALIDATOR);
VALIDATORS.put(Secure.FACE_UNLOCK_METHOD, BOOLEAN_VALIDATOR);
VALIDATORS.put(Secure.SCREEN_OFF_UDFPS_ENABLED, BOOLEAN_VALIDATOR);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,20 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.ContentObserver;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.RectF;
import android.hardware.biometrics.BiometricOverlayConstants;
import android.hardware.biometrics.SensorLocationInternal;
import android.hardware.display.AmbientDisplayConfiguration;
import android.hardware.display.DisplayManager;
import android.hardware.fingerprint.FingerprintManager;
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
import android.hardware.fingerprint.IUdfpsOverlayController;
import android.hardware.fingerprint.IUdfpsOverlayControllerCallback;
import android.media.AudioAttributes;
import android.net.Uri;
import android.os.Handler;
import android.os.PowerManager;
import android.os.Process;
Expand Down Expand Up @@ -80,6 +83,7 @@
import com.android.systemui.util.concurrency.DelayableExecutor;
import com.android.systemui.util.concurrency.Execution;
import com.android.systemui.util.time.SystemClock;
import com.android.systemui.util.settings.SecureSettings;

import java.util.HashSet;
import java.util.Optional;
Expand Down Expand Up @@ -169,6 +173,9 @@ public class UdfpsController implements DozeReceiver {
private boolean mAttemptedToDismissKeyguard;
private final int mUdfpsVendorCode;
private Set<Callback> mCallbacks = new HashSet<>();
private final AmbientDisplayConfiguration mAmbientDisplayConfiguration;
private final SecureSettings mSecureSettings;
private boolean mScreenOffFod;

private boolean mFrameworkDimming;
private int[][] mBrightnessAlphaArray;
Expand Down Expand Up @@ -331,7 +338,9 @@ public void setDebugMessage(int sensorId, String message) {
@Override
public void onAcquired(int sensorId, int acquiredInfo, int vendorCode) {
mFgExecutor.execute(() -> {
if (acquiredInfo == 6 && (mStatusBarStateController.isDozing() || !mScreenOn)) {
final boolean isAodEnabled = mAmbientDisplayConfiguration.alwaysOnEnabled(UserHandle.USER_CURRENT);
final boolean isShowingAmbientDisplay = mStatusBarStateController.isDozing() && mScreenOn;
if (acquiredInfo == 6 && ((mScreenOffFod && !mScreenOn) || (isAodEnabled && isShowingAmbientDisplay))) {
if (vendorCode == mUdfpsVendorCode) {
if (mContext.getResources().getBoolean(R.bool.config_pulseOnFingerDown)) {
mContext.sendBroadcastAsUser(new Intent(PULSE_ACTION),
Expand Down Expand Up @@ -585,7 +594,8 @@ public UdfpsController(@NonNull Context context,
@NonNull ConfigurationController configurationController,
@NonNull SystemClock systemClock,
@NonNull UnlockedScreenOffAnimationController unlockedScreenOffAnimationController,
@NonNull SystemUIDialogManager dialogManager) {
@NonNull SystemUIDialogManager dialogManager,
@NonNull SecureSettings secureSettings) {
mContext = context;
mExecution = execution;
mVibrator = vibrator;
Expand Down Expand Up @@ -652,7 +662,25 @@ public UdfpsController(@NonNull Context context,
udfpsHapticsSimulator.setUdfpsController(this);

mUdfpsVendorCode = mContext.getResources().getInteger(R.integer.config_udfps_vendor_code);
mAmbientDisplayConfiguration = new AmbientDisplayConfiguration(mContext);
mSecureSettings = secureSettings;
updateScreenOffFodState();
mSecureSettings.registerContentObserver(Settings.Secure.SCREEN_OFF_UDFPS_ENABLED,
new ContentObserver(mainHandler) {
@Override
public void onChange(boolean selfChange, Uri uri) {
if (uri.getLastPathSegment().equals(Settings.Secure.SCREEN_OFF_UDFPS_ENABLED)) {
updateScreenOffFodState();
}
}
}
);
}

private void updateScreenOffFodState() {
boolean isSupported = mContext.getResources().getBoolean(
com.android.internal.R.bool.config_supportsScreenOffUdfps);
mScreenOffFod = isSupported && mSecureSettings.getInt(Settings.Secure.SCREEN_OFF_UDFPS_ENABLED, 1) == 1;
}

/**
Expand Down

0 comments on commit 7d11663

Please sign in to comment.