Move LogPersist to SettingsLib
Bug: 62442606 Test: LogdSizePreferenceControllerTest, LogpersistPreferenceControllerTest Change-Id: Iabc3a86c839109f8e2b04d3e9b7128c987473ab3
This commit is contained in:
@@ -160,29 +160,6 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
private static final String ANIMATOR_DURATION_SCALE_KEY = "animator_duration_scale";
|
private static final String ANIMATOR_DURATION_SCALE_KEY = "animator_duration_scale";
|
||||||
private static final String OVERLAY_DISPLAY_DEVICES_KEY = "overlay_display_devices";
|
private static final String OVERLAY_DISPLAY_DEVICES_KEY = "overlay_display_devices";
|
||||||
private static final String DEBUG_DEBUGGING_CATEGORY_KEY = "debug_debugging_category";
|
private static final String DEBUG_DEBUGGING_CATEGORY_KEY = "debug_debugging_category";
|
||||||
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_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_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 SELECT_LOGPERSIST_KEY = "select_logpersist";
|
|
||||||
private static final String SELECT_LOGPERSIST_PROPERTY = "persist.logd.logpersistd";
|
|
||||||
private static final String ACTUAL_LOGPERSIST_PROPERTY = "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 ACTUAL_LOGPERSIST_PROPERTY_BUFFER = "logd.logpersistd.buffer";
|
|
||||||
private static final String ACTUAL_LOGPERSIST_PROPERTY_ENABLE = "logd.logpersistd.enable";
|
|
||||||
|
|
||||||
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";
|
||||||
@@ -305,8 +282,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
private SwitchPreference mForceRtlLayout;
|
private SwitchPreference mForceRtlLayout;
|
||||||
private ListPreference mDebugHwOverdraw;
|
private ListPreference mDebugHwOverdraw;
|
||||||
private ListPreference mDebugHwRenderer;
|
private ListPreference mDebugHwRenderer;
|
||||||
private ListPreference mLogdSize;
|
private LogdSizePreferenceController mLogdSizeController;
|
||||||
private ListPreference mLogpersist;
|
private LogpersistPreferenceController mLogpersistController;
|
||||||
private ListPreference mUsbConfiguration;
|
private ListPreference mUsbConfiguration;
|
||||||
private ListPreference mTrackFrameTime;
|
private ListPreference mTrackFrameTime;
|
||||||
private ListPreference mShowNonRectClip;
|
private ListPreference mShowNonRectClip;
|
||||||
@@ -346,8 +323,6 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
private Dialog mAdbKeysDialog;
|
private Dialog mAdbKeysDialog;
|
||||||
private boolean mUnavailable;
|
private boolean mUnavailable;
|
||||||
|
|
||||||
private boolean mLogpersistCleared;
|
|
||||||
private Dialog mLogpersistClearDialog;
|
|
||||||
private DashboardFeatureProvider mDashboardFeatureProvider;
|
private DashboardFeatureProvider mDashboardFeatureProvider;
|
||||||
private DevelopmentSwitchBarController mSwitchBarController;
|
private DevelopmentSwitchBarController mSwitchBarController;
|
||||||
private BugReportPreferenceController mBugReportController;
|
private BugReportPreferenceController mBugReportController;
|
||||||
@@ -391,6 +366,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
mBugReportController = new BugReportPreferenceController(getActivity());
|
mBugReportController = new BugReportPreferenceController(getActivity());
|
||||||
mBugReportInPowerController = new BugReportInPowerPreferenceController(getActivity());
|
mBugReportInPowerController = new BugReportInPowerPreferenceController(getActivity());
|
||||||
mTelephonyMonitorController = new TelephonyMonitorPreferenceController(getActivity());
|
mTelephonyMonitorController = new TelephonyMonitorPreferenceController(getActivity());
|
||||||
|
mLogdSizeController = new LogdSizePreferenceController(getActivity());
|
||||||
|
mLogpersistController = new LogpersistPreferenceController(getActivity(), getLifecycle());
|
||||||
mWebViewAppPrefController = new WebViewAppPreferenceController(getActivity());
|
mWebViewAppPrefController = new WebViewAppPreferenceController(getActivity());
|
||||||
mVerifyAppsOverUsbController = new VerifyAppsOverUsbPreferenceController(getActivity());
|
mVerifyAppsOverUsbController = new VerifyAppsOverUsbPreferenceController(getActivity());
|
||||||
mCameraHalHdrplusController = new CameraHalHdrplusPreferenceController(getActivity());
|
mCameraHalHdrplusController = new CameraHalHdrplusPreferenceController(getActivity());
|
||||||
@@ -405,6 +382,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
addPreferencesFromResource(R.xml.development_prefs);
|
addPreferencesFromResource(R.xml.development_prefs);
|
||||||
|
final PreferenceScreen preferenceScreen = getPreferenceScreen();
|
||||||
|
|
||||||
final PreferenceGroup debugDebuggingCategory = (PreferenceGroup)
|
final PreferenceGroup debugDebuggingCategory = (PreferenceGroup)
|
||||||
findPreference(DEBUG_DEBUGGING_CATEGORY_KEY);
|
findPreference(DEBUG_DEBUGGING_CATEGORY_KEY);
|
||||||
@@ -422,12 +400,14 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
mEnableTerminal = null;
|
mEnableTerminal = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
mBugReportController.displayPreference(getPreferenceScreen());
|
mBugReportController.displayPreference(preferenceScreen);
|
||||||
mBugReportInPowerController.displayPreference(getPreferenceScreen());
|
mBugReportInPowerController.displayPreference(preferenceScreen);
|
||||||
mTelephonyMonitorController.displayPreference(getPreferenceScreen());
|
mTelephonyMonitorController.displayPreference(preferenceScreen);
|
||||||
mWebViewAppPrefController.displayPreference(getPreferenceScreen());
|
mLogdSizeController.displayPreference(preferenceScreen);
|
||||||
mCameraHalHdrplusController.displayPreference(getPreferenceScreen());
|
mLogpersistController.displayPreference(preferenceScreen);
|
||||||
mEnableAdbController.displayPreference(getPreferenceScreen());
|
mWebViewAppPrefController.displayPreference(preferenceScreen);
|
||||||
|
mCameraHalHdrplusController.displayPreference(preferenceScreen);
|
||||||
|
mEnableAdbController.displayPreference(preferenceScreen);
|
||||||
|
|
||||||
mKeepScreenOn = (RestrictedSwitchPreference) findAndInitSwitchPref(KEEP_SCREEN_ON);
|
mKeepScreenOn = (RestrictedSwitchPreference) findAndInitSwitchPref(KEEP_SCREEN_ON);
|
||||||
mBtHciSnoopLog = findAndInitSwitchPref(BT_HCI_SNOOP_LOG);
|
mBtHciSnoopLog = findAndInitSwitchPref(BT_HCI_SNOOP_LOG);
|
||||||
@@ -455,7 +435,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
mMockLocationAppPref = findPreference(MOCK_LOCATION_APP_KEY);
|
mMockLocationAppPref = findPreference(MOCK_LOCATION_APP_KEY);
|
||||||
mAllPrefs.add(mMockLocationAppPref);
|
mAllPrefs.add(mMockLocationAppPref);
|
||||||
|
|
||||||
mVerifyAppsOverUsbController.displayPreference(getPreferenceScreen());
|
mVerifyAppsOverUsbController.displayPreference(preferenceScreen);
|
||||||
|
|
||||||
mStrictMode = findAndInitSwitchPref(STRICT_MODE_KEY);
|
mStrictMode = findAndInitSwitchPref(STRICT_MODE_KEY);
|
||||||
mPointerLocation = findAndInitSwitchPref(POINTER_LOCATION_KEY);
|
mPointerLocation = findAndInitSwitchPref(POINTER_LOCATION_KEY);
|
||||||
@@ -478,19 +458,6 @@ 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);
|
||||||
mTetheringHardwareOffload = findAndInitSwitchPref(TETHERING_HARDWARE_OFFLOAD);
|
mTetheringHardwareOffload = findAndInitSwitchPref(TETHERING_HARDWARE_OFFLOAD);
|
||||||
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);
|
||||||
mBluetoothDisableAbsVolume = findAndInitSwitchPref(BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_KEY);
|
mBluetoothDisableAbsVolume = findAndInitSwitchPref(BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_KEY);
|
||||||
mBluetoothEnableInbandRinging = findAndInitSwitchPref(BLUETOOTH_ENABLE_INBAND_RINGING_KEY);
|
mBluetoothEnableInbandRinging = findAndInitSwitchPref(BLUETOOTH_ENABLE_INBAND_RINGING_KEY);
|
||||||
@@ -644,6 +611,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
mEnableAdbController.enablePreference(enabled);
|
mEnableAdbController.enablePreference(enabled);
|
||||||
mBugReportInPowerController.enablePreference(enabled);
|
mBugReportInPowerController.enablePreference(enabled);
|
||||||
mTelephonyMonitorController.enablePreference(enabled);
|
mTelephonyMonitorController.enablePreference(enabled);
|
||||||
|
mLogdSizeController.enablePreference(enabled);
|
||||||
|
mLogpersistController.enablePreference(enabled);
|
||||||
mWebViewAppPrefController.enablePreference(enabled);
|
mWebViewAppPrefController.enablePreference(enabled);
|
||||||
mCameraHalHdrplusController.enablePreference(enabled);
|
mCameraHalHdrplusController.enablePreference(enabled);
|
||||||
updateAllOptions();
|
updateAllOptions();
|
||||||
@@ -816,8 +785,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
updateOtaDisableAutomaticUpdateOptions();
|
updateOtaDisableAutomaticUpdateOptions();
|
||||||
updateBugreportOptions();
|
updateBugreportOptions();
|
||||||
updateForceRtlOptions();
|
updateForceRtlOptions();
|
||||||
updateLogdSizeValues();
|
mLogdSizeController.updateLogdSizeValues();
|
||||||
updateLogpersistValues();
|
mLogpersistController.updateLogpersistValues();
|
||||||
updateWifiDisplayCertificationOptions();
|
updateWifiDisplayCertificationOptions();
|
||||||
updateWifiVerboseLoggingOptions();
|
updateWifiVerboseLoggingOptions();
|
||||||
updateWifiAggressiveHandoverOptions();
|
updateWifiAggressiveHandoverOptions();
|
||||||
@@ -850,8 +819,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
mBugReportInPowerController.resetPreference();
|
mBugReportInPowerController.resetPreference();
|
||||||
mEnableAdbController.resetPreference();
|
mEnableAdbController.resetPreference();
|
||||||
resetDebuggerOptions();
|
resetDebuggerOptions();
|
||||||
writeLogpersistOption(null, true);
|
mLogpersistController.writeLogpersistOption(null, true);
|
||||||
writeLogdSizeOption(null);
|
mLogdSizeController.writeLogdSizeOption(null);
|
||||||
writeAnimationScaleOption(0, mWindowAnimationScale, null);
|
writeAnimationScaleOption(0, mWindowAnimationScale, null);
|
||||||
writeAnimationScaleOption(1, mTransitionAnimationScale, null);
|
writeAnimationScaleOption(1, mTransitionAnimationScale, null);
|
||||||
writeAnimationScaleOption(2, mAnimatorDurationScale, null);
|
writeAnimationScaleOption(2, mAnimatorDurationScale, null);
|
||||||
@@ -1511,231 +1480,6 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
mTetheringHardwareOffload.isChecked() ? 0 : 1);
|
mTetheringHardwareOffload.isChecked() ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
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() {
|
|
||||||
if (mLogdSize != null) {
|
|
||||||
String currentTag = SystemProperties.get(SELECT_LOGD_TAG_PROPERTY);
|
|
||||||
String currentValue = SystemProperties.get(SELECT_LOGD_SIZE_PROPERTY);
|
|
||||||
if ((currentTag != null) && currentTag.startsWith(SELECT_LOGD_TAG_SILENCE)) {
|
|
||||||
currentValue = SELECT_LOGD_OFF_SIZE_MARKER_VALUE;
|
|
||||||
}
|
|
||||||
if (mLogpersist != null) {
|
|
||||||
String currentLogpersistEnable
|
|
||||||
= SystemProperties.get(ACTUAL_LOGPERSIST_PROPERTY_ENABLE);
|
|
||||||
if ((currentLogpersistEnable == null)
|
|
||||||
|| !currentLogpersistEnable.equals("true")
|
|
||||||
|| currentValue.equals(SELECT_LOGD_OFF_SIZE_MARKER_VALUE)) {
|
|
||||||
writeLogpersistOption(null, true);
|
|
||||||
mLogpersist.setEnabled(false);
|
|
||||||
} else if (DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(getContext())) {
|
|
||||||
mLogpersist.setEnabled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((currentValue == null) || (currentValue.length() == 0)) {
|
|
||||||
currentValue = defaultLogdSizeValue();
|
|
||||||
}
|
|
||||||
String[] values = getResources().getStringArray(R.array.select_logd_size_values);
|
|
||||||
String[] titles = getResources().getStringArray(R.array.select_logd_size_titles);
|
|
||||||
int index = 2; // punt to second entry if not found
|
|
||||||
if (SystemProperties.get("ro.config.low_ram").equals("true")) {
|
|
||||||
mLogdSize.setEntries(R.array.select_logd_size_lowram_titles);
|
|
||||||
titles = getResources().getStringArray(R.array.select_logd_size_lowram_titles);
|
|
||||||
index = 1;
|
|
||||||
}
|
|
||||||
String[] summaries = getResources().getStringArray(R.array.select_logd_size_summaries);
|
|
||||||
for (int i = 0; i < titles.length; i++) {
|
|
||||||
if (currentValue.equals(values[i])
|
|
||||||
|| currentValue.equals(titles[i])) {
|
|
||||||
index = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mLogdSize.setValue(values[index]);
|
|
||||||
mLogdSize.setSummary(summaries[index]);
|
|
||||||
mLogdSize.setOnPreferenceChangeListener(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void writeLogdSizeOption(Object newValue) {
|
|
||||||
boolean disable = (newValue != null) &&
|
|
||||||
(newValue.toString().equals(SELECT_LOGD_OFF_SIZE_MARKER_VALUE));
|
|
||||||
String currentTag = SystemProperties.get(SELECT_LOGD_TAG_PROPERTY);
|
|
||||||
if (currentTag == null) {
|
|
||||||
currentTag = "";
|
|
||||||
}
|
|
||||||
// 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) {
|
|
||||||
newValue = SELECT_LOGD_MINIMUM_SIZE_VALUE;
|
|
||||||
// Make sure snet_event_log get through first, but do not override
|
|
||||||
String snetValue = SystemProperties.get(SELECT_LOGD_SNET_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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Silence all log sources, security logs notwithstanding
|
|
||||||
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");
|
|
||||||
SystemPropPoker.getInstance().poke();
|
|
||||||
updateLogdSizeValues();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateLogpersistValues() {
|
|
||||||
if (mLogpersist == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String currentValue = SystemProperties.get(ACTUAL_LOGPERSIST_PROPERTY);
|
|
||||||
if (currentValue == null) {
|
|
||||||
currentValue = "";
|
|
||||||
}
|
|
||||||
String currentBuffers = SystemProperties.get(ACTUAL_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("kernel")) {
|
|
||||||
index = 3;
|
|
||||||
} else 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(ACTUAL_LOGPERSIST_PROPERTY, SELECT_LOGPERSIST_PROPERTY_CLEAR);
|
|
||||||
SystemPropPoker.getInstance().poke();
|
|
||||||
mLogpersistCleared = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setLogpersistOff(boolean update) {
|
|
||||||
SystemProperties.set(SELECT_LOGPERSIST_PROPERTY_BUFFER, "");
|
|
||||||
// deal with trampoline of empty properties
|
|
||||||
SystemProperties.set(ACTUAL_LOGPERSIST_PROPERTY_BUFFER, "");
|
|
||||||
SystemProperties.set(SELECT_LOGPERSIST_PROPERTY, "");
|
|
||||||
SystemProperties.set(ACTUAL_LOGPERSIST_PROPERTY,
|
|
||||||
update ? "" : SELECT_LOGPERSIST_PROPERTY_STOP);
|
|
||||||
SystemPropPoker.getInstance().poke();
|
|
||||||
if (update) {
|
|
||||||
updateLogpersistValues();
|
|
||||||
} else {
|
|
||||||
for (int i = 0; i < 3; i++) {
|
|
||||||
String currentValue = SystemProperties.get(ACTUAL_LOGPERSIST_PROPERTY);
|
|
||||||
if ((currentValue == null) || currentValue.equals("")) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
Thread.sleep(100);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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(ACTUAL_LOGPERSIST_PROPERTY);
|
|
||||||
if ((currentValue != null) &&
|
|
||||||
currentValue.equals(SELECT_LOGPERSIST_PROPERTY_SERVICE)) {
|
|
||||||
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(ACTUAL_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);
|
|
||||||
SystemPropPoker.getInstance().poke();
|
|
||||||
for (int i = 0; i < 3; i++) {
|
|
||||||
String currentValue = SystemProperties.get(ACTUAL_LOGPERSIST_PROPERTY);
|
|
||||||
if ((currentValue != null)
|
|
||||||
&& currentValue.equals(SELECT_LOGPERSIST_PROPERTY_SERVICE)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
Thread.sleep(100);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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);
|
||||||
@@ -2563,12 +2307,6 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
(preference == mBluetoothSelectA2dpLdacPlaybackQuality)) {
|
(preference == mBluetoothSelectA2dpLdacPlaybackQuality)) {
|
||||||
writeBluetoothConfigurationOption(preference, newValue);
|
writeBluetoothConfigurationOption(preference, newValue);
|
||||||
return true;
|
return true;
|
||||||
} else if (preference == mLogdSize) {
|
|
||||||
writeLogdSizeOption(newValue);
|
|
||||||
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;
|
||||||
@@ -2616,10 +2354,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
mEnableDialog.dismiss();
|
mEnableDialog.dismiss();
|
||||||
mEnableDialog = null;
|
mEnableDialog = null;
|
||||||
}
|
}
|
||||||
if (mLogpersistClearDialog != null) {
|
mLogpersistController.dismissDialogs();
|
||||||
mLogpersistClearDialog.dismiss();
|
|
||||||
mLogpersistClearDialog = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
@@ -2642,12 +2377,6 @@ 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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2658,8 +2387,6 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
mSwitchBar.setChecked(false);
|
mSwitchBar.setChecked(false);
|
||||||
}
|
}
|
||||||
mEnableDialog = null;
|
mEnableDialog = null;
|
||||||
} else if (dialog == mLogpersistClearDialog) {
|
|
||||||
mLogpersistClearDialog = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2017 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.development;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.android.settings.core.PreferenceControllerMixin;
|
||||||
|
import com.android.settingslib.development.AbstractLogdSizePreferenceController;
|
||||||
|
|
||||||
|
public class LogdSizePreferenceController extends AbstractLogdSizePreferenceController
|
||||||
|
implements PreferenceControllerMixin {
|
||||||
|
|
||||||
|
public LogdSizePreferenceController(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2017 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.development;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.support.v7.preference.ListPreference;
|
||||||
|
|
||||||
|
import com.android.settings.core.PreferenceControllerMixin;
|
||||||
|
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||||
|
import com.android.settingslib.development.AbstractLogpersistPreferenceController;
|
||||||
|
|
||||||
|
public class LogpersistPreferenceController extends AbstractLogpersistPreferenceController
|
||||||
|
implements PreferenceControllerMixin {
|
||||||
|
|
||||||
|
private Dialog mLogpersistClearDialog;
|
||||||
|
|
||||||
|
LogpersistPreferenceController(Context context, Lifecycle lifecycle) {
|
||||||
|
super(context, lifecycle);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showConfirmationDialog(ListPreference preference) {
|
||||||
|
if (mLogpersistClearDialog != null) dismissDialogs();
|
||||||
|
mLogpersistClearDialog = new AlertDialog.Builder(mContext).setMessage(
|
||||||
|
mContext.getString(
|
||||||
|
com.android.settingslib.R.string.dev_logpersist_clear_warning_message))
|
||||||
|
.setTitle(com.android.settingslib.R.string.dev_logpersist_clear_warning_title)
|
||||||
|
.setPositiveButton(android.R.string.yes, (dialog, which) -> setLogpersistOff(true))
|
||||||
|
.setNegativeButton(android.R.string.no, (dialog, which) -> updateLogpersistValues())
|
||||||
|
.show();
|
||||||
|
mLogpersistClearDialog.setOnDismissListener(dialog -> mLogpersistClearDialog = null);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dismissDialogs() {
|
||||||
|
if (mLogpersistClearDialog != null) {
|
||||||
|
mLogpersistClearDialog.dismiss();
|
||||||
|
mLogpersistClearDialog = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user