From e86fa6f9fabb0bc9b0e06e9d0d4d9eca95394bed Mon Sep 17 00:00:00 2001 From: Philipp Crocoll Date: Tue, 25 Mar 2025 10:56:24 +0100 Subject: [PATCH] add support for otpauth:// URIs --- .../Manifests/AndroidManifest_debug.xml | 9 ++++++++ .../Manifests/AndroidManifest_net.xml | 9 +++++++- .../Manifests/AndroidManifest_nonet.xml | 8 +++++++ .../SelectCurrentDbActivity.cs | 22 ++++++++++++++++++- 4 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/keepass2android-app/Manifests/AndroidManifest_debug.xml b/src/keepass2android-app/Manifests/AndroidManifest_debug.xml index 45df9101..e9b17aaa 100644 --- a/src/keepass2android-app/Manifests/AndroidManifest_debug.xml +++ b/src/keepass2android-app/Manifests/AndroidManifest_debug.xml @@ -243,6 +243,15 @@ The scheme=file is still there for old OS devices. It's also queried by apps lik + + + + + + + + + diff --git a/src/keepass2android-app/Manifests/AndroidManifest_net.xml b/src/keepass2android-app/Manifests/AndroidManifest_net.xml index 4c66a71b..a760e2a3 100644 --- a/src/keepass2android-app/Manifests/AndroidManifest_net.xml +++ b/src/keepass2android-app/Manifests/AndroidManifest_net.xml @@ -255,7 +255,14 @@ The scheme=file is still there for old OS devices. It's also queried by apps lik - x + + + + + + + + diff --git a/src/keepass2android-app/Manifests/AndroidManifest_nonet.xml b/src/keepass2android-app/Manifests/AndroidManifest_nonet.xml index f924a72a..cf2d83cc 100644 --- a/src/keepass2android-app/Manifests/AndroidManifest_nonet.xml +++ b/src/keepass2android-app/Manifests/AndroidManifest_nonet.xml @@ -236,6 +236,14 @@ The scheme=file is still there for old OS devices. It's also queried by apps lik + + + + + + + + diff --git a/src/keepass2android-app/SelectCurrentDbActivity.cs b/src/keepass2android-app/SelectCurrentDbActivity.cs index f3119577..0430dc8b 100644 --- a/src/keepass2android-app/SelectCurrentDbActivity.cs +++ b/src/keepass2android-app/SelectCurrentDbActivity.cs @@ -27,6 +27,7 @@ using KeePassLib.Serialization; using Console = System.Console; using Object = Java.Lang.Object; using AndroidX.Core.Content; +using Uri = Android.Net.Uri; namespace keepass2android { @@ -302,9 +303,23 @@ namespace keepass2android } else { + if (Intent.Action == Intent.ActionView) { - GetIocFromViewIntent(Intent); + if (IsOtpUri(Intent.Data)) + { + AppTask = new CreateEntryThenCloseTask() + { + AllFields = Newtonsoft.Json.JsonConvert.SerializeObject(new Dictionary() + { + { "otp", Intent.DataString } + }) + }; + } + else + { + GetIocFromViewIntent(Intent); + } } else if (Intent.Action == Intent.ActionSend) { @@ -334,6 +349,11 @@ namespace keepass2android } + private bool IsOtpUri(Uri? uri) + { + return uri?.Scheme == "otpauth"; + } + protected override void OnStart() { base.OnStart();