Skip to content

Commit

Permalink
improve crash reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
n8fr8 committed Oct 19, 2017
1 parent f37c7ab commit 0501022
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 20 deletions.
18 changes: 10 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ android {

defaultConfig {
applicationId "org.witness.proofmode"
minSdkVersion 14
minSdkVersion 15
targetSdkVersion 25
versionCode 101
versionName "0.0.10-alpha-1"
versionCode 102
versionName "0.0.10-alpha-2"
manifestPlaceholders = [HOCKEYAPP_APP_ID: "b72b51a4aa74469fb8051586deab598b"]
}
buildTypes {
release {
Expand All @@ -26,16 +27,17 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support:design:25.3.0'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.madgag.spongycastle:core:1.50.0.0'
compile 'com.madgag.spongycastle:pg:1.50.0.0'
compile 'com.madgag.spongycastle:pkix:1.50.0.0'
compile 'com.madgag.spongycastle:prov:1.50.0.0'
compile 'com.github.paolorotolo:appintro:4.1.0'
compile "com.android.support:support-v4:25.3.0"
compile "com.android.support:support-v13:25.3.0"
compile 'com.google.android.gms:play-services-safetynet:10.2.0'
compile "com.android.support:support-v4:25.3.1"
compile "com.android.support:support-v13:25.3.1"
compile 'com.google.android.gms:play-services-safetynet:11.0.4'
compile 'com.squareup.okhttp3:okhttp:3.8.1'
compile 'com.jakewharton.timber:timber:4.5.1'
compile 'net.hockeyapp.android:HockeySDK:5.0.3'
}
4 changes: 1 addition & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,8 @@
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
<meta-data
android:name="android.service.quicksettings.ACTIVE_TILE"
android:value="true" />
</service>
<meta-data android:name="net.hockeyapp.android.appIdentifier" android:value="${HOCKEYAPP_APP_ID}" />
</application>

</manifest>
31 changes: 31 additions & 0 deletions app/src/main/java/org/witness/proofmode/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
import android.widget.Switch;
import android.widget.Toast;

import net.hockeyapp.android.UpdateManager;
import net.hockeyapp.android.metrics.MetricsManager;

import org.spongycastle.jce.provider.BouncyCastleProvider;
import org.spongycastle.openpgp.PGPException;
import org.spongycastle.openpgp.PGPKeyRingGenerator;
Expand Down Expand Up @@ -111,6 +114,9 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
{
askForPermission(Manifest.permission.ACCESS_FINE_LOCATION, 1);
}

checkForUpdates();

}

@Override
Expand Down Expand Up @@ -261,4 +267,29 @@ private void refreshLocation ()
gpsTracker.getLocation();
}
}

private void checkForUpdates() {

// add this to your main activity's onCreate()-callback
MetricsManager.register(getApplication());

// Remove this for store builds!
UpdateManager.register(this);
}

private void unregisterManagers() {
UpdateManager.unregister();
}

@Override
public void onPause() {
super.onPause();
unregisterManagers();
}

@Override
public void onDestroy() {
super.onDestroy();
unregisterManagers();
}
}
31 changes: 22 additions & 9 deletions app/src/main/java/org/witness/proofmode/ProofModeApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@
import android.provider.ContactsContract;
import android.util.Log;

import net.hockeyapp.android.CrashManager;
import net.hockeyapp.android.UpdateManager;
import net.hockeyapp.android.metrics.MetricsManager;

import org.spongycastle.jce.provider.BouncyCastleProvider;
import org.witness.proofmode.service.MediaListenerService;
import org.witness.proofmode.service.PhotosContentJob;
import org.witness.proofmode.service.VideosContentJob;
import org.witness.proofmode.util.SafetyNetCheck;

import java.security.Security;
import java.util.HashMap;

import timber.log.Timber;

Expand Down Expand Up @@ -52,6 +57,8 @@ public void onCreate() {
}

SafetyNetCheck.buildGoogleApiClient(this);

checkForCrashes();
}

/** A tree which logs important information for crash reporting. */
Expand All @@ -61,16 +68,22 @@ private static class CrashReportingTree extends Timber.Tree {
return;
}

/**
FakeCrashLibrary.log(priority, tag, message);
// add this wherever you want to track a custom event
MetricsManager.trackEvent("Crash: " + tag);

// add this wherever you want to track a custom event and attach properties or measurements to it
HashMap<String, String> properties = new HashMap<>();
properties.put("Message", message);

HashMap<String, Double> measurements = new HashMap<>();
MetricsManager.trackEvent("YOUR_EVENT_NAME", properties, measurements);

if (t != null) {
if (priority == Log.ERROR) {
FakeCrashLibrary.logError(t);
} else if (priority == Log.WARN) {
FakeCrashLibrary.logWarning(t);
}
}**/
}
}

private void checkForCrashes() {
CrashManager.register(this);
}


}
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@
<string name="select_app">Select the app to share proof to...</string>
<string name="independent_notary">Independent notarization by Enigio TimeBeat at:</string>
<string name="packaging_proof">Packaging proof for sharing...</string>
<string name="view_public_key">View public key at: http://pgp.mit.edu/pks/lookup?search=0x</string>

</resources>

0 comments on commit 0501022

Please sign in to comment.