wifi直连设备名称
路径:Z:\luojun\MTK\vendor\packages\modules\Wifi\service\java\com\android\server\wifi\p2p\WifiP2pServiceImpl.java
代码:
private String getPersistedDeviceName() {
String deviceName = mSettingsConfigStore.get(WIFI_P2P_DEVICE_NAME);
if (null != deviceName) return deviceName;
String prefix = mWifiGlobals.getWifiP2pDeviceNamePrefix();
if (DEVICE_NAME_PREFIX_LENGTH_MAX < prefix.getBytes(StandardCharsets.UTF_8).length
|| 0 == prefix.getBytes(StandardCharsets.UTF_8).length) {
logw("The length of default device name prefix is invalid"
+ ", fallback to default name.");
prefix = DEFAULT_DEVICE_NAME_PREFIX;
}
// The length of remaining bytes is at least {@link #DEVICE_NAME_POSTFIX_LENGTH_MIN}.
int remainingBytes =
DEVICE_NAME_LENGTH_MAX - prefix.getBytes(StandardCharsets.UTF_8).length;
int numDigits = mWifiGlobals.getWifiP2pDeviceNamePostfixNumDigits();
if (numDigits > remainingBytes) {
logw("The postfix length exceeds the remaining byte number"
+ ", use the smaller one.");
numDigits = remainingBytes;
}
String postfix;
if (numDigits >= DEVICE_NAME_POSTFIX_LENGTH_MIN) {
postfix = StringUtil.generateRandomNumberString(numDigits);
} else {
// We use the 4 digits of the ANDROID_ID to have a friendly
// default that has low likelihood of collision with a peer
String id = mFrameworkFacade.getSecureStringSetting(mContext,
Settings.Secure.ANDROID_ID);
postfix = id.substring(0, 4);
}
logd("the default device name: " + prefix + postfix);
return prefix + postfix;
}