SnoopLogger: Debug enhancements added settings
Bug: 247859568 Tag: #feature Test: make RunSettingsRoboTests3 Test: make RunSettingsRoboTests4 Change-Id: I132a1558ea67400d9c10dda523456f99eb815b92 Merged-In: I132a1558ea67400d9c10dda523456f99eb815b92
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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.snooplogger;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.development.DevelopmentSettingsEnabler;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Bluetooth Snoop Logger Filters Dashboard
|
||||
*/
|
||||
@SearchIndexable
|
||||
public class SnoopLoggerFiltersDashboard extends DashboardFragment {
|
||||
|
||||
private static final String TAG = "SnoopLoggerFiltersDashboard";
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return SettingsEnums.SETTINGS_SNOOP_LOGGER_DASHBOARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLogTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.snoop_logger_filters_settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHelpResource() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(
|
||||
Context context, boolean enabled) {
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.snoop_logger_filters_settings;
|
||||
return List.of(sir);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isPageSearchEnabled(Context context) {
|
||||
return DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(context);
|
||||
}
|
||||
};
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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.snooplogger;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.SystemProperties;
|
||||
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
/**
|
||||
* Bluetooth Snoop Logger Filters Preference
|
||||
*/
|
||||
public class SnoopLoggerFiltersPreference extends SwitchPreference {
|
||||
|
||||
private final String mKey;
|
||||
private static final String TAG = "SnoopLoggerFiltersPreference";
|
||||
private static final String SNOOP_LOG_FILTERS_PREFIX = "persist.bluetooth.snooplogfilter.";
|
||||
private static final String SNOOP_LOG_FILTERS_SUFFIX = ".enabled";
|
||||
|
||||
public SnoopLoggerFiltersPreference(Context context, String key, String entry) {
|
||||
super(context);
|
||||
mKey = key;
|
||||
setKey(key);
|
||||
setTitle(entry);
|
||||
|
||||
String filterProp = SNOOP_LOG_FILTERS_PREFIX.concat(mKey).concat(SNOOP_LOG_FILTERS_SUFFIX);
|
||||
|
||||
boolean isFilterEnabled = SystemProperties.get(filterProp).equals("true");
|
||||
|
||||
super.setChecked(isFilterEnabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChecked(boolean isChecked) {
|
||||
super.setChecked(isChecked);
|
||||
String filterProp = SNOOP_LOG_FILTERS_PREFIX.concat(mKey).concat(SNOOP_LOG_FILTERS_SUFFIX);
|
||||
SystemProperties.set(filterProp, isChecked ? "true" : "false");
|
||||
}
|
||||
}
|
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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.snooplogger;
|
||||
|
||||
import android.content.Context;
|
||||
import android.sysprop.BluetoothProperties;
|
||||
|
||||
import androidx.preference.PreferenceGroup;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
/** A {@link BasePreferenceController} used in {@link SnoopLoggerFiltersDashboard} */
|
||||
public class SnoopLoggerFiltersPreferenceController extends BasePreferenceController {
|
||||
private static final String TAG = "SnoopLoggerFiltersPreferenceController";
|
||||
|
||||
private final String[] mListValues;
|
||||
private final String[] mListEntries;
|
||||
|
||||
public SnoopLoggerFiltersPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mListValues =
|
||||
context.getResources().getStringArray(R.array.bt_hci_snoop_log_filters_values);
|
||||
mListEntries =
|
||||
context.getResources().getStringArray(R.array.bt_hci_snoop_log_filters_entries);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
BluetoothProperties.snoop_log_mode_values snoopLogMode =
|
||||
BluetoothProperties.snoop_log_mode()
|
||||
.orElse(BluetoothProperties.snoop_log_mode_values.DISABLED);
|
||||
if (snoopLogMode == BluetoothProperties.snoop_log_mode_values.FILTERED) {
|
||||
return AVAILABLE;
|
||||
}
|
||||
return DISABLED_DEPENDENT_SETTING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
PreferenceGroup mGroup = screen.findPreference(getPreferenceKey());
|
||||
mGroup.removeAll();
|
||||
final Context prefContext = mGroup.getContext();
|
||||
for (int i = 0; i < mListValues.length; i++) {
|
||||
mGroup.addPreference(
|
||||
new SnoopLoggerFiltersPreference(prefContext, mListValues[i], mListEntries[i]));
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user