0%

安卓12 设置热点固定IP (Xposed)

项目地址

SoftApHelper

Hook点

仍然是android.net.ip.IpServerrequestIpv4Address函数。

IpServer.java#655

1
2
3
4
5
6
7
8
9
private LinkAddress requestIpv4Address(final boolean useLastAddress) {
if (mStaticIpv4ServerAddr != null) return mStaticIpv4ServerAddr;

if (mInterfaceType == TetheringManager.TETHERING_BLUETOOTH) {
return new LinkAddress(BLUETOOTH_IFACE_ADDR);
}

return mPrivateAddressCoordinator.requestDownstreamAddress(this, useLastAddress);
}

参数增加了一个boolean useLastAddress,加上即可。

通过反射调用getDeclaredMethods获取方法,从而适配安卓11和12。

Hook代码

见GitHub:MainHook.java