diff options
Diffstat (limited to 'Tethering/src/com/android/networkstack/tethering/TetheringConfiguration.java')
| -rw-r--r-- | Tethering/src/com/android/networkstack/tethering/TetheringConfiguration.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Tethering/src/com/android/networkstack/tethering/TetheringConfiguration.java b/Tethering/src/com/android/networkstack/tethering/TetheringConfiguration.java index eaf85899a1..f9f3ed9cc9 100644 --- a/Tethering/src/com/android/networkstack/tethering/TetheringConfiguration.java +++ b/Tethering/src/com/android/networkstack/tethering/TetheringConfiguration.java @@ -149,6 +149,7 @@ public class TetheringConfiguration { // TODO: Add to TetheringConfigurationParcel if required. private final boolean mEnableBpfOffload; private final boolean mEnableWifiP2pDedicatedIp; + private final int mP2pLeasesSubnetPrefixLength; private final int mUsbTetheringFunction; protected final ContentResolver mContentResolver; @@ -214,9 +215,27 @@ public class TetheringConfiguration { R.bool.config_tether_enable_legacy_wifi_p2p_dedicated_ip, false /* defaultValue */); + mP2pLeasesSubnetPrefixLength = getP2pLeasesSubnetPrefixLengthFromRes(res, configLog); + configLog.log(toString()); } + private int getP2pLeasesSubnetPrefixLengthFromRes(final Resources res, final SharedLog log) { + if (!mEnableWifiP2pDedicatedIp) return 0; + + int prefixLength = getResourceInteger(res, + R.integer.config_p2p_leases_subnet_prefix_length, 0 /* default value */); + + // DhcpLeaseRepository ignores the first and last addresses of the range so the max prefix + // length is 30. + if (prefixLength < 0 || prefixLength > 30) { + log.e("Invalid p2p leases subnet prefix length configuration: " + prefixLength); + return 0; + } + + return prefixLength; + } + /** Check whether using legacy dhcp server. */ public boolean useLegacyDhcpServer() { return mEnableLegacyDhcpServer; @@ -272,6 +291,15 @@ public class TetheringConfiguration { return mEnableWifiP2pDedicatedIp; } + /** + * Get subnet prefix length of dhcp leases for wifi p2p. + * This feature only support when wifi p2p use dedicated address. If + * #shouldEnableWifiP2pDedicatedIp is false, this method would always return 0. + */ + public int getP2pLeasesSubnetPrefixLength() { + return mP2pLeasesSubnetPrefixLength; + } + /** Does the dumping.*/ public void dump(PrintWriter pw) { pw.print("activeDataSubId: "); @@ -310,6 +338,9 @@ public class TetheringConfiguration { pw.print("enableWifiP2pDedicatedIp: "); pw.println(mEnableWifiP2pDedicatedIp); + pw.print("p2pLeasesSubnetPrefixLength: "); + pw.println(mP2pLeasesSubnetPrefixLength); + pw.print("mUsbTetheringFunction: "); pw.println(isUsingNcm() ? "NCM" : "RNDIS"); } |
