Skip to content

Commit 673bd6c

Browse files
authored
Merge pull request #424 from Microsoft/develop
v0.8.0 merge
2 parents 16946a2 + 0912f10 commit 673bd6c

File tree

51 files changed

+2638
-74
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2638
-74
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ The Mobile Center SDK uses a modular architecture so you can use any or all of t
1717

1818
3. **Mobile Center Distribute**: Mobile Center Distribute will let your users install a new version of the app when you distribute it via the Mobile Center. With a new version of the app available, the SDK will present an update dialog to the users to either download or postpone the new version. Once they choose to update, the SDK will start to update your application. This feature will NOT work if your app is deployed to the app store.
1919

20+
4. **Mobile Center Push**: Mobile Center Push enables you to send push notifications to users of your app from the Mobile Center portal. To do that the Mobile Center SDK and portal integrate with [Firebase Cloud Messaging](https://firebase.google.com/docs/cloud-messaging/).
21+
2022
## 1. Get started
2123
It is super easy to use Mobile Center. Have a look at our [get started documentation](https://docs.microsoft.com/en-us/mobile-center/sdk/getting-started/android) and onboard your app within minutes. Our [detailed documentation](https://docs.microsoft.com/en-us/mobile-center/sdk/) is available as well.
2224

apps/sasquatch/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/build
2+
google-services.json

apps/sasquatch/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ dependencies {
2727
projectDependencyCompile project(':sdk:mobile-center-analytics')
2828
projectDependencyCompile project(':sdk:mobile-center-crashes')
2929
projectDependencyCompile project(':sdk:mobile-center-distribute')
30+
projectDependencyCompile project(':sdk:mobile-center-push')
3031
jcenterDependencyCompile "com.microsoft.azure.mobile:mobile-center-analytics:${version}"
3132
jcenterDependencyCompile "com.microsoft.azure.mobile:mobile-center-crashes:${version}"
3233
jcenterDependencyCompile "com.microsoft.azure.mobile:mobile-center-distribute:${version}"
@@ -35,4 +36,6 @@ dependencies {
3536
androidTestCompile "com.android.support:support-annotations:${rootProject.ext.supportLibVersion}"
3637
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
3738
compile 'com.android.support.test.espresso:espresso-idling-resource:2.2.2'
38-
}
39+
}
40+
41+
apply plugin: 'com.google.gms.google-services'

apps/sasquatch/lint.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<lint>
3+
4+
<!-- Ignore the UnusedResources issue for the given ids -->
5+
<issue id="UnusedResources">
6+
<ignore regexp="google_crash_reporting_api_key" />
7+
</issue>
8+
</lint>

apps/sasquatch/src/androidTest/java/com/microsoft/azure/mobile/sasquatch/activities/CrashesTest.java

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import com.microsoft.azure.mobile.MobileCenter;
1818
import com.microsoft.azure.mobile.crashes.Crashes;
1919
import com.microsoft.azure.mobile.crashes.CrashesPrivateHelper;
20+
import com.microsoft.azure.mobile.crashes.model.ErrorReport;
2021
import com.microsoft.azure.mobile.crashes.utils.ErrorLogHelper;
2122
import com.microsoft.azure.mobile.sasquatch.R;
2223
import com.microsoft.azure.mobile.utils.storage.StorageHelper;
@@ -30,6 +31,7 @@
3031

3132
import java.io.File;
3233
import java.lang.reflect.Method;
34+
import java.util.Date;
3335

3436
import static android.support.test.InstrumentationRegistry.getInstrumentation;
3537
import static android.support.test.espresso.Espresso.onData;
@@ -49,6 +51,11 @@
4951
import static org.hamcrest.Matchers.allOf;
5052
import static org.hamcrest.Matchers.anyOf;
5153
import static org.hamcrest.Matchers.instanceOf;
54+
import static org.hamcrest.Matchers.lessThan;
55+
import static org.junit.Assert.assertArrayEquals;
56+
import static org.junit.Assert.assertEquals;
57+
import static org.junit.Assert.assertNotNull;
58+
import static org.junit.Assert.assertThat;
5259
import static org.junit.Assert.assertTrue;
5360

5461
@SuppressWarnings("unused")
@@ -131,13 +138,27 @@ private void crashTest(@StringRes int titleId) throws InterruptedException {
131138
withChild(withText(R.string.title_crashes)),
132139
withChild(withText(R.string.description_crashes))))
133140
.perform(click());
134-
141+
CrashFailureHandler failureHandler = new CrashFailureHandler();
135142
onCrash(titleId)
136-
.withFailureHandler(new CrashFailureHandler())
143+
.withFailureHandler(failureHandler)
137144
.perform(click());
138145

139146
/* Check error report. */
140147
assertTrue(Crashes.hasCrashedInLastSession());
148+
ErrorReport errorReport = CrashesPrivateHelper.getLastSessionCrashReport();
149+
assertNotNull(errorReport);
150+
assertNotNull(errorReport.getId());
151+
assertEquals(mContext.getMainLooper().getThread().getName(), errorReport.getThreadName());
152+
assertThat("AppStartTime",
153+
new Date().getTime() - errorReport.getAppStartTime().getTime(),
154+
lessThan(60000L));
155+
assertThat("AppErrorTime",
156+
new Date().getTime() - errorReport.getAppErrorTime().getTime(),
157+
lessThan(10000L));
158+
assertNotNull(errorReport.getDevice());
159+
assertEquals(failureHandler.uncaughtException.getClass(), errorReport.getThrowable().getClass());
160+
assertEquals(failureHandler.uncaughtException.getMessage(), errorReport.getThrowable().getMessage());
161+
assertArrayEquals(failureHandler.uncaughtException.getStackTrace(), errorReport.getThrowable().getStackTrace());
141162

142163
/* Send report. */
143164
waitFor(onView(withText(R.string.crash_confirmation_dialog_send_button))
@@ -180,14 +201,20 @@ public void describeTo(Description description) {
180201

181202
private class CrashFailureHandler implements FailureHandler {
182203

204+
Throwable uncaughtException;
205+
183206
@Override
184207
public void handle(Throwable error, Matcher<View> viewMatcher) {
185-
Throwable uncaughtException = error instanceof EspressoException ? error.getCause() : error;
208+
uncaughtException = error instanceof EspressoException ? error.getCause() : error;
186209

187210
/* Save exception. */
188211
CrashesPrivateHelper.saveUncaughtException(mContext.getMainLooper().getThread(), uncaughtException);
189212

190213
/* Relaunch. */
214+
relaunchActivity();
215+
}
216+
217+
private void relaunchActivity() {
191218
ActivityCompat.finishAffinity(mActivityTestRule.getActivity());
192219
unsetInstance(MobileCenter.class);
193220
unsetInstance(Crashes.class);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.microsoft.azure.mobile.sasquatch.features;
2+
3+
public class PushListenerHelper {
4+
5+
public static void setup() {
6+
7+
/* Not available in jCenter yet. See project build flavour class file. */
8+
}
9+
}

apps/sasquatch/src/jcenterDependency/java/com/microsoft/azure/mobile/sasquatch/utils/SasquatchDistributeListener.java

Lines changed: 0 additions & 4 deletions
This file was deleted.

apps/sasquatch/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
<activity
4242
android:name=".activities.ManagedErrorActivity"
4343
android:label="@string/title_error"/>
44+
<activity android:name=".activities.CustomPropertiesActivity"></activity>
4445
</application>
4546

4647
</manifest>

apps/sasquatch/src/main/java/com/microsoft/azure/mobile/crashes/CrashesPrivateHelper.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.microsoft.azure.mobile.crashes;
22

3+
import com.microsoft.azure.mobile.crashes.model.ErrorReport;
4+
35
public final class CrashesPrivateHelper {
46

57
private CrashesPrivateHelper() {
@@ -12,4 +14,8 @@ public static void trackException(Throwable throwable) {
1214
public static void saveUncaughtException(Thread thread, Throwable exception) {
1315
Crashes.getInstance().saveUncaughtException(thread, exception);
1416
}
17+
18+
public static ErrorReport getLastSessionCrashReport() {
19+
return Crashes.getLastSessionCrashReport();
20+
}
1521
}

0 commit comments

Comments
 (0)