Merge "whitelist "snet_event_log" when turning logs off" am: 574814a4c2

am: 836be3ff89

* commit '836be3ff89124e7ac8cf221f56de1c45b7a8c092':
  whitelist "snet_event_log" when turning logs off
This commit is contained in:
Mark Salyzyn
2016-01-08 22:46:02 +00:00
committed by android-build-merger

View File

@@ -155,7 +155,16 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
private static final String SELECT_LOGD_SIZE_KEY = "select_logd_size"; private static final String SELECT_LOGD_SIZE_KEY = "select_logd_size";
private static final String SELECT_LOGD_SIZE_PROPERTY = "persist.logd.size"; private static final String SELECT_LOGD_SIZE_PROPERTY = "persist.logd.size";
private static final String SELECT_LOGD_TAG_PROPERTY = "persist.log.tag"; private static final String SELECT_LOGD_TAG_PROPERTY = "persist.log.tag";
// Tricky, isLoggable only checks for first character, assumes silence
private static final String SELECT_LOGD_TAG_SILENCE = "Settings";
private static final String SELECT_LOGD_SNET_TAG_PROPERTY = "persist.log.tag.snet_event_log";
private static final String SELECT_LOGD_RUNTIME_SNET_TAG_PROPERTY = "log.tag.snet_event_log";
private static final String SELECT_LOGD_DEFAULT_SIZE_PROPERTY = "ro.logd.size"; private static final String SELECT_LOGD_DEFAULT_SIZE_PROPERTY = "ro.logd.size";
private static final String SELECT_LOGD_DEFAULT_SIZE_VALUE = "262144";
private static final String SELECT_LOGD_SVELTE_DEFAULT_SIZE_VALUE = "65536";
// 32768 is merely a menu marker, 64K is our lowest log buffer size we replace it with.
private static final String SELECT_LOGD_MINIMUM_SIZE_VALUE = "65536";
private static final String SELECT_LOGD_OFF_SIZE_MARKER_VALUE = "32768";
private static final String WIFI_DISPLAY_CERTIFICATION_KEY = "wifi_display_certification"; private static final String WIFI_DISPLAY_CERTIFICATION_KEY = "wifi_display_certification";
private static final String WIFI_VERBOSE_LOGGING_KEY = "wifi_verbose_logging"; private static final String WIFI_VERBOSE_LOGGING_KEY = "wifi_verbose_logging";
@@ -194,8 +203,6 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
private static final int REQUEST_CODE_ENABLE_OEM_UNLOCK = 0; private static final int REQUEST_CODE_ENABLE_OEM_UNLOCK = 0;
private static String DEFAULT_LOG_RING_BUFFER_SIZE_IN_BYTES = "262144"; // 256K
private static final int[] MOCK_LOCATION_APP_OPS = new int[] {AppOpsManager.OP_MOCK_LOCATION}; private static final int[] MOCK_LOCATION_APP_OPS = new int[] {AppOpsManager.OP_MOCK_LOCATION};
private IWindowManager mWindowManager; private IWindowManager mWindowManager;
@@ -1359,22 +1366,27 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
mMobileDataAlwaysOn.isChecked() ? 1 : 0); mMobileDataAlwaysOn.isChecked() ? 1 : 0);
} }
private String defaultLogdSizeValue() {
String defaultValue = SystemProperties.get(SELECT_LOGD_DEFAULT_SIZE_PROPERTY);
if ((defaultValue == null) || (defaultValue.length() == 0)) {
if (SystemProperties.get("ro.config.low_ram").equals("true")) {
defaultValue = SELECT_LOGD_SVELTE_DEFAULT_SIZE_VALUE;
} else {
defaultValue = SELECT_LOGD_DEFAULT_SIZE_VALUE;
}
}
return defaultValue;
}
private void updateLogdSizeValues() { private void updateLogdSizeValues() {
if (mLogdSize != null) { if (mLogdSize != null) {
String currentTag = SystemProperties.get(SELECT_LOGD_TAG_PROPERTY); String currentTag = SystemProperties.get(SELECT_LOGD_TAG_PROPERTY);
String currentValue = SystemProperties.get(SELECT_LOGD_SIZE_PROPERTY); String currentValue = SystemProperties.get(SELECT_LOGD_SIZE_PROPERTY);
if ((currentTag != null) && currentTag.equals("S")) { if ((currentTag != null) && currentTag.startsWith(SELECT_LOGD_TAG_SILENCE)) {
currentValue = "32768"; currentValue = SELECT_LOGD_OFF_SIZE_MARKER_VALUE;
}
if (currentValue == null) {
currentValue = SystemProperties.get(SELECT_LOGD_DEFAULT_SIZE_PROPERTY);
if (currentValue == null) {
if (SystemProperties.get("ro.config.low_ram").equals("true")) {
currentValue = "64K";
} else {
currentValue = "256K";
}
} }
if ((currentValue == null) || (currentValue.length() == 0)) {
currentValue = defaultLogdSizeValue();
} }
String[] values = getResources().getStringArray(R.array.select_logd_size_values); String[] values = getResources().getStringArray(R.array.select_logd_size_values);
String[] titles = getResources().getStringArray(R.array.select_logd_size_titles); String[] titles = getResources().getStringArray(R.array.select_logd_size_titles);
@@ -1399,20 +1411,42 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
} }
private void writeLogdSizeOption(Object newValue) { private void writeLogdSizeOption(Object newValue) {
String currentValue = SystemProperties.get(SELECT_LOGD_DEFAULT_SIZE_PROPERTY); boolean disable = (newValue != null) &&
if (currentValue != null) { (newValue.toString().equals(SELECT_LOGD_OFF_SIZE_MARKER_VALUE));
DEFAULT_LOG_RING_BUFFER_SIZE_IN_BYTES = currentValue; String currentTag = SystemProperties.get(SELECT_LOGD_TAG_PROPERTY);
if (currentTag == null) {
currentTag = "";
} }
boolean disable = (newValue != null) && (newValue.equals("32768")); // filter clean and unstack all references to our setting
String newTag = currentTag.replaceAll(
",+" + SELECT_LOGD_TAG_SILENCE, "").replaceFirst(
"^" + SELECT_LOGD_TAG_SILENCE + ",*", "").replaceAll(
",+", ",").replaceFirst(
",+$", "");
if (disable) { if (disable) {
newValue = "65536"; newValue = SELECT_LOGD_MINIMUM_SIZE_VALUE;
SystemProperties.set(SELECT_LOGD_TAG_PROPERTY, "S"); // Make sure snet_event_log get through first, but do not override
} else { String snetValue = SystemProperties.get(SELECT_LOGD_SNET_TAG_PROPERTY);
SystemProperties.set(SELECT_LOGD_TAG_PROPERTY, ""); if ((snetValue == null) || (snetValue.length() == 0)) {
snetValue = SystemProperties.get(SELECT_LOGD_RUNTIME_SNET_TAG_PROPERTY);
if ((snetValue == null) || (snetValue.length() == 0)) {
SystemProperties.set(SELECT_LOGD_SNET_TAG_PROPERTY, "I");
} }
final String size = (newValue != null) ? }
newValue.toString() : DEFAULT_LOG_RING_BUFFER_SIZE_IN_BYTES; // Silence all log sources, security logs notwithstanding
SystemProperties.set(SELECT_LOGD_SIZE_PROPERTY, size); if (newTag.length() != 0) {
newTag = "," + newTag;
}
// Stack settings, stack to help preserve original value
newTag = SELECT_LOGD_TAG_SILENCE + newTag;
}
if (!newTag.equals(currentTag)) {
SystemProperties.set(SELECT_LOGD_TAG_PROPERTY, newTag);
}
String defaultValue = defaultLogdSizeValue();
final String size = ((newValue != null) && (newValue.toString().length() != 0)) ?
newValue.toString() : defaultValue;
SystemProperties.set(SELECT_LOGD_SIZE_PROPERTY, defaultValue.equals(size) ? "" : size);
SystemProperties.set("ctl.start", "logd-reinit"); SystemProperties.set("ctl.start", "logd-reinit");
pokeSystemProperties(); pokeSystemProperties();
updateLogdSizeValues(); updateLogdSizeValues();