最近遇到一个安卓6.0的项目,客户要求额外出一个固件专门用于清海关,这个固件其中有一个要求就是去掉所有蓝牙功能,意义在于海关检查设备机器,如果机器没有蓝牙功能可以少交点税,如下就是去掉系统中几个关于蓝牙的功能的记录:

1. 去掉下拉状态栏中的蓝牙快捷设置:到frameworks/base/packages/SystemUI/res/values/config.xml文件中的quick_settings_tiles_default属性中去掉bt即可

 

2. 去掉系统设置中的蓝牙菜单条目: 如下补丁所示

diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 8529a03..a7519ca 100755
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -376,7 +376,7 @@
                        android:value="com.android.settings.ApnSettings" />
         </activity>
 
-        <activity android:name="Settings$BluetoothSettingsActivity"
+        <!-- activity android:name="Settings$BluetoothSettingsActivity"
                 android:label="@string/bluetooth_settings_title"
                 android:taskAffinity="">
             <intent-filter android:priority="1">
@@ -393,10 +393,10 @@
                 android:value="com.android.settings.bluetooth.BluetoothSettings" />
             <meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
                 android:resource="@id/bluetooth_settings" />
-        </activity>
+        </activity -->
 
         <!-- Keep compatibility with old shortcuts. -->
-        <activity-alias android:name=".bluetooth.BluetoothSettings"
+        <!-- activity-alias android:name=".bluetooth.BluetoothSettings"
                 android:label="@string/bluetooth_settings_title"
                 android:targetActivity="Settings$BluetoothSettingsActivity"
                 android:exported="true"
@@ -405,7 +405,7 @@
                 android:value="com.android.settings.bluetooth.BluetoothSettings" />
             <meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
                 android:resource="@id/bluetooth_settings" />
-        </activity-alias>
+        </activity-alias -->
 
         <activity android:name=".bluetooth.DevicePickerActivity"
                 android:theme="@style/Theme.SubSettingsDialogWhenLarge"
diff --git a/res/xml/dashboard_categories.xml b/res/xml/dashboard_categories.xml
index 47c28ec..7793799 100755
--- a/res/xml/dashboard_categories.xml
+++ b/res/xml/dashboard_categories.xml
@@ -32,12 +32,12 @@
                 />
 
         <!-- Bluetooth -->
-        <dashboard-tile
+        <!-- dashboard-tile
                 android:id="@+id/bluetooth_settings"
                 android:title="@string/bluetooth_settings_title"
                 android:fragment="com.android.settings.bluetooth.BluetoothSettings"
                 android:icon="@drawable/ic_settings_bluetooth"
-                />
+                / -->
 
         <!-- SIM Cards -->
         <dashboard-tile
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index b7614ea..6b3b129 100755
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -261,7 +261,7 @@ public class SettingsActivity extends Activity
     private int[] SETTINGS_FOR_RESTRICTED = {
             R.id.wireless_section,
             R.id.wifi_settings,
-            R.id.bluetooth_settings,
+            //R.id.bluetooth_settings,
             R.id.data_usage_settings,
             R.id.sim_settings,
             R.id.wireless_settings,
@@ -1257,12 +1257,12 @@ public class SettingsActivity extends Activity
                     if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI)) {
                         removeTile = true;
                     }
-                } else if (id == R.id.bluetooth_settings) {
+                } /*else if (id == R.id.bluetooth_settings) {
                     // Remove Bluetooth Settings if Bluetooth service is not available.
                     if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)||(SystemProperties.get("ro.rk.bt_enable", "true").equals("false"))) {
                         removeTile = true;
                     }
-                } else if (id == R.id.data_usage_settings) {
+                }*/ else if (id == R.id.data_usage_settings) {
                     // Remove data usage when kernel module not enabled
                     if (!Utils.isBandwidthControlEnabled()) {
                         removeTile = true;

3. 去掉设置-更多-网络共享和便携式热点里面的《蓝牙共享网络》这项:

到packages/apps/Settings/src/com/android/settings/TetherSettings.java类中的onCreate()方法中最后添加
                    getPreferenceScreen().removePreference(mBluetoothTether);这行代码即可

 

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐