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;
    }
相关推荐
Kapaseker5 分钟前
Android 开发来看看 Kotlin 2.4.0 更新了个啥
android·kotlin
前端与小赵6 分钟前
快速生成安卓证书并打包生成安卓apk(保姆教程)
android·前端
代码熬夜敲Q9 分钟前
网络工程相关
linux·服务器·网络
呉師傅40 分钟前
EPSON爱普生 L3118打印头【喷头】清洗方法
运维·服务器·网络·学习·电脑
酿情师1 小时前
区块链网络与跨链操作03:区块链的分叉
网络·centos·区块链
TheRouter1 小时前
LLM 推理成本工程:从 Token 计量到分层路由的生产降本实践
网络·ai
小鸡毛程序员1 小时前
从零搭建 Linux 开发服务器:VMware NAT 静态网络 + Docker + MySQL + Redis + 云服务器迁移
linux·服务器·网络
xlq223221 小时前
64.TCP 可靠性与效率
网络·网络协议·tcp/ip
吃螺丝粉1 小时前
MySQL 5.7 到 9.7.0 LTS 升级核心指南
android
24zhgjx-lxq1 小时前
BGP路由黑洞
网络·安全·华为·智能路由器·hcip·ensp