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;
    }
相关推荐
JoyCong19984 小时前
打破远程协助的安全信任困局,ToDesk AI审计功能自动操作留痕
网络·人工智能·科技·安全·电脑·远程工作
Mr.HeBoYan6 小时前
一次持续三天才出现的丢包故障——深入解析 DPDK Memory Ordering、rte_ring 与 CPU Memory Barrier (下)
linux·网络·算法·架构·dpdk
Xzaveir7 小时前
不要用一个状态表示“号码已认证”:企业号码身份的四域模型
android·人工智能
(Charon)8 小时前
【C++】手写 MySQL 连接池(二):同步连接的获取、加锁与释放
android
zhangjin11209 小时前
AOSP下载
android
Mico1810 小时前
MySQL 8.0.35 GTID 主从复制搭建-基于GITD
android·mysql·adb
kp0000010 小时前
System Prompt Leakage(系统提示词泄露)及安全防御
网络·安全·网络安全·信息安全·prompt·ai安全
许彰午10 小时前
02-网络的抽象层
网络·智能路由器
ttod_qzstudio10 小时前
【软考备考】计算机网络详解:OSI/TCP-IP 分层 + IP 子网划分,一篇拿下网络模块(附 10 道练习)
网络·tcp/ip·计算机网络·软考
Geek-Chow11 小时前
A Practical Tour of AWS Networking: VPCs, Subnets, Gateways, and More
网络·aws