From 407e3c9e2fab137d2086f3f4756994f0711fc8af Mon Sep 17 00:00:00 2001 From: Joshua McCloskey Date: Mon, 23 Sep 2024 17:36:16 +0000 Subject: [PATCH] Removed flag from environment This flag should never have been there in the first place. The environment is essentially a library, and the features that are built on top of this library should be gaurded by flags. Flag: EXEMPT not needed Fixes: 369161783 Test: Manual Change-Id: Id165bec98bd5f2669ccfde51e4755e47e5e88e06 --- .../android/settings/SettingsApplication.java | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/com/android/settings/SettingsApplication.java b/src/com/android/settings/SettingsApplication.java index b1177dd2d87..c908855ee49 100644 --- a/src/com/android/settings/SettingsApplication.java +++ b/src/com/android/settings/SettingsApplication.java @@ -24,6 +24,7 @@ import android.hardware.fingerprint.FingerprintManager; import android.net.Uri; import android.provider.Settings; import android.util.FeatureFlagUtils; +import android.util.Log; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -58,8 +59,9 @@ import java.util.List; ) public class SettingsApplication extends Application { + private static final String TAG = "SettingsApplication"; private WeakReference mHomeActivity = new WeakReference<>(null); - @Nullable private BiometricsEnvironment mBiometricsEnvironment; + @Nullable volatile private BiometricsEnvironment mBiometricsEnvironment; @Override protected void attachBaseContext(Context base) { @@ -138,20 +140,23 @@ public class SettingsApplication extends Application { @Nullable public BiometricsEnvironment getBiometricEnvironment() { - if (Flags.fingerprintV2Enrollment()) { - if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) { - final FingerprintManager fpm = getSystemService(FingerprintManager.class); - if (mBiometricsEnvironment == null) { - mBiometricsEnvironment = new BiometricsEnvironment(this, fpm); + BiometricsEnvironment localEnvironment = mBiometricsEnvironment; + if (localEnvironment == null) { + synchronized (this) { + if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) { + return null; + } + final FingerprintManager fpm = getSystemService(FingerprintManager.class); + localEnvironment = mBiometricsEnvironment; + if (fpm != null && localEnvironment == null) { + mBiometricsEnvironment = localEnvironment = new BiometricsEnvironment(this, + fpm); + } else { + Log.e(TAG, "Error when creating environment, fingerprint manager was null"); } - return mBiometricsEnvironment; - - } else { - return null; } - } - return null; + return localEnvironment; } @Override