diff --git a/src/Android/Android.csproj b/src/Android/Android.csproj index 4cd7ff816..1d12a7205 100644 --- a/src/Android/Android.csproj +++ b/src/Android/Android.csproj @@ -145,6 +145,7 @@ + diff --git a/src/Android/MainActivity.cs b/src/Android/MainActivity.cs index d37ef173c..deb9eda28 100644 --- a/src/Android/MainActivity.cs +++ b/src/Android/MainActivity.cs @@ -378,7 +378,7 @@ namespace Bit.Droid { return; } - await _stateService.SaveAsync(Constants.LastClipboardValueKey, data.Item1); + StaticStore.LastClipboardValue = data.Item1; var triggerMs = Java.Lang.JavaSystem.CurrentTimeMillis() + clearMs.Value; var alarmManager = GetSystemService(AlarmService) as AlarmManager; alarmManager.Set(AlarmType.Rtc, triggerMs, _clearClipboardPendingIntent); diff --git a/src/Android/Receivers/ClearClipboardAlarmReceiver.cs b/src/Android/Receivers/ClearClipboardAlarmReceiver.cs index d99fb8ff1..4085cf69b 100644 --- a/src/Android/Receivers/ClearClipboardAlarmReceiver.cs +++ b/src/Android/Receivers/ClearClipboardAlarmReceiver.cs @@ -2,22 +2,21 @@ using Bit.Core; using Bit.Core.Abstractions; using Bit.Core.Utilities; +using Bit.Droid.Utilities; namespace Bit.Droid.Receivers { [BroadcastReceiver(Name = "com.x8bit.bitwarden.ClearClipboardAlarmReceiver", Exported = false)] public class ClearClipboardAlarmReceiver : BroadcastReceiver { - public async override void OnReceive(Context context, Intent intent) + public override void OnReceive(Context context, Intent intent) { - var stateService = ServiceContainer.Resolve("stateService"); var clipboardManager = context.GetSystemService(Context.ClipboardService) as ClipboardManager; - var lastClipboardValue = await stateService.GetAsync(Constants.LastClipboardValueKey); - await stateService.RemoveAsync(Constants.LastClipboardValueKey); - if(lastClipboardValue == clipboardManager.Text) + if(StaticStore.LastClipboardValue != null && StaticStore.LastClipboardValue == clipboardManager.Text) { clipboardManager.Text = string.Empty; } + StaticStore.LastClipboardValue = null; } } } diff --git a/src/Android/Utilities/StaticStore.cs b/src/Android/Utilities/StaticStore.cs new file mode 100644 index 000000000..1be4cf9a4 --- /dev/null +++ b/src/Android/Utilities/StaticStore.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Android.App; +using Android.Content; +using Android.OS; +using Android.Runtime; +using Android.Views; +using Android.Widget; + +namespace Bit.Droid.Utilities +{ + public static class StaticStore + { + public static string LastClipboardValue { get; set; } + } +} diff --git a/src/Core/Constants.cs b/src/Core/Constants.cs index f9d4f8e0a..56547444e 100644 --- a/src/Core/Constants.cs +++ b/src/Core/Constants.cs @@ -24,7 +24,6 @@ public static string PushInitialPromptShownKey = "pushInitialPromptShown"; public static string ThemeKey = "theme"; public static string ClearClipboardKey = "clearClipboard"; - public static string LastClipboardValueKey = "lastClipboardValue"; public static string LastBuildKey = "lastBuild"; public static string OldUserIdKey = "userId"; public static string AddSitePromptShownKey = "addSitePromptShown";