Skip to content
This repository has been archived by the owner on Feb 19, 2020. It is now read-only.

Releases/v5.1.1 #398

Merged
merged 50 commits into from
Aug 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
9bedd6e
return didCrashInLastSession immediately, if we do not need to wait
MatkovIvan Jan 11, 2018
e60ef6b
Add LatchFuture
MatkovIvan Jan 11, 2018
b0303b4
Don't use thread pool to wait device id
MatkovIvan Jan 11, 2018
ad9d0f6
Fix device id usage in exception handler
MatkovIvan Jan 11, 2018
fe332ad
Fix tests
MatkovIvan Jan 11, 2018
91c5b95
Merge pull request #347 from bitstadium/master
Jan 11, 2018
8152a86
Merge branch 'develop' into fix/possible-deadlock
Jan 11, 2018
4307287
Merge pull request #348 from MatkovIvan/fix/possible-deadlock
Jan 11, 2018
2640eaa
Update bintray-release to 0.8.0
friederbluemle Jan 15, 2018
350e427
Update Gradle wrapper to 4.4.1
friederbluemle Sep 26, 2017
24af70b
Merge pull request #349 from friederbluemle/update-dependencies
Jan 16, 2018
ee92ec6
Do not show keyboard on feedback list view
MatkovIvan Jan 18, 2018
b3efade
Merge pull request #353 from MatkovIvan/fix/keyboard-on-feedback-list
Jan 19, 2018
89a3a8d
Truncate large stacktraces
MatkovIvan Jan 23, 2018
8ec93b2
Merge pull request #355 from MatkovIvan/fix/truncate-large-stacktrace
Jan 23, 2018
b55385d
Add timeout to http connection
MatkovIvan Apr 24, 2018
eae5001
Merge pull request #370 from MatkovIvan/fix/http-conn-timeout
Apr 25, 2018
4801bb2
Fix error message for empty stacktrace files
MatkovIvan May 8, 2018
4da1021
Truncate crash stack trace during save process
May 15, 2018
e7abdb5
Test added
May 15, 2018
4a0c039
Truncate stack trace during generation
May 15, 2018
15c583d
Fix callback and add test for that
MatkovIvan May 18, 2018
fe3ab81
Move max length check into contentsOfFile
MatkovIvan May 18, 2018
2874014
Use TextUtils.isEmpty to check if stacktrace is invalid
MatkovIvan May 21, 2018
89ea370
Merge branch 'develop' into fix/message-for-empty-stacktrace
guperrot May 21, 2018
c82b301
Fix BoundPrintWriter and CrashDetails constructor
Jun 8, 2018
dd7113b
Implement BoundedWriter as Writer
Jun 11, 2018
30eafc6
Merge pull request #375 from MatkovIvan/fix/message-for-empty-stacktrace
Jun 12, 2018
790045e
Merge branch 'develop' into fix/truncate-large-reports
Jun 13, 2018
9a5c164
Merge pull request #378 from bmourat/fix/truncate-large-reports
Jul 12, 2018
50d8bd0
fix bitrise badge
Jul 16, 2018
eb76be5
Fix untagged socket
MatkovIvan Jul 18, 2018
48135d5
Merge branch 'develop' into fix/fix-bitrise-badge
guperrot Jul 18, 2018
59bfed6
Remove the bitrise badge
Jul 18, 2018
0969ddf
Merge branch 'fix/fix-bitrise-badge' of https://github.com/bitstadium…
Jul 18, 2018
5649d6e
Merge pull request #387 from MatkovIvan/fix/socket-tag
Jul 18, 2018
b244004
Merge branch 'develop' into fix/fix-bitrise-badge
guperrot Jul 18, 2018
d6a1393
Merge pull request #384 from bitstadium/fix/fix-bitrise-badge
Jul 18, 2018
a7e6c59
Add list of files null check
MatkovIvan Jul 31, 2018
b7d344c
Merge pull request #390 from MatkovIvan/fix/send-task-npe
Jul 31, 2018
ee4ec9f
Merge branch 'develop' into fix/submit-crash-oom
MatkovIvan Aug 9, 2018
98ab863
Fix filename for feedback attachments
MatkovIvan Aug 9, 2018
a32a8e4
Merge pull request #392 from MatkovIvan/fix/submit-crash-oom
Aug 9, 2018
ed28189
Merge branch 'develop' into fix/attachment-filename
Aug 9, 2018
375efd6
Merge pull request #393 from MatkovIvan/fix/attachment-filename
Aug 9, 2018
2802226
Add null context check
MatkovIvan Aug 13, 2018
c9487cb
Merge pull request #396 from MatkovIvan/fix/downloadfile-npe
thyeggman Aug 13, 2018
447c9e5
Bump Hockey SDK version
Aug 21, 2018
bd3c450
Set compile tools and target platform versions to 28
Aug 21, 2018
0dcb452
Bump version in README.md
Aug 21, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[![Build Status](https://www.bitrise.io/app/562949a18404dad6/status.svg?token=IZE4w-D2xii7QjqvJVc51A&branch=master)](https://www.bitrise.io/app/562949a18404dad6)
[![Slack Status](https://slack.hockeyapp.net/badge.svg)](https://slack.hockeyapp.net)

## Version 5.1.0
## Version 5.1.1

HockeySDK-Android implements support for using HockeyApp in your Android applications.

Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.novoda:bintray-release:0.5.0'
classpath 'com.novoda:bintray-release:0.8.0'
}
}

Expand Down Expand Up @@ -37,13 +37,13 @@ allprojects {

ext {
ARTIFACT_ID = 'HockeySDK'
VERSION_NAME = '5.1.0'
VERSION_CODE = 19
VERSION_NAME = '5.1.1'
VERSION_CODE = 20
SITE_URL = 'https://github.com/bitstadium/hockeysdk-android'
GIT_URL = 'https://github.com/bitstadium/HockeySDK-Android.git'
BINTRAY_USER = HOCKEYAPP_BINTRAY_USER
GROUP_NAME = 'net.hockeyapp.android'
COMPILE_SDK = 27
COMPILE_SDK = 28
IS_UPLOADING = project.getGradle().startParameter.taskNames.any{it.contains('bintrayUpload')}
DESCRIPTION = 'HockeySDK-Android implements support for using HockeyApp in your Android application. The following features are currently supported:\n' +
'\n' +
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Sun Aug 27 11:31:58 PDT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-all.zip
13 changes: 5 additions & 8 deletions hockeysdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ android {

defaultConfig {
minSdkVersion 15
targetSdkVersion 27
targetSdkVersion 28
versionCode VERSION_CODE
versionName VERSION_NAME
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -49,17 +49,14 @@ publish {
}

dependencies {
// Mocking
androidTestImplementation 'com.linkedin.dexmaker:dexmaker-mockito:2.2.0'

testImplementation 'junit:junit:4.12'
testImplementation 'org.powermock:powermock-api-mockito:1.6.6'
testImplementation 'org.powermock:powermock-module-junit4:1.6.6'
testImplementation 'org.powermock:powermock-module-junit4-rule-agent:1.6.6'

androidTestImplementation 'org.hamcrest:hamcrest-core:1.3'
androidTestImplementation 'org.hamcrest:hamcrest-library:1.3'
testImplementation 'junit:junit:4.12'

androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test:rules:1.0.1'
androidTestImplementation 'com.linkedin.dexmaker:dexmaker-mockito:2.2.0'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ConstantsTest {
@Test
public void testLoadingConstantsWorks() throws Exception {
Constants.loadFromContext(InstrumentationRegistry.getContext());
Constants.LOADING_LATCH.await();
Constants.DEVICE_IDENTIFIER.get();

assertNotNull(Constants.BASE_URL);
assertEquals("https://sdk.hockeyapp.net/", Constants.BASE_URL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

public class CrashManagerHelper {

public static void loadConstants(Context context) throws InterruptedException {
public static void loadConstants(Context context) throws Exception {
Constants.loadFromContext(context);
Constants.LOADING_LATCH.await();
Constants.DEVICE_IDENTIFIER.get();
}

public static void reset(Context context) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.hockeyapp.android;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

Expand All @@ -11,11 +12,17 @@
import org.junit.runner.RunWith;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.lang.ref.WeakReference;
import java.util.UUID;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

@RunWith(AndroidJUnit4.class)
public class CrashManagerTest {
Expand Down Expand Up @@ -121,4 +128,42 @@ public void xamarinCrashCorrect() throws Exception {
Boolean containsCausedByXamarin = throwableStackTrace.contains("Xamarin caused by:");
assertTrue(containsCausedByXamarin);
}

@Test
public void invalidStackTrace() throws Exception {
File file = new File(filesDirectory, UUID.randomUUID().toString() + ".stacktrace");
file.createNewFile();

CrashManagerListener listener = mock(CrashManagerListener.class);
WeakReference<Context> weakContext = new WeakReference<>(InstrumentationRegistry.getTargetContext());

CrashManager.submitStackTraces(weakContext, listener);

verify(listener).onCrashesNotSent();
assertEquals(0, CrashManager.stackTracesCount);
}

@Test
public void largeStackTrace() throws Exception {
String stackTrace = "java.lang.OutOfMemoryError: Failed to allocate a 37657308 byte allocation with 16776928 free bytes and 27MB until OOM\n" +
"\tat java.lang.String.<init>(String.java:400)\n" +
"\tat java.lang.AbstractStringBuilder.toString(AbstractStringBuilder.java:633)\n" +
"\tat java.lang.StringBuilder.toString(StringBuilder.java:663)\n" +
"\tat net.hockeyapp.android.CrashManager.contentsOfFile(CrashManager.java:772)\n" +
"\tat net.hockeyapp.android.CrashManager.submitStackTrace(CrashManager.java:379)\n" +
"\tat net.hockeyapp.android.CrashManager.access$500(CrashManager.java:47)\n" +
"\tat net.hockeyapp.android.CrashManager$8.doInBackground(CrashManager.java:647)\n" +
"\tat net.hockeyapp.android.CrashManager$8.doInBackground(CrashManager.java:639)\n";

String filename = UUID.randomUUID().toString() + ".stacktrace";
File file = new File(filesDirectory, filename);
PrintWriter writer = new PrintWriter(file);
writer.print(stackTrace);
writer.flush();
writer.close();

WeakReference<Context> weakContext = new WeakReference<>(InstrumentationRegistry.getTargetContext());
String result = CrashManager.contentsOfFile(weakContext, filename, 500);
assertTrue(result.endsWith("submitStackTrace(CrashManager.java:379)\n"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void setUp() throws Exception {
* will write to a different preferences key than the test tracking module
*/
Constants.loadFromContext(mActivityRule.getActivity());
Constants.LOADING_LATCH.await();
Constants.DEVICE_IDENTIFIER.get();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,20 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;

@RunWith(AndroidJUnit4.class)
public class CrashDetailsTest {
Expand Down Expand Up @@ -64,4 +73,58 @@ public void testCrashDetailParsing() throws Exception {
assertNotNull(details.getAppCrashDate());
assertTrue("Crash date must be later than initialization date", details.getAppCrashDate().compareTo(details.getAppStartDate()) > 0);
}

@Test
public void testCrashStacktraceIsTruncated() {
Throwable tr = new RuntimeException("Just a test exception");
Throwable throwableSpy = Mockito.spy(tr);
doAnswer(new Answer<Void>() {
public Void answer(InvocationOnMock invocation) {
PrintWriter writer = (PrintWriter) invocation.getArguments()[0];
final int bufferSize = 1024 * 1024;
char [] stackTraceBuffer = new char[bufferSize];
Arrays.fill(stackTraceBuffer, 0, bufferSize - 1,'0');
for(int i = 0; i < 5; i++) {
writer.write(stackTraceBuffer);
}
return null;
}
}).when(throwableSpy).printStackTrace(any(PrintWriter.class));

CrashDetails details = new CrashDetails("id", throwableSpy);
assertTrue("Crash stacktrace was not truncated", details.getThrowableStackTrace().length() <= CrashDetails.CRASH_FILE_STACKTRACE_SIZE);
}

@Test
public void testXamarinCrashStacktraceIsTruncated() {
final int bufferSize = 1024 * 1024;
final char [] stackTraceBuffer = new char[bufferSize];
Arrays.fill(stackTraceBuffer, 0, bufferSize - 1,'0');
Throwable tr = new RuntimeException("Just a test exception");
Throwable throwableSpy = Mockito.spy(tr);
doAnswer(new Answer<Void>() {
public Void answer(InvocationOnMock invocation) {
PrintWriter writer = (PrintWriter) invocation.getArguments()[0];
for(int i = 0; i < 5; i++) {
writer.write(stackTraceBuffer);
}
return null;
}
}).when(throwableSpy).printStackTrace(any(PrintWriter.class));

final String managedException = new StringBuilder()
.append(stackTraceBuffer)
.append("\n")
.append(stackTraceBuffer)
.append("\n")
.append(stackTraceBuffer)
.append("\n")
.append(stackTraceBuffer)
.toString();

CrashDetails details = new CrashDetails("id", throwableSpy, managedException, false);
final int xamarinHeaderLength = CrashDetails.FIELD_XAMARIN_CAUSED_BY.length();
assertTrue("Crash stacktrace was not truncated",
details.getThrowableStackTrace().length() <= CrashDetails.CRASH_FILE_STACKTRACE_SIZE + xamarinHeaderLength);
}
}
2 changes: 1 addition & 1 deletion hockeysdk/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<application>

<activity android:name=".UpdateActivity" />
<activity android:name=".FeedbackActivity" android:windowSoftInputMode="adjustResize|stateVisible" />
<activity android:name=".FeedbackActivity" />
<activity android:name=".PaintActivity" />
<activity android:name=".LoginActivity" />
<activity android:name=".ExpiryInfoActivity" />
Expand Down
33 changes: 12 additions & 21 deletions hockeysdk/src/main/java/net/hockeyapp/android/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@
import android.os.Bundle;

import net.hockeyapp.android.utils.AsyncTaskUtils;
import net.hockeyapp.android.utils.CompletedFuture;
import net.hockeyapp.android.utils.LatchFuture;
import net.hockeyapp.android.utils.HockeyLog;

import java.io.File;
import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Future;

/**
Expand All @@ -41,6 +39,8 @@ public class Constants {

public static final String FILES_DIRECTORY_NAME = "HockeyApp";

public static final int THREAD_STATS_TAG = SDK_NAME.hashCode();

/**
* The user agent string the SDK will send with every HockeyApp API request.
*/
Expand Down Expand Up @@ -85,25 +85,16 @@ public class Constants {
/**
* Unique identifier for device, not dependent on package or device.
*/
static String DEVICE_IDENTIFIER = null;
static LatchFuture<String> DEVICE_IDENTIFIER = new LatchFuture<>();

private static AsyncTask<Void, Object, String> loadIdentifiersTask;

/**
* Lock used to wait for loading of identifiers.
*/
static CountDownLatch LOADING_LATCH = new CountDownLatch(1);

public static Future<String> getDeviceIdentifier() {
if (LOADING_LATCH.getCount() == 0) {
return new CompletedFuture<>(DEVICE_IDENTIFIER);
}
return AsyncTaskUtils.execute(new Callable<String>() {

@Override
public String call() throws Exception {
LOADING_LATCH.await();
return DEVICE_IDENTIFIER;
}
});
return DEVICE_IDENTIFIER;
}

/**
Expand Down Expand Up @@ -187,11 +178,11 @@ private static int loadBuildNumber(Context context, PackageManager packageManage
* @param context the context to use. Usually your Activity object.
*/
@SuppressLint("StaticFieldLeak")
private static void loadIdentifiers(final Context context) {
if (DEVICE_IDENTIFIER != null) {
private static synchronized void loadIdentifiers(final Context context) {
if (DEVICE_IDENTIFIER.isDone() || loadIdentifiersTask != null) {
return;
}
AsyncTaskUtils.execute(new AsyncTask<Void, Object, String>() {
AsyncTaskUtils.execute(loadIdentifiersTask = new AsyncTask<Void, Object, String>() {
@Override
protected String doInBackground(Void... voids) {
final SharedPreferences preferences = context.getSharedPreferences("HockeyApp", Context.MODE_PRIVATE);
Expand All @@ -200,13 +191,13 @@ protected String doInBackground(Void... voids) {
deviceIdentifier = UUID.randomUUID().toString();
preferences.edit().putString("deviceIdentifier", deviceIdentifier).apply();
}
DEVICE_IDENTIFIER.complete(deviceIdentifier);
return deviceIdentifier;
}

@Override
protected void onPostExecute(String deviceIdentifier) {
DEVICE_IDENTIFIER = deviceIdentifier;
LOADING_LATCH.countDown();
loadIdentifiersTask = null;
}
});
}
Expand Down
Loading