mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 21:59:54 +01:00
Use strict mode to log potential problems with testing builds.
This commit is contained in:
@@ -5,6 +5,7 @@ import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
|
|||||||
import static java.util.logging.Level.INFO;
|
import static java.util.logging.Level.INFO;
|
||||||
import static org.briarproject.android.TestingConstants.DEFAULT_LOG_LEVEL;
|
import static org.briarproject.android.TestingConstants.DEFAULT_LOG_LEVEL;
|
||||||
import static org.briarproject.android.TestingConstants.PREVENT_SCREENSHOTS;
|
import static org.briarproject.android.TestingConstants.PREVENT_SCREENSHOTS;
|
||||||
|
import static org.briarproject.android.TestingConstants.TESTING;
|
||||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_MATCH;
|
import static org.briarproject.android.util.CommonLayoutParams.MATCH_MATCH;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -16,10 +17,15 @@ import org.briarproject.api.db.DatabaseConfig;
|
|||||||
|
|
||||||
import roboguice.RoboGuice;
|
import roboguice.RoboGuice;
|
||||||
import roboguice.activity.RoboSplashActivity;
|
import roboguice.activity.RoboSplashActivity;
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.StrictMode;
|
||||||
|
import android.os.StrictMode.ThreadPolicy;
|
||||||
|
import android.os.StrictMode.VmPolicy;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
@@ -37,6 +43,7 @@ public class SplashScreenActivity extends RoboSplashActivity {
|
|||||||
|
|
||||||
public SplashScreenActivity() {
|
public SplashScreenActivity() {
|
||||||
Logger.getLogger("").setLevel(DEFAULT_LOG_LEVEL);
|
Logger.getLogger("").setLevel(DEFAULT_LOG_LEVEL);
|
||||||
|
enableStrictMode();
|
||||||
minDisplayMs = 500;
|
minDisplayMs = 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,6 +91,20 @@ public class SplashScreenActivity extends RoboSplashActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("NewApi")
|
||||||
|
private void enableStrictMode() {
|
||||||
|
if(TESTING && Build.VERSION.SDK_INT >= 9) {
|
||||||
|
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 delete(File f) {
|
private void delete(File f) {
|
||||||
if(f.isFile()) f.delete();
|
if(f.isFile()) f.delete();
|
||||||
else if(f.isDirectory()) for(File child : f.listFiles()) delete(child);
|
else if(f.isDirectory()) for(File child : f.listFiles()) delete(child);
|
||||||
|
|||||||
@@ -1,31 +1,34 @@
|
|||||||
package org.briarproject.android;
|
package org.briarproject.android;
|
||||||
|
|
||||||
import static java.util.logging.Level.INFO;
|
import static java.util.logging.Level.INFO;
|
||||||
|
import static java.util.logging.Level.OFF;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
interface TestingConstants {
|
interface TestingConstants {
|
||||||
|
|
||||||
/** Default log level - this should be OFF for release builds. */
|
/**
|
||||||
Level DEFAULT_LOG_LEVEL = INFO;
|
* Whether this is an alpha or beta build. This should be set to false for
|
||||||
|
* release builds.
|
||||||
|
*/
|
||||||
|
boolean TESTING = true;
|
||||||
|
|
||||||
|
/** Default log level. */
|
||||||
|
Level DEFAULT_LOG_LEVEL = TESTING ? INFO : OFF;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to prevent screenshots from being taken. This should be true for
|
* Whether to prevent screenshots from being taken. Setting this to true
|
||||||
* release builds, to prevent Recent Apps from storing screenshots of
|
* prevents Recent Apps from storing screenshots of private information.
|
||||||
* private information. Unfortunately this also prevents the user from
|
* Unfortunately this also prevents the user from taking screenshots
|
||||||
* taking screenshots intentionally.
|
* intentionally.
|
||||||
*/
|
*/
|
||||||
boolean PREVENT_SCREENSHOTS = false;
|
boolean PREVENT_SCREENSHOTS = TESTING ? false : true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to allow TestingActivity to be launched from SettingsActivity.
|
* Whether to allow TestingActivity to be launched from SettingsActivity.
|
||||||
* This should be false for release builds.
|
|
||||||
*/
|
*/
|
||||||
boolean SHOW_TESTING_ACTIVITY = true;
|
boolean SHOW_TESTING_ACTIVITY = TESTING ? true : false;
|
||||||
|
|
||||||
/**
|
/** Whether to allow crash reports to be submitted by email. */
|
||||||
* Whether to allow crash reports to be submitted by email. This should
|
boolean SHARE_CRASH_REPORTS = TESTING ? true : false;
|
||||||
* be false for release builds.
|
|
||||||
*/
|
|
||||||
boolean SHARE_CRASH_REPORTS = true;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user