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

java 复制代码
@@ -110,6 +110,7 @@ public class IpServer extends StateMachine {

     // TODO: have PanService use some visible version of this constant
     private static final String BLUETOOTH_IFACE_ADDR = "192.168.44.1/24";
+    private static final LinkAddress WIFI_HOST_IFACE_ADDR = new LinkAddress("192.168.43.1/24");

     // TODO: have this configurable
     private static final int DHCP_LEASE_TIME_SECS = 3600;
@@ -597,7 +598,8 @@ public class IpServer extends StateMachine {
         if (VDBG) Log.d(TAG, "configureIPv4(" + enabled + ")");

         if (enabled) {
-            mIpv4Address = requestIpv4Address();
+           // mIpv4Address = requestIpv4Address();
+          mIpv4Address = WIFI_HOST_IFACE_ADDR;
         }

         if (mIpv4Address == null) {

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

java 复制代码
private boolean configureIPv4(boolean enabled) {
    if (VDBG) Log.d(TAG, "configureIPv4(" + enabled + ")");

    // TODO: Replace this hard-coded information with dynamically selected
    // config passed down to us by a higher layer IP-coordinating element.
    String ipAsString = null;
    int prefixLen = 0;
    if (mInterfaceType == ConnectivityManager.TETHERING_USB) {
        ipAsString = USB_NEAR_IFACE_ADDR;
        prefixLen = USB_PREFIX_LENGTH;
    } else if (mInterfaceType == ConnectivityManager.TETHERING_WIFI) {
        ipAsString = getRandomWifiIPv4Address();
        //ip固定设置为192.168.43.1
        ipAsString = "192.168.43.1";
        prefixLen = WIFI_HOST_IFACE_PREFIX_LENGTH;
    } else {
        // Nothing to do, BT does this elsewhere.
        return true;
    }
相关推荐
用户2530171996273 小时前
第6篇:从技术到产品 — Ghost Proxifier 的设计哲学
网络协议
用户2530171996274 小时前
第3篇:注入的艺术 — Ghost Proxifier 核心架构拆解
网络协议
通玄7 小时前
Jetpack Compose 入门系列(六):Navigation 3 页面导航
android
rocpp9 小时前
Android 多语言切换实战:从 Context 到 Android 13 应用语言适配
android·kotlin
释然小师弟10 小时前
Android开发十年:反思与回顾
android·后端·嵌入式
黄林晴12 小时前
用了这么久 Koin Scope,原来一直都用错了?
android·kotlin
爱勇宝1 天前
我做了一个只用来搜歌词的小 App
android·前端·后端
众少成多积小致巨1 天前
JNI (Java Native Interface) 技术手册中文参考指南
android·java·c++
Coffeeee1 天前
如何使用Glide和Coil加载WebP动图
android·kotlin·glide
王二端茶倒水1 天前
商业 WiFi 不是免费上网,而是门店数字化的入口
网络协议