summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Chien <markchien@google.com>2019-10-24 06:38:24 -0700
committerandroid-build-merger <android-build-merger@google.com>2019-10-24 06:38:24 -0700
commitc7ed6b4fe5735447337cedd701b3d61753f80a68 (patch)
tree7af8690fbb215fde223126a780142390f11e1098
parentba2f29b80a2b474e6f47930475ed03b0cbe48bfd (diff)
parent72d5460dda6dfb605a5d010bb2e163d6e69053f8 (diff)
downloadbase-c7ed6b4fe5735447337cedd701b3d61753f80a68.tar.gz
Merge "[Tether02] Migrate TetheringConfiguration into module"
am: 72d5460dda Change-Id: I8fa812a78f61976741bc06ccf4000f625b75ecbe
-rw-r--r--Android.bp6
-rw-r--r--packages/Tethering/Android.bp10
-rw-r--r--packages/Tethering/src/com/android/server/connectivity/tethering/TetheringConfiguration.java (renamed from services/core/java/com/android/server/connectivity/tethering/TetheringConfiguration.java)11
-rw-r--r--packages/Tethering/tests/unit/Android.bp47
-rw-r--r--packages/Tethering/tests/unit/AndroidManifest.xml26
-rw-r--r--packages/Tethering/tests/unit/src/com/android/server/connectivity/tethering/TetheringConfigurationTest.java (renamed from tests/net/java/com/android/server/connectivity/tethering/TetheringConfigurationTest.java)36
-rw-r--r--services/core/Android.bp1
-rw-r--r--services/net/Android.bp8
-rw-r--r--tests/net/Android.bp6
9 files changed, 130 insertions, 21 deletions
diff --git a/Android.bp b/Android.bp
index 2f8bf759f578..a913324aa9ca 100644
--- a/Android.bp
+++ b/Android.bp
@@ -511,6 +511,12 @@ filegroup {
],
}
+filegroup {
+ name: "framework-tethering-shared-srcs",
+ srcs: [
+ "core/java/android/util/LocalLog.java",
+ ],
+}
// Build ext.jar
// ============================================================
java_library {
diff --git a/packages/Tethering/Android.bp b/packages/Tethering/Android.bp
index a8d3018bc1b3..dc88fd4014da 100644
--- a/packages/Tethering/Android.bp
+++ b/packages/Tethering/Android.bp
@@ -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",
+ ],
+}
diff --git a/services/core/java/com/android/server/connectivity/tethering/TetheringConfiguration.java b/packages/Tethering/src/com/android/server/connectivity/tethering/TetheringConfiguration.java
index a1b94ca33944..77097271c454 100644
--- a/services/core/java/com/android/server/connectivity/tethering/TetheringConfiguration.java
+++ b/packages/Tethering/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");
diff --git a/packages/Tethering/tests/unit/Android.bp b/packages/Tethering/tests/unit/Android.bp
new file mode 100644
index 000000000000..089bbd31d9f3
--- /dev/null
+++ b/packages/Tethering/tests/unit/Android.bp
@@ -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",
+ ],
+}
diff --git a/packages/Tethering/tests/unit/AndroidManifest.xml b/packages/Tethering/tests/unit/AndroidManifest.xml
new file mode 100644
index 000000000000..049ff6d415f3
--- /dev/null
+++ b/packages/Tethering/tests/unit/AndroidManifest.xml
@@ -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>
diff --git a/tests/net/java/com/android/server/connectivity/tethering/TetheringConfigurationTest.java b/packages/Tethering/tests/unit/src/com/android/server/connectivity/tethering/TetheringConfigurationTest.java
index e28296354d2a..9f9221f3010d 100644
--- a/tests/net/java/com/android/server/connectivity/tethering/TetheringConfigurationTest.java
+++ b/packages/Tethering/tests/unit/src/com/android/server/connectivity/tethering/TetheringConfigurationTest.java
@@ -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);
}
}
diff --git a/services/core/Android.bp b/services/core/Android.bp
index 16432212d8e2..58fb0bfd48e4 100644
--- a/services/core/Android.bp
+++ b/services/core/Android.bp
@@ -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",
diff --git a/services/net/Android.bp b/services/net/Android.bp
index b0af59927945..6a871aa81543 100644
--- a/services/net/Android.bp
+++ b/services/net/Android.bp
@@ -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"
+ ],
+}
diff --git a/tests/net/Android.bp b/tests/net/Android.bp
index beb5e0db6422..b9b2238572ac 100644
--- a/tests/net/Android.bp
+++ b/tests/net/Android.bp
@@ -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",