mirror of
https://github.com/bitwarden/android.git
synced 2024-12-24 18:08:26 +03:00
make crash email util
This commit is contained in:
parent
b139eadf0b
commit
7e23a8169f
3 changed files with 55 additions and 39 deletions
|
@ -331,6 +331,7 @@
|
|||
<Compile Include="Services\ReflectionService.cs" />
|
||||
<Compile Include="Services\SqlService.cs" />
|
||||
<Compile Include="SplashActivity.cs" />
|
||||
<Compile Include="Utilities.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="8bit.keystore.enc" />
|
||||
|
|
|
@ -12,7 +12,6 @@ using Android.App;
|
|||
using Plugin.Settings.Abstractions;
|
||||
using Java.Util;
|
||||
using Javax.Crypto.Spec;
|
||||
using Android.Content;
|
||||
|
||||
namespace Bit.Android.Services
|
||||
{
|
||||
|
@ -47,45 +46,11 @@ namespace Bit.Android.Services
|
|||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
SendEmail(e.Message + "\n\n" + e.StackTrace);
|
||||
Utilities.SendCrashEmail(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void SendEmail(string text, bool includeSecurityProviders = true)
|
||||
{
|
||||
var crashMessage = "bitwarden has crashed. Please send this email to our support team so that we can help " +
|
||||
"resolve the problem for you. Thank you.";
|
||||
|
||||
text = crashMessage + "\n\n =============================================== \n\n" + text;
|
||||
|
||||
if(includeSecurityProviders)
|
||||
{
|
||||
text += "\n\n";
|
||||
var providers = Security.GetProviders();
|
||||
foreach(var provider in providers)
|
||||
{
|
||||
text += ("provider: " + provider.Name + "\n");
|
||||
var services = provider.Services;
|
||||
foreach(var service in provider.Services)
|
||||
{
|
||||
text += ("- alg: " + service.Algorithm + "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
text += "\n\n ==================================================== \n\n" + crashMessage;
|
||||
|
||||
var emailIntent = new Intent(Intent.ActionSend);
|
||||
|
||||
emailIntent.SetType("plain/text");
|
||||
emailIntent.PutExtra(Intent.ExtraEmail, new String[] { "hello@bitwarden.com" });
|
||||
emailIntent.PutExtra(Intent.ExtraSubject, "bitwarden Crash Report");
|
||||
emailIntent.PutExtra(Intent.ExtraText, text);
|
||||
|
||||
Application.Context.StartActivity(Intent.CreateChooser(emailIntent, "Send mail..."));
|
||||
}
|
||||
|
||||
public bool Contains(string key)
|
||||
{
|
||||
return _settings.Contains(string.Format(SettingsFormat, key)) || _oldKeyStorageService.Contains(key);
|
||||
|
@ -125,7 +90,7 @@ namespace Bit.Android.Services
|
|||
{
|
||||
Console.WriteLine("Failed to decrypt from secure storage.");
|
||||
_settings.Remove(formattedKey);
|
||||
SendEmail(e.Message + "\n\n" + e.StackTrace);
|
||||
Utilities.SendCrashEmail(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -154,7 +119,7 @@ namespace Bit.Android.Services
|
|||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("Failed to encrypt to secure storage.");
|
||||
SendEmail(e.Message + "\n\n" + e.StackTrace);
|
||||
Utilities.SendCrashEmail(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -233,7 +198,7 @@ namespace Bit.Android.Services
|
|||
Console.WriteLine("Cannot get AesKey.");
|
||||
_keyStore.DeleteEntry(KeyAlias);
|
||||
_settings.Remove(AesKey);
|
||||
SendEmail(e.Message + "\n\n" + e.StackTrace);
|
||||
Utilities.SendCrashEmail(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
50
src/Android/Utilities.cs
Normal file
50
src/Android/Utilities.cs
Normal file
|
@ -0,0 +1,50 @@
|
|||
using System;
|
||||
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using Java.Security;
|
||||
|
||||
namespace Bit.Android
|
||||
{
|
||||
public static class Utilities
|
||||
{
|
||||
public static void SendCrashEmail(Exception e, bool includeSecurityProviders = true)
|
||||
{
|
||||
SendCrashEmail(e.Message + "\n\n" + e.StackTrace, includeSecurityProviders);
|
||||
}
|
||||
|
||||
public static void SendCrashEmail(string text, bool includeSecurityProviders = true)
|
||||
{
|
||||
var crashMessage = "bitwarden has crashed. Please send this email to our support team so that we can help " +
|
||||
"resolve the problem for you. Thank you.";
|
||||
|
||||
text = crashMessage + "\n\n =============================================== \n\n" + text;
|
||||
|
||||
if(includeSecurityProviders)
|
||||
{
|
||||
text += "\n\n";
|
||||
var providers = Security.GetProviders();
|
||||
foreach(var provider in providers)
|
||||
{
|
||||
text += ("provider: " + provider.Name + "\n");
|
||||
var services = provider.Services;
|
||||
foreach(var service in provider.Services)
|
||||
{
|
||||
text += ("- alg: " + service.Algorithm + "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
text += "\n\n ==================================================== \n\n" + crashMessage;
|
||||
|
||||
var emailIntent = new Intent(Intent.ActionSend);
|
||||
|
||||
emailIntent.SetType("plain/text");
|
||||
emailIntent.PutExtra(Intent.ExtraEmail, new String[] { "hello@bitwarden.com" });
|
||||
emailIntent.PutExtra(Intent.ExtraSubject, "bitwarden Crash Report");
|
||||
emailIntent.PutExtra(Intent.ExtraText, text);
|
||||
|
||||
Application.Context.StartActivity(Intent.CreateChooser(emailIntent, "Send mail..."));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue