diff --git a/Apps/Contoso.Android.Puppet/Contoso.Android.Puppet.csproj b/Apps/Contoso.Android.Puppet/Contoso.Android.Puppet.csproj index 2a2198694..b62b2cf3c 100644 --- a/Apps/Contoso.Android.Puppet/Contoso.Android.Puppet.csproj +++ b/Apps/Contoso.Android.Puppet/Contoso.Android.Puppet.csproj @@ -104,6 +104,7 @@ + diff --git a/Apps/Contoso.Android.Puppet/CrashActivity.cs b/Apps/Contoso.Android.Puppet/CrashActivity.cs new file mode 100644 index 000000000..992735063 --- /dev/null +++ b/Apps/Contoso.Android.Puppet/CrashActivity.cs @@ -0,0 +1,14 @@ +using Android.App; +using Android.OS; + +namespace Contoso.Android.Puppet +{ + [Activity(Label = "CrashActivity")] + public class CrashActivity : Activity + { + protected override void OnCreate(Bundle savedInstanceState) + { + // will crash with super not called, a pure Java exception with no .NET crash handler. + } + } +} diff --git a/Apps/Contoso.Android.Puppet/MainActivity.cs b/Apps/Contoso.Android.Puppet/MainActivity.cs index b826e883e..b6facb4f4 100644 --- a/Apps/Contoso.Android.Puppet/MainActivity.cs +++ b/Apps/Contoso.Android.Puppet/MainActivity.cs @@ -51,17 +51,27 @@ protected override void OnCreate(Bundle savedInstanceState) Distribute.ReleaseAvailable = OnReleaseAvailable; MobileCenterLog.Assert(LogTag, "MobileCenter.Configured=" + MobileCenter.Configured); - MobileCenterLog.Assert(LogTag, "MobileCenter.InstallId (before configure)=" + MobileCenter.InstallId); MobileCenter.SetLogUrl("https://in-integration.dev.avalanch.es"); Distribute.SetInstallUrl("http://install.asgard-int.trafficmanager.net"); Distribute.SetApiUrl("https://asgard-int.trafficmanager.net/api/v0.1"); MobileCenter.Start("bff0949b-7970-439d-9745-92cdc59b10fe", typeof(Analytics), typeof(Crashes), typeof(Distribute)); - MobileCenterLog.Info(LogTag, "MobileCenter.InstallId=" + MobileCenter.InstallId); - MobileCenterLog.Info(LogTag, "Crashes.HasCrashedInLastSession=" + Crashes.HasCrashedInLastSession); + MobileCenter.IsEnabledAsync().ContinueWith(enabled => + { + MobileCenterLog.Info(LogTag, "MobileCenter.Enabled=" + enabled.Result); + }); + MobileCenter.GetInstallIdAsync().ContinueWith(installId => + { + MobileCenterLog.Info(LogTag, "MobileCenter.InstallId=" + installId.Result); + }); + Crashes.HasCrashedInLastSessionAsync().ContinueWith(hasCrashed => + { + MobileCenterLog.Info(LogTag, "Crashes.HasCrashedInLastSession=" + hasCrashed.Result); + }); Crashes.GetLastSessionCrashReportAsync().ContinueWith(report => { - MobileCenterLog.Info(LogTag, " Crashes.LastSessionCrashReport.Exception=" + report.Result?.Exception); + MobileCenterLog.Info(LogTag, "Crashes.LastSessionCrashReport.Exception=" + report.Result?.Exception); + MobileCenterLog.Info(LogTag, "Crashes.LastSessionCrashReport.Throwable=" + report.Result?.AndroidDetails?.Throwable); }); } diff --git a/Apps/Contoso.Android.Puppet/ModulePages/AnalyticsFragment.cs b/Apps/Contoso.Android.Puppet/ModulePages/AnalyticsFragment.cs index 7fd664eef..874dddf0d 100644 --- a/Apps/Contoso.Android.Puppet/ModulePages/AnalyticsFragment.cs +++ b/Apps/Contoso.Android.Puppet/ModulePages/AnalyticsFragment.cs @@ -47,20 +47,20 @@ public override void OnViewCreated(View view, Bundle savedInstanceState) UpdateState(); } - protected override void UpdateState() + protected override async void UpdateState() { AnalyticsEnabledSwitch.CheckedChange -= UpdateEnabled; AnalyticsEnabledSwitch.Enabled = true; - AnalyticsEnabledSwitch.Checked = Analytics.Enabled; - AnalyticsEnabledSwitch.Enabled = MobileCenter.Enabled; + AnalyticsEnabledSwitch.Checked = await Analytics.IsEnabledAsync(); + AnalyticsEnabledSwitch.Enabled = await MobileCenter.IsEnabledAsync(); AnalyticsEnabledSwitch.CheckedChange += UpdateEnabled; PropertiesCountLabel.Text = mEventProperties.Count.ToString(); } - private void UpdateEnabled(object sender, CompoundButton.CheckedChangeEventArgs e) + private async void UpdateEnabled(object sender, CompoundButton.CheckedChangeEventArgs e) { - Analytics.Enabled = e.IsChecked; - AnalyticsEnabledSwitch.Checked = Analytics.Enabled; + await Analytics.SetEnabledAsync(e.IsChecked); + AnalyticsEnabledSwitch.Checked = await Analytics.IsEnabledAsync(); } private void Properties(object sender, EventArgs e) diff --git a/Apps/Contoso.Android.Puppet/ModulePages/CrashesFragment.cs b/Apps/Contoso.Android.Puppet/ModulePages/CrashesFragment.cs index 14c423f67..114473ac8 100644 --- a/Apps/Contoso.Android.Puppet/ModulePages/CrashesFragment.cs +++ b/Apps/Contoso.Android.Puppet/ModulePages/CrashesFragment.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using Android.Content; using Android.OS; using Android.Views; using Android.Widget; @@ -17,6 +18,7 @@ public class CrashesFragment : PageFragment private Button CrashWithNullReferenceExceptionButton; private Button CatchNullReferenceExceptionButton; private Button CrashAsyncButton; + private Button CrashSuperNotCalledButton; public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -35,6 +37,7 @@ public override void OnViewCreated(View view, Bundle savedInstanceState) CrashWithNullReferenceExceptionButton = view.FindViewById(Resource.Id.crash_with_null_reference_exception) as Button; CatchNullReferenceExceptionButton = view.FindViewById(Resource.Id.catch_null_reference_exception) as Button; CrashAsyncButton = view.FindViewById(Resource.Id.crash_async) as Button; + CrashSuperNotCalledButton = view.FindViewById(Resource.Id.crash_super_not_called) as Button; // Subscribe to events. CrashesEnabledSwitch.CheckedChange += UpdateEnabled; @@ -44,23 +47,24 @@ public override void OnViewCreated(View view, Bundle savedInstanceState) CrashWithNullReferenceExceptionButton.Click += CrashWithNullReferenceException; CatchNullReferenceExceptionButton.Click += CatchNullReferenceException; CrashAsyncButton.Click += CrashAsync; + CrashSuperNotCalledButton.Click += CrashSuperNotCalled; UpdateState(); } - protected override void UpdateState() + protected override async void UpdateState() { CrashesEnabledSwitch.CheckedChange -= UpdateEnabled; CrashesEnabledSwitch.Enabled = true; - CrashesEnabledSwitch.Checked = Crashes.Enabled; - CrashesEnabledSwitch.Enabled = MobileCenter.Enabled; + CrashesEnabledSwitch.Checked = await Crashes.IsEnabledAsync(); + CrashesEnabledSwitch.Enabled = await MobileCenter.IsEnabledAsync(); CrashesEnabledSwitch.CheckedChange += UpdateEnabled; } - private void UpdateEnabled(object sender, CompoundButton.CheckedChangeEventArgs e) + private async void UpdateEnabled(object sender, CompoundButton.CheckedChangeEventArgs e) { - Crashes.Enabled = e.IsChecked; - CrashesEnabledSwitch.Checked = Crashes.Enabled; + await Crashes.SetEnabledAsync(e.IsChecked); + CrashesEnabledSwitch.Checked = await Crashes.IsEnabledAsync(); } private void TestCrash(object sender, EventArgs e) @@ -115,6 +119,11 @@ async private void CrashAsync(object sender, EventArgs e) await FakeService.DoStuffInBackground(); } + private void CrashSuperNotCalled(object sender, EventArgs e) + { + StartActivity(new Intent(Activity, typeof(CrashActivity))); + } + static Exception PrepareException() { try diff --git a/Apps/Contoso.Android.Puppet/ModulePages/DistributeFragment.cs b/Apps/Contoso.Android.Puppet/ModulePages/DistributeFragment.cs index 983e13504..8c0f5a442 100644 --- a/Apps/Contoso.Android.Puppet/ModulePages/DistributeFragment.cs +++ b/Apps/Contoso.Android.Puppet/ModulePages/DistributeFragment.cs @@ -28,19 +28,19 @@ public override void OnViewCreated(View view, Bundle savedInstanceState) UpdateState(); } - protected override void UpdateState() + protected override async void UpdateState() { DistributeEnabledSwitch.CheckedChange -= UpdateEnabled; DistributeEnabledSwitch.Enabled = true; - DistributeEnabledSwitch.Checked = Distribute.Enabled; - DistributeEnabledSwitch.Enabled = MobileCenter.Enabled; + DistributeEnabledSwitch.Checked = await Distribute.IsEnabledAsync(); + DistributeEnabledSwitch.Enabled = await MobileCenter.IsEnabledAsync(); DistributeEnabledSwitch.CheckedChange += UpdateEnabled; } - private void UpdateEnabled(object sender, CompoundButton.CheckedChangeEventArgs e) + private async void UpdateEnabled(object sender, CompoundButton.CheckedChangeEventArgs e) { - Distribute.Enabled = e.IsChecked; - DistributeEnabledSwitch.Checked = Distribute.Enabled; + await Distribute.SetEnabledAsync(e.IsChecked); + DistributeEnabledSwitch.Checked = await Distribute.IsEnabledAsync(); } } } diff --git a/Apps/Contoso.Android.Puppet/ModulePages/MobileCenterFragment.cs b/Apps/Contoso.Android.Puppet/ModulePages/MobileCenterFragment.cs index 023200808..18511809c 100644 --- a/Apps/Contoso.Android.Puppet/ModulePages/MobileCenterFragment.cs +++ b/Apps/Contoso.Android.Puppet/ModulePages/MobileCenterFragment.cs @@ -61,10 +61,10 @@ public override void OnViewCreated(View view, Bundle savedInstanceState) UpdateState(); } - protected override void UpdateState() + protected override async void UpdateState() { MobileCenterEnabledSwitch.CheckedChange -= UpdateEnabled; - MobileCenterEnabledSwitch.Checked = MobileCenter.Enabled; + MobileCenterEnabledSwitch.Checked = await MobileCenter.IsEnabledAsync(); MobileCenterEnabledSwitch.CheckedChange += UpdateEnabled; LogLevelLabel.Text = LogLevelNames[MobileCenter.LogLevel]; LogWriteLevelLabel.Text = LogLevelNames[mLogWriteLevel]; @@ -91,10 +91,10 @@ public override void OnActivityResult(int requestCode, int resultCode, Intent da } } - private void UpdateEnabled(object sender, CompoundButton.CheckedChangeEventArgs e) + private async void UpdateEnabled(object sender, CompoundButton.CheckedChangeEventArgs e) { - MobileCenter.Enabled = e.IsChecked; - MobileCenterEnabledSwitch.Checked = MobileCenter.Enabled; + await MobileCenter.SetEnabledAsync(e.IsChecked); + MobileCenterEnabledSwitch.Checked = await MobileCenter.IsEnabledAsync(); } private void LogLevelClicked(object sender, EventArgs e) diff --git a/Apps/Contoso.Android.Puppet/Properties/AndroidManifest.xml b/Apps/Contoso.Android.Puppet/Properties/AndroidManifest.xml index 46e3bbd88..ab1707c2d 100644 --- a/Apps/Contoso.Android.Puppet/Properties/AndroidManifest.xml +++ b/Apps/Contoso.Android.Puppet/Properties/AndroidManifest.xml @@ -1,5 +1,5 @@ - + \ No newline at end of file diff --git a/Apps/Contoso.Android.Puppet/Properties/AssemblyInfo.cs b/Apps/Contoso.Android.Puppet/Properties/AssemblyInfo.cs index c656c9296..71847ff6a 100644 --- a/Apps/Contoso.Android.Puppet/Properties/AssemblyInfo.cs +++ b/Apps/Contoso.Android.Puppet/Properties/AssemblyInfo.cs @@ -25,5 +25,5 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("0.0.0.0")] -[assembly: AssemblyFileVersion("0.13.1.0")] -[assembly: AssemblyInformationalVersion("0.13.1-SNAPSHOT")] +[assembly: AssemblyFileVersion("0.14.0.0")] +[assembly: AssemblyInformationalVersion("0.14.0-SNAPSHOT")] diff --git a/Apps/Contoso.Android.Puppet/Resources/layout/Crashes.axml b/Apps/Contoso.Android.Puppet/Resources/layout/Crashes.axml index bc4832bb4..f390cb544 100644 --- a/Apps/Contoso.Android.Puppet/Resources/layout/Crashes.axml +++ b/Apps/Contoso.Android.Puppet/Resources/layout/Crashes.axml @@ -60,6 +60,11 @@ android:text="@string/CrashAsync" android:layout_width="match_parent" android:layout_height="wrap_content" /> +