diff --git a/app/src/main/java/me/impy/aegis/otp/GoogleAuthInfo.java b/app/src/main/java/me/impy/aegis/otp/GoogleAuthInfo.java index 478833c4..daea4086 100644 --- a/app/src/main/java/me/impy/aegis/otp/GoogleAuthInfo.java +++ b/app/src/main/java/me/impy/aegis/otp/GoogleAuthInfo.java @@ -48,6 +48,14 @@ public class GoogleAuthInfo { return builder.build(); } + public static GoogleAuthInfo parseUri(String s) throws GoogleAuthInfoException { + Uri uri = Uri.parse(s); + if (uri == null) { + throw new GoogleAuthInfoException("bad uri format"); + } + return GoogleAuthInfo.parseUri(uri); + } + public static GoogleAuthInfo parseUri(Uri uri) throws GoogleAuthInfoException { if (!uri.getScheme().equals("otpauth")) { throw new GoogleAuthInfoException("unsupported protocol"); diff --git a/app/src/main/java/me/impy/aegis/ui/ScannerActivity.java b/app/src/main/java/me/impy/aegis/ui/ScannerActivity.java index b7f8f720..908625ec 100644 --- a/app/src/main/java/me/impy/aegis/ui/ScannerActivity.java +++ b/app/src/main/java/me/impy/aegis/ui/ScannerActivity.java @@ -108,8 +108,7 @@ public class ScannerActivity extends AegisActivity implements ZXingScannerView.R public void handleResult(Result rawResult) { try { // parse google auth uri - Uri uri = Uri.parse(rawResult.getText()); - GoogleAuthInfo info = GoogleAuthInfo.parseUri(uri); + GoogleAuthInfo info = GoogleAuthInfo.parseUri(rawResult.getText()); DatabaseEntry entry = new DatabaseEntry(info); Intent intent = new Intent();