当前位置:   article > 正文

Android 固定WIFI热点路由IP

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

  1. @@ -110,6 +110,7 @@ public class IpServer extends StateMachine {
  2. // TODO: have PanService use some visible version of this constant
  3. private static final String BLUETOOTH_IFACE_ADDR = "192.168.44.1/24";
  4. + private static final LinkAddress WIFI_HOST_IFACE_ADDR = new LinkAddress("192.168.43.1/24");
  5. // TODO: have this configurable
  6. private static final int DHCP_LEASE_TIME_SECS = 3600;
  7. @@ -597,7 +598,8 @@ public class IpServer extends StateMachine {
  8. if (VDBG) Log.d(TAG, "configureIPv4(" + enabled + ")");
  9. if (enabled) {
  10. - mIpv4Address = requestIpv4Address();
  11. + // mIpv4Address = requestIpv4Address();
  12. + mIpv4Address = WIFI_HOST_IFACE_ADDR;
  13. }
  14. if (mIpv4Address == null) {

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

  1. private boolean configureIPv4(boolean enabled) {
  2. if (VDBG) Log.d(TAG, "configureIPv4(" + enabled + ")");
  3. // TODO: Replace this hard-coded information with dynamically selected
  4. // config passed down to us by a higher layer IP-coordinating element.
  5. String ipAsString = null;
  6. int prefixLen = 0;
  7. if (mInterfaceType == ConnectivityManager.TETHERING_USB) {
  8. ipAsString = USB_NEAR_IFACE_ADDR;
  9. prefixLen = USB_PREFIX_LENGTH;
  10. } else if (mInterfaceType == ConnectivityManager.TETHERING_WIFI) {
  11. ipAsString = getRandomWifiIPv4Address();
  12. //ip固定设置为192.168.43.1
  13. ipAsString = "192.168.43.1";
  14. prefixLen = WIFI_HOST_IFACE_PREFIX_LENGTH;
  15. } else {
  16. // Nothing to do, BT does this elsewhere.
  17. return true;
  18. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/252743
推荐阅读
相关标签
  

闽ICP备14008679号