1. 程式人生 > >修改wifi direct/ hotspot/ Bluetooth預設名稱

修改wifi direct/ hotspot/ Bluetooth預設名稱

1. wifi direct or wifi p2p

預設名稱為Android_XXXX.

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) {
                // 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;
        }

P2pStateMachine

defined in frameworks/opt/net/wifi/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java

2. hotspot or softap

預設名稱為Android_XXXX.

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.apBand = WifiConfiguration.AP_BAND_2GHZ;
        config.SSID = mContext.getResources().getString(
                R.string.wifi_tether_configure_ssid_default) + "_" + getRandomIntForDefaultSsid();
        config.allowedKeyManagement.set(KeyMgmt.WPA2_PSK);
        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

預設名稱為QCOM-BTD

device/qcom/commom/bdroid_buildcfg.h

#define BTM_DEF_LOCAL_NAME   "QCOM-BTD"