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;
    }
相关推荐
BduL OWED1 小时前
mysql的主从配置
android·mysql·adb
OPHKVPS2 小时前
Anthropic 为 Claude Code 推出“自动模式”:AI 编码工具迈向更高自主性
网络·人工智能·安全·ai
志栋智能2 小时前
超自动化运维的终极目标:让系统自治运行
运维·网络·人工智能·安全·自动化
人需要PID2 小时前
【卡尔曼工具箱-EKF-MATLAB应用】
android
3GPP仿真实验室2 小时前
【MATLAB源码】CSI-RS:测量链路
linux·网络·matlab
阿 才2 小时前
WSL2 + TFTP + 网络启动(Linux开发板与WSL2建立网络连接)
linux·运维·网络
SP八岐大兔2 小时前
AI对话&OpenClaw全域终极指令大全
网络·人工智能·openclaw
DfromY3 小时前
【随手记】YOCTO下MQTT使用简记
c语言·网络协议
llilian_163 小时前
信号失真度测试仪 自动失真测试仪 低失真度自动测量仪为各行业精准赋能 自动失真仪
网络·功能测试·单片机·测试工具
亘元有量-流量变现3 小时前
APP自动识别跳转各大应用商店(鸿蒙+iOS+安卓全品牌)|可直接部署落地页源码
android·ios·harmonyos