Skip to content

Commit 9d53fdb

Browse files
authored
Merge pull request #316 from Microsoft/develop
0.5.0
2 parents 5cff320 + e25e2fd commit 9d53fdb

File tree

9 files changed

+64
-57
lines changed

9 files changed

+64
-57
lines changed

README.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,6 @@ You create your own Crashes listener and assign it like this:
193193
```
194194
Pass one option of `SEND`, `DONT_SEND` or `ALWAYS_SEND`.
195195
196-
* **Binary attachment:** If you'd like to attach text/binary data to a crash report, implement this callback. Before sending the crash, our SDK will add the attachment to the crash report and you can view it on the Mobile Center portal. Note that attachment will show in the portal in the future as the UI is still not ready.
197-
198-
```Java
199-
ErrorAttachment CrashesListener.getErrorAttachment(ErrorReport report) {
200-
// return your own created ErrorAttachment object
201-
}
202-
```
203-
204196
* **Before sending a crash report:** This callback will be invoked just before the crash is sent to Mobile Center:
205197
206198
```Java

apps/sasquatch/src/main/java/com/microsoft/azure/mobile/sasquatch/activities/MainActivity.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
import com.microsoft.azure.mobile.analytics.Analytics;
2222
import com.microsoft.azure.mobile.crashes.AbstractCrashesListener;
2323
import com.microsoft.azure.mobile.crashes.Crashes;
24-
import com.microsoft.azure.mobile.crashes.ErrorAttachments;
25-
import com.microsoft.azure.mobile.crashes.model.ErrorAttachment;
2624
import com.microsoft.azure.mobile.crashes.model.ErrorReport;
2725
import com.microsoft.azure.mobile.sasquatch.R;
2826
import com.microsoft.azure.mobile.sasquatch.features.TestFeatures;
@@ -31,7 +29,7 @@
3129

3230
public class MainActivity extends AppCompatActivity {
3331

34-
public static final String LOG_TAG = "MobileCenterSasquatch";
32+
private static final String LOG_TAG = "MobileCenterSasquatch";
3533
static final String APP_SECRET = "45d1d9f6-2492-4e68-bd44-7190351eb5f3";
3634
static final String APP_SECRET_KEY = "appSecret";
3735
static final String SERVER_URL_KEY = "serverUrl";
@@ -129,10 +127,11 @@ public void onClick(DialogInterface dialog, int which) {
129127
return true;
130128
}
131129

132-
@Override
133-
public ErrorAttachment getErrorAttachment(ErrorReport report) {
134-
return ErrorAttachments.attachment("This is a text attachment.", "This is a binary attachment.".getBytes(), "binary.txt", "text/plain");
135-
}
130+
/* TODO (getErrorAttachment): Re-enable error attachment when the feature becomes available. */
131+
// @Override
132+
// public ErrorAttachment getErrorAttachment(ErrorReport report) {
133+
// return ErrorAttachments.attachment("This is a text attachment.", "This is a binary attachment.".getBytes(), "binary.txt", "text/plain");
134+
// }
136135

137136
@Override
138137
public void onBeforeSending(ErrorReport report) {

sdk/mobile-center-crashes/src/androidTest/java/com/microsoft/azure/mobile/crashes/CrashesAndroidTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ public void onResult(ErrorReport errorReport) {
171171
verify(channel).enqueue(any(Log.class), anyString());
172172
assertNotNull(log.get());
173173
assertEquals(1, ErrorLogHelper.getErrorStorageDirectory().listFiles().length);
174-
verify(crashesListener).getErrorAttachment(any(ErrorReport.class));
174+
175+
/* TODO (getErrorAttachment): Re-enable error attachment when the feature becomes available. */
176+
// verify(crashesListener).getErrorAttachment(any(ErrorReport.class));
175177
verifyNoMoreInteractions(crashesListener);
176178

177179
/* Third process: sending succeeds. */

sdk/mobile-center-crashes/src/main/java/com/microsoft/azure/mobile/crashes/AbstractCrashesListener.java

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

3-
import com.microsoft.azure.mobile.crashes.model.ErrorAttachment;
43
import com.microsoft.azure.mobile.crashes.model.ErrorReport;
54

65
/**
@@ -17,10 +16,11 @@ public boolean shouldAwaitUserConfirmation() {
1716
return false;
1817
}
1918

20-
@Override
21-
public ErrorAttachment getErrorAttachment(ErrorReport report) {
22-
return null;
23-
}
19+
/* TODO (getErrorAttachment): Re-enable error attachment when the feature becomes available. */
20+
// @Override
21+
// public ErrorAttachment getErrorAttachment(ErrorReport report) {
22+
// return null;
23+
// }
2424

2525
@SuppressWarnings("EmptyMethod")
2626
@Override

sdk/mobile-center-crashes/src/main/java/com/microsoft/azure/mobile/crashes/Crashes.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import com.microsoft.azure.mobile.channel.Channel;
1818
import com.microsoft.azure.mobile.crashes.ingestion.models.ManagedErrorLog;
1919
import com.microsoft.azure.mobile.crashes.ingestion.models.json.ManagedErrorLogFactory;
20-
import com.microsoft.azure.mobile.crashes.model.ErrorAttachment;
2120
import com.microsoft.azure.mobile.crashes.model.ErrorReport;
2221
import com.microsoft.azure.mobile.crashes.model.TestCrashException;
2322
import com.microsoft.azure.mobile.crashes.utils.ErrorLogHelper;
@@ -735,11 +734,13 @@ public void run() {
735734

736735
Map.Entry<UUID, ErrorLogReport> unprocessedEntry = unprocessedIterator.next();
737736
ErrorLogReport errorLogReport = unprocessedEntry.getValue();
738-
ErrorAttachment attachment = mCrashesListener.getErrorAttachment(errorLogReport.report);
739-
if (attachment == null)
740-
MobileCenterLog.debug(LOG_TAG, "CrashesListener.getErrorAttachment returned null, no additional information will be attached to log: " + errorLogReport.log.getId().toString());
741-
else
742-
errorLogReport.log.setErrorAttachment(attachment);
737+
738+
/* TODO (getErrorAttachment): Re-enable error attachment when the feature becomes available. */
739+
// ErrorAttachment attachment = mCrashesListener.getErrorAttachment(errorLogReport.report);
740+
// if (attachment == null)
741+
// MobileCenterLog.debug(LOG_TAG, "CrashesListener.getErrorAttachment returned null, no additional information will be attached to log: " + errorLogReport.log.getId().toString());
742+
// else
743+
// errorLogReport.log.setErrorAttachment(attachment);
743744
mChannel.enqueue(errorLogReport.log, ERROR_GROUP);
744745

745746
/* Clean up an error log file and map entry. */

sdk/mobile-center-crashes/src/main/java/com/microsoft/azure/mobile/crashes/CrashesListener.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ public interface CrashesListener {
3737
* @param report The crash report for additional information.
3838
* @return {@link ErrorAttachment} instance to be attached to the crash report.
3939
*/
40-
@WorkerThread
41-
ErrorAttachment getErrorAttachment(ErrorReport report);
40+
/* TODO (getErrorAttachment): Re-enable error attachment when the feature becomes available. */
41+
// @WorkerThread
42+
// ErrorAttachment getErrorAttachment(ErrorReport report);
4243

4344
/**
4445
* Called right before sending a crash report. The callback can be invoked multiple times based on the number of crash reports.

sdk/mobile-center-crashes/src/main/java/com/microsoft/azure/mobile/crashes/ErrorAttachments.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import com.microsoft.azure.mobile.crashes.model.ErrorAttachment;
66
import com.microsoft.azure.mobile.crashes.model.ErrorBinaryAttachment;
7-
import com.microsoft.azure.mobile.crashes.model.ErrorReport;
87
import com.microsoft.azure.mobile.utils.MobileCenterLog;
98

109
import static com.microsoft.azure.mobile.MobileCenter.LOG_TAG;
@@ -13,7 +12,8 @@
1312
* Error attachment utilities.
1413
*/
1514
@SuppressWarnings("WeakerAccess")
16-
public final class ErrorAttachments {
15+
/* TODO (getErrorAttachment): Re-enable error attachment in javadoc when the feature becomes available. Add @ before link. */
16+
final class ErrorAttachments {
1717

1818
@VisibleForTesting
1919
ErrorAttachments() {
@@ -22,7 +22,7 @@ public final class ErrorAttachments {
2222
}
2323

2424
/**
25-
* Build an attachment with text suitable for using in {@link CrashesListener#getErrorAttachment(ErrorReport)}.
25+
* Build an attachment with text suitable for using in {link CrashesListener#getErrorAttachment(ErrorReport)}.
2626
*
2727
* @param text Text to attach to the error report.
2828
* @return error Attachment or null if null text is passed.
@@ -32,7 +32,7 @@ public static ErrorAttachment attachmentWithText(String text) {
3232
}
3333

3434
/**
35-
* Build an attachment with binary suitable for using in {@link CrashesListener#getErrorAttachment(ErrorReport)}.
35+
* Build an attachment with binary suitable for using in {link CrashesListener#getErrorAttachment(ErrorReport)}.
3636
*
3737
* @param data binary data.
3838
* @param fileName file name to use on reports.
@@ -44,7 +44,7 @@ public static ErrorAttachment attachmentWithBinary(byte[] data, String fileName,
4444
}
4545

4646
/**
47-
* Build an attachment with text and binary suitable for using in {@link CrashesListener#getErrorAttachment(ErrorReport)}.
47+
* Build an attachment with text and binary suitable for using in {link CrashesListener#getErrorAttachment(ErrorReport)}.
4848
*
4949
* @param text text data.
5050
* @param data binary data.

sdk/mobile-center-crashes/src/test/java/com/microsoft/azure/mobile/crashes/CrashesTest.java

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import com.microsoft.azure.mobile.crashes.ingestion.models.ManagedErrorLog;
1313
import com.microsoft.azure.mobile.crashes.ingestion.models.StackFrame;
1414
import com.microsoft.azure.mobile.crashes.ingestion.models.json.ManagedErrorLogFactory;
15-
import com.microsoft.azure.mobile.crashes.model.ErrorAttachment;
1615
import com.microsoft.azure.mobile.crashes.model.ErrorReport;
1716
import com.microsoft.azure.mobile.crashes.model.TestCrashException;
1817
import com.microsoft.azure.mobile.crashes.utils.ErrorLogHelper;
@@ -292,11 +291,14 @@ public void queuePendingCrashesShouldProcess() throws IOException, ClassNotFound
292291
when(StorageHelper.InternalStorage.read(any(File.class))).thenReturn("");
293292
when(StorageHelper.InternalStorage.readObject(any(File.class))).thenReturn(new RuntimeException());
294293

295-
ErrorAttachment mockAttachment = mock(ErrorAttachment.class);
294+
/* TODO (getErrorAttachment): Re-enable error attachment when the feature becomes available. */
295+
// ErrorAttachment mockAttachment = mock(ErrorAttachment.class);
296296
CrashesListener mockListener = mock(CrashesListener.class);
297297
when(mockListener.shouldProcess(report)).thenReturn(true);
298298
when(mockListener.shouldAwaitUserConfirmation()).thenReturn(false);
299-
when(mockListener.getErrorAttachment(report)).thenReturn(mockAttachment);
299+
300+
/* TODO (getErrorAttachment): Re-enable error attachment when the feature becomes available. */
301+
// when(mockListener.getErrorAttachment(report)).thenReturn(mockAttachment);
300302

301303
Crashes crashes = Crashes.getInstance();
302304
LogSerializer logSerializer = mock(LogSerializer.class);
@@ -308,7 +310,9 @@ public void queuePendingCrashesShouldProcess() throws IOException, ClassNotFound
308310

309311
verify(mockListener).shouldProcess(report);
310312
verify(mockListener).shouldAwaitUserConfirmation();
311-
verify(mockListener).getErrorAttachment(report);
313+
314+
/* TODO (getErrorAttachment): Re-enable error attachment when the feature becomes available. */
315+
// verify(mockListener).getErrorAttachment(report);
312316
verify(mockChannel).enqueue(argThat(new ArgumentMatcher<Log>() {
313317
@Override
314318
public boolean matches(Object log) {
@@ -344,7 +348,9 @@ public void queuePendingCrashesShouldNotProcess() throws IOException, ClassNotFo
344348

345349
verify(mockListener).shouldProcess(report);
346350
verify(mockListener, never()).shouldAwaitUserConfirmation();
347-
verify(mockListener, never()).getErrorAttachment(report);
351+
352+
/* TODO (getErrorAttachment): Re-enable error attachment when the feature becomes available. */
353+
// verify(mockListener, never()).getErrorAttachment(report);
348354
verify(mockChannel, never()).enqueue(any(Log.class), eq(crashes.getGroupName()));
349355
}
350356

@@ -376,7 +382,9 @@ public void queuePendingCrashesAlwaysSend() throws IOException, ClassNotFoundExc
376382

377383
verify(mockListener).shouldProcess(report);
378384
verify(mockListener, never()).shouldAwaitUserConfirmation();
379-
verify(mockListener).getErrorAttachment(report);
385+
386+
/* TODO (getErrorAttachment): Re-enable error attachment when the feature becomes available. */
387+
// verify(mockListener).getErrorAttachment(report);
380388
verify(mockChannel).enqueue(argThat(new ArgumentMatcher<Log>() {
381389
@Override
382390
public boolean matches(Object log) {
@@ -469,6 +477,13 @@ public void disabledDuringHandleUserConfirmation() throws IOException, ClassNotF
469477
LogSerializer logSerializer = mock(LogSerializer.class);
470478
when(logSerializer.deserializeLog(anyString())).thenReturn(mErrorLog).thenReturn(errorLog);
471479
Channel channel = mock(Channel.class);
480+
doAnswer(new Answer<Object>() {
481+
@Override
482+
public Object answer(InvocationOnMock invocation) throws Throwable {
483+
Crashes.setEnabled(false);
484+
return null;
485+
}
486+
}).when(channel).enqueue(any(Log.class), anyString());
472487

473488
mockStatic(ErrorLogHelper.class);
474489
when(ErrorLogHelper.getStoredErrorLogFiles()).thenReturn(new File[]{mock(File.class), mock(File.class)});
@@ -480,14 +495,6 @@ public void disabledDuringHandleUserConfirmation() throws IOException, ClassNotF
480495
when(StorageHelper.InternalStorage.readObject(any(File.class))).thenReturn(EXCEPTION);
481496
when(StorageHelper.InternalStorage.read(any(File.class))).thenReturn("");
482497

483-
when(listener.getErrorAttachment(errorReport1)).thenAnswer(new Answer<ErrorAttachment>() {
484-
@Override
485-
public ErrorAttachment answer(InvocationOnMock invocation) throws Throwable {
486-
Crashes.setEnabled(false);
487-
return null;
488-
}
489-
});
490-
491498
Crashes crashes = Crashes.getInstance();
492499
crashes.setLogSerializer(logSerializer);
493500
crashes.setInstanceListener(listener);
@@ -497,7 +504,9 @@ public ErrorAttachment answer(InvocationOnMock invocation) throws Throwable {
497504
verify(listener, times(2)).shouldProcess(any(ErrorReport.class));
498505
verify(listener).shouldAwaitUserConfirmation();
499506
verify(channel).enqueue(any(Log.class), anyString());
500-
verify(listener).getErrorAttachment(any(ErrorReport.class));
507+
508+
/* TODO (getErrorAttachment): Re-enable error attachment when the feature becomes available. */
509+
// verify(listener).getErrorAttachment(any(ErrorReport.class));
501510
verifyNoMoreInteractions(listener);
502511
}
503512

@@ -712,7 +721,8 @@ public void handleUserConfirmationDoNotSend() throws IOException, ClassNotFoundE
712721

713722
Crashes.notifyUserConfirmation(Crashes.DONT_SEND);
714723

715-
verify(mockListener, never()).getErrorAttachment(any(ErrorReport.class));
724+
/* TODO (getErrorAttachment): Re-enable error attachment when the feature becomes available. */
725+
// verify(mockListener, never()).getErrorAttachment(any(ErrorReport.class));
716726
verify(mMockLooper).quit();
717727

718728
verifyStatic();
@@ -813,10 +823,11 @@ public boolean shouldAwaitUserConfirmation() {
813823
return false;
814824
}
815825

816-
@Override
817-
public ErrorAttachment getErrorAttachment(ErrorReport report) {
818-
return null;
819-
}
826+
/* TODO (getErrorAttachment): Re-enable error attachment when the feature becomes available. */
827+
// @Override
828+
// public ErrorAttachment getErrorAttachment(ErrorReport report) {
829+
// return null;
830+
// }
820831

821832
@Override
822833
public void onBeforeSending(ErrorReport report) {
@@ -841,7 +852,8 @@ public void onSendingSucceeded(ErrorReport report) {
841852
assertFalse(defaultListener.shouldAwaitUserConfirmation());
842853

843854
/* Nothing to verify. */
844-
defaultListener.getErrorAttachment(null);
855+
/* TODO (getErrorAttachment): Re-enable error attachment when the feature becomes available. */
856+
// defaultListener.getErrorAttachment(null);
845857
defaultListener.onBeforeSending(null);
846858
defaultListener.onSendingSucceeded(null);
847859
defaultListener.onSendingFailed(null, null);

versions.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Version constants
22

33
ext {
4-
versionCode = 12
5-
versionName = '0.4.0'
4+
versionCode = 13
5+
versionName = '0.5.0'
66
minSdkVersion = 15
77
targetSdkVersion = 25
88
compileSdkVersion = 25

0 commit comments

Comments
 (0)