mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
Merge branch 'enable-logging-for-beta-builds' into 'master'
Enable logging for beta builds See merge request !573
This commit is contained in:
@@ -2,6 +2,9 @@ package org.briarproject.briar.android;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.os.StrictMode;
|
||||
import android.os.StrictMode.ThreadPolicy;
|
||||
import android.os.StrictMode.VmPolicy;
|
||||
|
||||
import org.acra.ACRA;
|
||||
import org.acra.ReportingInteractionMode;
|
||||
@@ -33,6 +36,8 @@ import static org.acra.ReportField.REPORT_ID;
|
||||
import static org.acra.ReportField.STACK_TRACE;
|
||||
import static org.acra.ReportField.USER_APP_START_DATE;
|
||||
import static org.acra.ReportField.USER_CRASH_DATE;
|
||||
import static org.briarproject.briar.android.TestingConstants.DEFAULT_LOG_LEVEL;
|
||||
import static org.briarproject.briar.android.TestingConstants.IS_DEBUG_BUILD;
|
||||
|
||||
@ReportsCrashes(
|
||||
reportPrimerClass = BriarReportPrimer.class,
|
||||
@@ -72,6 +77,9 @@ public class BriarApplicationImpl extends Application
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
if (IS_DEBUG_BUILD) enableStrictMode();
|
||||
Logger.getLogger("").setLevel(DEFAULT_LOG_LEVEL);
|
||||
LOG.info("Created");
|
||||
|
||||
applicationComponent = DaggerAndroidComponent.builder()
|
||||
@@ -85,6 +93,17 @@ public class BriarApplicationImpl extends Application
|
||||
AndroidEagerSingletons.initEagerSingletons(applicationComponent);
|
||||
}
|
||||
|
||||
private void enableStrictMode() {
|
||||
ThreadPolicy.Builder threadPolicy = new ThreadPolicy.Builder();
|
||||
threadPolicy.detectAll();
|
||||
threadPolicy.penaltyLog();
|
||||
StrictMode.setThreadPolicy(threadPolicy.build());
|
||||
VmPolicy.Builder vmPolicy = new VmPolicy.Builder();
|
||||
vmPolicy.detectAll();
|
||||
vmPolicy.penaltyLog();
|
||||
StrictMode.setVmPolicy(vmPolicy.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public AndroidComponent getApplicationComponent() {
|
||||
return applicationComponent;
|
||||
|
||||
@@ -10,13 +10,21 @@ import static java.util.logging.Level.OFF;
|
||||
public interface TestingConstants {
|
||||
|
||||
/**
|
||||
* Whether this is an alpha or beta build. This should be set to false for
|
||||
* Whether this is a debug build.
|
||||
*/
|
||||
boolean IS_DEBUG_BUILD = BuildConfig.DEBUG;
|
||||
|
||||
/**
|
||||
* Whether this is a beta build. This should be set to false for final
|
||||
* release builds.
|
||||
*/
|
||||
boolean TESTING = BuildConfig.DEBUG;
|
||||
boolean IS_BETA_BUILD = true;
|
||||
|
||||
/** Default log level. */
|
||||
Level DEFAULT_LOG_LEVEL = TESTING ? INFO : OFF;
|
||||
/**
|
||||
* Default log level. Disable logging for final release builds.
|
||||
*/
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
Level DEFAULT_LOG_LEVEL = IS_DEBUG_BUILD || IS_BETA_BUILD ? INFO : OFF;
|
||||
|
||||
/**
|
||||
* Whether to prevent screenshots from being taken. Setting this to true
|
||||
@@ -24,5 +32,5 @@ public interface TestingConstants {
|
||||
* Unfortunately this also prevents the user from taking screenshots
|
||||
* intentionally.
|
||||
*/
|
||||
boolean PREVENT_SCREENSHOTS = !TESTING;
|
||||
boolean PREVENT_SCREENSHOTS = !IS_DEBUG_BUILD;
|
||||
}
|
||||
|
||||
@@ -4,9 +4,6 @@ import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.StrictMode;
|
||||
import android.os.StrictMode.ThreadPolicy;
|
||||
import android.os.StrictMode.VmPolicy;
|
||||
import android.support.v7.preference.PreferenceManager;
|
||||
import android.transition.Fade;
|
||||
|
||||
@@ -23,8 +20,6 @@ import java.util.logging.Logger;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static org.briarproject.briar.android.BriarApplication.EXPIRY_DATE;
|
||||
import static org.briarproject.briar.android.TestingConstants.DEFAULT_LOG_LEVEL;
|
||||
import static org.briarproject.briar.android.TestingConstants.TESTING;
|
||||
|
||||
public class SplashScreenActivity extends BaseActivity {
|
||||
|
||||
@@ -36,11 +31,6 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
@Inject
|
||||
protected AndroidExecutor androidExecutor;
|
||||
|
||||
public SplashScreenActivity() {
|
||||
Logger.getLogger("").setLevel(DEFAULT_LOG_LEVEL);
|
||||
enableStrictMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
super.onCreate(state);
|
||||
@@ -81,19 +71,6 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
|
||||
private void enableStrictMode() {
|
||||
if (TESTING) {
|
||||
ThreadPolicy.Builder threadPolicy = new ThreadPolicy.Builder();
|
||||
threadPolicy.detectAll();
|
||||
threadPolicy.penaltyLog();
|
||||
StrictMode.setThreadPolicy(threadPolicy.build());
|
||||
VmPolicy.Builder vmPolicy = new VmPolicy.Builder();
|
||||
vmPolicy.detectAll();
|
||||
vmPolicy.penaltyLog();
|
||||
StrictMode.setVmPolicy(vmPolicy.build());
|
||||
}
|
||||
}
|
||||
|
||||
private void setPreferencesDefaults() {
|
||||
androidExecutor.runOnBackgroundThread(new Runnable() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user