resolve merge conflicts of 9e28f9a to nyc-dev-plus-aosp

Change-Id: If75736f8e36e2a8e13fe9740f89f632ee6bedd49
This commit is contained in:
Ruchi Kandoi
2016-06-10 22:04:52 -07:00
2 changed files with 151 additions and 0 deletions

View File

@@ -147,6 +147,13 @@
android:entries="@array/select_logd_size_titles" android:entries="@array/select_logd_size_titles"
android:entryValues="@array/select_logd_size_values" /> android:entryValues="@array/select_logd_size_values" />
<ListPreference
android:key="select_logpersist"
android:title="@string/select_logpersist_title"
android:dialogTitle="@string/select_logpersist_dialog_title"
android:entries="@array/select_logpersist_titles"
android:entryValues="@array/select_logpersist_values" />
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:key="debug_networking_category" <PreferenceCategory android:key="debug_networking_category"

View File

@@ -171,6 +171,12 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
// 32768 is merely a menu marker, 64K is our lowest log buffer size we replace it with. // 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_MINIMUM_SIZE_VALUE = "65536";
private static final String SELECT_LOGD_OFF_SIZE_MARKER_VALUE = "32768"; private static final String SELECT_LOGD_OFF_SIZE_MARKER_VALUE = "32768";
private static final String SELECT_LOGPERSIST_KEY = "select_logpersist";
private static final String SELECT_LOGPERSIST_PROPERTY = "persist.logd.logpersistd";
private static final String SELECT_LOGPERSIST_PROPERTY_SERVICE = "logcatd";
private static final String SELECT_LOGPERSIST_PROPERTY_CLEAR = "clear";
private static final String SELECT_LOGPERSIST_PROPERTY_STOP = "stop";
private static final String SELECT_LOGPERSIST_PROPERTY_BUFFER = "persist.logd.logpersistd.buffer";
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";
@@ -272,6 +278,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
private SwitchPreference mForceRtlLayout; private SwitchPreference mForceRtlLayout;
private ListPreference mDebugHwOverdraw; private ListPreference mDebugHwOverdraw;
private ListPreference mLogdSize; private ListPreference mLogdSize;
private ListPreference mLogpersist;
private ListPreference mUsbConfiguration; private ListPreference mUsbConfiguration;
private ListPreference mTrackFrameTime; private ListPreference mTrackFrameTime;
private ListPreference mShowNonRectClip; private ListPreference mShowNonRectClip;
@@ -312,6 +319,9 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
private Dialog mAdbKeysDialog; private Dialog mAdbKeysDialog;
private boolean mUnavailable; private boolean mUnavailable;
private boolean mLogpersistCleared;
private Dialog mLogpersistClearDialog;
public DevelopmentSettings() { public DevelopmentSettings() {
super(UserManager.DISALLOW_DEBUGGING_FEATURES); super(UserManager.DISALLOW_DEBUGGING_FEATURES);
} }
@@ -423,6 +433,18 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
mWifiAllowScansWithTraffic = findAndInitSwitchPref(WIFI_ALLOW_SCAN_WITH_TRAFFIC_KEY); mWifiAllowScansWithTraffic = findAndInitSwitchPref(WIFI_ALLOW_SCAN_WITH_TRAFFIC_KEY);
mMobileDataAlwaysOn = findAndInitSwitchPref(MOBILE_DATA_ALWAYS_ON); mMobileDataAlwaysOn = findAndInitSwitchPref(MOBILE_DATA_ALWAYS_ON);
mLogdSize = addListPreference(SELECT_LOGD_SIZE_KEY); mLogdSize = addListPreference(SELECT_LOGD_SIZE_KEY);
if ("1".equals(SystemProperties.get("ro.debuggable", "0"))) {
mLogpersist = addListPreference(SELECT_LOGPERSIST_KEY);
} else {
mLogpersist = (ListPreference) findPreference(SELECT_LOGPERSIST_KEY);
if (mLogpersist != null) {
mLogpersist.setEnabled(false);
if (debugDebuggingCategory != null) {
debugDebuggingCategory.removePreference(mLogpersist);
}
}
mLogpersist = null;
}
mUsbConfiguration = addListPreference(USB_CONFIGURATION_KEY); mUsbConfiguration = addListPreference(USB_CONFIGURATION_KEY);
mWebViewProvider = addListPreference(WEBVIEW_PROVIDER_KEY); mWebViewProvider = addListPreference(WEBVIEW_PROVIDER_KEY);
mWebViewMultiprocess = findAndInitSwitchPref(WEBVIEW_MULTIPROCESS_KEY); mWebViewMultiprocess = findAndInitSwitchPref(WEBVIEW_MULTIPROCESS_KEY);
@@ -690,6 +712,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
updateBugreportOptions(); updateBugreportOptions();
updateForceRtlOptions(); updateForceRtlOptions();
updateLogdSizeValues(); updateLogdSizeValues();
updateLogpersistValues();
updateWifiDisplayCertificationOptions(); updateWifiDisplayCertificationOptions();
updateWifiVerboseLoggingOptions(); updateWifiVerboseLoggingOptions();
updateWifiAggressiveHandoverOptions(); updateWifiAggressiveHandoverOptions();
@@ -717,6 +740,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
} }
} }
resetDebuggerOptions(); resetDebuggerOptions();
writeLogpersistOption(null, true);
writeLogdSizeOption(null); writeLogdSizeOption(null);
writeAnimationScaleOption(0, mWindowAnimationScale, null); writeAnimationScaleOption(0, mWindowAnimationScale, null);
writeAnimationScaleOption(1, mTransitionAnimationScale, null); writeAnimationScaleOption(1, mTransitionAnimationScale, null);
@@ -1450,6 +1474,14 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
String currentValue = SystemProperties.get(SELECT_LOGD_SIZE_PROPERTY); String currentValue = SystemProperties.get(SELECT_LOGD_SIZE_PROPERTY);
if ((currentTag != null) && currentTag.startsWith(SELECT_LOGD_TAG_SILENCE)) { if ((currentTag != null) && currentTag.startsWith(SELECT_LOGD_TAG_SILENCE)) {
currentValue = SELECT_LOGD_OFF_SIZE_MARKER_VALUE; currentValue = SELECT_LOGD_OFF_SIZE_MARKER_VALUE;
if (mLogpersist != null) {
writeLogpersistOption(null, true);
mLogpersist.setEnabled(false);
}
} else {
if ((mLogpersist != null) && mLastEnabledState) {
mLogpersist.setEnabled(true);
}
} }
if ((currentValue == null) || (currentValue.length() == 0)) { if ((currentValue == null) || (currentValue.length() == 0)) {
currentValue = defaultLogdSizeValue(); currentValue = defaultLogdSizeValue();
@@ -1518,6 +1550,103 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
updateLogdSizeValues(); updateLogdSizeValues();
} }
private void updateLogpersistValues() {
if (mLogpersist == null) {
return;
}
String currentValue = SystemProperties.get(SELECT_LOGPERSIST_PROPERTY);
if (currentValue == null) {
currentValue = "";
}
String currentBuffers = SystemProperties.get(SELECT_LOGPERSIST_PROPERTY_BUFFER);
if ((currentBuffers == null) || (currentBuffers.length() == 0)) {
currentBuffers = "all";
}
int index = 0;
if (currentValue.equals(SELECT_LOGPERSIST_PROPERTY_SERVICE)) {
index = 1;
if (!currentBuffers.equals("all") &&
!currentBuffers.contains("radio") &&
currentBuffers.contains("security") &&
currentBuffers.contains("kernel")) {
index = 2;
if (!currentBuffers.contains("default")) {
String[] contains = { "main", "events", "system", "crash" };
for (int i = 0; i < contains.length; i++) {
if (!currentBuffers.contains(contains[i])) {
index = 1;
break;
}
}
}
}
}
mLogpersist.setValue(getResources().getStringArray(R.array.select_logpersist_values)[index]);
mLogpersist.setSummary(getResources().getStringArray(R.array.select_logpersist_summaries)[index]);
mLogpersist.setOnPreferenceChangeListener(this);
if (index != 0) {
mLogpersistCleared = false;
} else if (!mLogpersistCleared) {
// would File.delete() directly but need to switch uid/gid to access
SystemProperties.set(SELECT_LOGPERSIST_PROPERTY, SELECT_LOGPERSIST_PROPERTY_CLEAR);
pokeSystemProperties();
mLogpersistCleared = true;
}
}
private void setLogpersistOff(boolean update) {
SystemProperties.set(SELECT_LOGPERSIST_PROPERTY_BUFFER, "");
SystemProperties.set(SELECT_LOGPERSIST_PROPERTY,
update ? "" : SELECT_LOGPERSIST_PROPERTY_STOP);
pokeSystemProperties();
if (update) {
updateLogpersistValues();
}
}
private void writeLogpersistOption(Object newValue, boolean skipWarning) {
if (mLogpersist == null) {
return;
}
String currentTag = SystemProperties.get(SELECT_LOGD_TAG_PROPERTY);
if ((currentTag != null) && currentTag.startsWith(SELECT_LOGD_TAG_SILENCE)) {
newValue = null;
skipWarning = true;
}
if ((newValue == null) || newValue.toString().equals("")) {
if (skipWarning) {
mLogpersistCleared = false;
} else if (!mLogpersistCleared) {
// if transitioning from on to off, pop up an are you sure?
String currentValue = SystemProperties.get(SELECT_LOGPERSIST_PROPERTY);
if ((currentValue != null) && (currentValue.length() != 0)) {
if (mLogpersistClearDialog != null) dismissDialogs();
mLogpersistClearDialog = new AlertDialog.Builder(getActivity()).setMessage(
getActivity().getResources().getString(
R.string.dev_logpersist_clear_warning_message))
.setTitle(R.string.dev_logpersist_clear_warning_title)
.setPositiveButton(android.R.string.yes, this)
.setNegativeButton(android.R.string.no, this)
.show();
mLogpersistClearDialog.setOnDismissListener(this);
return;
}
}
setLogpersistOff(true);
return;
}
String currentBuffer = SystemProperties.get(SELECT_LOGPERSIST_PROPERTY_BUFFER);
if ((currentBuffer != null) && !currentBuffer.equals(newValue.toString())) {
setLogpersistOff(false);
}
SystemProperties.set(SELECT_LOGPERSIST_PROPERTY_BUFFER, newValue.toString());
SystemProperties.set(SELECT_LOGPERSIST_PROPERTY, SELECT_LOGPERSIST_PROPERTY_SERVICE);
pokeSystemProperties();
updateLogpersistValues();
}
private void updateUsbConfigurationValues() { private void updateUsbConfigurationValues() {
if (mUsbConfiguration != null) { if (mUsbConfiguration != null) {
UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE); UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE);
@@ -1948,6 +2077,9 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
} else if (preference == mLogdSize) { } else if (preference == mLogdSize) {
writeLogdSizeOption(newValue); writeLogdSizeOption(newValue);
return true; return true;
} else if (preference == mLogpersist) {
writeLogpersistOption(newValue, false);
return true;
} else if (preference == mUsbConfiguration) { } else if (preference == mUsbConfiguration) {
writeUsbConfigurationOption(newValue); writeUsbConfigurationOption(newValue);
return true; return true;
@@ -1995,6 +2127,10 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
mEnableDialog.dismiss(); mEnableDialog.dismiss();
mEnableDialog = null; mEnableDialog = null;
} }
if (mLogpersistClearDialog != null) {
mLogpersistClearDialog.dismiss();
mLogpersistClearDialog = null;
}
} }
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
@@ -2031,6 +2167,12 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
// Reset the toggle // Reset the toggle
mSwitchBar.setChecked(false); mSwitchBar.setChecked(false);
} }
} else if (dialog == mLogpersistClearDialog) {
if (which == DialogInterface.BUTTON_POSITIVE) {
setLogpersistOff(true);
} else {
updateLogpersistValues();
}
} }
} }
@@ -2046,6 +2188,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
mSwitchBar.setChecked(false); mSwitchBar.setChecked(false);
} }
mEnableDialog = null; mEnableDialog = null;
} else if (dialog == mLogpersistClearDialog) {
mLogpersistClearDialog = null;
} }
} }