Loading packages/Tethering/src/com/android/networkstack/tethering/PrivateAddressCoordinator.java +5 −6 Original line number Diff line number Diff line Loading @@ -80,11 +80,6 @@ public class PrivateAddressCoordinator { private final SparseArray<LinkAddress> mCachedAddresses; public PrivateAddressCoordinator(Context context, TetheringConfiguration config) { this(context, config, new ArrayList<>(Arrays.asList(new IpPrefix("192.168.0.0/16")))); } public PrivateAddressCoordinator(Context context, TetheringConfiguration config, List<IpPrefix> prefixPools) { mDownstreams = new ArraySet<>(); mUpstreamPrefixMap = new ArrayMap<>(); mConnectivityMgr = (ConnectivityManager) context.getSystemService( Loading @@ -95,7 +90,11 @@ public class PrivateAddressCoordinator { mCachedAddresses.put(TETHERING_BLUETOOTH, new LinkAddress(LEGACY_BLUETOOTH_IFACE_ADDRESS)); mCachedAddresses.put(TETHERING_WIFI_P2P, new LinkAddress(LEGACY_WIFI_P2P_IFACE_ADDRESS)); mTetheringPrefixes = prefixPools; mTetheringPrefixes = new ArrayList<>(Arrays.asList(new IpPrefix("192.168.0.0/16"))); if (config.isSelectAllPrefixRangeEnabled()) { mTetheringPrefixes.add(new IpPrefix("172.16.0.0/12")); mTetheringPrefixes.add(new IpPrefix("10.0.0.0/8")); } } /** Loading packages/Tethering/src/com/android/networkstack/tethering/TetheringConfiguration.java +21 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,6 @@ import java.util.Arrays; import java.util.Collection; import java.util.StringJoiner; /** * A utility class to encapsulate the various tethering configuration elements. * Loading Loading @@ -87,6 +86,13 @@ public class TetheringConfiguration { public static final String USE_LEGACY_WIFI_P2P_DEDICATED_IP = "use_legacy_wifi_p2p_dedicated_ip"; /** * Flag use to enable select all prefix ranges feature. * TODO: Remove this flag if there are no problems after M-2020-12 rolls out. */ public static final String TETHER_ENABLE_SELECT_ALL_PREFIX_RANGES = "tether_enable_select_all_prefix_ranges"; /** * Default value that used to periodic polls tether offload stats from tethering offload HAL * to make the data warnings work. Loading Loading @@ -118,6 +124,8 @@ public class TetheringConfiguration { private final boolean mEnableBpfOffload; private final boolean mEnableWifiP2pDedicatedIp; private final boolean mEnableSelectAllPrefixRange; public TetheringConfiguration(Context ctx, SharedLog log, int id) { final SharedLog configLog = log.forSubComponent("config"); Loading Loading @@ -164,6 +172,11 @@ public class TetheringConfiguration { R.bool.config_tether_enable_legacy_wifi_p2p_dedicated_ip, false /* defaultValue */); // Flags should normally not be booleans, but this is a kill-switch flag that is only used // to turn off the feature, so binary rollback problems do not apply. mEnableSelectAllPrefixRange = getDeviceConfigBoolean( TETHER_ENABLE_SELECT_ALL_PREFIX_RANGES, true /* defaultValue */); configLog.log(toString()); } Loading Loading @@ -249,6 +262,9 @@ public class TetheringConfiguration { pw.print("enableWifiP2pDedicatedIp: "); pw.println(mEnableWifiP2pDedicatedIp); pw.print("mEnableSelectAllPrefixRange: "); pw.println(mEnableSelectAllPrefixRange); } /** Returns the string representation of this object.*/ Loading Loading @@ -310,6 +326,10 @@ public class TetheringConfiguration { return mEnableBpfOffload; } public boolean isSelectAllPrefixRangeEnabled() { return mEnableSelectAllPrefixRange; } private static Collection<Integer> getUpstreamIfaceTypes(Resources res, boolean dunRequired) { final int[] ifaceTypes = res.getIntArray(R.array.config_tether_upstream_types); final ArrayList<Integer> upstreamIfaceTypes = new ArrayList<>(ifaceTypes.length); Loading packages/Tethering/tests/mts/Android.bp 0 → 100644 +56 −0 Original line number Diff line number Diff line // Copyright (C) 2020 The Android Open Source Project // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. android_test { // This tests for functionality that is not required for devices that // don't use Tethering mainline module. name: "MtsTetheringTest", libs: [ "android.test.base", ], srcs: [ "src/**/*.java", ], static_libs: [ "androidx.test.rules", // mockito-target-extended-minus-junit4 used in this lib have dependency with // jni_libs libdexmakerjvmtiagent and libstaticjvmtiagent. "cts-net-utils", // This is needed for androidx.test.runner.AndroidJUnitRunner. "ctstestrunner-axt", "junit", "junit-params", ], jni_libs: [ // For mockito extended which is pulled in from -net-utils -> net-tests-utils // (mockito-target-extended-minus-junit4). "libdexmakerjvmtiagent", "libstaticjvmtiagent", ], platform_apis: true, // Tag this module as a mts test artifact test_suites: [ "general-tests", "mts", ], // Include both the 32 and 64 bit versions compile_multilib: "both", } packages/Tethering/tests/mts/AndroidManifest.xml 0 → 100644 +34 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- * Copyright (C) 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="android.tethering.mts"> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.INTERNET"/> <application android:debuggable="true"> <uses-library android:name="android.test.runner" /> </application> <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner" android:targetPackage="android.tethering.mts" android:label="MTS tests of android.tethering"> <meta-data android:name="listener" android:value="com.android.cts.runner.CtsTestRunListener" /> </instrumentation> </manifest> packages/Tethering/tests/mts/AndroidTest.xml 0 → 100644 +36 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2019 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <configuration description="Config for MTS Tethering test cases"> <option name="test-suite-tag" value="mts" /> <option name="config-descriptor:metadata" key="component" value="networking" /> <!-- Instant app do not have INTERNET permission. --> <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" /> <!-- Feature is not backed by native code. --> <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" /> <!-- Allow running this against a secondary user. --> <option name="config-descriptor:metadata" key="parameter" value="secondary_user" /> <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller"> <option name="cleanup-apks" value="true" /> <option name="test-file-name" value="MtsTetheringTest.apk" /> </target_preparer> <test class="com.android.tradefed.testtype.AndroidJUnitTest" > <option name="package" value="android.tethering.mts" /> </test> <object type="module_controller" class="com.android.tradefed.testtype.suite.module.MainlineTestModuleController"> <option name="mainline-module-package-name" value="com.google.android.tethering" /> </object> </configuration> Loading
packages/Tethering/src/com/android/networkstack/tethering/PrivateAddressCoordinator.java +5 −6 Original line number Diff line number Diff line Loading @@ -80,11 +80,6 @@ public class PrivateAddressCoordinator { private final SparseArray<LinkAddress> mCachedAddresses; public PrivateAddressCoordinator(Context context, TetheringConfiguration config) { this(context, config, new ArrayList<>(Arrays.asList(new IpPrefix("192.168.0.0/16")))); } public PrivateAddressCoordinator(Context context, TetheringConfiguration config, List<IpPrefix> prefixPools) { mDownstreams = new ArraySet<>(); mUpstreamPrefixMap = new ArrayMap<>(); mConnectivityMgr = (ConnectivityManager) context.getSystemService( Loading @@ -95,7 +90,11 @@ public class PrivateAddressCoordinator { mCachedAddresses.put(TETHERING_BLUETOOTH, new LinkAddress(LEGACY_BLUETOOTH_IFACE_ADDRESS)); mCachedAddresses.put(TETHERING_WIFI_P2P, new LinkAddress(LEGACY_WIFI_P2P_IFACE_ADDRESS)); mTetheringPrefixes = prefixPools; mTetheringPrefixes = new ArrayList<>(Arrays.asList(new IpPrefix("192.168.0.0/16"))); if (config.isSelectAllPrefixRangeEnabled()) { mTetheringPrefixes.add(new IpPrefix("172.16.0.0/12")); mTetheringPrefixes.add(new IpPrefix("10.0.0.0/8")); } } /** Loading
packages/Tethering/src/com/android/networkstack/tethering/TetheringConfiguration.java +21 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,6 @@ import java.util.Arrays; import java.util.Collection; import java.util.StringJoiner; /** * A utility class to encapsulate the various tethering configuration elements. * Loading Loading @@ -87,6 +86,13 @@ public class TetheringConfiguration { public static final String USE_LEGACY_WIFI_P2P_DEDICATED_IP = "use_legacy_wifi_p2p_dedicated_ip"; /** * Flag use to enable select all prefix ranges feature. * TODO: Remove this flag if there are no problems after M-2020-12 rolls out. */ public static final String TETHER_ENABLE_SELECT_ALL_PREFIX_RANGES = "tether_enable_select_all_prefix_ranges"; /** * Default value that used to periodic polls tether offload stats from tethering offload HAL * to make the data warnings work. Loading Loading @@ -118,6 +124,8 @@ public class TetheringConfiguration { private final boolean mEnableBpfOffload; private final boolean mEnableWifiP2pDedicatedIp; private final boolean mEnableSelectAllPrefixRange; public TetheringConfiguration(Context ctx, SharedLog log, int id) { final SharedLog configLog = log.forSubComponent("config"); Loading Loading @@ -164,6 +172,11 @@ public class TetheringConfiguration { R.bool.config_tether_enable_legacy_wifi_p2p_dedicated_ip, false /* defaultValue */); // Flags should normally not be booleans, but this is a kill-switch flag that is only used // to turn off the feature, so binary rollback problems do not apply. mEnableSelectAllPrefixRange = getDeviceConfigBoolean( TETHER_ENABLE_SELECT_ALL_PREFIX_RANGES, true /* defaultValue */); configLog.log(toString()); } Loading Loading @@ -249,6 +262,9 @@ public class TetheringConfiguration { pw.print("enableWifiP2pDedicatedIp: "); pw.println(mEnableWifiP2pDedicatedIp); pw.print("mEnableSelectAllPrefixRange: "); pw.println(mEnableSelectAllPrefixRange); } /** Returns the string representation of this object.*/ Loading Loading @@ -310,6 +326,10 @@ public class TetheringConfiguration { return mEnableBpfOffload; } public boolean isSelectAllPrefixRangeEnabled() { return mEnableSelectAllPrefixRange; } private static Collection<Integer> getUpstreamIfaceTypes(Resources res, boolean dunRequired) { final int[] ifaceTypes = res.getIntArray(R.array.config_tether_upstream_types); final ArrayList<Integer> upstreamIfaceTypes = new ArrayList<>(ifaceTypes.length); Loading
packages/Tethering/tests/mts/Android.bp 0 → 100644 +56 −0 Original line number Diff line number Diff line // Copyright (C) 2020 The Android Open Source Project // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. android_test { // This tests for functionality that is not required for devices that // don't use Tethering mainline module. name: "MtsTetheringTest", libs: [ "android.test.base", ], srcs: [ "src/**/*.java", ], static_libs: [ "androidx.test.rules", // mockito-target-extended-minus-junit4 used in this lib have dependency with // jni_libs libdexmakerjvmtiagent and libstaticjvmtiagent. "cts-net-utils", // This is needed for androidx.test.runner.AndroidJUnitRunner. "ctstestrunner-axt", "junit", "junit-params", ], jni_libs: [ // For mockito extended which is pulled in from -net-utils -> net-tests-utils // (mockito-target-extended-minus-junit4). "libdexmakerjvmtiagent", "libstaticjvmtiagent", ], platform_apis: true, // Tag this module as a mts test artifact test_suites: [ "general-tests", "mts", ], // Include both the 32 and 64 bit versions compile_multilib: "both", }
packages/Tethering/tests/mts/AndroidManifest.xml 0 → 100644 +34 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- * Copyright (C) 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="android.tethering.mts"> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.INTERNET"/> <application android:debuggable="true"> <uses-library android:name="android.test.runner" /> </application> <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner" android:targetPackage="android.tethering.mts" android:label="MTS tests of android.tethering"> <meta-data android:name="listener" android:value="com.android.cts.runner.CtsTestRunListener" /> </instrumentation> </manifest>
packages/Tethering/tests/mts/AndroidTest.xml 0 → 100644 +36 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2019 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <configuration description="Config for MTS Tethering test cases"> <option name="test-suite-tag" value="mts" /> <option name="config-descriptor:metadata" key="component" value="networking" /> <!-- Instant app do not have INTERNET permission. --> <option name="config-descriptor:metadata" key="parameter" value="not_instant_app" /> <!-- Feature is not backed by native code. --> <option name="config-descriptor:metadata" key="parameter" value="not_multi_abi" /> <!-- Allow running this against a secondary user. --> <option name="config-descriptor:metadata" key="parameter" value="secondary_user" /> <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller"> <option name="cleanup-apks" value="true" /> <option name="test-file-name" value="MtsTetheringTest.apk" /> </target_preparer> <test class="com.android.tradefed.testtype.AndroidJUnitTest" > <option name="package" value="android.tethering.mts" /> </test> <object type="module_controller" class="com.android.tradefed.testtype.suite.module.MainlineTestModuleController"> <option name="mainline-module-package-name" value="com.google.android.tethering" /> </object> </configuration>