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

Commit

Permalink
Merge pull request #425 from bitstadium/release/5.2.0
Browse files Browse the repository at this point in the history
Release/5.2.0
  • Loading branch information
Anna Kocheshkova authored May 21, 2019
2 parents 9e5d533 + 6084db0 commit dbd24e7
Show file tree
Hide file tree
Showing 25 changed files with 508 additions and 142 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Slack Status](https://slack.hockeyapp.net/badge.svg)](https://slack.hockeyapp.net)

## Version 5.1.1
## Version 5.2.0

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

Expand All @@ -25,7 +25,7 @@ It is super easy to use HockeyApp in your Android app. Have a look at our [docum

Please visit [our landing page](https://support.hockeyapp.net/kb/client-integration-android) as a starting point for all of our documentation.

Please check out our [getting started documentation](https://support.hockeyapp.net/kb/client-integration-android/hockeyapp-for-android-sdk), [change log](https://github.com/bitstadium/HockeySDK-Android/releases/tag/5.1.1), [java doc](https://www.hockeyapp.net/help/sdk/android/5.1.1/index.html) as well as our [troubleshooting section](https://support.hockeyapp.net/kb/client-integration-android/hockeyapp-for-android-sdk#troubleshooting).
Please check out our [getting started documentation](https://support.hockeyapp.net/kb/client-integration-android/hockeyapp-for-android-sdk), [change log](https://github.com/bitstadium/HockeySDK-Android/releases/tag/5.2.0), [java doc](https://www.hockeyapp.net/help/sdk/android/5.2.0/index.html) as well as our [troubleshooting section](https://support.hockeyapp.net/kb/client-integration-android/hockeyapp-for-android-sdk#troubleshooting).

## 3. Contributing

Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.novoda:bintray-release:0.8.0'
}
}
Expand Down Expand Up @@ -37,8 +37,8 @@ allprojects {

ext {
ARTIFACT_ID = 'HockeySDK'
VERSION_NAME = '5.1.1'
VERSION_CODE = 20
VERSION_NAME = '5.2.0'
VERSION_CODE = 21
SITE_URL = 'https://github.com/bitstadium/hockeysdk-android'
GIT_URL = 'https://github.com/bitstadium/HockeySDK-Android.git'
BINTRAY_USER = HOCKEYAPP_BINTRAY_USER
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-all.zip
2 changes: 1 addition & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
DEFAULT_JVM_OPTS='"-Xmx64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
Expand Down
2 changes: 1 addition & 1 deletion gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DEFAULT_JVM_OPTS="-Xmx64m"

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
Expand Down
7 changes: 6 additions & 1 deletion hockeysdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ android {
compileSdkVersion COMPILE_SDK

defaultConfig {
minSdkVersion 15
minSdkVersion 16
targetSdkVersion 28
versionCode VERSION_CODE
versionName VERSION_NAME
Expand All @@ -17,6 +17,11 @@ android {
minifyEnabled false
}
}
testOptions {
unitTests.all {
jvmArgs '-noverify'
}
}
lintOptions {
disable 'GoogleAppIndexingWarning','RtlEnabled'
textReport true
Expand Down
4 changes: 4 additions & 0 deletions hockeysdk/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@
-keepclassmembers class net.hockeyapp.android.UpdateFragment {
*;
}

-keepclassmembers class * implements javax.net.ssl.SSLSocketFactory {
private final javax.net.ssl.SSLSocketFactory delegate;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.junit.runner.RunWith;

import java.io.File;
import java.net.HttpURLConnection;
import javax.net.ssl.HttpsURLConnection;
import java.util.concurrent.Executor;

import static org.junit.Assert.*;
Expand Down Expand Up @@ -55,7 +55,7 @@ public void testInstanceInitialisation() throws Exception {

@Test
public void testCreateConnection() {
HttpURLConnection connection = sut.createConnection();
HttpsURLConnection connection = sut.createConnection();
assertNotNull(connection);

}
Expand Down
12 changes: 6 additions & 6 deletions hockeysdk/src/main/java/net/hockeyapp/android/CrashManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import net.hockeyapp.android.utils.AsyncTaskUtils;
import net.hockeyapp.android.utils.CompletedFuture;
import net.hockeyapp.android.utils.HockeyLog;
import net.hockeyapp.android.utils.HttpURLConnectionBuilder;
import net.hockeyapp.android.utils.HttpsURLConnectionBuilder;
import net.hockeyapp.android.utils.Util;

import java.io.BufferedReader;
Expand All @@ -30,7 +30,7 @@
import java.io.StringWriter;
import java.lang.Thread.UncaughtExceptionHandler;
import java.lang.ref.WeakReference;
import java.net.HttpURLConnection;
import javax.net.ssl.HttpsURLConnection;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
Expand Down Expand Up @@ -408,7 +408,7 @@ public static synchronized void submitStackTraces(final WeakReference<Context> w
private static void submitStackTrace(final WeakReference<Context> weakContext, String filename, CrashManagerListener listener, CrashMetaData crashMetaData) {
String stacktrace = null;
try {
stacktrace = contentsOfFile(weakContext, filename, HttpURLConnectionBuilder.FORM_FIELD_LIMIT);
stacktrace = contentsOfFile(weakContext, filename, HttpsURLConnectionBuilder.FORM_FIELD_LIMIT);
} catch (Exception e) {
HockeyLog.error("Failed to read crash data", e);
}
Expand All @@ -422,7 +422,7 @@ private static void submitStackTrace(final WeakReference<Context> weakContext, S
return;
}
Boolean successful = false;
HttpURLConnection urlConnection = null;
HttpsURLConnection urlConnection = null;
try {
// Transmit stack trace with POST request
HockeyLog.debug("Transmitting crash data: \n" + stacktrace);
Expand Down Expand Up @@ -462,13 +462,13 @@ private static void submitStackTrace(final WeakReference<Context> weakContext, S
parameters.put("sdk_version", BuildConfig.VERSION_NAME);

TrafficStats.setThreadStatsTag(Constants.THREAD_STATS_TAG);
urlConnection = new HttpURLConnectionBuilder(getURLString())
urlConnection = new HttpsURLConnectionBuilder(getURLString())
.setRequestMethod("POST")
.writeFormFields(parameters)
.build();

int responseCode = urlConnection.getResponseCode();
successful = (responseCode == HttpURLConnection.HTTP_ACCEPTED || responseCode == HttpURLConnection.HTTP_CREATED);
successful = (responseCode == HttpsURLConnection.HTTP_ACCEPTED || responseCode == HttpsURLConnection.HTTP_CREATED);
} catch (Exception e) {
HockeyLog.error("Failed to transmit crash data", e);
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public class PaintActivity extends Activity {
private PaintView mPaintView;
private Uri mImageUri;

@SuppressLint("StaticFieldLeak")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -53,7 +52,11 @@ public void onCreate(Bundle savedInstanceState) {
return;
}
mImageUri = extras.getParcelable(EXTRA_IMAGE_URI);
determineOrientation();
}

@SuppressLint("StaticFieldLeak")
private void determineOrientation() {
AsyncTaskUtils.execute(new AsyncTask<Void, Object, Integer>() {
@Override
protected Integer doInBackground(Void... voids) {
Expand Down
33 changes: 17 additions & 16 deletions hockeysdk/src/main/java/net/hockeyapp/android/metrics/Sender.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
import net.hockeyapp.android.Constants;
import net.hockeyapp.android.utils.AsyncTaskUtils;
import net.hockeyapp.android.utils.HockeyLog;
import net.hockeyapp.android.utils.Util;

import java.io.*;
import java.lang.ref.WeakReference;
import java.net.HttpURLConnection;
import javax.net.ssl.HttpsURLConnection;;
import java.net.URL;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -101,7 +102,7 @@ protected Void doInBackground(Void... params) {
}

@SuppressLint("StaticFieldLeak")
protected void triggerSendingForTesting(final HttpURLConnection connection, final File file, final String persistedData) {
protected void triggerSendingForTesting(final HttpsURLConnection connection, final File file, final String persistedData) {
if (requestCount() < MAX_REQUEST_COUNT) {
mRequestCount.getAndIncrement();

Expand All @@ -125,7 +126,7 @@ protected void sendAvailableFiles() {
if (this.getPersistence() != null) {
File fileToSend = this.getPersistence().nextAvailableFileInDirectory();
String persistedData = loadData(fileToSend);
HttpURLConnection connection = createConnection();
HttpsURLConnection connection = createConnection();

if ((persistedData != null) && (connection != null)) {
send(connection, fileToSend, persistedData);
Expand All @@ -143,7 +144,7 @@ protected void sendAvailableFiles() {
* @param file
* @param persistedData
*/
protected void send(HttpURLConnection connection, File file, String persistedData) {
protected void send(HttpsURLConnection connection, File file, String persistedData) {
// TODO Why does this get the file and persistedData reference, even though everything is in the connection?
// TODO Looks like this will have to be rewritten for its own AsyncTask subclass.
if (connection != null && file != null && persistedData != null) {
Expand Down Expand Up @@ -215,9 +216,9 @@ protected String loadData(File file) {
* @return connection to the API endpoint
*/
@SuppressWarnings("ConstantConditions")
protected HttpURLConnection createConnection() {
protected HttpsURLConnection createConnection() {
URL url;
HttpURLConnection connection = null;
HttpsURLConnection connection = null;
try {
if (getCustomServerURL() == null) {
url = new URL(DEFAULT_ENDPOINT_URL);
Expand All @@ -230,8 +231,8 @@ protected HttpURLConnection createConnection() {
}
}

// TODO Replace with HttpUrlConnectionBuilder calls - expand this if necessary.
connection = (HttpURLConnection) url.openConnection();
// TODO Replace with HttpsUrlConnectionBuilder calls - expand this if necessary.
connection = Util.openHttpsConnection(url);
connection.setReadTimeout(DEFAULT_SENDER_READ_TIMEOUT);
connection.setConnectTimeout(DEFAULT_SENDER_CONNECT_TIMEOUT);
connection.setRequestMethod("POST");
Expand All @@ -253,7 +254,7 @@ protected HttpURLConnection createConnection() {
* @param payload the payload which generated this response
* @param fileToSend reference to the file we want to send
*/
protected void onResponse(HttpURLConnection connection, int responseCode, String payload, File
protected void onResponse(HttpsURLConnection connection, int responseCode, String payload, File
fileToSend) {
// TODO Remove possible redundancy between response code and connection which also provides the same response code.
// TODO This looks like a weird solution to keep the reference to the payload and the sent file.
Expand Down Expand Up @@ -301,9 +302,9 @@ protected boolean isRecoverableError(int responseCode) {
429 -> TOO MANY REQUESTS
503 -> SERVICE UNAVAILABLE
511 -> NETWORK AUTHENTICATION REQUIRED
All not available in HttpUrlConnection, thus listed here for reference.
All not available in HttpsUrlConnection, thus listed here for reference.
*/
List<Integer> recoverableCodes = Arrays.asList(HttpURLConnection.HTTP_CLIENT_TIMEOUT, 429, HttpURLConnection.HTTP_INTERNAL_ERROR, 503, 511);
List<Integer> recoverableCodes = Arrays.asList(HttpsURLConnection.HTTP_CLIENT_TIMEOUT, 429, HttpsURLConnection.HTTP_INTERNAL_ERROR, 503, 511);
return recoverableCodes.contains(responseCode);
}

Expand All @@ -314,7 +315,7 @@ protected boolean isRecoverableError(int responseCode) {
* @return True, if the response code means a successful operation, otherwise false.
*/
protected boolean isExpected(int responseCode) {
return (HttpURLConnection.HTTP_OK <= responseCode && responseCode <= HttpURLConnection.HTTP_NOT_AUTHORITATIVE);
return (HttpsURLConnection.HTTP_OK <= responseCode && responseCode <= HttpsURLConnection.HTTP_NOT_AUTHORITATIVE);
}

/**
Expand All @@ -324,7 +325,7 @@ protected boolean isExpected(int responseCode) {
* @param responseCode The response code from the connection.
* @param builder A string builder for storing the response.
*/
protected void onUnexpected(HttpURLConnection connection, int responseCode, StringBuilder
protected void onUnexpected(HttpsURLConnection connection, int responseCode, StringBuilder
builder) {
String message = String.format(Locale.ROOT, "Unexpected response code: %d", responseCode);
builder.append(message);
Expand All @@ -344,7 +345,7 @@ protected void onUnexpected(HttpURLConnection connection, int responseCode, Stri
* @param connection the connection
* @param payload the payload of telemetry data
*/
private void logRequest(HttpURLConnection connection, String payload) throws IOException, SecurityException {
private void logRequest(HttpsURLConnection connection, String payload) throws IOException, SecurityException {
// TODO Rename this to reflect the true nature of this method: Sending the payload
Writer writer = null;
try {
Expand Down Expand Up @@ -373,7 +374,7 @@ private void logRequest(HttpURLConnection connection, String payload) throws IOE
* @param connection the connection which will read the response
* @param builder a string builder for storing the response
*/
protected void readResponse(HttpURLConnection connection, StringBuilder builder) {
protected void readResponse(HttpsURLConnection connection, StringBuilder builder) {
String result;
StringBuilder buffer = new StringBuilder();
InputStream inputStream = null;
Expand Down Expand Up @@ -423,7 +424,7 @@ protected void readResponse(HttpURLConnection connection, StringBuilder builder)
* @throws java.io.IOException Exception thrown by GZIP (used in SDK 19+)
*/
@TargetApi(Build.VERSION_CODES.KITKAT)
protected Writer getWriter(HttpURLConnection connection) throws IOException {
protected Writer getWriter(HttpsURLConnection connection) throws IOException {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
// GZIP if we are running SDK 19 or higher
connection.addRequestProperty("Content-Encoding", "gzip");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.hockeyapp.android.utils.AsyncTaskUtils;
import net.hockeyapp.android.utils.HockeyLog;
import net.hockeyapp.android.utils.ImageUtils;
import net.hockeyapp.android.utils.Util;
import net.hockeyapp.android.views.AttachmentView;

import java.io.BufferedInputStream;
Expand All @@ -21,7 +22,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import javax.net.ssl.HttpsURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.LinkedList;
Expand Down Expand Up @@ -227,9 +228,9 @@ private void loadImageThumbnail(File file) {
private boolean downloadAttachment(String url, File file) {
InputStream input = null;
OutputStream output = null;
HttpURLConnection connection = null;
HttpsURLConnection connection = null;
try {
connection = (HttpURLConnection) createConnection(new URL(url));
connection = (HttpsURLConnection) createConnection(new URL(url));
TrafficStats.setThreadStatsTag(Constants.THREAD_STATS_TAG);
connection.connect();

Expand Down Expand Up @@ -278,7 +279,7 @@ private boolean downloadAttachment(String url, File file) {
}

private URLConnection createConnection(URL url) throws IOException {
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
HttpsURLConnection connection = Util.openHttpsConnection(url);
connection.addRequestProperty("User-Agent", Constants.SDK_USER_AGENT);
connection.setInstanceFollowRedirects(true);
return connection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ protected JSONArray doInBackground(Void... args) {
}

protected URLConnection createConnection(URL url) throws IOException {
URLConnection connection = url.openConnection();
URLConnection connection = Util.openHttpsConnection(url);
connection.addRequestProperty("User-Agent", Constants.SDK_USER_AGENT);
return connection;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import javax.net.ssl.HttpsURLConnection;

/**
* <h3>Description</h3>
Expand All @@ -17,11 +17,15 @@
**/
public abstract class ConnectionTask<Params, Progress, Result> extends AsyncTask<Params, Progress, Result> {

protected static String getStringFromConnection(HttpURLConnection connection) throws IOException {
InputStream inputStream = new BufferedInputStream(connection.getInputStream());
String jsonString = Util.convertStreamToString(inputStream);
inputStream.close();

return jsonString;
protected static String getStringFromConnection(HttpsURLConnection connection) throws IOException {
InputStream inputStream = null;
try {
inputStream = new BufferedInputStream(connection.getInputStream());
return Util.convertStreamToString(inputStream);
} finally {
if (inputStream != null) {
inputStream.close();
}
}
}
}
Loading

0 comments on commit dbd24e7

Please sign in to comment.