Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Firebase Crashlytics #277

Merged
merged 1 commit into from Aug 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 16 additions & 18 deletions Android/app/build.gradle
@@ -1,5 +1,6 @@
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'

// See https://developer.android.com/studio/publish/app-signing#secure-shared-keystore
def keystorePropertiesFile = rootProject.file("keystore.properties")
Expand Down Expand Up @@ -28,9 +29,8 @@ android {

defaultConfig {
applicationId "app.intra"
// The Java code is compatible back to SDK version 14, but gomobile requires
// a minSdkVersion of 15.
minSdkVersion 15
// Firebase Crashlytics requires SDK version 16.
minSdkVersion 16
targetSdkVersion 29
versionCode 58
versionName "1.3.1"
Expand All @@ -49,6 +49,11 @@ android {
'proguard-rules.pro'
signingConfig signingConfigs.config
resValue("bool", "FIREBASE_ENABLED", "true")
firebaseCrashlytics {
nativeSymbolUploadEnabled true
strippedNativeLibsDir 'build/intermediates/stripped_native_libs/release/out/lib'
unstrippedNativeLibsDir 'build/intermediates/merged_native_libs/release/out/lib'
}
}
debug {
pseudoLocalesEnabled true
Expand All @@ -68,10 +73,6 @@ android {
}
}

crashlytics {
enableNdk true
}

repositories {
maven {
url 'test-repo'
Expand All @@ -98,21 +99,18 @@ dependencies {
androidTestImplementation 'androidx.annotation:annotation:1.1.0'
androidTestImplementation 'androidx.test:runner:1.2.0'
// UI libraries.
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.0'
implementation 'androidx.preference:preference:1.1.1'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation "androidx.viewpager2:viewpager2:1.0.0"
// For Firebase Analytics, etc.
//noinspection GradleDependency : Last version to support API <16
implementation 'com.google.firebase:firebase-core:16.0.9'
//noinspection GradleDependency : Last version to support API <17
implementation 'com.google.firebase:firebase-perf:16.2.5'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation 'com.crashlytics.sdk.android:crashlytics-ndk:2.1.1'
//noinspection GradleDependency : Last version to support API <16
implementation 'com.google.firebase:firebase-config:16.5.0'
implementation 'com.google.firebase:firebase-core:17.4.4'
implementation 'com.google.firebase:firebase-perf:19.0.8'
implementation 'com.google.firebase:firebase-crashlytics:17.1.1'
implementation 'com.google.firebase:firebase-crashlytics-ndk:17.1.1'
implementation 'com.google.firebase:firebase-config:19.2.0'
// For go-tun2socks
implementation project(":tun2socks")
}
Expand Down
144 changes: 30 additions & 114 deletions Android/app/lint-baseline.xml
@@ -1,16 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="5" by="lint 3.4.2" client="gradle" variant="all" version="3.4.2">

<issue
id="DefaultLocale"
message="Implicitly using the default locale is a common source of bugs: Use `toLowerCase(Locale)` instead. For strings meant to be internal use `Locale.ROOT`, otherwise `Locale.getDefault()`."
errorLine1=" if (e.getMessage().toLowerCase().contains(&quot;cert&quot;)) {"
errorLine2=" ~~~~~~~~~~~">
<location
file="src/main/java/app/intra/net/go/TLSProbe.java"
line="35"
column="26"/>
</issue>
<issues format="5" by="lint 4.0.1" client="gradle" variant="all" version="4.0.1">

<issue
id="LocaleFolder"
Expand All @@ -20,86 +9,42 @@
</issue>

<issue
id="UnusedAttribute"
message="Attribute `layoutDirection` is only used in API level 17 and higher (current min is 15)"
errorLine1=" android:layoutDirection=&quot;ltr&quot;"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/res/layout/intro_pager.xml"
line="12"
column="53"/>
</issue>

<issue
id="GradleDependency"
message="A newer version of androidx.annotation:annotation than 1.0.0 is available: 1.1.0"
errorLine1=" androidTestImplementation &apos;androidx.annotation:annotation:1.0.0&apos;"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="build.gradle"
line="110"
column="5"/>
</issue>

<issue
id="GradleDependency"
message="A newer version of androidx.appcompat:appcompat than 1.0.2 is available: 1.1.0"
errorLine1=" implementation &apos;androidx.appcompat:appcompat:1.0.2&apos;"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="build.gradle"
line="113"
column="5"/>
</issue>

<issue
id="GradleDependency"
message="A newer version of androidx.preference:preference than 1.0.0 is available: 1.1.0"
errorLine1=" implementation &apos;androidx.preference:preference:1.0.0&apos;"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
id="InflateParams"
message="Avoid passing `null` as the view root (needed to resolve layout parameters on the inflated layout&apos;s root element)"
errorLine1=" final View dialogContent = inflater.inflate(R.layout.server_notice_dialog, null);"
errorLine2=" ~~~~">
<location
file="build.gradle"
line="115"
column="5"/>
</issue>

<issue
id="GradleDependency"
message="A newer version of com.google.firebase:firebase-core than 16.0.9 is available: 17.2.0"
errorLine1=" implementation &apos;com.google.firebase:firebase-core:16.0.9&apos; // Last version to support API &lt;16"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="build.gradle"
line="120"
column="5"/>
file="src/main/java/app/intra/ui/settings/ServerApprovalDialogFragment.java"
line="125"
column="80"/>
</issue>

<issue
id="GradleDependency"
message="A newer version of com.google.firebase:firebase-perf than 16.2.5 is available: 19.0.0"
errorLine1=" implementation &apos;com.google.firebase:firebase-perf:16.2.5&apos; // Last version to support API &lt;17"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
id="UseCompatLoadingForDrawables"
message="Use `ResourcesCompat.getDrawable()`"
errorLine1=" Drawable leftChevron = getResources().getDrawable(R.drawable.ic_chevron_left);"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="build.gradle"
line="121"
column="5"/>
file="src/main/java/app/intra/ui/IntroDialog.java"
line="70"
column="28"/>
</issue>

<issue
id="GradleDependency"
message="A newer version of com.google.firebase:firebase-config than 16.5.0 is available: 19.0.1"
errorLine1=" implementation &apos;com.google.firebase:firebase-config:16.5.0&apos; // Last version to support API &lt;16"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
id="UseCompatLoadingForDrawables"
message="Use `ResourcesCompat.getDrawable()`"
errorLine1=" Drawable rightChevron = getResources().getDrawable(R.drawable.ic_chevron_right);"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="build.gradle"
line="124"
column="5"/>
file="src/main/java/app/intra/ui/IntroDialog.java"
line="71"
column="29"/>
</issue>

<issue
id="Typos"
message="&quot;Packet&quot; is a common misspelling; did you mean &quot;Paket&quot; ?"
errorLine1=" &lt;string name=&quot;description2&quot;>Großer globaler Resolver von IBM und Packet Clearinghouse. Blockt bösartige Domains.&lt;/string>"
errorLine1=" &lt;string name=&quot;description2&quot;>Großer globaler Resolver von IBM und Packet Clearinghouse. Blockt bösartige Domains.&lt;/string>"
errorLine2=" ^">
<location
file="src/main/res/values-de/servers.xml"
Expand All @@ -108,14 +53,14 @@
</issue>

<issue
id="SetJavaScriptEnabled"
message="Using `setJavaScriptEnabled` can introduce XSS vulnerabilities into your application, review carefully."
errorLine1=" webView.getSettings().setJavaScriptEnabled(true);"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
id="Typos"
message="Repeated word &quot;die&quot; in message: possible typo"
errorLine1=" &lt;string name=&quot;description13&quot;>Betrieben von einer deutsch-schweizerischen Gesellschaft, die die Grundrechte im digitalen Raum verteidigt. Dazu werden Server in der Schweiz, in Deutschland oder in Österreich verwendet.&lt;/string>"
errorLine2=" ^">
<location
file="src/main/java/app/intra/ui/settings/ServerApprovalDialogFragment.java"
line="114"
column="5"/>
file="src/main/res/values-de/servers.xml"
line="16"
column="90"/>
</issue>

<issue
Expand All @@ -129,17 +74,6 @@
column="6"/>
</issue>

<issue
id="ObsoleteSdkInt"
message="Unnecessary; SDK_INT is always >= 15"
errorLine1=" return Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH;"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/app/intra/ui/MainActivity.java"
line="472"
column="12"/>
</issue>

<issue
id="Overdraw"
message="Possible overdraw: Root element paints background `@color/floating` with a theme that also paints a background (inferred theme is `@style/AppTheme`)"
Expand All @@ -162,29 +96,11 @@
column="34"/>
</issue>

<issue
id="IconLauncherShape"
message="Launcher icons should not fill every pixel of their square region; see the design guide for details">
<location
file="src/main/res/mipmap-hdpi/ic_launcher_background.png"/>
</issue>

<issue
id="IconLocation"
message="Found bitmap drawable `res/drawable/logo_backdrop.png` in densityless folder">
<location
file="src/main/res/drawable/logo_backdrop.png"/>
</issue>

<issue
id="GoogleAppIndexingWarning"
message="App is not indexable by Google Search; consider adding at least one Activity with an ACTION-VIEW intent filter. See issue explanation for more details."
errorLine1=" &lt;application"
errorLine2=" ^">
<location
file="src/main/AndroidManifest.xml"
line="11"
column="5"/>
</issue>

</issues>
3 changes: 3 additions & 0 deletions Android/app/src/main/java/app/intra/sys/CountryCode.java
Expand Up @@ -15,6 +15,7 @@
*/
package app.intra.sys;

import android.annotation.SuppressLint;
import android.content.Context;
import android.telephony.TelephonyManager;
import androidx.annotation.NonNull;
Expand Down Expand Up @@ -55,6 +56,7 @@ public CountryCode(Context context) {
// User appears to be non-GSM. Try CDMA.
try {
// Get the system properties by reflection.
@SuppressLint("PrivateApi")
Class<?> systemPropertiesClass = Class.forName("android.os.SystemProperties");
Method get = systemPropertiesClass.getMethod("get", String.class);
String cdmaOperator = (String)get.invoke(systemPropertiesClass,
Expand All @@ -64,6 +66,7 @@ public CountryCode(Context context) {
return "";
}
String mcc = cdmaOperator.substring(0, 3);
@SuppressLint("PrivateApi")
Class<?> mccTableClass = Class.forName("com.android.internal.telephony.MccTable");
Method countryCodeForMcc = mccTableClass.getMethod("countryCodeForMcc", String.class);
return (String)countryCodeForMcc.invoke(mccTableClass, mcc);
Expand Down
13 changes: 4 additions & 9 deletions Android/app/src/main/java/app/intra/sys/IntraVpnService.java
Expand Up @@ -173,11 +173,8 @@ public int onStartCommand(Intent intent, int flags, int startId) {
builder = new Notification.Builder(this, MAIN_CHANNEL_ID);
} else {
builder = new Notification.Builder(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
// Min-priority notifications don't show an icon in the notification bar, reducing clutter.
// Only available in API >= 16. Deprecated in API 26.
builder = builder.setPriority(Notification.PRIORITY_MIN);
}
// Min-priority notifications don't show an icon in the notification bar, reducing clutter.
builder = builder.setPriority(Notification.PRIORITY_MIN);
}

builder.setSmallIcon(R.drawable.ic_status_bar)
Expand Down Expand Up @@ -280,10 +277,8 @@ public void signalStopService(boolean userInitiated) {
} else {
builder = new Notification.Builder(this);
builder.setVibrate(vibrationPattern);
if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
// Only available in API >= 16. Deprecated in API 26.
builder = builder.setPriority(Notification.PRIORITY_MAX);
}
// Deprecated in API 26.
builder = builder.setPriority(Notification.PRIORITY_MAX);
}

PendingIntent mainActivityIntent = PendingIntent.getActivity(
Expand Down
12 changes: 6 additions & 6 deletions Android/app/src/main/java/app/intra/sys/firebase/LogWrapper.java
Expand Up @@ -17,7 +17,7 @@

import android.util.Log;
import app.intra.BuildConfig;
import com.crashlytics.android.Crashlytics;
import com.google.firebase.crashlytics.FirebaseCrashlytics;

/**
* Wrapper for Crashlytics. This allows unit testing of classes that contain logging and allows
Expand All @@ -26,24 +26,24 @@
*/
public class LogWrapper {
public static void logException(Throwable t) {
Log.e("LogWrapper", "Error", t);
if (BuildConfig.DEBUG) {
Log.e("LogWrapper", "Error", t);
return;
}
try {
Crashlytics.logException(t);
FirebaseCrashlytics.getInstance().recordException(t);
} catch (IllegalStateException e) {
// This only occurs during unit tests.
}
}

public static void log(int i, String s, String s1) {
public static void log(int severity, String tag, String message) {
Log.println(severity, tag, message);
if (BuildConfig.DEBUG) {
Log.println(i, s, s1);
return;
}
try {
Crashlytics.log(i, s, s1);
FirebaseCrashlytics.getInstance().log(tag + ": " + message);
} catch (IllegalStateException e) {
// This only occurs during unit tests.
}
Expand Down
11 changes: 2 additions & 9 deletions Android/app/src/main/java/app/intra/ui/HistoryGraph.java
Expand Up @@ -252,14 +252,7 @@ protected void onDraw(Canvas canvas) {
canvas.drawCircle(tagX, yoffset, radius, pulsePaint);
}

// Queue up the next animation frame.
if (Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
// Redraw the UI at its preferred update frequency.
postInvalidateOnAnimation();
} else {
// postInvalidateOnAnimation is only available in Jelly Bean and higher. On older devices,
// update every RESOLUTION_MS (currently 10 FPS, which is choppy but good enough).
postInvalidateDelayed(RESOLUTION_MS);
}
// Draw the next frame at the UI's preferred update frequency.
postInvalidateOnAnimation();
}
}