Merge "Add log to capture the hardware status." into rvc-dev am: 1117895745

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/11908539

Change-Id: I0c23ec0766d3d9a87e59d59f0003778e4edc6acc
This commit is contained in:
Stanley Wang
2020-06-22 08:29:58 +00:00
committed by Automerger Merge Worker
9 changed files with 40 additions and 22 deletions

View File

@@ -95,9 +95,20 @@ public class FaceSettings extends DashboardFragment {
private final FaceSettingsEnrollButtonPreferenceController.Listener mEnrollListener = intent ->
startActivityForResult(intent, ENROLL_REQUEST);
public static boolean isAvailable(Context context) {
/**
* @param context
* @return true if the Face hardware is detected.
*/
public static boolean isFaceHardwareDetected(Context context) {
FaceManager manager = Utils.getFaceManagerOrNull(context);
return manager != null && manager.isHardwareDetected();
boolean isHardwareDetected = false;
if (manager == null) {
Log.d(TAG, "FaceManager is null");
} else {
isHardwareDetected = manager.isHardwareDetected();
Log.d(TAG, "FaceManager is not null. Hardware detected: " + isHardwareDetected);
}
return manager != null && isHardwareDetected;
}
@Override
@@ -126,7 +137,7 @@ public class FaceSettings extends DashboardFragment {
super.onCreate(savedInstanceState);
final Context context = getPrefContext();
if (!isAvailable(context)) {
if (!isFaceHardwareDetected(context)) {
Log.w(TAG, "no faceManager, finish this");
finish();
return;
@@ -273,7 +284,7 @@ public class FaceSettings extends DashboardFragment {
@Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
if (!isAvailable(context)) {
if (!isFaceHardwareDetected(context)) {
return null;
}
mControllers = buildPreferenceControllers(context, getSettingsLifecycle());
@@ -314,7 +325,7 @@ public class FaceSettings extends DashboardFragment {
@Override
public List<AbstractPreferenceController> createPreferenceControllers(
Context context) {
if (isAvailable(context)) {
if (isFaceHardwareDetected(context)) {
return buildPreferenceControllers(context, null /* lifecycle */);
} else {
return null;
@@ -323,7 +334,7 @@ public class FaceSettings extends DashboardFragment {
@Override
protected boolean isPageSearchEnabled(Context context) {
if (isAvailable(context)) {
if (isFaceHardwareDetected(context)) {
return hasEnrolledBiometrics(context);
}
@@ -333,7 +344,10 @@ public class FaceSettings extends DashboardFragment {
@Override
public List<String> getNonIndexableKeys(Context context) {
final List<String> keys = super.getNonIndexableKeys(context);
if (isAvailable(context)) {
final boolean isFaceHardwareDetected = isFaceHardwareDetected(context);
Log.d(TAG, "Get non indexable keys. isFaceHardwareDetected: "
+ isFaceHardwareDetected + ", size:" + keys.size());
if (isFaceHardwareDetected) {
final boolean hasEnrolled = hasEnrolledBiometrics(context);
keys.add(hasEnrolled ? PREF_KEY_ENROLL_FACE_UNLOCK
: PREF_KEY_DELETE_FACE_DATA);

View File

@@ -22,10 +22,10 @@ import android.content.Context;
import android.hardware.face.FaceManager;
import android.provider.Settings;
import com.android.settings.Utils;
import androidx.preference.Preference;
import com.android.settings.Utils;
/**
* Preference controller for Face settings page controlling the ability to use
* Face authentication in apps (through BiometricPrompt).
@@ -51,7 +51,7 @@ public class FaceSettingsAppPreferenceController extends FaceSettingsPreferenceC
@Override
public boolean isChecked() {
if (!FaceSettings.isAvailable(mContext)) {
if (!FaceSettings.isFaceHardwareDetected(mContext)) {
return false;
}
return Settings.Secure.getIntForUser(
@@ -67,7 +67,7 @@ public class FaceSettingsAppPreferenceController extends FaceSettingsPreferenceC
@Override
public void updateState(Preference preference) {
super.updateState(preference);
if (!FaceSettings.isAvailable(mContext)) {
if (!FaceSettings.isFaceHardwareDetected(mContext)) {
preference.setEnabled(false);
} else if (!mFaceManager.hasEnrolledTemplates(getUserId())) {
preference.setEnabled(false);

View File

@@ -93,7 +93,7 @@ public class FaceSettingsAttentionPreferenceController extends FaceSettingsPrefe
@Override
public boolean isChecked() {
if (!FaceSettings.isAvailable(mContext)) {
if (!FaceSettings.isFaceHardwareDetected(mContext)) {
return true;
}
// Set to disabled until we know the true value.

View File

@@ -25,7 +25,6 @@ import android.provider.Settings;
import androidx.preference.Preference;
import com.android.settings.Utils;
import com.android.settings.core.TogglePreferenceController;
/**
* Preference controller giving the user an option to always require confirmation.
@@ -65,7 +64,7 @@ public class FaceSettingsConfirmPreferenceController extends FaceSettingsPrefere
@Override
public void updateState(Preference preference) {
super.updateState(preference);
if (!FaceSettings.isAvailable(mContext)) {
if (!FaceSettings.isFaceHardwareDetected(mContext)) {
preference.setEnabled(false);
} else if (!mFaceManager.hasEnrolledTemplates(getUserId())) {
preference.setEnabled(false);

View File

@@ -53,7 +53,7 @@ public class FaceSettingsKeyguardPreferenceController extends FaceSettingsPrefer
@Override
public boolean isChecked() {
if (!FaceSettings.isAvailable(mContext)) {
if (!FaceSettings.isFaceHardwareDetected(mContext)) {
return false;
} else if (getRestrictingAdmin() != null) {
return false;
@@ -77,7 +77,7 @@ public class FaceSettingsKeyguardPreferenceController extends FaceSettingsPrefer
public void updateState(Preference preference) {
EnforcedAdmin admin;
super.updateState(preference);
if (!FaceSettings.isAvailable(mContext)) {
if (!FaceSettings.isFaceHardwareDetected(mContext)) {
preference.setEnabled(false);
} else if ((admin = getRestrictingAdmin()) != null) {
((RestrictedSwitchPreference) preference).setDisabledByAdmin(admin);

View File

@@ -47,7 +47,7 @@ public class FaceSettingsLockscreenBypassPreferenceController
@Override
public boolean isChecked() {
if (!FaceSettings.isAvailable(mContext)) {
if (!FaceSettings.isFaceHardwareDetected(mContext)) {
return false;
} else if (getRestrictingAdmin() != null) {
return false;
@@ -69,7 +69,7 @@ public class FaceSettingsLockscreenBypassPreferenceController
public void updateState(Preference preference) {
EnforcedAdmin admin;
super.updateState(preference);
if (!FaceSettings.isAvailable(mContext)) {
if (!FaceSettings.isFaceHardwareDetected(mContext)) {
preference.setEnabled(false);
} else if ((admin = getRestrictingAdmin()) != null) {
((RestrictedSwitchPreference) preference).setDisabledByAdmin(admin);

View File

@@ -165,7 +165,7 @@ public class FaceSettingsRemoveButtonPreferenceController extends BasePreference
.findViewById(R.id.security_settings_face_settings_remove_button);
mButton.setOnClickListener(this);
if (!FaceSettings.isAvailable(mContext)) {
if (!FaceSettings.isFaceHardwareDetected(mContext)) {
mButton.setEnabled(false);
} else {
mButton.setEnabled(!mRemoving);

View File

@@ -41,7 +41,7 @@ public class FaceStatusPreferenceController extends BiometricStatusPreferenceCon
@Override
protected boolean isDeviceSupported() {
return mFaceManager != null && mFaceManager.isHardwareDetected();
return FaceSettings.isFaceHardwareDetected(mContext);
}
@Override

View File

@@ -21,6 +21,7 @@ import static android.provider.Settings.Secure.ASSIST_GESTURE_SILENCE_ALERTS_ENA
import android.content.Context;
import android.provider.Settings;
import android.util.Log;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
@@ -31,6 +32,7 @@ import com.android.settings.overlay.FeatureFactory;
public class AssistGestureSettingsPreferenceController extends GesturePreferenceController {
private static final String TAG = "AssistGesture";
private static final String PREF_KEY_VIDEO = "gesture_assist_video";
private static final String SECURE_KEY_ASSIST = ASSIST_GESTURE_ENABLED;
@@ -55,8 +57,11 @@ public class AssistGestureSettingsPreferenceController extends GesturePreference
@Override
public int getAvailabilityStatus() {
final boolean isAvailable = mAssistOnly ? mFeatureProvider.isSupported(mContext)
: mFeatureProvider.isSensorAvailable(mContext);
final boolean isSupported = mFeatureProvider.isSupported(mContext);
final boolean isSensorAvailable = mFeatureProvider.isSensorAvailable(mContext);
final boolean isAvailable = mAssistOnly ? isSupported : isSensorAvailable;
Log.d(TAG, "mAssistOnly:" + mAssistOnly + ", isSupported:" + isSupported
+ ", isSensorAvailable:" + isSensorAvailable);
return isAvailable ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}