系统设置--蓝牙--手机名称
1、手机名称的修改,定位到LocalDeviceNameDialogFragment中,如下:
@Override
protected String getDeviceName() {
if (mLocalAdapter != null && mLocalAdapter.isEnabled()) {
return mLocalAdapter.getName();
}
return null;
}
@Override
protected void setDeviceName(String deviceName) {
mLocalAdapter.setName(deviceName);
}
private LocalBluetoothAdapter mLocalAdapter;
frameworks/base/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothAdapter.java
public String getName() {
return mAdapter.getName();
}
/** This class does not allow direct access to the BluetoothAdapter. */
private final BluetoothAdapter mAdapter;
frameworks/base/core/java/android/bluetooth/BluetoothAdapter.java
public String getName() {
try {
return mManagerService.getName();
} catch (RemoteException e) {Log.e(TAG, "", e);}
return null;
}
BluetoothManagerService.java
public String getName() {
mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM,
"Need BLUETOOTH permission");
if ((Binder.getCallingUid() != Process.SYSTEM_UID) &&
(!checkIfCallerIsForegroundUser())) {
Slog.w(TAG,"getName(): not allowed for non-active and non system user");
return null;
}
try {
mBluetoothLock.readLock().lock();
if (mBluetooth != null) return mBluetooth.getName();
} catch (RemoteException e) {
Slog.e(TAG, "getName(): Unable to retrieve name remotely. Returning cached name", e);
} finally {
mBluetoothLock.readLock().unlock();
}
// mName is accessed from outside.
// It alright without a lock. Here, bluetooth is off, no other thread is
// changing mName
return mName;
}
mName = Settings.Secure.getString(mContentResolver, SECURE_SETTINGS_BLUETOOTH_NAME);
这里的bluetooth_name保存在/data/system/users/0/settings_secure.xml文件中。
在 Android6.0版本时,SettingsProvider被重构,Android 从性能、安全等方面考虑,把SettingsProvider 中原本保存在settings.db中的数据,目前全部保存在 XML 文件中。
具体修改地方:
device/qcom/common/bdroid_buildcfg.h
#define BTM_DEF_LOCAL_NAME "Acuteag-P6"
MTK平台,修改device目录下custom.conf文件中的bluetooth.HostName的值。
回贴