Merge "[Tether02] Migrate TetheringConfiguration into module" am: 72d5460dda am: c7ed6b4fe5
am: c95ca17d04
Change-Id: Ifbcc8a81d4ea7521f0d3ae56e0951974b9355334
This commit is contained in:
@@ -511,6 +511,12 @@ filegroup {
|
||||
],
|
||||
}
|
||||
|
||||
filegroup {
|
||||
name: "framework-tethering-shared-srcs",
|
||||
srcs: [
|
||||
"core/java/android/util/LocalLog.java",
|
||||
],
|
||||
}
|
||||
// Build ext.jar
|
||||
// ============================================================
|
||||
java_library {
|
||||
|
||||
@@ -19,6 +19,8 @@ java_defaults {
|
||||
platform_apis: true,
|
||||
srcs: [
|
||||
"src/**/*.java",
|
||||
":framework-tethering-shared-srcs",
|
||||
":services-tethering-shared-srcs",
|
||||
],
|
||||
static_libs: [
|
||||
"androidx.annotation_annotation",
|
||||
@@ -60,3 +62,11 @@ android_app {
|
||||
// The permission configuration *must* be included to ensure security of the device
|
||||
required: ["NetworkPermissionConfig"],
|
||||
}
|
||||
|
||||
// This group will be removed when tethering migration is done.
|
||||
filegroup {
|
||||
name: "tethering-services-srcs",
|
||||
srcs: [
|
||||
"src/com/android/server/connectivity/tethering/TetheringConfiguration.java",
|
||||
],
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public class TetheringConfiguration {
|
||||
"192.168.48.2", "192.168.48.254", "192.168.49.2", "192.168.49.254",
|
||||
};
|
||||
|
||||
private final String[] DEFAULT_IPV4_DNS = {"8.8.4.4", "8.8.8.8"};
|
||||
private static final String[] DEFAULT_IPV4_DNS = {"8.8.4.4", "8.8.8.8"};
|
||||
|
||||
public final String[] tetherableUsbRegexs;
|
||||
public final String[] tetherableWifiRegexs;
|
||||
@@ -133,10 +133,12 @@ public class TetheringConfiguration {
|
||||
configLog.log(toString());
|
||||
}
|
||||
|
||||
/** Check whether input interface belong to usb.*/
|
||||
public boolean isUsb(String iface) {
|
||||
return matchesDownstreamRegexs(iface, tetherableUsbRegexs);
|
||||
}
|
||||
|
||||
/** Check whether input interface belong to wifi.*/
|
||||
public boolean isWifi(String iface) {
|
||||
return matchesDownstreamRegexs(iface, tetherableWifiRegexs);
|
||||
}
|
||||
@@ -146,18 +148,22 @@ public class TetheringConfiguration {
|
||||
return matchesDownstreamRegexs(iface, tetherableWifiP2pRegexs);
|
||||
}
|
||||
|
||||
/** Check whether using legacy mode for wifi P2P. */
|
||||
public boolean isWifiP2pLegacyTetheringMode() {
|
||||
return (tetherableWifiP2pRegexs == null || tetherableWifiP2pRegexs.length == 0);
|
||||
}
|
||||
|
||||
/** Check whether input interface belong to bluetooth.*/
|
||||
public boolean isBluetooth(String iface) {
|
||||
return matchesDownstreamRegexs(iface, tetherableBluetoothRegexs);
|
||||
}
|
||||
|
||||
/** Check whether no ui entitlement application is available.*/
|
||||
public boolean hasMobileHotspotProvisionApp() {
|
||||
return !TextUtils.isEmpty(provisioningAppNoUi);
|
||||
}
|
||||
|
||||
/** Does the dumping.*/
|
||||
public void dump(PrintWriter pw) {
|
||||
pw.print("subId: ");
|
||||
pw.println(subId);
|
||||
@@ -186,6 +192,7 @@ public class TetheringConfiguration {
|
||||
pw.println(enableLegacyDhcpServer);
|
||||
}
|
||||
|
||||
/** Returns the string representation of this object.*/
|
||||
public String toString() {
|
||||
final StringJoiner sj = new StringJoiner(" ");
|
||||
sj.add(String.format("subId:%d", subId));
|
||||
@@ -210,7 +217,7 @@ public class TetheringConfiguration {
|
||||
|
||||
if (values != null) {
|
||||
final StringJoiner sj = new StringJoiner(", ", "[", "]");
|
||||
for (String value : values) { sj.add(value); }
|
||||
for (String value : values) sj.add(value);
|
||||
pw.print(sj.toString());
|
||||
} else {
|
||||
pw.print("null");
|
||||
47
packages/Tethering/tests/unit/Android.bp
Normal file
47
packages/Tethering/tests/unit/Android.bp
Normal file
@@ -0,0 +1,47 @@
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
android_test {
|
||||
name: "TetheringTests",
|
||||
certificate: "platform",
|
||||
srcs: ["src/**/*.java"],
|
||||
test_suites: ["device-tests"],
|
||||
static_libs: [
|
||||
"androidx.test.rules",
|
||||
"frameworks-base-testutils",
|
||||
"mockito-target-extended-minus-junit4",
|
||||
"TetheringApiCurrentLib",
|
||||
"testables",
|
||||
],
|
||||
libs: [
|
||||
"android.test.runner",
|
||||
"android.test.base",
|
||||
"android.test.mock",
|
||||
],
|
||||
jni_libs: [
|
||||
// For mockito extended
|
||||
"libdexmakerjvmtiagent",
|
||||
"libstaticjvmtiagent",
|
||||
],
|
||||
}
|
||||
|
||||
// This group would be removed when tethering migration is done.
|
||||
filegroup {
|
||||
name: "tethering-tests-src",
|
||||
srcs: [
|
||||
"src/com/android/server/connectivity/tethering/TetheringConfigurationTest.java",
|
||||
],
|
||||
}
|
||||
26
packages/Tethering/tests/unit/AndroidManifest.xml
Normal file
26
packages/Tethering/tests/unit/AndroidManifest.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<?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.
|
||||
-->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.android.tethering.tests.unit">
|
||||
|
||||
<application android:debuggable="true">
|
||||
<uses-library android:name="android.test.runner" />
|
||||
</application>
|
||||
<instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
|
||||
android:targetPackage="com.android.tethering.tests.unit"
|
||||
android:label="Tethering service tests">
|
||||
</instrumentation>
|
||||
</manifest>
|
||||
@@ -24,7 +24,12 @@ import static android.net.ConnectivityManager.TYPE_WIFI;
|
||||
import static android.provider.Settings.Global.TETHER_ENABLE_LEGACY_DHCP_SERVER;
|
||||
import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||
|
||||
import static com.android.internal.R.array.config_mobile_hotspot_provision_app;
|
||||
import static com.android.internal.R.array.config_tether_bluetooth_regexs;
|
||||
import static com.android.internal.R.array.config_tether_dhcp_range;
|
||||
import static com.android.internal.R.array.config_tether_upstream_types;
|
||||
import static com.android.internal.R.array.config_tether_usb_regexs;
|
||||
import static com.android.internal.R.array.config_tether_wifi_regexs;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
@@ -86,7 +91,9 @@ public class TetheringConfigurationTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Resources getResources() { return mResources; }
|
||||
public Resources getResources() {
|
||||
return mResources;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getSystemService(String name) {
|
||||
@@ -105,17 +112,13 @@ public class TetheringConfigurationTest {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
when(mResources.getStringArray(com.android.internal.R.array.config_tether_dhcp_range))
|
||||
.thenReturn(new String[0]);
|
||||
when(mResources.getStringArray(com.android.internal.R.array.config_tether_usb_regexs))
|
||||
.thenReturn(new String[0]);
|
||||
when(mResources.getStringArray(com.android.internal.R.array.config_tether_wifi_regexs))
|
||||
when(mResources.getStringArray(config_tether_dhcp_range)).thenReturn(new String[0]);
|
||||
when(mResources.getStringArray(config_tether_usb_regexs)).thenReturn(new String[0]);
|
||||
when(mResources.getStringArray(config_tether_wifi_regexs))
|
||||
.thenReturn(new String[]{ "test_wlan\\d" });
|
||||
when(mResources.getStringArray(com.android.internal.R.array.config_tether_bluetooth_regexs))
|
||||
.thenReturn(new String[0]);
|
||||
when(mResources.getStringArray(config_tether_bluetooth_regexs)).thenReturn(new String[0]);
|
||||
when(mResources.getIntArray(config_tether_upstream_types)).thenReturn(new int[0]);
|
||||
when(mResources.getStringArray(
|
||||
com.android.internal.R.array.config_mobile_hotspot_provision_app))
|
||||
when(mResources.getStringArray(config_mobile_hotspot_provision_app))
|
||||
.thenReturn(new String[0]);
|
||||
mContentResolver = new MockContentResolver();
|
||||
mContentResolver.addProvider(Settings.AUTHORITY, new FakeSettingsProvider());
|
||||
@@ -297,19 +300,16 @@ public class TetheringConfigurationTest {
|
||||
|
||||
private void setUpResourceForSubId() {
|
||||
when(mResourcesForSubId.getStringArray(
|
||||
com.android.internal.R.array.config_tether_dhcp_range)).thenReturn(new String[0]);
|
||||
config_tether_dhcp_range)).thenReturn(new String[0]);
|
||||
when(mResourcesForSubId.getStringArray(
|
||||
com.android.internal.R.array.config_tether_usb_regexs)).thenReturn(new String[0]);
|
||||
config_tether_usb_regexs)).thenReturn(new String[0]);
|
||||
when(mResourcesForSubId.getStringArray(
|
||||
com.android.internal.R.array.config_tether_wifi_regexs))
|
||||
.thenReturn(new String[]{ "test_wlan\\d" });
|
||||
config_tether_wifi_regexs)).thenReturn(new String[]{ "test_wlan\\d" });
|
||||
when(mResourcesForSubId.getStringArray(
|
||||
com.android.internal.R.array.config_tether_bluetooth_regexs))
|
||||
.thenReturn(new String[0]);
|
||||
config_tether_bluetooth_regexs)).thenReturn(new String[0]);
|
||||
when(mResourcesForSubId.getIntArray(config_tether_upstream_types)).thenReturn(new int[0]);
|
||||
when(mResourcesForSubId.getStringArray(
|
||||
com.android.internal.R.array.config_mobile_hotspot_provision_app))
|
||||
.thenReturn(PROVISIONING_APP_NAME);
|
||||
config_mobile_hotspot_provision_app)).thenReturn(PROVISIONING_APP_NAME);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,6 +20,7 @@ java_library_static {
|
||||
":vold_aidl",
|
||||
":gsiservice_aidl",
|
||||
":platform-compat-config",
|
||||
":tethering-services-srcs",
|
||||
"java/com/android/server/EventLogTags.logtags",
|
||||
"java/com/android/server/am/EventLogTags.logtags",
|
||||
"java/com/android/server/policy/EventLogTags.logtags",
|
||||
|
||||
@@ -18,3 +18,11 @@ filegroup {
|
||||
"java/android/net/netlink/*.java",
|
||||
],
|
||||
}
|
||||
|
||||
filegroup {
|
||||
name: "services-tethering-shared-srcs",
|
||||
srcs: [
|
||||
":framework-annotations",
|
||||
"java/android/net/util/SharedLog.java"
|
||||
],
|
||||
}
|
||||
|
||||
@@ -44,7 +44,11 @@ java_defaults {
|
||||
android_test {
|
||||
name: "FrameworksNetTests",
|
||||
defaults: ["FrameworksNetTests-jni-defaults"],
|
||||
srcs: ["java/**/*.java", "java/**/*.kt"],
|
||||
srcs: [
|
||||
":tethering-tests-src",
|
||||
"java/**/*.java",
|
||||
"java/**/*.kt",
|
||||
],
|
||||
platform_apis: true,
|
||||
test_suites: ["device-tests"],
|
||||
certificate: "platform",
|
||||
|
||||
Reference in New Issue
Block a user