• Android 固定WIFI热点路由IP


    android11和安卓低版本一样固定WIFI热点路由器IP 的路径不同

    这个是在 android11上的修改:

    --- a/frameworks/base/packages/Tethering/src/android/net/ip/IpServer.java

    +++ b/frameworks/base/packages/Tethering/src/android/net/ip/IpServer.java

    1. @@ -110,6 +110,7 @@ public class IpServer extends StateMachine {
    2. // TODO: have PanService use some visible version of this constant
    3. private static final String BLUETOOTH_IFACE_ADDR = "192.168.44.1/24";
    4. + private static final LinkAddress WIFI_HOST_IFACE_ADDR = new LinkAddress("192.168.43.1/24");
    5. // TODO: have this configurable
    6. private static final int DHCP_LEASE_TIME_SECS = 3600;
    7. @@ -597,7 +598,8 @@ public class IpServer extends StateMachine {
    8. if (VDBG) Log.d(TAG, "configureIPv4(" + enabled + ")");
    9. if (enabled) {
    10. - mIpv4Address = requestIpv4Address();
    11. + // mIpv4Address = requestIpv4Address();
    12. + mIpv4Address = WIFI_HOST_IFACE_ADDR;
    13. }
    14. if (mIpv4Address == null) {

    android 9修改路径frameworks/base/services/core/java/com/android/server/connectivity/tethering/TetherInterfaceStateMachine.java

    1. private boolean configureIPv4(boolean enabled) {
    2. if (VDBG) Log.d(TAG, "configureIPv4(" + enabled + ")");
    3. // TODO: Replace this hard-coded information with dynamically selected
    4. // config passed down to us by a higher layer IP-coordinating element.
    5. String ipAsString = null;
    6. int prefixLen = 0;
    7. if (mInterfaceType == ConnectivityManager.TETHERING_USB) {
    8. ipAsString = USB_NEAR_IFACE_ADDR;
    9. prefixLen = USB_PREFIX_LENGTH;
    10. } else if (mInterfaceType == ConnectivityManager.TETHERING_WIFI) {
    11. ipAsString = getRandomWifiIPv4Address();
    12. //ip固定设置为192.168.43.1
    13. ipAsString = "192.168.43.1";
    14. prefixLen = WIFI_HOST_IFACE_PREFIX_LENGTH;
    15. } else {
    16. // Nothing to do, BT does this elsewhere.
    17. return true;
    18. }

  • 相关阅读:
    由gomonkey引发的一些思考
    使用wireshark抓取Tcp三次握手
    解决哈希冲突的几种方式
    HTML5 Canvas绘制图形从入门到精通
    Docker部署jenkins容器时,允许jenkins容器内部控制宿主机上的docker
    C++为什么始终无法取代 C 吗?
    初识Linux
    docker-desktop启动k8s
    进程地址空间(Linux虚拟内存机制)
    【Java】I/O流—缓冲流的基础入门和文件拷贝的实战应用
  • 原文地址:https://blog.csdn.net/BOJUE01/article/details/136658093