Don't attempt caching for BiometricManager.Strings

Always fetch the latest requested string when a getter method of
BiometricManager.Strings is called, rather than attempted to cache the
strings.

Test: atest BiometricManagerTest

Fixes: 192573011
Change-Id: Ic73e2d0092d200e5912084e1b8f4efdb81bbf2d8
This commit is contained in:
Curtis Belmonte
2021-07-01 11:14:11 -07:00
parent 8fd5255fc4
commit 8858de4478

View File

@@ -223,10 +223,6 @@ public class BiometricManager {
@NonNull private final IAuthService mService;
@Authenticators.Types int mAuthenticators;
@Nullable CharSequence mButtonLabel;
@Nullable CharSequence mPromptMessage;
@Nullable CharSequence mSettingName;
private Strings(@NonNull Context context, @NonNull IAuthService service,
@Authenticators.Types int authenticators) {
mContext = context;
@@ -259,16 +255,13 @@ public class BiometricManager {
@RequiresPermission(USE_BIOMETRIC)
@Nullable
public CharSequence getButtonLabel() {
if (mButtonLabel == null) {
final int userId = mContext.getUserId();
final String opPackageName = mContext.getOpPackageName();
try {
mButtonLabel = mService.getButtonLabel(userId, opPackageName, mAuthenticators);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
final int userId = mContext.getUserId();
final String opPackageName = mContext.getOpPackageName();
try {
return mService.getButtonLabel(userId, opPackageName, mAuthenticators);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
return mButtonLabel;
}
/**
@@ -296,16 +289,13 @@ public class BiometricManager {
@RequiresPermission(USE_BIOMETRIC)
@Nullable
public CharSequence getPromptMessage() {
if (mPromptMessage == null) {
final int userId = mContext.getUserId();
final String opPackageName = mContext.getOpPackageName();
try {
return mService.getPromptMessage(userId, opPackageName, mAuthenticators);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
final int userId = mContext.getUserId();
final String opPackageName = mContext.getOpPackageName();
try {
return mService.getPromptMessage(userId, opPackageName, mAuthenticators);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
return mPromptMessage;
}
/**
@@ -335,16 +325,13 @@ public class BiometricManager {
@RequiresPermission(USE_BIOMETRIC)
@Nullable
public CharSequence getSettingName() {
if (mSettingName == null) {
final int userId = mContext.getUserId();
final String opPackageName = mContext.getOpPackageName();
try {
return mService.getSettingName(userId, opPackageName, mAuthenticators);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
final int userId = mContext.getUserId();
final String opPackageName = mContext.getOpPackageName();
try {
return mService.getSettingName(userId, opPackageName, mAuthenticators);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
return mSettingName;
}
}