New debug setting to enable strict mode logging.
For now it only enables it for the main process. I've added a flag to EmailServiceProxy for EAS, but it's not used in the exchange side. Bug 3500292 Change-Id: I5b27c69fe7cc995a430e9def54b2463076032c78
This commit is contained in:
parent
833bf485a8
commit
19b2a7ebc9
@ -68,6 +68,8 @@ public class EmailServiceProxy extends ServiceProxy implements IEmailService {
|
||||
public static final int DEBUG_VERBOSE_BIT = 2;
|
||||
// File (SD card) logging
|
||||
public static final int DEBUG_FILE_BIT = 4;
|
||||
// Enable strict mode
|
||||
public static final int DEBUG_ENABLE_STRICT_MODE = 8;
|
||||
|
||||
// The first two constructors are used with local services that can be referenced by class
|
||||
public EmailServiceProxy(Context _context, Class<?> _class) {
|
||||
|
@ -44,6 +44,7 @@ import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.os.StrictMode;
|
||||
import android.provider.OpenableColumns;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
@ -1128,4 +1129,13 @@ public class Utility {
|
||||
public static boolean areStringsEqual(String s1, String s2) {
|
||||
return (s1 != null && s1.equals(s2)) || (s1 == null && s2 == null);
|
||||
}
|
||||
|
||||
public static void enableStrictMode(boolean enabled) {
|
||||
StrictMode.setThreadPolicy(enabled
|
||||
? new StrictMode.ThreadPolicy.Builder().detectAll().build()
|
||||
: StrictMode.ThreadPolicy.LAX);
|
||||
StrictMode.setVmPolicy(enabled
|
||||
? new StrictMode.VmPolicy.Builder().detectAll().build()
|
||||
: StrictMode.VmPolicy.LAX);
|
||||
}
|
||||
}
|
||||
|
@ -63,4 +63,10 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/debug_force_one_minute_refresh_label"
|
||||
/>
|
||||
<CheckBox
|
||||
android:id="@+id/debug_enable_strict_mode"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/debug_enable_strict_mode_label"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
@ -262,6 +262,9 @@
|
||||
<!-- Do Not Translate. Checkbox label, shown on debug screen. -->
|
||||
<string name="debug_force_one_minute_refresh_label" translatable="false">
|
||||
Force 1-minute refresh for POP/IMAP</string>
|
||||
<!-- Do Not Translate. Checkbox label, shown on debug screen. -->
|
||||
<string name="debug_enable_strict_mode_label" translatable="false">
|
||||
Enable strict mode (with logging)</string>
|
||||
|
||||
<!-- The text in the small separator between smart folders and the accounts -->
|
||||
<string name="account_folder_list_separator_accounts">Accounts</string>
|
||||
|
@ -197,6 +197,7 @@ public class Email extends Application {
|
||||
Preferences prefs = Preferences.getPreferences(this);
|
||||
DEBUG = prefs.getEnableDebugLogging();
|
||||
sDebugInhibitGraphicsAcceleration = prefs.getInhibitGraphicsAcceleration();
|
||||
enableStrictMode(prefs.getEnableStrictMode());
|
||||
TempDirectory.setTempDirectory(this);
|
||||
|
||||
// Tie MailRefreshManager to the Controller.
|
||||
@ -221,7 +222,9 @@ public class Email extends Application {
|
||||
prefs.getEnableExchangeLogging() ? EmailServiceProxy.DEBUG_VERBOSE_BIT : 0;
|
||||
int fileLogging =
|
||||
prefs.getEnableExchangeFileLogging() ? EmailServiceProxy.DEBUG_FILE_BIT : 0;
|
||||
int debugBits = debugLogging | verboseLogging | fileLogging;
|
||||
int enableStrictMode =
|
||||
prefs.getEnableStrictMode() ? EmailServiceProxy.DEBUG_ENABLE_STRICT_MODE : 0;
|
||||
int debugBits = debugLogging | verboseLogging | fileLogging | enableStrictMode;
|
||||
Controller.getInstance(context).serviceLogging(debugBits);
|
||||
}
|
||||
|
||||
@ -263,4 +266,8 @@ public class Email extends Application {
|
||||
public static String getMessageDecodeErrorString() {
|
||||
return sMessageDecodeErrorString != null ? sMessageDecodeErrorString : "";
|
||||
}
|
||||
|
||||
public static void enableStrictMode(boolean enabled) {
|
||||
Utility.enableStrictMode(enabled);
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ public class Preferences {
|
||||
private static final String ENABLE_EXCHANGE_FILE_LOGGING = "enableExchangeFileLogging";
|
||||
private static final String INHIBIT_GRAPHICS_ACCELERATION = "inhibitGraphicsAcceleration";
|
||||
private static final String FORCE_ONE_MINUTE_REFRESH = "forceOneMinuteRefresh";
|
||||
private static final String ENABLE_STRICT_MODE = "enableStrictMode";
|
||||
private static final String DEVICE_UID = "deviceUID";
|
||||
private static final String ONE_TIME_INITIALIZATION_PROGRESS = "oneTimeInitializationProgress";
|
||||
private static final String AUTO_ADVANCE_DIRECTION = "autoAdvance";
|
||||
@ -194,6 +195,14 @@ public class Preferences {
|
||||
return mSharedPreferences.getBoolean(FORCE_ONE_MINUTE_REFRESH, false);
|
||||
}
|
||||
|
||||
public void setEnableStrictMode(boolean value) {
|
||||
mSharedPreferences.edit().putBoolean(ENABLE_STRICT_MODE, value).apply();
|
||||
}
|
||||
|
||||
public boolean getEnableStrictMode() {
|
||||
return mSharedPreferences.getBoolean(ENABLE_STRICT_MODE, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a new "device UID". This is local to Email app only, to prevent possibility
|
||||
* of correlation with any other user activities in any other apps.
|
||||
|
@ -44,6 +44,7 @@ public class DebugFragment extends Fragment implements OnCheckedChangeListener,
|
||||
private CheckBox mEnableExchangeFileLoggingView;
|
||||
private CheckBox mInhibitGraphicsAccelerationView;
|
||||
private CheckBox mForceOneMinuteRefreshView;
|
||||
private CheckBox mEnableStrictModeView;
|
||||
|
||||
private Preferences mPreferences;
|
||||
|
||||
@ -95,6 +96,11 @@ public class DebugFragment extends Fragment implements OnCheckedChangeListener,
|
||||
mForceOneMinuteRefreshView.setChecked(mPreferences.getForceOneMinuteRefresh());
|
||||
mForceOneMinuteRefreshView.setOnCheckedChangeListener(this);
|
||||
|
||||
mEnableStrictModeView = (CheckBox)
|
||||
view.findViewById(R.id.debug_enable_strict_mode);
|
||||
mEnableStrictModeView.setChecked(mPreferences.getEnableStrictMode());
|
||||
mEnableStrictModeView.setOnCheckedChangeListener(this);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@ -122,6 +128,10 @@ public class DebugFragment extends Fragment implements OnCheckedChangeListener,
|
||||
mPreferences.setForceOneMinuteRefresh(isChecked);
|
||||
MailService.actionReschedule(getActivity());
|
||||
break;
|
||||
case R.id.debug_enable_strict_mode:
|
||||
mPreferences.setEnableStrictMode(isChecked);
|
||||
Email.enableStrictMode(isChecked);
|
||||
break;
|
||||
}
|
||||
|
||||
Email.updateLoggingFlags(getActivity());
|
||||
|
Loading…
Reference in New Issue
Block a user