Skip to content

Commit

Permalink
v3.4.1 - Bugfix for Crashlytics #828, NPE when checking network errors
Browse files Browse the repository at this point in the history
The error message checker (looking for SSL errors) didn't do null checks, that's
bad because there isn't always a message. Fixing this before there's a disaster!

Also moved the warning message into string resources

(cherry picked from commit 97b7beb)
  • Loading branch information
baka-kaba committed Oct 31, 2017
1 parent 9a75a6c commit fa2da93
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Awful.apk/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ferg.awfulapp"
android:versionCode="176"
android:versionName="3.4.0"
android:versionCode="178"
android:versionName="3.4.1"
android:installLocation="auto">
<supports-screens
android:smallScreens="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@
* <p>
* The update might fail because the user needs to install or update Google Play Services manually,
* or it could hit an unrecoverable error - which means the app might not work at all, especially
* if it's an old device that's still trying to use SSLv3. The last known state is held in {@link #status}
* if it's an old device that's still trying to use SSLv3. Use {@link #getStatus()} to get the most recent status.
* <p>
* See: <a href="https://developer.android.com/training/articles/security-gms-provider.html">Updating Your Security Provider to Protect Against SSL Exploits</a>
*/
abstract class SecurityProvider {

private static String TAG = SecurityProvider.class.getSimpleName();
private static Status status = Status.UNCHECKED;
private static boolean userNotified = false;


/**
* Update the system's security provider to fix network vulnerabilities.
Expand All @@ -47,7 +45,11 @@ static void update(@NonNull Context context) {
status = Status.PLAY_SERVICES_ERROR;
Log.w(TAG, "Security Provider can't update!", e);
}
}

@NonNull
public static Status getStatus() {
return status;
}

enum Status {UNCHECKED, UP_TO_DATE, PLAY_SERVICES_UPDATE_REQUIRED, PLAY_SERVICES_ERROR}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
import com.android.volley.toolbox.HttpHeaderParser;
import com.crashlytics.android.Crashlytics;
import com.ferg.awfulapp.AwfulApplication;
import com.ferg.awfulapp.R;
import com.ferg.awfulapp.constants.Constants;
import com.ferg.awfulapp.network.NetworkUtils;
import com.ferg.awfulapp.preferences.AwfulPreferences;
import com.ferg.awfulapp.util.AwfulError;

import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MultipartEntityBuilder;
Expand Down Expand Up @@ -156,9 +158,8 @@ public void onResponse(T response) {
@Override
public void onErrorResponse(VolleyError error) {
// TODO: 29/10/2017 this is a temporary warning/advice for people on older devices who can't connect - remove it once there's something better for recommending security updates
if (error.getMessage().contains("SSLProtocolException")) {
String message = "CAN'T CONNECT\nYour device is trying to use an outdated secure connection!\nUpdate \"Google Play Services\" in the Play Store, and try restarting the app";
Toast.makeText(cont, message, Toast.LENGTH_LONG).show();
if (error != null && StringUtils.contains(error.getMessage(), "SSLProtocolException")) {
Toast.makeText(cont, R.string.ssl_connection_error_message, Toast.LENGTH_LONG).show();
}
if(resultListener != null){
resultListener.failure(error);
Expand Down
3 changes: 2 additions & 1 deletion Awful.apk/src/main/res/values/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
<resources>
<string-array name="changelog">
<item>
3.4.0:\n
3.4.1:\n
- Fix for HTTPS connection failures on older devices. If you still get SSL errors, try updating Google Play Services in the Play Store and restart the app!\n\n
- Oreo support including adaptive icons that jiggle around or something\n\n
- Imgur uploading - limited uploads per day for now\n\n
- Instagram embedding, and -very- experimental Twitch embeds\n\n
- Settings gets some visual tweaks and fixes\n\n
- Other bug fixes
</item>
<item>
3.3.1:\n
Expand Down
1 change: 1 addition & 0 deletions Awful.apk/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@
<string name="insert_video_url_field_hint">Video URL</string>

<!-- other shit -->
<string name="ssl_connection_error_message">CAN\'T CONNECT Your device is trying to use an outdated secure connection! Update \"Google Play Services\" in the Play Store, and try restarting the app</string>
<string name="alert_message_1">GIF Animations are now disabled by default. This significantly improves battery life on
most devices. \n
\n
Expand Down

0 comments on commit fa2da93

Please sign in to comment.