mirror of
https://github.com/moparisthebest/keepass2android
synced 2024-11-25 18:52:19 -05:00
start implementing Xamarin.Insights based error reports
This commit is contained in:
parent
870e34d02e
commit
8fc98df53b
@ -14,6 +14,7 @@
|
||||
<AssemblyName>KeePassLib2Android</AssemblyName>
|
||||
<TargetFrameworkVersion>v6.0</TargetFrameworkVersion>
|
||||
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
|
||||
<NuGetPackageImportStamp>8482b288</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
@ -54,6 +55,9 @@
|
||||
<Reference Include="Mono.Android" />
|
||||
<Reference Include="OpenTK-1.0" />
|
||||
<Reference Include="Mono.Security" />
|
||||
<Reference Include="Xamarin.Insights">
|
||||
<HintPath>..\packages\Xamarin.Insights.1.11.3\lib\MonoAndroid10\Xamarin.Insights.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="IDatabaseFormat.cs" />
|
||||
@ -146,6 +150,7 @@
|
||||
<Compile Include="Delegates\Handlers.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
<None Include="Resources\AboutResources.txt" />
|
||||
<None Include="KeePassLib.pfx" />
|
||||
</ItemGroup>
|
||||
@ -163,4 +168,11 @@
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
|
||||
<Import Project="..\packages\Xamarin.Insights.1.11.3\build\MonoAndroid10\Xamarin.Insights.targets" Condition="Exists('..\packages\Xamarin.Insights.1.11.3\build\MonoAndroid10\Xamarin.Insights.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>Dieses Projekt verweist auf mindestens ein NuGet-Paket, das auf diesem Computer fehlt. Aktivieren Sie die Wiederherstellung von NuGet-Paketen, um die fehlende Datei herunterzuladen. Weitere Informationen finden Sie unter "http://go.microsoft.com/fwlink/?LinkID=322105". Die fehlende Datei ist "{0}".</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Xamarin.Insights.1.11.3\build\MonoAndroid10\Xamarin.Insights.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Insights.1.11.3\build\MonoAndroid10\Xamarin.Insights.targets'))" />
|
||||
</Target>
|
||||
</Project>
|
@ -16,6 +16,7 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Android.Preferences;
|
||||
using KeePassLib.Serialization;
|
||||
@ -68,5 +69,13 @@ namespace keepass2android
|
||||
return (bool) _logToFile;
|
||||
}
|
||||
}
|
||||
public static event EventHandler<Exception> OnUnexpectedError;
|
||||
|
||||
public static void LogUnexpectedError(Exception exception)
|
||||
{
|
||||
Log(exception.ToString());
|
||||
if (OnUnexpectedError != null)
|
||||
OnUnexpectedError(null, exception);
|
||||
}
|
||||
}
|
||||
}
|
@ -251,7 +251,7 @@ namespace KeePassLib.Serialization
|
||||
Kp2aLog.Log(e.ToString());
|
||||
} catch (Exception e)
|
||||
{
|
||||
Kp2aLog.Log(e.ToString());
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
Debug.Assert(false);
|
||||
}
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ namespace keepass2android.Io
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.Log(e.ToString());
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ namespace keepass2android.Io
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.Log(e.ToString());
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
<TargetFrameworkVersion>v6.0</TargetFrameworkVersion>
|
||||
<AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk>
|
||||
<NuGetPackageImportStamp>06ffb71c</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@ -53,6 +54,9 @@
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Xamarin.Insights">
|
||||
<HintPath>..\packages\Xamarin.Insights.1.11.3\lib\MonoAndroid10\Xamarin.Insights.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="database\CheckDatabaseForChanges.cs" />
|
||||
@ -138,7 +142,17 @@
|
||||
<Name>TwofishCipher</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
|
||||
<Import Project="..\packages\Xamarin.Insights.1.11.3\build\MonoAndroid10\Xamarin.Insights.targets" Condition="Exists('..\packages\Xamarin.Insights.1.11.3\build\MonoAndroid10\Xamarin.Insights.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>Dieses Projekt verweist auf mindestens ein NuGet-Paket, das auf diesem Computer fehlt. Aktivieren Sie die Wiederherstellung von NuGet-Paketen, um die fehlende Datei herunterzuladen. Weitere Informationen finden Sie unter "http://go.microsoft.com/fwlink/?LinkID=322105". Die fehlende Datei ist "{0}".</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Xamarin.Insights.1.11.3\build\MonoAndroid10\Xamarin.Insights.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Insights.1.11.3\build\MonoAndroid10\Xamarin.Insights.targets'))" />
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
@ -135,7 +135,7 @@ namespace keepass2android
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.Log(e.ToString());
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -94,20 +94,20 @@ namespace keepass2android
|
||||
{
|
||||
message = innerException.Message;
|
||||
// Override the message shown with the last (hopefully most recent) inner exception
|
||||
Kp2aLog.Log("Exception: " + innerException);
|
||||
Kp2aLog.LogUnexpectedError(innerException);
|
||||
}
|
||||
Finish(false, _app.GetResourceString(UiStringKey.ErrorOcurred) + " " + message, Exception);
|
||||
return;
|
||||
}
|
||||
catch (DuplicateUuidsException e)
|
||||
{
|
||||
Kp2aLog.Log("Exception: " + e);
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
Finish(false, _app.GetResourceString(UiStringKey.DuplicateUuidsError) + " " + e.Message + _app.GetResourceString(UiStringKey.DuplicateUuidsErrorAdditional), Exception);
|
||||
return;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.Log("Exception: " + e);
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
Finish(false, _app.GetResourceString(UiStringKey.ErrorOcurred) + " " + e.Message, Exception);
|
||||
return;
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ namespace keepass2android
|
||||
bSuccess = false;
|
||||
}
|
||||
*/
|
||||
Kp2aLog.Log("Error while saving: " + e.ToString());
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
Finish(false, e.Message);
|
||||
return;
|
||||
}
|
||||
@ -188,6 +188,7 @@ namespace keepass2android
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
Kp2aLog.Log("Error in worker thread of SaveDb: " + e);
|
||||
Finish(false, e.Message);
|
||||
}
|
||||
@ -197,6 +198,7 @@ namespace keepass2android
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
Kp2aLog.Log("Error starting worker thread of SaveDb: "+e);
|
||||
Finish(false, e.Message);
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ namespace KeeChallenge
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.Log(e.ToString());
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -388,7 +388,7 @@ namespace keepass2android
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.Log(e.ToString());
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ namespace keepass2android
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.Log(e.ToString());
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1128,7 +1128,8 @@ namespace keepass2android
|
||||
TextView tv = (TextView) FindViewById(viewId);
|
||||
if (tv == null)
|
||||
{
|
||||
Kp2aLog.Log("Invalid viewId " + viewId);
|
||||
var e = new Exception("Invalid viewId " + viewId);
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
return;
|
||||
}
|
||||
tv.Text = text;
|
||||
|
@ -97,7 +97,7 @@ namespace keepass2android
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.Log(e.ToString());
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ namespace keepass2android
|
||||
}
|
||||
catch (IllegalStateException ise)
|
||||
{
|
||||
Kp2aLog.Log(ise.Message);
|
||||
Kp2aLog.LogUnexpectedError(ise);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -745,7 +745,7 @@ namespace keepass2android
|
||||
catch (Exception e)
|
||||
{
|
||||
//don't crash if adding to dirty fails but log the exception:
|
||||
Kp2aLog.Log(e.ToString());
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
}
|
||||
|
||||
AppTask = new NullTask();
|
||||
|
@ -85,7 +85,7 @@ namespace keepass2android
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Kp2aLog.Log(ex.ToString());
|
||||
Kp2aLog.LogUnexpectedError(ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ namespace keepass2android
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Kp2aLog.Log(ex.ToString());
|
||||
Kp2aLog.LogUnexpectedError(ex);
|
||||
}
|
||||
|
||||
base.OnDestroy();
|
||||
|
@ -56,7 +56,7 @@ namespace keepass2android
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Kp2aLog.Log(ex.ToString());
|
||||
Kp2aLog.LogUnexpectedError(ex);
|
||||
}
|
||||
|
||||
base.OnDestroy();
|
||||
|
@ -87,7 +87,7 @@ namespace keepass2android
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.Log(e.ToString());
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
Toast.MakeText(this, "No Yubikey OTP found!", ToastLength.Long).Show();
|
||||
Finish();
|
||||
return;
|
||||
|
@ -396,7 +396,7 @@ namespace keepass2android
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.Log(e.ToString());
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -482,7 +482,7 @@ namespace keepass2android
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.Log(e.ToString());
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
//retry with saved ioc
|
||||
try
|
||||
{
|
||||
@ -494,7 +494,7 @@ namespace keepass2android
|
||||
}
|
||||
catch (Exception e2)
|
||||
{
|
||||
Kp2aLog.Log(e2.ToString());
|
||||
Kp2aLog.LogUnexpectedError(e2);
|
||||
}
|
||||
|
||||
}
|
||||
@ -701,6 +701,7 @@ namespace keepass2android
|
||||
private FingerprintDecryption _fingerprintDec;
|
||||
private bool _fingerprintPermissionGranted;
|
||||
private PasswordActivityBroadcastReceiver _intentReceiver;
|
||||
private int _appnameclickCount;
|
||||
|
||||
|
||||
internal class MyActionBarDrawerToggle : ActionBarDrawerToggle
|
||||
@ -1003,6 +1004,20 @@ namespace keepass2android
|
||||
AppSettingsActivity.Launch(this);
|
||||
};
|
||||
|
||||
FindViewById(Resource.Id.nav_app_name).Click += (sender, args) =>
|
||||
{
|
||||
_appnameclickCount++;
|
||||
if (_appnameclickCount == 6)
|
||||
Toast.MakeText(this, "Once again and the app will crash.", ToastLength.Long).Show();
|
||||
if (_appnameclickCount == 7)
|
||||
{
|
||||
Xamarin.Insights.Report(new Exception("blabla"), new Dictionary<string, string>() { { "key", "the value"}});
|
||||
throw new Exception("This is an easter egg crash (for testing unhandled exceptions.)");
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
private void InitializeToolbar()
|
||||
@ -1415,7 +1430,7 @@ namespace keepass2android
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.Log(e.ToString());
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
errorMessage = e.Message;
|
||||
return false;
|
||||
}
|
||||
@ -1430,7 +1445,7 @@ namespace keepass2android
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.Log(e.ToString());
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
errorMessage = GetString(Resource.String.OtpKeyError);
|
||||
|
||||
return false;
|
||||
@ -1941,6 +1956,7 @@ namespace keepass2android
|
||||
|
||||
_act.ClearEnteredPassword();
|
||||
_act.BroadcastOpenDatabase();
|
||||
_act.InvalidCompositeKeyCount = 0;
|
||||
|
||||
|
||||
GC.Collect(); // Ensure temporary memory used while loading is collected
|
||||
@ -1949,6 +1965,7 @@ namespace keepass2android
|
||||
|
||||
if (Exception is InvalidCompositeKeyException)
|
||||
{
|
||||
_act.InvalidCompositeKeyCount++;
|
||||
if (_act.UsedFingerprintUnlock)
|
||||
{
|
||||
//disable fingerprint unlock if master password changed
|
||||
@ -1957,9 +1974,24 @@ namespace keepass2android
|
||||
|
||||
Message = _act.GetString(Resource.String.fingerprint_disabled_wrong_masterkey);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_act.InvalidCompositeKeyCount > 1)
|
||||
{
|
||||
Message = _act.GetString(Resource.String.RepeatedInvalidCompositeKeyHelp);
|
||||
}
|
||||
else
|
||||
{
|
||||
Message = _act.GetString(Resource.String.FirstInvalidCompositeKeyError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if ((Exception != null) && (Exception.Message == KeePassLib.Resources.KLRes.FileCorrupted))
|
||||
{
|
||||
Message = _act.GetString(Resource.String.CorruptDatabaseHelp);
|
||||
}
|
||||
|
||||
|
||||
if ((Message != null) && (Message.Length > 150)) //show long messages as dialog
|
||||
@ -1992,6 +2024,11 @@ namespace keepass2android
|
||||
}
|
||||
}
|
||||
|
||||
public int InvalidCompositeKeyCount
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
private void BroadcastOpenDatabase()
|
||||
{
|
||||
App.Kp2a.BroadcastDatabaseAction(this, Strings.ActionOpenDatabase);
|
||||
@ -2039,7 +2076,7 @@ namespace keepass2android
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.Log(e.Message);
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
|
||||
Toast.MakeText(_act, _act.GetString(Resource.String.ErrorUpdatingOtpAuxFile) + " " + e.Message,
|
||||
ToastLength.Long).Show();
|
||||
@ -2063,7 +2100,6 @@ namespace keepass2android
|
||||
switch (intent.Action)
|
||||
{
|
||||
case Intent.ActionScreenOff:
|
||||
Kp2aLog.Log("bla");
|
||||
_activity.OnScreenLocked();
|
||||
break;
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ namespace keepass2android
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.Log(e.ToString());
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
}
|
||||
if (String.IsNullOrEmpty(_requestedUrl))
|
||||
Toast.MakeText(this, GetString(Resource.String.query_credentials, new Java.Lang.Object[] {pluginDisplayName}), ToastLength.Long).Show();
|
||||
@ -156,7 +156,7 @@ namespace keepass2android
|
||||
//double check we really have the permission
|
||||
if (!new PluginDatabase(this).HasAcceptedScope(_pluginPackage, _requiredScope))
|
||||
{
|
||||
Kp2aLog.Log("Ohoh! Scope not available, shouldn't get here. Malicious app somewhere?");
|
||||
Kp2aLog.LogUnexpectedError(new Exception("Ohoh! Scope not available, shouldn't get here. Malicious app somewhere?"));
|
||||
SetResult(Result.Canceled);
|
||||
Finish();
|
||||
return;
|
||||
|
@ -340,7 +340,7 @@ namespace keepass2android
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.Log(e.ToString());
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -399,6 +399,7 @@
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/navheader_bg" />
|
||||
<TextView
|
||||
android:id="@+id/nav_app_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/app_name"
|
||||
|
@ -613,6 +613,25 @@
|
||||
<string name="Continue">Continue</string>
|
||||
<string name="NoFilenameWarning">The URI you have entered does not look like a filename. Are you sure this is a valid file?</string>
|
||||
|
||||
<string name="FirstInvalidCompositeKeyError">Invalid composite key! Please try again.</string>
|
||||
<string name="RepeatedInvalidCompositeKeyHelp">Invalid composite key! Please try the following steps to unlock your database:\n
|
||||
* Make sure you have entered the correct password. Use the eye icon to reveal the entered password.\n
|
||||
* Make sure you have selected the correct password type. Make sure this matches the type used when creating the database.\n
|
||||
* Make sure you have selected the correct database file.</string>
|
||||
<string name="CorruptDatabaseHelp">
|
||||
File is corrupted. \n
|
||||
Here are some hints which might help to diagnose the issue:\n
|
||||
* If you copied the file over USB (MTP-Mode), please try again with tools like MyPhoneExplorer. MTP truncates files in certain cases.\n
|
||||
* If you cannot open the file from the same location on your PC, it is very likely that the file is actually corrupted. Please use a database backup then. If you assume that Keepass2Android has corrupted the file, please contact support.\n
|
||||
* If you can still open the file on your PC, please contact support. You might try to save it with different settings (e.g. unzipped) on the PC and retry to open in Keepass2Android.</string>
|
||||
|
||||
<string name="ErrorReportTitle">Keepass2Android: An error occurred.</string>
|
||||
<string name="ErrorReportText">An unexpected error occurred. Please help us fix this by enabling error reports.</string>
|
||||
<string name="ErrorReportPromise">Error reports will never contain any contents of your database or master password. You can disable them in the application settings.</string>
|
||||
<string name="ErrorReportEnable">Enable</string>
|
||||
<string name="ErrorReportDisable">Disable</string>
|
||||
|
||||
|
||||
<string name="ChangeLog_0_9_8c">
|
||||
Version 0.9.8c\n
|
||||
* Fix for SSL vulnerability in Microsoft Live SDK (used when accessing files via OneDrive)\n
|
||||
|
@ -168,7 +168,7 @@ namespace PluginTOTP
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.Log(e.ToString());
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
//ignore, it's only a warning
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ namespace keepass2android
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.Log(e.ToString());
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ namespace keepass2android.Utils
|
||||
}
|
||||
catch (Exception t)
|
||||
{
|
||||
Kp2aLog.Log(t.ToString());
|
||||
Kp2aLog.LogUnexpectedError(t);
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,7 +121,7 @@ namespace keepass2android.Utils
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.Log(e.ToString());
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -276,7 +276,7 @@ namespace keepass2android
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.Log(e.ToString());
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
}
|
||||
|
||||
String filename = data.Data.Path;
|
||||
|
@ -178,7 +178,7 @@ namespace OtpKeyProv
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.Log(e.ToString());
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -31,6 +31,7 @@ using KeePassLib.Cryptography.Cipher;
|
||||
using KeePassLib.Keys;
|
||||
using KeePassLib.Serialization;
|
||||
using Android.Preferences;
|
||||
using Android.Support.V4.App;
|
||||
#if !EXCLUDE_TWOFISH
|
||||
using TwofishCipher;
|
||||
#endif
|
||||
@ -365,7 +366,7 @@ namespace keepass2android
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.Log(e.ToString());
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
}
|
||||
|
||||
}
|
||||
@ -410,7 +411,7 @@ namespace keepass2android
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.Log(e.ToString());
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
}
|
||||
|
||||
}
|
||||
@ -566,7 +567,7 @@ namespace keepass2android
|
||||
}
|
||||
|
||||
|
||||
enum ValidationMode
|
||||
public enum ValidationMode
|
||||
{
|
||||
Ignore, Warn, Error
|
||||
}
|
||||
@ -754,6 +755,9 @@ namespace keepass2android
|
||||
#endif
|
||||
#endif
|
||||
public class App : Application {
|
||||
public const string Kp2AActionDisableerrorreport = "kp2a.action.DisableErrorReport";
|
||||
public const string Kp2AActionEnableerrorreport = "kp2a.action.EnableErrorReport";
|
||||
public const string PrefErrorreportmode = "pref_ErrorReportMode";
|
||||
|
||||
public App (IntPtr javaReference, JniHandleOwnership transfer)
|
||||
: base(javaReference, transfer)
|
||||
@ -762,6 +766,13 @@ namespace keepass2android
|
||||
|
||||
public static readonly Kp2aApp Kp2a = new Kp2aApp();
|
||||
|
||||
public enum ErrorReportMode
|
||||
{
|
||||
AskAgain=0,
|
||||
Disabled=1,
|
||||
Enabled=2
|
||||
}
|
||||
|
||||
public override void OnCreate() {
|
||||
base.OnCreate();
|
||||
|
||||
@ -769,12 +780,50 @@ namespace keepass2android
|
||||
|
||||
Kp2a.OnCreate(this);
|
||||
AndroidEnvironment.UnhandledExceptionRaiser += MyApp_UnhandledExceptionHandler;
|
||||
Kp2aLog.OnUnexpectedError += (sender, exception) =>
|
||||
{
|
||||
var currentErrorReportMode = GetErrorReportMode();
|
||||
if (currentErrorReportMode == ErrorReportMode.AskAgain)
|
||||
{
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(ApplicationContext);
|
||||
var notification =
|
||||
builder.SetContentTitle(Resources.GetString(Resource.String.ErrorReportTitle))
|
||||
.SetContentText(Resources.GetString(Resource.String.ErrorReportText) + " " +
|
||||
Resources.GetString(Resource.String.ErrorReportPromise))
|
||||
.AddAction(Android.Resource.Drawable.IcMenuCloseClearCancel, Resource.String.ErrorReportDisable,
|
||||
PendingIntent.GetBroadcast(ApplicationContext, 0, new Intent(Kp2AActionDisableerrorreport),
|
||||
PendingIntentFlags.CancelCurrent))
|
||||
.AddAction(Android.Resource.Drawable.IcMenuCloseClearCancel, Resource.String.ErrorReportEnable,
|
||||
PendingIntent.GetBroadcast(ApplicationContext, 0, new Intent(Kp2AActionEnableerrorreport),
|
||||
PendingIntentFlags.CancelCurrent))
|
||||
.Build();
|
||||
((NotificationManager) GetSystemService(NotificationService)).Notify(18919, notification);
|
||||
|
||||
var filter = new IntentFilter();
|
||||
filter.AddAction(Kp2AActionDisableerrorreport);
|
||||
filter.AddAction(Kp2AActionEnableerrorreport);
|
||||
RegisterReceiver(new ErrorReportSettingsReceiver(), filter);
|
||||
}
|
||||
};
|
||||
Xamarin.Insights.Initialize("fed2b273ed2a964d0ba6acc3743e68f7a04da957", ApplicationContext);
|
||||
Xamarin.Insights.DisableExceptionCatching = true;
|
||||
var errorReportMode = GetErrorReportMode();
|
||||
Xamarin.Insights.DisableDataTransmission = errorReportMode != ErrorReportMode.Enabled;
|
||||
}
|
||||
|
||||
private ErrorReportMode GetErrorReportMode()
|
||||
{
|
||||
ErrorReportMode errorReportMode;
|
||||
Enum.TryParse(PreferenceManager.GetDefaultSharedPreferences(this.ApplicationContext)
|
||||
.GetString(PrefErrorreportmode, ErrorReportMode.AskAgain.ToString()), out errorReportMode);
|
||||
return errorReportMode;
|
||||
}
|
||||
|
||||
|
||||
void MyApp_UnhandledExceptionHandler(object sender, RaiseThrowableEventArgs e)
|
||||
{
|
||||
Kp2aLog.Log(e.Exception.ToString());
|
||||
Kp2aLog.LogUnexpectedError(e.Exception);
|
||||
Xamarin.Insights.Save();
|
||||
// Do your error handling here.
|
||||
throw e.Exception;
|
||||
}
|
||||
@ -793,5 +842,24 @@ namespace keepass2android
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class ErrorReportSettingsReceiver : BroadcastReceiver
|
||||
{
|
||||
public override void OnReceive(Context context, Intent intent)
|
||||
{
|
||||
if (intent.Action == App.Kp2AActionDisableerrorreport)
|
||||
{
|
||||
PreferenceManager.GetDefaultSharedPreferences(context)
|
||||
.Edit()
|
||||
.PutString(App.PrefErrorreportmode, App.ErrorReportMode.Disabled.ToString());
|
||||
}
|
||||
if (intent.Action == App.Kp2AActionEnableerrorreport)
|
||||
{
|
||||
PreferenceManager.GetDefaultSharedPreferences(context)
|
||||
.Edit()
|
||||
.PutString(App.PrefErrorreportmode, App.ErrorReportMode.Enabled.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ namespace keepass2android
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.Log(e.ToString());
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -57,7 +57,7 @@ namespace keepass2android
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Kp2aLog.Log(e.ToString());
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -71,7 +71,7 @@ namespace keepass2android
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.Log(e.ToString());
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -92,7 +92,7 @@ namespace keepass2android
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.Log(e.ToString());
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ This file is part of Keepass2Android, Copyright 2013 Philipp Crocoll. This file
|
||||
along with Keepass2Android. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
@ -59,7 +60,7 @@ private static Drawable _blank;
|
||||
}
|
||||
|
||||
else
|
||||
Kp2aLog.Log("icon not found : " + icon);
|
||||
Kp2aLog.LogUnexpectedError(new Exception("icon not found : " + icon));
|
||||
}
|
||||
|
||||
public Drawable GetIconDrawable (Context context, PwDatabase db, PwIcon icon, PwUuid customIconId, bool forGroup)
|
||||
@ -113,7 +114,7 @@ private static Drawable _blank;
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Kp2aLog.Log(e.ToString());
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
draw = context.Resources.GetDrawable(Resource.Drawable.ic99_blank);
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
<MandroidI18n />
|
||||
<JavaMaximumHeapSize>1G</JavaMaximumHeapSize>
|
||||
<AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk>
|
||||
<NuGetPackageImportStamp>9e78b013</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
@ -110,6 +111,9 @@
|
||||
<HintPath>..\packages\Xamarin.GooglePlayServices.Drive.27.0.0.0\lib\MonoAndroid41\Xamarin.GooglePlayServices.Drive.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Xamarin.Insights">
|
||||
<HintPath>..\packages\Xamarin.Insights.1.11.3\lib\MonoAndroid10\Xamarin.Insights.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="addons\OtpKeyProv\EncodingUtil.cs" />
|
||||
@ -1666,4 +1670,11 @@
|
||||
<AndroidResource Include="Resources\drawable-mdpi\ic_fp_40px.png" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
|
||||
<Import Project="..\packages\Xamarin.Insights.1.11.3\build\MonoAndroid10\Xamarin.Insights.targets" Condition="Exists('..\packages\Xamarin.Insights.1.11.3\build\MonoAndroid10\Xamarin.Insights.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>Dieses Projekt verweist auf mindestens ein NuGet-Paket, das auf diesem Computer fehlt. Aktivieren Sie die Wiederherstellung von NuGet-Paketen, um die fehlende Datei herunterzuladen. Weitere Informationen finden Sie unter "http://go.microsoft.com/fwlink/?LinkID=322105". Die fehlende Datei ist "{0}".</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Xamarin.Insights.1.11.3\build\MonoAndroid10\Xamarin.Insights.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Insights.1.11.3\build\MonoAndroid10\Xamarin.Insights.targets'))" />
|
||||
</Target>
|
||||
</Project>
|
@ -7,4 +7,5 @@
|
||||
<package id="Xamarin.GooglePlayServices.Base" version="27.0.0.0" targetFramework="MonoAndroid50" />
|
||||
<package id="Xamarin.GooglePlayServices.Basement" version="27.0.0.0" targetFramework="MonoAndroid50" />
|
||||
<package id="Xamarin.GooglePlayServices.Drive" version="27.0.0.0" targetFramework="MonoAndroid50" />
|
||||
<package id="Xamarin.Insights" version="1.11.3" targetFramework="MonoAndroid60" />
|
||||
</packages>
|
@ -87,7 +87,7 @@ namespace keepass2android.search
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Kp2aLog.Log("Failed to search for suggestions: " + e.Message);
|
||||
Kp2aLog.LogUnexpectedError(new Exception("Failed to search for suggestions", e));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -100,7 +100,7 @@ namespace keepass2android.search
|
||||
try {
|
||||
Group = App.Kp2a.GetDb().Search (searchParams, null);
|
||||
} catch (Exception e) {
|
||||
Kp2aLog.Log(e.ToString());
|
||||
Kp2aLog.LogUnexpectedError(e);
|
||||
Toast.MakeText(this,e.Message, ToastLength.Long).Show();
|
||||
Finish();
|
||||
return;
|
||||
|
@ -385,7 +385,7 @@ namespace keepass2android
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Kp2aLog.Log(ex.ToString());
|
||||
Kp2aLog.LogUnexpectedError(ex);
|
||||
}
|
||||
|
||||
|
||||
@ -428,7 +428,7 @@ namespace keepass2android
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Kp2aLog.Log(ex.ToString());
|
||||
Kp2aLog.LogUnexpectedError(ex);
|
||||
}
|
||||
|
||||
|
||||
@ -553,7 +553,7 @@ namespace keepass2android
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Kp2aLog.Log(ex.ToString());
|
||||
Kp2aLog.LogUnexpectedError(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -585,7 +585,7 @@ namespace keepass2android
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Kp2aLog.Log(ex.ToString());
|
||||
Kp2aLog.LogUnexpectedError(ex);
|
||||
Toast.MakeText(Application.Context, ex.Message, ToastLength.Long).Show();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user