Android11去掉掉连接偏好里的【蓝牙】、【投射】、【通过蓝牙收到的文件】这三个菜单

碰到一个不要wifi不要蓝牙的项目,客户要求去掉Settings中跟蓝牙相关的功能菜单条目,因为硬件都不贴,所以软件对应也要去掉,因为ic芯片是蓝牙wifi是二合一的,所以其实wifi也是不支持的,这里只讲述去掉蓝牙相关菜单,具体修改如下:packages/apps/Settings目录下

java 复制代码
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
old mode 100644
new mode 100755
index 16b29dc..29f878e
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -411,7 +411,7 @@
         </activity>
 
         <!-- Keep compatibility with old shortcuts. -->
-        <activity-alias
+        <!-- activity-alias
             android:name="Settings$BluetoothSettingsActivity"
             android:label="@string/devices_title"
             android:targetActivity=".Settings$ConnectedDeviceDashboardActivity"
@@ -422,17 +422,17 @@
             </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment" />
-        </activity-alias>
+        </activity-alias -->
 
         <!-- Keep compatibility with old shortcuts. -->
-        <activity-alias android:name=".bluetooth.BluetoothSettings"
+        <!-- activity-alias android:name=".bluetooth.BluetoothSettings"
                         android:label="@string/devices_title"
                         android:targetActivity="Settings$BluetoothSettingsActivity"
                         android:exported="true"
                         android:clearTaskOnLaunch="true">
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                        android:value="com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment" />
-        </activity-alias>
+        </activity-alias -->
 
         <activity android:name="Settings$AssistGestureSettingsActivity"
             android:label="@string/assist_gesture_title"
@@ -2151,7 +2151,7 @@
                 android:value="true" />
         </activity>
 
-        <activity
+        <!-- activity
             android:name="Settings$WifiDisplaySettingsActivity"
             android:label="@string/wifi_display_settings_title"
             android:icon="@drawable/ic_cast_24dp">
@@ -2161,7 +2161,7 @@
             </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.wfd.WifiDisplaySettings" />
-        </activity>
+        </activity -->
 
         <activity android:name="Settings$TestingSettingsActivity" android:label="@string/testing">
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
diff --git a/res/xml/connected_devices.xml b/res/xml/connected_devices.xml
old mode 100644
new mode 100755
index e7e3c2c..c137590
--- a/res/xml/connected_devices.xml
+++ b/res/xml/connected_devices.xml
@@ -60,7 +60,7 @@
             android:order="10"
             settings:searchable="false"
             android:fragment="com.android.settings.connecteddevice.PreviouslyConnectedDeviceDashboardFragment"/>
-    </PreferenceCategory>
+    </PreferenceCategory >
 
     <Preference
         android:key="connection_preferences"
@@ -70,11 +70,11 @@
         settings:allowDividerAbove="true"
         settings:controller="com.android.settings.connecteddevice.AdvancedConnectedDeviceController"/>
 
-    <com.android.settingslib.widget.FooterPreference
+    <!-- com.android.settingslib.widget.FooterPreference
         android:key="discoverable_footer"
         android:title="@string/bluetooth_off_footer"
         android:selectable="false"
         settings:controller="com.android.settings.connecteddevice.DiscoverableFooterPreferenceController">
-    </com.android.settingslib.widget.FooterPreference>
+    </com.android.settingslib.widget.FooterPreference -->
 
 </PreferenceScreen>
diff --git a/res/xml/connected_devices_advanced.xml b/res/xml/connected_devices_advanced.xml
old mode 100644
new mode 100755
index 3ff7d99..3fe6140
--- a/res/xml/connected_devices_advanced.xml
+++ b/res/xml/connected_devices_advanced.xml
@@ -19,12 +19,12 @@
     xmlns:settings="http://schemas.android.com/apk/res-auto"
     android:title="@string/connected_device_connections_title">
 
-    <Preference
+    <!-- Preference
         android:fragment="com.android.settings.connecteddevice.BluetoothDashboardFragment"
         android:key="bluetooth_switchbar_screen"
         android:title="@string/bluetooth_settings_title"
         android:icon="@*android:drawable/ic_settings_bluetooth"
-        android:order="-9"/>
+        android:order="-9"/-->
 
     <Preference
         android:fragment="com.android.settings.connecteddevice.NfcAndPaymentFragment"
@@ -35,14 +35,14 @@
         settings:searchable="false"
         settings:controller="com.android.settings.connecteddevice.NfcAndPaymentFragmentController"/>
 
-    <Preference
+    <!-- Preference
         android:fragment="com.android.settings.wfd.WifiDisplaySettings"
         android:key="wifi_display_settings"
         android:title="@string/wifi_display_settings_title"
         android:icon="@drawable/ic_cast_24dp"
         android:order="-6"
         settings:controller="com.android.settings.wfd.WifiDisplayPreferenceController"
-        settings:keywords="@string/keywords_wifi_display_settings"/>
+        settings:keywords="@string/keywords_wifi_display_settings"/ -->
 
     <com.android.settingslib.RestrictedPreference
         android:fragment="com.android.settings.nfc.AndroidBeam"
@@ -60,10 +60,10 @@
         android:fragment="com.android.settings.print.PrintSettingsFragment"
         android:order="-3"/>
 
-    <Preference
+    <!-- Preference
         android:key="bt_received_files"
         android:icon="@drawable/ic_folder_vd_theme_24"
-        android:title="@string/bluetooth_show_files_received_via_bluetooth"/>
+        android:title="@string/bluetooth_show_files_received_via_bluetooth"/ -->
 
     <PreferenceCategory
         android:key="dashboard_tile_placeholder"
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
old mode 100644
new mode 100755
index e94e647..a1ae81d
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -33,7 +33,7 @@ public class Settings extends SettingsActivity {
     * Settings subclasses for launching independently.
     */
     public static class AssistGestureSettingsActivity extends SettingsActivity { /* empty */}
-    public static class BluetoothSettingsActivity extends SettingsActivity { /* empty */ }
+    //public static class BluetoothSettingsActivity extends SettingsActivity { /* empty */ }
     public static class CreateShortcutActivity extends SettingsActivity { /* empty */ }
     public static class FaceSettingsActivity extends SettingsActivity { /* empty */ }
     public static class FingerprintSettingsActivity extends SettingsActivity { /* empty */ }
@@ -131,7 +131,7 @@ public class Settings extends SettingsActivity {
     public static class SavedAccessPointsSettingsActivity extends SettingsActivity { /* empty */ }
     public static class TextToSpeechSettingsActivity extends SettingsActivity { /* empty */ }
     public static class AndroidBeamSettingsActivity extends SettingsActivity { /* empty */ }
-    public static class WifiDisplaySettingsActivity extends SettingsActivity { /* empty */ }
+    //public static class WifiDisplaySettingsActivity extends SettingsActivity { /* empty */ }
     public static class DreamSettingsActivity extends SettingsActivity { /* empty */ }
     public static class NotificationStationActivity extends SettingsActivity { /* empty */ }
     public static class UserSettingsActivity extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
old mode 100644
new mode 100755
index 76739f0..0657cd0
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -605,14 +605,15 @@ public class SettingsActivity extends SettingsBaseActivity
         boolean somethingChanged = false;
         final String packageName = getPackageName();
         final StringBuilder changedList = new StringBuilder();
-        somethingChanged = setTileEnabled(changedList,
+               Log.d("wzh","FEATURE_WIFI = " + pm.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH) + "----FEATURE_BLUETOOTH = " + pm.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH));
+        /*somethingChanged = setTileEnabled(changedList,
                 new ComponentName(packageName, WifiSettingsActivity.class.getName()),
-                pm.hasSystemFeature(PackageManager.FEATURE_WIFI), isAdmin) || somethingChanged;
+                pm.hasSystemFeature(PackageManager.FEATURE_WIFI), isAdmin) || somethingChanged;*/
 
-        somethingChanged = setTileEnabled(changedList, new ComponentName(packageName,
+        /*somethingChanged = setTileEnabled(changedList, new ComponentName(packageName,
                         Settings.BluetoothSettingsActivity.class.getName()),
                 pm.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH), isAdmin)
-                || somethingChanged;
+                || somethingChanged;*/
 
         // Enable DataUsageSummaryActivity if the data plan feature flag is turned on otherwise
         // enable DataPlanUsageSummaryActivity.
@@ -649,10 +650,10 @@ public class SettingsActivity extends SettingsBaseActivity
                 showDev, isAdmin)
                 || somethingChanged;
 
-        somethingChanged = setTileEnabled(changedList, new ComponentName(packageName,
+        /*somethingChanged = setTileEnabled(changedList, new ComponentName(packageName,
                         Settings.WifiDisplaySettingsActivity.class.getName()),
                 WifiDisplaySettings.isAvailable(this), isAdmin)
-                || somethingChanged;
+                || somethingChanged;*/
 
         somethingChanged = setTileEnabled(changedList, new ComponentName(packageName,
                         Settings.ScreenshotSettingsActivity.class.getName()),
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
old mode 100644
new mode 100755
index 77adbf0..51116ee
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -337,8 +337,8 @@ public class SettingsGateway {
             Settings.WifiSettings2Activity.class.getName(),
             Settings.DataUsageSummaryActivity.class.getName(),
             // Home page > Connected devices
-            Settings.BluetoothSettingsActivity.class.getName(),
-            Settings.WifiDisplaySettingsActivity.class.getName(),
+            //Settings.BluetoothSettingsActivity.class.getName(),
+            //Settings.WifiDisplaySettingsActivity.class.getName(),
             Settings.PrintSettingsActivity.class.getName(),
             // Home page > Apps & Notifications
             Settings.UserSettingsActivity.class.getName(),
diff --git a/src/com/android/settings/wifi/WifiMasterSwitchPreferenceController.java b/src/com/android/settings/wifi/WifiMasterSwitchPreferenceController.java
old mode 100644
new mode 100755
index 1e18c59..0c07938
--- a/src/com/android/settings/wifi/WifiMasterSwitchPreferenceController.java
+++ b/src/com/android/settings/wifi/WifiMasterSwitchPreferenceController.java
@@ -55,6 +55,9 @@ public class WifiMasterSwitchPreferenceController extends AbstractPreferenceCont
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         mWifiPreference = screen.findPreference(KEY_TOGGLE_WIFI);
+
+               mWifiPreference.setEnabled(false);
+        mWifiPreference.setSwitchEnabled(false);
     }
 
     @Override
@@ -85,8 +88,8 @@ public class WifiMasterSwitchPreferenceController extends AbstractPreferenceCont
 
     @Override
     public void onStart() {
-        mWifiEnabler = new WifiEnabler(mContext, new MasterSwitchController(mWifiPreference),
-            mMetricsFeatureProvider);
+        //mWifiEnabler = new WifiEnabler(mContext, new MasterSwitchController(mWifiPreference),
+        //    mMetricsFeatureProvider);
     }
 
     @Override
相关推荐
Daniel 大东16 分钟前
idea 解决缓存损坏问题
java·缓存·intellij-idea
wind瑞22 分钟前
IntelliJ IDEA插件开发-代码补全插件入门开发
java·ide·intellij-idea
HappyAcmen22 分钟前
IDEA部署AI代写插件
java·人工智能·intellij-idea
马剑威(威哥爱编程)28 分钟前
读写锁分离设计模式详解
java·设计模式·java-ee
鸽鸽程序猿28 分钟前
【算法】【优选算法】前缀和(上)
java·算法·前缀和
修道-032329 分钟前
【JAVA】二、设计模式之策略模式
java·设计模式·策略模式
九圣残炎35 分钟前
【从零开始的LeetCode-算法】2559. 统计范围内的元音字符串数
java·算法·leetcode
当归10241 小时前
若依项目-结构解读
java
hlsd#1 小时前
关于 SpringBoot 时间处理的总结
java·spring boot·后端
iiiiiankor1 小时前
C/C++内存管理 | new的机制 | 重载自己的operator new
java·c语言·c++