Android 8.1 设备删除蓝牙功能
最近接到项目反馈,要求删除设备的蓝牙功能,具体修改参照如下:
/project/ProjectConfig.mk:
+MTK_BT_SUPPORT = no
/vendor/mediatek/proprietary/packages/apps/SettingsProvider/res/values/defaults.xml
+ <bool name="def_bluetooth_on">false</bool>
/vendor/mediatek/proprietary/packages/apps/SystemUI/res/values/config.xml
<string name="quick_settings_tiles_default" translatable="false">
- wifi,cell,battery,dnd,rotation,bt,airplane,location
+ wifi,cell,battery,dnd,rotation,airplane,location
</string>
<string name="quick_settings_tiles_stock" translatable="false">
- wifi,cell,battery,dnd,flashlight,rotation,bt,airplane,location,inversion,saver,work,cast,night
+ wifi,cell,battery,dnd,flashlight,rotation,airplane,location,inversion,saver,work,cast,night
</string>
/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/values/strings.xml
- <string name="connected_devices_dashboard_summary">Bluetooth, Cast, NFC</string>
+ <string name="connected_devices_dashboard_summary">Cast, NFC</string>
- <string name="connected_devices_dashboard_no_nfc_summary">Bluetooth, Cast</string>
+ <string name="connected_devices_dashboard_no_nfc_summary">Cast</string>
/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/values-zh-rCN/strings.xml
- <string name="connected_devices_dashboard_summary" msgid="2390582103384791904">"蓝牙、投射、NFC"</string>
+ <string name="connected_devices_dashboard_summary" msgid="2390582103384791904">"投射、NFC"</string>
- <string name="connected_devices_dashboard_no_nfc_summary" msgid="9106040742715366495">"蓝牙、投射"</string>
+ <string name="connected_devices_dashboard_no_nfc_summary" msgid="9106040742715366495">"投射"</string>
/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/xml/connected_devices.xml
- <com.android.settings.widget.MasterSwitchPreference
- android:key="toggle_bluetooth"
- android:title="@string/bluetooth_settings_title"
- android:icon="@drawable/ic_settings_bluetooth"
- android:order="-7"/>
/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/xml/device_info_status.xml
- <Preference
- android:key="bt_address"
- android:enabled="false"
- android:shouldDisableView="false"
- android:title="@string/status_bt_address"
- android:summary="@string/summary_placeholder"
- android:persistent="false" />
/vendor/mediatek/proprietary/packages/apps/MtkSettings/res/xml/location_scanning.xml
- <SwitchPreference
- android:title="@string/location_scanning_bluetooth_always_scanning_title"
- android:summary="@string/location_scanning_bluetooth_always_scanning_description"
- android:defaultValue="true"
- android:key="bluetooth_always_scanning" />
/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/SettingsActivity.java
somethingChanged = setTileEnabled(new ComponentName(packageName,
Settings.BluetoothSettingsActivity.class.getName()),
- pm.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH), isAdmin)
+ false/*pm.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)*/, isAdmin)
|| somethingChanged;
/vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java
- final BluetoothMasterSwitchPreferenceController bluetoothPreferenceController =
- new BluetoothMasterSwitchPreferenceController(
- context, Utils.getLocalBtManager(context), this,
- (SettingsActivity) getActivity());
- lifecycle.addObserver(bluetoothPreferenceController);
- controllers.add(bluetoothPreferenceController);
public List<String> getNonIndexableKeys(Context context) {
final List<String> keys = super.getNonIndexableKeys(context);
PackageManager pm = context.getPackageManager();
if (!pm.hasSystemFeature(PackageManager.FEATURE_NFC)) {
keys.add(NfcPreferenceController.KEY_TOGGLE_NFC);
keys.add(NfcPreferenceController.KEY_ANDROID_BEAM_SETTINGS);
}
- keys.add(BluetoothMasterSwitchPreferenceController.KEY_TOGGLE_BLUETOOTH);
SmsMirroringFeatureProvider smsMirroringFeatureProvider =
FeatureFactory.getFactory(context).getSmsMirroringFeatureProvider();
SmsMirroringPreferenceController smsMirroringController =
smsMirroringFeatureProvider.getController(context);
smsMirroringController.updateNonIndexableKeys(keys);
重新编译验证,修改生效,设备已删除蓝牙功能