原文地址:http://www.javashuo.com/article/p-nvkwjbca-mg.htmljava
1. wifi direct or wifi p2pandroid
默认名称为Android_XXXX.git
frameworks\opt\net\wifi\service\java\com\android\server\wifi\p2p\WifiP2pServiceImpl.java private String getPersistedDeviceName() { String deviceName = Settings.Global.getString(mContext.getContentResolver(), Settings.Global.WIFI_P2P_DEVICE_NAME); if (deviceName == null) { String wifi_direct_name = mContext.getResources().getString( R.string.def_wifi_direct_name); if (!TextUtils.isEmpty(wifi_direct_name)){ return wifi_direct_name; } /* 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 = Settings.Secure.getString(mContext.getContentResolver(), Settings.Secure.ANDROID_ID); return "Android_" + id.substring(0,4); } return deviceName; }
2. hotspot or softapdom
默认名称为Android_XXXX
ui
frameworks\opt\net\wifi\service\java\com\android\server\wifi\WifiApConfigStore.java /** * Generate a default WPA2 based configuration with a random password. * We are changing the Wifi Ap configuration storage from secure settings to a * flat file accessible only by the system. A WPA2 based default configuration * will keep the device secure after the update. */ private WifiConfiguration getDefaultApConfiguration() { WifiConfiguration config = new WifiConfiguration(); config.SSID = mContext.getResources().getString( R.string.wifi_tether_configure_ssid_default); int wifiApSecurityType = mContext.getResources().getInteger( R.integer.wifi_hotspot_security_type); config.allowedKeyManagement.set(wifiApSecurityType); config.preSharedKey = mContext.getResources().getString( R.string.def_wifi_wifihotspot_pass); if (TextUtils.isEmpty(config.preSharedKey)) { String randomUUID = UUID.randomUUID().toString(); //first 12 chars from xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx config.preSharedKey = randomUUID.substring(0, 8) + randomUUID.substring(9,13); } return config; } frameworks/base/core/res/res/values/strings.xml <string name="wifi_tether_configure_ssid_default" translatable="false">AndroidAP</string>
3. bluetooth.net
默认名称为QCOM-BTD
code
device/qcom/commom/bdroid_buildcfg.h #define BTM_DEF_LOCAL_NAME "QCOM-BTD" system/bt/btif/src/btif_dm.cc or vendor/qcom/opensource/commonsys/system/bt/btif/src/btif_dm.cc static char* btif_get_default_local_name() { if (btif_default_local_name[0] == '\0') { int max_len = sizeof(btif_default_local_name) - 1; if (BTM_DEF_LOCAL_NAME[0] != '\0') { //若该值定义,使用该值 strncpy(btif_default_local_name, BTM_DEF_LOCAL_NAME, max_len); } else { //若该值未定义,使用产品名PROPERTY_PRODUCT_MODEL(ro.product.model) char prop_model[PROPERTY_VALUE_MAX]; osi_property_get(PROPERTY_PRODUCT_MODEL, prop_model, ""); strncpy(btif_default_local_name, prop_model, max_len); } btif_default_local_name[max_len] = '\0'; } return btif_default_local_name; }