mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-19 14:19:53 +01:00
Enable logging for beta builds.
Some devices were logging and others not, due to the log level being set in the SplashScreenActivity constructor.
This commit is contained in:
@@ -2,6 +2,9 @@ package org.briarproject.briar.android;
|
|||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.Context;
|
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.ACRA;
|
||||||
import org.acra.ReportingInteractionMode;
|
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.STACK_TRACE;
|
||||||
import static org.acra.ReportField.USER_APP_START_DATE;
|
import static org.acra.ReportField.USER_APP_START_DATE;
|
||||||
import static org.acra.ReportField.USER_CRASH_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(
|
@ReportsCrashes(
|
||||||
reportPrimerClass = BriarReportPrimer.class,
|
reportPrimerClass = BriarReportPrimer.class,
|
||||||
@@ -72,6 +77,9 @@ public class BriarApplicationImpl extends Application
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
|
|
||||||
|
if (IS_DEBUG_BUILD) enableStrictMode();
|
||||||
|
Logger.getLogger("").setLevel(DEFAULT_LOG_LEVEL);
|
||||||
LOG.info("Created");
|
LOG.info("Created");
|
||||||
|
|
||||||
applicationComponent = DaggerAndroidComponent.builder()
|
applicationComponent = DaggerAndroidComponent.builder()
|
||||||
@@ -85,6 +93,17 @@ public class BriarApplicationImpl extends Application
|
|||||||
AndroidEagerSingletons.initEagerSingletons(applicationComponent);
|
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
|
@Override
|
||||||
public AndroidComponent getApplicationComponent() {
|
public AndroidComponent getApplicationComponent() {
|
||||||
return applicationComponent;
|
return applicationComponent;
|
||||||
|
|||||||
@@ -10,13 +10,21 @@ import static java.util.logging.Level.OFF;
|
|||||||
public interface TestingConstants {
|
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.
|
* 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
|
* 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
|
* Unfortunately this also prevents the user from taking screenshots
|
||||||
* intentionally.
|
* 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.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
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.support.v7.preference.PreferenceManager;
|
||||||
import android.transition.Fade;
|
import android.transition.Fade;
|
||||||
|
|
||||||
@@ -23,8 +20,6 @@ import java.util.logging.Logger;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import static org.briarproject.briar.android.BriarApplication.EXPIRY_DATE;
|
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 {
|
public class SplashScreenActivity extends BaseActivity {
|
||||||
|
|
||||||
@@ -36,11 +31,6 @@ public class SplashScreenActivity extends BaseActivity {
|
|||||||
@Inject
|
@Inject
|
||||||
protected AndroidExecutor androidExecutor;
|
protected AndroidExecutor androidExecutor;
|
||||||
|
|
||||||
public SplashScreenActivity() {
|
|
||||||
Logger.getLogger("").setLevel(DEFAULT_LOG_LEVEL);
|
|
||||||
enableStrictMode();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle state) {
|
public void onCreate(Bundle state) {
|
||||||
super.onCreate(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() {
|
private void setPreferencesDefaults() {
|
||||||
androidExecutor.runOnBackgroundThread(new Runnable() {
|
androidExecutor.runOnBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user