Android:更改热点的网关地址

问题描述 投票:1回答:1

有没有办法将Android的AP热点功能的网关地址从192.168.43.1更改为其他内容,如192.168.43.3,而无需重新编译任何内容?我有一个扎根的Android设备。

android wifi android-wifi personal-hotspot
1个回答
0
投票

您正在尝试更改已为Android热点硬编码的设置这是来自http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.0.1_r1/android/net/wifi/WifiStateMachine.java

private boolean startTethering(ArrayList<String> available) {                                 

    boolean wifiAvailable = false;                                                            

    checkAndSetConnectivityInstance();                                                         

    String[] wifiRegexs = mCm.getTetherableWifiRegexs();                                      

    for (String intf : available) {                                                           
        for (String regex : wifiRegexs) {                                                     
            if (intf.matches(regex)) {                                                        

                InterfaceConfiguration ifcg = null;                                           
                try {                                                                          
                    ifcg = mNwService.getInterfaceConfig(intf);                               
                    if (ifcg != null) {                                                       
                        /* IP/netmask: 192.168.43.1/255.255.255.0 */                           
                        ifcg.setLinkAddress(new LinkAddress(                                  
                                NetworkUtils.numericToInetAddress("192.168.43.1"), 24));       
                        ifcg.setInterfaceUp();                                                

                        mNwService.setInterfaceConfig(intf, ifcg);                            
                    }                                                                          
                } catch (Exception e) {                                                       
                    loge("Error configuring interface " + intf + ", :" + e);                  
                    return false;                                                              
                }                                                                              

                if(mCm.tether(intf) != ConnectivityManager.TETHER_ERROR_NO_ERROR) {           
                    loge("Error tethering on " + intf);                                       
                    return false;                                                              
                }                                                                              
                mTetherInterfaceName = intf;                                                  
                return true;                                                                   
            }                                                                                  
        }                                                                                      
    }                                                                                          
    // We found no interfaces to tether                                                        
    return false;                                                                              
} 

试试看这个答案https://android.stackexchange.com/questions/46499/how-configure-the-dhcp-settings-of-wifi-tetheringhotspot-in-android

© www.soinside.com 2019 - 2024. All rights reserved.