mirror of
https://github.com/bitwarden/android.git
synced 2024-12-25 02:18:27 +03:00
save crash file to external storage instead
This commit is contained in:
parent
0c71f783fc
commit
cf3998942f
3 changed files with 42 additions and 14 deletions
|
@ -49,7 +49,8 @@ namespace Bit.Android
|
||||||
private void AndroidEnvironment_UnhandledExceptionRaiser(object sender, RaiseThrowableEventArgs e)
|
private void AndroidEnvironment_UnhandledExceptionRaiser(object sender, RaiseThrowableEventArgs e)
|
||||||
{
|
{
|
||||||
var message = AppendExceptionToMessage("", e.Exception);
|
var message = AppendExceptionToMessage("", e.Exception);
|
||||||
Utilities.SendCrashEmail(message, false);
|
Utilities.SaveCrashFile(message, true);
|
||||||
|
//Utilities.SendCrashEmail(message, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string AppendExceptionToMessage(string message, Exception ex)
|
private string AppendExceptionToMessage(string message, Exception ex)
|
||||||
|
|
|
@ -96,7 +96,8 @@ namespace Bit.Android.Services
|
||||||
{
|
{
|
||||||
Console.WriteLine("Failed to decrypt from secure storage.");
|
Console.WriteLine("Failed to decrypt from secure storage.");
|
||||||
_settings.Remove(formattedKey);
|
_settings.Remove(formattedKey);
|
||||||
Utilities.SendCrashEmail(e);
|
//Utilities.SendCrashEmail(e);
|
||||||
|
Utilities.SaveCrashFile(e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,7 +126,8 @@ namespace Bit.Android.Services
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Failed to encrypt to secure storage.");
|
Console.WriteLine("Failed to encrypt to secure storage.");
|
||||||
Utilities.SendCrashEmail(e);
|
//Utilities.SendCrashEmail(e);
|
||||||
|
Utilities.SaveCrashFile(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,7 +234,8 @@ namespace Bit.Android.Services
|
||||||
_settings.Remove(AesKey);
|
_settings.Remove(AesKey);
|
||||||
if(!v1)
|
if(!v1)
|
||||||
{
|
{
|
||||||
Utilities.SendCrashEmail(e);
|
//Utilities.SendCrashEmail(e);
|
||||||
|
Utilities.SaveCrashFile(e);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
using Android.App;
|
using Android.App;
|
||||||
using Android.Content;
|
using Android.Content;
|
||||||
using Java.Security;
|
using Java.Security;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace Bit.Android
|
namespace Bit.Android
|
||||||
{
|
{
|
||||||
|
@ -13,7 +13,39 @@ namespace Bit.Android
|
||||||
SendCrashEmail(e.Message + "\n\n" + e.StackTrace, includeSecurityProviders);
|
SendCrashEmail(e.Message + "\n\n" + e.StackTrace, includeSecurityProviders);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SaveCrashFile(Exception e, bool includeSecurityProviders = true)
|
||||||
|
{
|
||||||
|
SaveCrashFile(e.Message + "\n\n" + e.StackTrace, includeSecurityProviders);
|
||||||
|
}
|
||||||
|
|
||||||
public static void SendCrashEmail(string text, bool includeSecurityProviders = true)
|
public static void SendCrashEmail(string text, bool includeSecurityProviders = true)
|
||||||
|
{
|
||||||
|
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, FormatText(text, includeSecurityProviders));
|
||||||
|
|
||||||
|
Application.Context.StartActivity(Intent.CreateChooser(emailIntent, "Send mail..."));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SaveCrashFile(string text, bool includeSecurityProviders = true)
|
||||||
|
{
|
||||||
|
var path = global::Android.OS.Environment.ExternalStorageDirectory.AbsolutePath;
|
||||||
|
var dir = Path.Combine(path, "bitwarden");
|
||||||
|
if(!Directory.Exists(dir))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(dir);
|
||||||
|
}
|
||||||
|
var filename = Path.Combine(dir, $"crash-{Java.Lang.JavaSystem.CurrentTimeMillis()}.txt");
|
||||||
|
using(var streamWriter = new StreamWriter(filename, true))
|
||||||
|
{
|
||||||
|
streamWriter.WriteLine(FormatText(text, includeSecurityProviders));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string FormatText(string text, bool includeSecurityProviders = true)
|
||||||
{
|
{
|
||||||
var crashMessage = "bitwarden has crashed. Please send this email to our support team so that we can help " +
|
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.";
|
"resolve the problem for you. Thank you.";
|
||||||
|
@ -36,15 +68,7 @@ namespace Bit.Android
|
||||||
}
|
}
|
||||||
|
|
||||||
text += "\n\n ==================================================== \n\n" + crashMessage;
|
text += "\n\n ==================================================== \n\n" + crashMessage;
|
||||||
|
return text;
|
||||||
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