add support for otpauth:// URIs

This commit is contained in:
Philipp Crocoll
2025-03-25 10:56:24 +01:00
parent 8eaf6d3f88
commit e86fa6f9fa
4 changed files with 46 additions and 2 deletions

View File

@@ -243,6 +243,15 @@ The scheme=file is still there for old OS devices. It's also queried by apps lik
<action android:name="keepass2android.ACTION_START_WITH_TASK" /> <action android:name="keepass2android.ACTION_START_WITH_TASK" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
</intent-filter> </intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="otpauth"/>
<data android:host="totp"/>
<data android:host="hotp"/>
</intent-filter>
</activity> </activity>
<uses-library android:required="false" android:name="com.sec.android.app.multiwindow" /> <uses-library android:required="false" android:name="com.sec.android.app.multiwindow" />
<meta-data android:name="com.sec.android.support.multiwindow" android:value="true" /> <meta-data android:name="com.sec.android.support.multiwindow" android:value="true" />

View File

@@ -255,7 +255,14 @@ The scheme=file is still there for old OS devices. It's also queried by apps lik
<action android:name="keepass2android.ACTION_START_WITH_TASK" /> <action android:name="keepass2android.ACTION_START_WITH_TASK" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
</intent-filter> </intent-filter>
x <intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="otpauth"/>
<data android:host="totp"/>
<data android:host="hotp"/>
</intent-filter>
</activity> </activity>
<uses-library android:required="false" android:name="com.sec.android.app.multiwindow" /> <uses-library android:required="false" android:name="com.sec.android.app.multiwindow" />
<meta-data android:name="com.sec.android.support.multiwindow" android:value="true" /> <meta-data android:name="com.sec.android.support.multiwindow" android:value="true" />

View File

@@ -236,6 +236,14 @@ The scheme=file is still there for old OS devices. It's also queried by apps lik
<action android:name="keepass2android.ACTION_START_WITH_TASK" /> <action android:name="keepass2android.ACTION_START_WITH_TASK" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
</intent-filter> </intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="otpauth"/>
<data android:host="totp"/>
<data android:host="hotp"/>
</intent-filter>
</activity> </activity>
<uses-library android:required="false" android:name="com.sec.android.app.multiwindow" /> <uses-library android:required="false" android:name="com.sec.android.app.multiwindow" />
<meta-data android:name="com.sec.android.support.multiwindow" android:value="true" /> <meta-data android:name="com.sec.android.support.multiwindow" android:value="true" />

View File

@@ -27,6 +27,7 @@ using KeePassLib.Serialization;
using Console = System.Console; using Console = System.Console;
using Object = Java.Lang.Object; using Object = Java.Lang.Object;
using AndroidX.Core.Content; using AndroidX.Core.Content;
using Uri = Android.Net.Uri;
namespace keepass2android namespace keepass2android
{ {
@@ -302,9 +303,23 @@ namespace keepass2android
} }
else else
{ {
if (Intent.Action == Intent.ActionView) if (Intent.Action == Intent.ActionView)
{ {
GetIocFromViewIntent(Intent); if (IsOtpUri(Intent.Data))
{
AppTask = new CreateEntryThenCloseTask()
{
AllFields = Newtonsoft.Json.JsonConvert.SerializeObject(new Dictionary<string, string>()
{
{ "otp", Intent.DataString }
})
};
}
else
{
GetIocFromViewIntent(Intent);
}
} }
else if (Intent.Action == Intent.ActionSend) 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() protected override void OnStart()
{ {
base.OnStart(); base.OnStart();