From 21f3755e4433659a82dc54ffd23a264767a579a5 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 8 Jun 2017 12:44:16 -0400 Subject: [PATCH] version bump. all unhandled crash report email --- src/Android/MainApplication.cs | 19 +++++++++++++ src/Android/Properties/AndroidManifest.xml | 2 +- .../Services/KeyStoreBackedStorageService.cs | 28 +++++++------------ 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/Android/MainApplication.cs b/src/Android/MainApplication.cs index 4f308ef5e..7760ea90e 100644 --- a/src/Android/MainApplication.cs +++ b/src/Android/MainApplication.cs @@ -38,12 +38,31 @@ namespace Bit.Android public MainApplication(IntPtr handle, JniHandleOwnership transer) : base(handle, transer) { + AndroidEnvironment.UnhandledExceptionRaiser += AndroidEnvironment_UnhandledExceptionRaiser; + if(!Resolver.IsSet) { SetIoc(this); } } + private void AndroidEnvironment_UnhandledExceptionRaiser(object sender, RaiseThrowableEventArgs e) + { + var message = AppendExceptionToMessage("", e.Exception); + Utilities.SendCrashEmail(message, false); + } + + private string AppendExceptionToMessage(string message, Exception ex) + { + message += ("\n\n" + ex.Message + "\n\n" + ex.StackTrace); + if(ex.InnerException != null) + { + return AppendExceptionToMessage(message, ex.InnerException); + } + + return message; + } + public override void OnCreate() { base.OnCreate(); diff --git a/src/Android/Properties/AndroidManifest.xml b/src/Android/Properties/AndroidManifest.xml index 1f98cc16d..98f8d22f9 100644 --- a/src/Android/Properties/AndroidManifest.xml +++ b/src/Android/Properties/AndroidManifest.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Android/Services/KeyStoreBackedStorageService.cs b/src/Android/Services/KeyStoreBackedStorageService.cs index fbff9f6aa..74a34463b 100644 --- a/src/Android/Services/KeyStoreBackedStorageService.cs +++ b/src/Android/Services/KeyStoreBackedStorageService.cs @@ -30,25 +30,17 @@ namespace Bit.Android.Services public KeyStoreBackedStorageService(ISettings settings) { - try - { - _oldAndroid = Build.VERSION.SdkInt < BuildVersionCodes.M; - _rsaMode = _oldAndroid ? "RSA/ECB/PKCS1Padding" : "RSA/ECB/OAEPWithSHA-1AndMGF1Padding"; + _oldAndroid = Build.VERSION.SdkInt < BuildVersionCodes.M; + _rsaMode = _oldAndroid ? "RSA/ECB/PKCS1Padding" : "RSA/ECB/OAEPWithSHA-1AndMGF1Padding"; - _oldKeyStorageService = new KeyStoreStorageService(new char[] { }); - _settings = settings; + _oldKeyStorageService = new KeyStoreStorageService(new char[] { }); + _settings = settings; - _keyStore = KeyStore.GetInstance(AndroidKeyStore); - _keyStore.Load(null); + _keyStore = KeyStore.GetInstance(AndroidKeyStore); + _keyStore.Load(null); - GenerateRsaKey(); - GenerateAesKey(); - } - catch(Exception e) - { - Utilities.SendCrashEmail(e); - throw; - } + GenerateRsaKey(); + GenerateAesKey(); } public bool Contains(string key) @@ -116,7 +108,7 @@ namespace Bit.Android.Services var cipherString = App.Utilities.Crypto.AesCbcEncrypt(dataBytes, aesKey); _settings.AddOrUpdateValue(formattedKey, cipherString.EncryptedString); } - catch (Exception e) + catch(Exception e) { Console.WriteLine("Failed to encrypt to secure storage."); Utilities.SendCrashEmail(e); @@ -193,7 +185,7 @@ namespace Bit.Android.Services var key = RsaDecrypt(encKeyBytes); return new App.Models.SymmetricCryptoKey(key); } - catch (Exception e) + catch(Exception e) { Console.WriteLine("Cannot get AesKey."); _keyStore.DeleteEntry(KeyAlias);