如果修改机器被其他设置搜索到的蓝牙名称即打开蓝牙在其他设备上搜索到的机器名称。可以尝试修改以下代码.\vendor\mediatek\proprietary\packages\apps\Bluetooth\src\com\android\bluetooth\btservice\AdapterProperties.javapublic void init(RemoteDevices remoteDevices) {mProfileConnectionState.clear();mRemoteDevices remoteDevices;//修改蓝牙名称开始setName(MTR M17 Plus);//修改蓝牙名称结束// Get default max connected audio devices from config.xml in frameworks/base/coreint configDefaultMaxConnectedAudioDevices mService.getResources().getInteger(com.android.internal.R.integer.config_bluetooth_max_connected_audio_devices);// Override max connected audio devices if MAX_CONNECTED_AUDIO_DEVICES_PROPERTY is setint propertyOverlayedMaxConnectedAudioDevices SystemProperties.getInt(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY,configDefaultMaxConnectedAudioDevices);// Make sure the final value of max connected audio devices is within allowed rangemMaxConnectedAudioDevices Math.min(Math.max(propertyOverlayedMaxConnectedAudioDevices,MAX_CONNECTED_AUDIO_DEVICES_LOWER_BOND), MAX_CONNECTED_AUDIO_DEVICES_UPPER_BOUND);Log.i(TAG, init(), maxConnectedAudioDevices, default configDefaultMaxConnectedAudioDevices , propertyOverlayed propertyOverlayedMaxConnectedAudioDevices , finalValue mMaxConnectedAudioDevices);mA2dpOffloadEnabled SystemProperties.getBoolean(A2DP_OFFLOAD_SUPPORTED_PROPERTY, false) !SystemProperties.getBoolean(A2DP_OFFLOAD_DISABLED_PROPERTY, false);IntentFilter filter new IntentFilter();filter.addAction(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED);filter.addAction(BluetoothHeadsetClient.ACTION_CONNECTION_STATE_CHANGED);filter.addAction(BluetoothHearingAid.ACTION_CONNECTION_STATE_CHANGED);filter.addAction(BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED);filter.addAction(BluetoothA2dpSink.ACTION_CONNECTION_STATE_CHANGED);filter.addAction(BluetoothHidDevice.ACTION_CONNECTION_STATE_CHANGED);filter.addAction(BluetoothHidHost.ACTION_CONNECTION_STATE_CHANGED);filter.addAction(BluetoothAvrcpController.ACTION_CONNECTION_STATE_CHANGED);filter.addAction(BluetoothPan.ACTION_CONNECTION_STATE_CHANGED);filter.addAction(BluetoothMap.ACTION_CONNECTION_STATE_CHANGED);filter.addAction(BluetoothMapClient.ACTION_CONNECTION_STATE_CHANGED);filter.addAction(BluetoothSap.ACTION_CONNECTION_STATE_CHANGED);filter.addAction(BluetoothPbapClient.ACTION_CONNECTION_STATE_CHANGED);if (mService ! null) {mService.registerReceiver(mReceiver, filter);mReceiverRegistered true;}}在另一个地方进行同步设置void onBluetoothReady() {debugLog(onBluetoothReady, state BluetoothAdapter.nameForState(getState()) , ScanMode mScanMode);synchronized (mObject) {// Reset adapter and profile connection statesif (mProfilesConnected 0 mProfilesConnecting 0 mProfilesDisconnecting 0) {setConnectionState(BluetoothAdapter.STATE_DISCONNECTED);mProfileConnectionState.clear();mProfilesConnected 0;mProfilesConnecting 0;mProfilesDisconnecting 0;}//修改蓝牙名称开始String currentName getName();if (!MTR M17 Plus.equals(currentName)) {boolean result setName(MTR M17 Plus);Log.i(TAG, Set Bluetooth name to MTR M17 Plus, result result (was: currentName ));}//修改蓝牙名称结束// adapterPropertyChangedCallback has already been received. Set the scan mode.setScanMode(AbstractionLayer.BT_SCAN_MODE_CONNECTABLE);// This keeps NV up-to date on first-boot after flash.setDiscoverableTimeout(mDiscoverableTimeout);}}
Android MTK6737 Q版本上修改蓝牙名称
如果修改机器被其他设置搜索到的蓝牙名称即打开蓝牙在其他设备上搜索到的机器名称。可以尝试修改以下代码.\vendor\mediatek\proprietary\packages\apps\Bluetooth\src\com\android\bluetooth\btservice\AdapterProperties.javapublic void init(RemoteDevices remoteDevices) {mProfileConnectionState.clear();mRemoteDevices remoteDevices;//修改蓝牙名称开始setName(MTR M17 Plus);//修改蓝牙名称结束// Get default max connected audio devices from config.xml in frameworks/base/coreint configDefaultMaxConnectedAudioDevices mService.getResources().getInteger(com.android.internal.R.integer.config_bluetooth_max_connected_audio_devices);// Override max connected audio devices if MAX_CONNECTED_AUDIO_DEVICES_PROPERTY is setint propertyOverlayedMaxConnectedAudioDevices SystemProperties.getInt(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY,configDefaultMaxConnectedAudioDevices);// Make sure the final value of max connected audio devices is within allowed rangemMaxConnectedAudioDevices Math.min(Math.max(propertyOverlayedMaxConnectedAudioDevices,MAX_CONNECTED_AUDIO_DEVICES_LOWER_BOND), MAX_CONNECTED_AUDIO_DEVICES_UPPER_BOUND);Log.i(TAG, init(), maxConnectedAudioDevices, default configDefaultMaxConnectedAudioDevices , propertyOverlayed propertyOverlayedMaxConnectedAudioDevices , finalValue mMaxConnectedAudioDevices);mA2dpOffloadEnabled SystemProperties.getBoolean(A2DP_OFFLOAD_SUPPORTED_PROPERTY, false) !SystemProperties.getBoolean(A2DP_OFFLOAD_DISABLED_PROPERTY, false);IntentFilter filter new IntentFilter();filter.addAction(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED);filter.addAction(BluetoothHeadsetClient.ACTION_CONNECTION_STATE_CHANGED);filter.addAction(BluetoothHearingAid.ACTION_CONNECTION_STATE_CHANGED);filter.addAction(BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED);filter.addAction(BluetoothA2dpSink.ACTION_CONNECTION_STATE_CHANGED);filter.addAction(BluetoothHidDevice.ACTION_CONNECTION_STATE_CHANGED);filter.addAction(BluetoothHidHost.ACTION_CONNECTION_STATE_CHANGED);filter.addAction(BluetoothAvrcpController.ACTION_CONNECTION_STATE_CHANGED);filter.addAction(BluetoothPan.ACTION_CONNECTION_STATE_CHANGED);filter.addAction(BluetoothMap.ACTION_CONNECTION_STATE_CHANGED);filter.addAction(BluetoothMapClient.ACTION_CONNECTION_STATE_CHANGED);filter.addAction(BluetoothSap.ACTION_CONNECTION_STATE_CHANGED);filter.addAction(BluetoothPbapClient.ACTION_CONNECTION_STATE_CHANGED);if (mService ! null) {mService.registerReceiver(mReceiver, filter);mReceiverRegistered true;}}在另一个地方进行同步设置void onBluetoothReady() {debugLog(onBluetoothReady, state BluetoothAdapter.nameForState(getState()) , ScanMode mScanMode);synchronized (mObject) {// Reset adapter and profile connection statesif (mProfilesConnected 0 mProfilesConnecting 0 mProfilesDisconnecting 0) {setConnectionState(BluetoothAdapter.STATE_DISCONNECTED);mProfileConnectionState.clear();mProfilesConnected 0;mProfilesConnecting 0;mProfilesDisconnecting 0;}//修改蓝牙名称开始String currentName getName();if (!MTR M17 Plus.equals(currentName)) {boolean result setName(MTR M17 Plus);Log.i(TAG, Set Bluetooth name to MTR M17 Plus, result result (was: currentName ));}//修改蓝牙名称结束// adapterPropertyChangedCallback has already been received. Set the scan mode.setScanMode(AbstractionLayer.BT_SCAN_MODE_CONNECTABLE);// This keeps NV up-to date on first-boot after flash.setDiscoverableTimeout(mDiscoverableTimeout);}}