Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ec1bd37d authored by Grace Cheng's avatar Grace Cheng
Browse files

Prevent NPE on deleting fingerprint in Settings

Gate all Settings FingerprintUnlockCategory logic on isSfps() check to prevent NPE

Fixes: 279866500
Test: Enroll 2+ fingerprints on a non-sfps device, delete fingerprint,
observe no crash

Change-Id: I040d498426e0f8efb789875eedeb7bcf44436149
parent 24666c97
Loading
Loading
Loading
Loading
+22 −14
Original line number Diff line number Diff line
@@ -283,7 +283,9 @@ public class FingerprintSettings extends SubSettings {
                    case MSG_REFRESH_FINGERPRINT_TEMPLATES:
                        removeFingerprintPreference(msg.arg1);
                        updateAddPreference();
                        if (isSfps()) {
                            updateFingerprintUnlockCategoryVisibility();
                        }
                        updatePreferences();
                        break;
                    case MSG_FINGER_AUTH_SUCCESS:
@@ -494,11 +496,15 @@ public class FingerprintSettings extends SubSettings {
        }

        private boolean isSfps() {
            mFingerprintManager = Utils.getFingerprintManagerOrNull(getActivity());
            if (mFingerprintManager != null) {
                mSensorProperties = mFingerprintManager.getSensorPropertiesInternal();
                for (FingerprintSensorPropertiesInternal prop : mSensorProperties) {
                    if (prop.isAnySidefpsType()) {
                        return true;
                    }
                }
            }
            return false;
        }

@@ -838,6 +844,7 @@ public class FingerprintSettings extends SubSettings {

        private List<AbstractPreferenceController> buildPreferenceControllers(Context context) {
            final List<AbstractPreferenceController> controllers = new ArrayList<>();
            if (isSfps()) {
                mFingerprintUnlockCategoryPreferenceController =
                    new FingerprintUnlockCategoryController(
                        context,
@@ -850,6 +857,7 @@ public class FingerprintSettings extends SubSettings {
                        );
                controllers.add(mFingerprintUnlockCategoryPreferenceController);
                controllers.add(mRequireScreenOnToAuthPreferenceController);
            }
            return controllers;
        }