Skip to content

Commit

Permalink
[local-authentication] Bail early when in background (#6971)
Browse files Browse the repository at this point in the history
# Why

Follow up to #6962, fail with a proper error when `getCurrentActivity()` returns `null`.

# How

Reject the promise if we cannot get ahold of the current activity

# Test Plan

Try triggering local authentication when in the background
  • Loading branch information
LinusU committed Feb 4, 2020
1 parent ad0ed4b commit 936202c
Showing 1 changed file with 5 additions and 0 deletions.
Expand Up @@ -102,6 +102,11 @@ public void authenticateAsync(final Promise promise) {
return;
}

if (getCurrentActivity() == null) {
promise.reject("E_NOT_FOREGROUND", "Cannot display biometric prompt when the app is not in the foreground");
return;
}

if (getKeyguardManager().isDeviceSecure() == false) {
Bundle errorResult = new Bundle();
errorResult.putBoolean("success", false);
Expand Down

0 comments on commit 936202c

Please sign in to comment.