diff options
38 files changed, 542 insertions, 403 deletions
diff --git a/api/system-current.txt b/api/system-current.txt index 8e0992848a0f..94f932341588 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -3276,13 +3276,19 @@ package android.net { method @Nullable public java.net.InetAddress getGateway(); method @Nullable public android.net.LinkAddress getIpAddress(); method @NonNull public java.util.List<android.net.RouteInfo> getRoutes(@Nullable String); - method public void setDomains(@Nullable String); - method public void setGateway(@Nullable java.net.InetAddress); - method public void setIpAddress(@Nullable android.net.LinkAddress); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.net.StaticIpConfiguration> CREATOR; } + public static final class StaticIpConfiguration.Builder { + ctor public StaticIpConfiguration.Builder(); + method @NonNull public android.net.StaticIpConfiguration build(); + method @NonNull public android.net.StaticIpConfiguration.Builder setDnsServers(@NonNull Iterable<java.net.InetAddress>); + method @NonNull public android.net.StaticIpConfiguration.Builder setDomains(@Nullable String); + method @NonNull public android.net.StaticIpConfiguration.Builder setGateway(@Nullable java.net.InetAddress); + method @NonNull public android.net.StaticIpConfiguration.Builder setIpAddress(@Nullable android.net.LinkAddress); + } + public class TrafficStats { method public static void setThreadStatsTagApp(); method public static void setThreadStatsTagBackup(); @@ -3328,37 +3334,6 @@ package android.net.apf { } -package android.net.captiveportal { - - public final class CaptivePortalProbeResult { - ctor public CaptivePortalProbeResult(int); - ctor public CaptivePortalProbeResult(int, @Nullable String, @Nullable String); - ctor public CaptivePortalProbeResult(int, @Nullable String, @Nullable String, @Nullable android.net.captiveportal.CaptivePortalProbeSpec); - method public boolean isFailed(); - method public boolean isPartialConnectivity(); - method public boolean isPortal(); - method public boolean isSuccessful(); - field @NonNull public static final android.net.captiveportal.CaptivePortalProbeResult FAILED; - field public static final int FAILED_CODE = 599; // 0x257 - field public static final android.net.captiveportal.CaptivePortalProbeResult PARTIAL; - field public static final int PORTAL_CODE = 302; // 0x12e - field @NonNull public static final android.net.captiveportal.CaptivePortalProbeResult SUCCESS; - field public static final int SUCCESS_CODE = 204; // 0xcc - field @Nullable public final String detectUrl; - field @Nullable public final android.net.captiveportal.CaptivePortalProbeSpec probeSpec; - field @Nullable public final String redirectUrl; - } - - public abstract class CaptivePortalProbeSpec { - method @NonNull public String getEncodedSpec(); - method @NonNull public abstract android.net.captiveportal.CaptivePortalProbeResult getResult(int, @Nullable String); - method @NonNull public java.net.URL getUrl(); - method @NonNull public static java.util.Collection<android.net.captiveportal.CaptivePortalProbeSpec> parseCaptivePortalProbeSpecs(@NonNull String); - method @Nullable public static android.net.captiveportal.CaptivePortalProbeSpec parseSpecOrNull(@Nullable String); - } - -} - package android.net.metrics { public final class ApfProgramEvent implements android.net.metrics.IpConnectivityLog.Event { diff --git a/api/test-current.txt b/api/test-current.txt index 7f86d5d665eb..16852e43f8a8 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -696,13 +696,19 @@ package android.net { method @Nullable public java.net.InetAddress getGateway(); method @Nullable public android.net.LinkAddress getIpAddress(); method @NonNull public java.util.List<android.net.RouteInfo> getRoutes(@Nullable String); - method public void setDomains(@Nullable String); - method public void setGateway(@Nullable java.net.InetAddress); - method public void setIpAddress(@Nullable android.net.LinkAddress); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.net.StaticIpConfiguration> CREATOR; } + public static final class StaticIpConfiguration.Builder { + ctor public StaticIpConfiguration.Builder(); + method @NonNull public android.net.StaticIpConfiguration build(); + method @NonNull public android.net.StaticIpConfiguration.Builder setDnsServers(@NonNull Iterable<java.net.InetAddress>); + method @NonNull public android.net.StaticIpConfiguration.Builder setDomains(@Nullable String); + method @NonNull public android.net.StaticIpConfiguration.Builder setGateway(@Nullable java.net.InetAddress); + method @NonNull public android.net.StaticIpConfiguration.Builder setIpAddress(@Nullable android.net.LinkAddress); + } + public final class TestNetworkInterface implements android.os.Parcelable { ctor public TestNetworkInterface(android.os.ParcelFileDescriptor, String); method public int describeContents(); @@ -747,37 +753,6 @@ package android.net.apf { } -package android.net.captiveportal { - - public final class CaptivePortalProbeResult { - ctor public CaptivePortalProbeResult(int); - ctor public CaptivePortalProbeResult(int, @Nullable String, @Nullable String); - ctor public CaptivePortalProbeResult(int, @Nullable String, @Nullable String, @Nullable android.net.captiveportal.CaptivePortalProbeSpec); - method public boolean isFailed(); - method public boolean isPartialConnectivity(); - method public boolean isPortal(); - method public boolean isSuccessful(); - field @NonNull public static final android.net.captiveportal.CaptivePortalProbeResult FAILED; - field public static final int FAILED_CODE = 599; // 0x257 - field public static final android.net.captiveportal.CaptivePortalProbeResult PARTIAL; - field public static final int PORTAL_CODE = 302; // 0x12e - field @NonNull public static final android.net.captiveportal.CaptivePortalProbeResult SUCCESS; - field public static final int SUCCESS_CODE = 204; // 0xcc - field @Nullable public final String detectUrl; - field @Nullable public final android.net.captiveportal.CaptivePortalProbeSpec probeSpec; - field @Nullable public final String redirectUrl; - } - - public abstract class CaptivePortalProbeSpec { - method @NonNull public String getEncodedSpec(); - method @NonNull public abstract android.net.captiveportal.CaptivePortalProbeResult getResult(int, @Nullable String); - method @NonNull public java.net.URL getUrl(); - method @NonNull public static java.util.Collection<android.net.captiveportal.CaptivePortalProbeSpec> parseCaptivePortalProbeSpecs(@NonNull String); - method @Nullable public static android.net.captiveportal.CaptivePortalProbeSpec parseSpecOrNull(@Nullable String); - } - -} - package android.net.metrics { public final class ApfProgramEvent implements android.net.metrics.IpConnectivityLog.Event { diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 7cd1b087d9ca..a6f19f4c8f27 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -5694,6 +5694,10 @@ public final class ActivityThread extends ClientTransactionHandler { UserHandle.myUserId()); VMRuntime.setProcessPackageName(data.appInfo.packageName); + // Pass data directory path to ART. This is used for caching information and + // should be set before any application code is loaded. + VMRuntime.setProcessDataDirectory(data.appInfo.dataDir); + if (mProfiler.profileFd != null) { mProfiler.startProfiling(); } diff --git a/core/java/android/net/CaptivePortal.java b/core/java/android/net/CaptivePortal.java index db1951520a26..25e111e27f1c 100644 --- a/core/java/android/net/CaptivePortal.java +++ b/core/java/android/net/CaptivePortal.java @@ -137,6 +137,8 @@ public class CaptivePortal implements Parcelable { /** * Log a captive portal login event. + * @param eventId one of the CAPTIVE_PORTAL_LOGIN_* constants in metrics_constants.proto. + * @param packageName captive portal application package name. * @hide */ @SystemApi diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java index 6ba4a30abe22..2906710b0655 100644 --- a/core/java/android/net/ConnectivityManager.java +++ b/core/java/android/net/ConnectivityManager.java @@ -2617,7 +2617,7 @@ public class ConnectivityManager { /** * Start listening to tethering change events. Any new added callback will receive the last - * tethering status right away. If callback is registered when tethering loses its upstream or + * tethering status right away. If callback is registered when tethering has no upstream or * disabled, {@link OnTetheringEventCallback#onUpstreamChanged} will immediately be called * with a null argument. The same callback object cannot be registered twice. * diff --git a/core/java/android/net/DhcpResults.java b/core/java/android/net/DhcpResults.java index 6f9e65fdf12c..a33f3fcfb263 100644 --- a/core/java/android/net/DhcpResults.java +++ b/core/java/android/net/DhcpResults.java @@ -72,15 +72,12 @@ public final class DhcpResults implements Parcelable { * Create a {@link StaticIpConfiguration} based on the DhcpResults. */ public StaticIpConfiguration toStaticIpConfiguration() { - final StaticIpConfiguration s = new StaticIpConfiguration(); - // All these except dnsServers are immutable, so no need to make copies. - s.setIpAddress(ipAddress); - s.setGateway(gateway); - for (InetAddress addr : dnsServers) { - s.addDnsServer(addr); - } - s.setDomains(domains); - return s; + return new StaticIpConfiguration.Builder() + .setIpAddress(ipAddress) + .setGateway(gateway) + .setDnsServers(dnsServers) + .setDomains(domains) + .build(); } public DhcpResults(StaticIpConfiguration source) { diff --git a/core/java/android/net/StaticIpConfiguration.java b/core/java/android/net/StaticIpConfiguration.java index 14dbca0183f0..fb5acfab611c 100644 --- a/core/java/android/net/StaticIpConfiguration.java +++ b/core/java/android/net/StaticIpConfiguration.java @@ -22,6 +22,7 @@ import android.annotation.SystemApi; import android.annotation.TestApi; import android.annotation.UnsupportedAppUsage; import android.net.shared.InetAddressUtils; +import android.os.Build; import android.os.Parcel; import android.os.Parcelable; @@ -33,20 +34,19 @@ import java.util.Objects; /** * Class that describes static IP configuration. * - * This class is different from LinkProperties because it represents + * <p>This class is different from {@link LinkProperties} because it represents * configuration intent. The general contract is that if we can represent * a configuration here, then we should be able to configure it on a network. * The intent is that it closely match the UI we have for configuring networks. * - * In contrast, LinkProperties represents current state. It is much more + * <p>In contrast, {@link LinkProperties} represents current state. It is much more * expressive. For example, it supports multiple IP addresses, multiple routes, * stacked interfaces, and so on. Because LinkProperties is so expressive, * using it to represent configuration intent as well as current state causes * problems. For example, we could unknowingly save a configuration that we are * not in fact capable of applying, or we could save a configuration that the * UI cannot display, which has the potential for malicious code to hide - * hostile or unexpected configuration from the user: see, for example, - * http://b/12663469 and http://b/16893413 . + * hostile or unexpected configuration from the user. * * @hide */ @@ -54,24 +54,24 @@ import java.util.Objects; @TestApi public final class StaticIpConfiguration implements Parcelable { /** @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) @Nullable public LinkAddress ipAddress; /** @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) @Nullable public InetAddress gateway; /** @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) @NonNull public final ArrayList<InetAddress> dnsServers; /** @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) @Nullable public String domains; public StaticIpConfiguration() { - dnsServers = new ArrayList<InetAddress>(); + dnsServers = new ArrayList<>(); } public StaticIpConfiguration(@Nullable StaticIpConfiguration source) { @@ -92,32 +92,96 @@ public final class StaticIpConfiguration implements Parcelable { domains = null; } + /** + * Get the static IP address included in the configuration. + */ public @Nullable LinkAddress getIpAddress() { return ipAddress; } - public void setIpAddress(@Nullable LinkAddress ipAddress) { - this.ipAddress = ipAddress; - } - + /** + * Get the gateway included in the configuration. + */ public @Nullable InetAddress getGateway() { return gateway; } - public void setGateway(@Nullable InetAddress gateway) { - this.gateway = gateway; - } - + /** + * Get the DNS servers included in the configuration. + */ public @NonNull List<InetAddress> getDnsServers() { return dnsServers; } + /** + * Get a {@link String} listing in priority order of the comma separated domains to search when + * resolving host names on the link. + */ public @Nullable String getDomains() { return domains; } - public void setDomains(@Nullable String newDomains) { - domains = newDomains; + /** + * Helper class to build a new instance of {@link StaticIpConfiguration}. + */ + public static final class Builder { + private LinkAddress mIpAddress; + private InetAddress mGateway; + private Iterable<InetAddress> mDnsServers; + private String mDomains; + + /** + * Set the IP address to be included in the configuration; null by default. + * @return The {@link Builder} for chaining. + */ + public @NonNull Builder setIpAddress(@Nullable LinkAddress ipAddress) { + mIpAddress = ipAddress; + return this; + } + + /** + * Set the address of the gateway to be included in the configuration; null by default. + * @return The {@link Builder} for chaining. + */ + public @NonNull Builder setGateway(@Nullable InetAddress gateway) { + mGateway = gateway; + return this; + } + + /** + * Set the addresses of the DNS servers included in the configuration; empty by default. + * @return The {@link Builder} for chaining. + */ + public @NonNull Builder setDnsServers(@NonNull Iterable<InetAddress> dnsServers) { + mDnsServers = dnsServers; + return this; + } + + /** + * Sets the DNS domain search path to be used on the link; null by default. + * @param newDomains A {@link String} containing the comma separated domains to search when + * resolving host names on this link, in priority order. + * @return The {@link Builder} for chaining. + */ + public @NonNull Builder setDomains(@Nullable String newDomains) { + mDomains = newDomains; + return this; + } + + /** + * Create a {@link StaticIpConfiguration} from the parameters in this {@link Builder}. + * @return The newly created StaticIpConfiguration. + */ + public @NonNull StaticIpConfiguration build() { + final StaticIpConfiguration config = new StaticIpConfiguration(); + config.ipAddress = mIpAddress; + config.gateway = mGateway; + for (InetAddress server : mDnsServers) { + config.dnsServers.add(server); + } + config.domains = mDomains; + return config; + } } /** @@ -129,16 +193,17 @@ public final class StaticIpConfiguration implements Parcelable { /** * Returns the network routes specified by this object. Will typically include a - * directly-connected route for the IP address's local subnet and a default route. If the - * default gateway is not covered by the directly-connected route, it will also contain a host - * route to the gateway as well. This configuration is arguably invalid, but it used to work - * in K and earlier, and other OSes appear to accept it. + * directly-connected route for the IP address's local subnet and a default route. + * @param iface Interface to include in the routes. */ public @NonNull List<RouteInfo> getRoutes(@Nullable String iface) { List<RouteInfo> routes = new ArrayList<RouteInfo>(3); if (ipAddress != null) { RouteInfo connectedRoute = new RouteInfo(ipAddress, null, iface); routes.add(connectedRoute); + // If the default gateway is not covered by the directly-connected route, also add a + // host route to the gateway as well. This configuration is arguably invalid, but it + // used to work in K and earlier, and other OSes appear to accept it. if (gateway != null && !connectedRoute.matches(gateway)) { routes.add(RouteInfo.makeHostRoute(gateway, iface)); } diff --git a/core/java/android/view/LayoutInflater.java b/core/java/android/view/LayoutInflater.java index 2ee72bffc9ec..ae2deb97c756 100644 --- a/core/java/android/view/LayoutInflater.java +++ b/core/java/android/view/LayoutInflater.java @@ -512,7 +512,7 @@ public abstract class LayoutInflater { String layout = res.getResourceEntryName(resource); try { - Class clazz = mPrecompiledClassLoader.loadClass("" + pkg + ".CompiledView"); + Class clazz = Class.forName("" + pkg + ".CompiledView", false, mPrecompiledClassLoader); Method inflater = clazz.getMethod(layout, Context.class, int.class); View view = (View) inflater.invoke(null, mContext, resource); @@ -731,8 +731,8 @@ public abstract class LayoutInflater { if (constructor == null) { // Class not found in the cache, see if it's real, and try to add it - clazz = mContext.getClassLoader().loadClass( - prefix != null ? (prefix + name) : name).asSubclass(View.class); + clazz = Class.forName(prefix != null ? (prefix + name) : name, false, + mContext.getClassLoader()).asSubclass(View.class); if (mFilter != null && clazz != null) { boolean allowed = mFilter.onLoadClass(clazz); @@ -750,8 +750,8 @@ public abstract class LayoutInflater { Boolean allowedState = mFilterMap.get(name); if (allowedState == null) { // New class -- remember whether it is allowed - clazz = mContext.getClassLoader().loadClass( - prefix != null ? (prefix + name) : name).asSubclass(View.class); + clazz = Class.forName(prefix != null ? (prefix + name) : name, false, + mContext.getClassLoader()).asSubclass(View.class); boolean allowed = clazz != null && mFilter.onLoadClass(clazz); mFilterMap.put(name, allowed); diff --git a/keystore/tests/Android.bp b/keystore/tests/Android.bp new file mode 100644 index 000000000000..d382dd9e7625 --- /dev/null +++ b/keystore/tests/Android.bp @@ -0,0 +1,23 @@ +// Copyright (C) 2017 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: "KeystoreTests", + // LOCAL_MODULE := keystore + srcs: ["src/**/*.java"], + static_libs: ["android-support-test"], + platform_apis: true, + libs: ["android.test.runner"], + certificate: "platform", +} diff --git a/keystore/tests/Android.mk b/keystore/tests/Android.mk deleted file mode 100644 index 596e5f530970..000000000000 --- a/keystore/tests/Android.mk +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright (C) 2017 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. - -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -# LOCAL_MODULE := keystore -LOCAL_MODULE_TAGS := tests - -LOCAL_SRC_FILES := $(call all-java-files-under, src) - -LOCAL_STATIC_JAVA_LIBRARIES := \ - android-support-test - -LOCAL_PACKAGE_NAME := KeystoreTests -LOCAL_PRIVATE_PLATFORM_APIS := true - -LOCAL_JAVA_LIBRARIES := android.test.runner - -LOCAL_CERTIFICATE := platform - -include $(BUILD_PACKAGE) - diff --git a/location/Android.mk b/location/Android.mk deleted file mode 100644 index 50509c6f1a3c..000000000000 --- a/location/Android.mk +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright (C) 2010 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. - -LOCAL_PATH := $(call my-dir) - -include $(call all-subdir-makefiles, $(LOCAL_PATH))
\ No newline at end of file diff --git a/location/tests/Android.bp b/location/tests/Android.bp new file mode 100644 index 000000000000..8b137891791f --- /dev/null +++ b/location/tests/Android.bp @@ -0,0 +1 @@ + diff --git a/location/tests/Android.mk b/location/tests/Android.mk deleted file mode 100644 index 57848f353fd4..000000000000 --- a/location/tests/Android.mk +++ /dev/null @@ -1,3 +0,0 @@ -LOCAL_PATH:= $(call my-dir) - -include $(call all-makefiles-under, $(LOCAL_PATH))
\ No newline at end of file diff --git a/location/tests/locationtests/Android.bp b/location/tests/locationtests/Android.bp new file mode 100644 index 000000000000..735ee0e5d098 --- /dev/null +++ b/location/tests/locationtests/Android.bp @@ -0,0 +1,19 @@ +android_test { + name: "FrameworksLocationTests", + // Include all test java files. + srcs: ["src/**/*.java"], + libs: [ + "android.test.runner", + "android.test.base", + ], + platform_apis: true, + static_libs: [ + "android-support-test", + "core-test-rules", + "guava", + "mockito-target-minus-junit4", + "frameworks-base-testutils", + "truth-prebuilt", + ], + test_suites: ["device-tests"], +} diff --git a/location/tests/locationtests/Android.mk b/location/tests/locationtests/Android.mk deleted file mode 100644 index b2fd8ecef734..000000000000 --- a/location/tests/locationtests/Android.mk +++ /dev/null @@ -1,23 +0,0 @@ -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -# We only want this apk build for tests. -LOCAL_MODULE_TAGS := tests - -# Include all test java files. -LOCAL_SRC_FILES := $(call all-java-files-under, src) - -LOCAL_JAVA_LIBRARIES := android.test.runner android.test.base -LOCAL_PACKAGE_NAME := FrameworksLocationTests -LOCAL_PRIVATE_PLATFORM_APIS := true - -LOCAL_STATIC_JAVA_LIBRARIES := \ - android-support-test \ - core-test-rules \ - guava \ - mockito-target-minus-junit4 \ - frameworks-base-testutils \ - truth-prebuilt \ - -LOCAL_COMPATIBILITY_SUITE := device-tests -include $(BUILD_PACKAGE) diff --git a/media/jni/Android.bp b/media/jni/Android.bp index 5966192707f7..7a41c775b149 100644 --- a/media/jni/Android.bp +++ b/media/jni/Android.bp @@ -151,6 +151,8 @@ cc_library_shared { "libutils", // Have to use shared lib to make libandroid_runtime behave correctly. // Otherwise, AndroidRuntime::getJNIEnv() will return NULL. + + "libcgrouprc", // LL-NDK ], header_libs: ["libhardware_headers"], diff --git a/media/tests/MediaFrameworkTest/Android.bp b/media/tests/MediaFrameworkTest/Android.bp new file mode 100644 index 000000000000..4fbd852098ca --- /dev/null +++ b/media/tests/MediaFrameworkTest/Android.bp @@ -0,0 +1,14 @@ +android_test { + name: "mediaframeworktest", + srcs: ["**/*.java"], + libs: [ + "android.test.runner", + "android.test.base", + ], + static_libs: [ + "mockito-target-minus-junit4", + "android-support-test", + "android-ex-camera2", + ], + platform_apis: true, +} diff --git a/media/tests/MediaFrameworkTest/Android.mk b/media/tests/MediaFrameworkTest/Android.mk deleted file mode 100644 index fb473f0581c9..000000000000 --- a/media/tests/MediaFrameworkTest/Android.mk +++ /dev/null @@ -1,18 +0,0 @@ -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := tests - -LOCAL_SRC_FILES := $(call all-subdir-java-files) - -LOCAL_JAVA_LIBRARIES := android.test.runner android.test.base - -LOCAL_STATIC_JAVA_LIBRARIES := \ - mockito-target-minus-junit4 \ - android-support-test \ - android-ex-camera2 - -LOCAL_PACKAGE_NAME := mediaframeworktest -LOCAL_PRIVATE_PLATFORM_APIS := true - -include $(BUILD_PACKAGE) diff --git a/media/tests/MtpTests/Android.bp b/media/tests/MtpTests/Android.bp new file mode 100644 index 000000000000..1189430dfee4 --- /dev/null +++ b/media/tests/MtpTests/Android.bp @@ -0,0 +1,6 @@ +android_test { + name: "MtpTests", + srcs: ["**/*.java"], + static_libs: ["android-support-test"], + platform_apis: true, +} diff --git a/media/tests/MtpTests/Android.mk b/media/tests/MtpTests/Android.mk deleted file mode 100644 index 6375ed3f3c83..000000000000 --- a/media/tests/MtpTests/Android.mk +++ /dev/null @@ -1,13 +0,0 @@ -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := tests - -LOCAL_SRC_FILES := $(call all-subdir-java-files) - -LOCAL_STATIC_JAVA_LIBRARIES := android-support-test - -LOCAL_PACKAGE_NAME := MtpTests -LOCAL_PRIVATE_PLATFORM_APIS := true - -include $(BUILD_PACKAGE) diff --git a/packages/CaptivePortalLogin/Android.bp b/packages/CaptivePortalLogin/Android.bp index f545a61aff4f..732acca6094f 100644 --- a/packages/CaptivePortalLogin/Android.bp +++ b/packages/CaptivePortalLogin/Android.bp @@ -23,6 +23,7 @@ android_app { static_libs: [ "android-support-v4", "metrics-constants-protos", + "captiveportal-lib", ], manifest: "AndroidManifest.xml", } diff --git a/packages/NetworkStack/Android.bp b/packages/NetworkStack/Android.bp index d56f97f55f7e..57a3db586c53 100644 --- a/packages/NetworkStack/Android.bp +++ b/packages/NetworkStack/Android.bp @@ -14,6 +14,15 @@ // limitations under the License. // +java_library { + name: "captiveportal-lib", + srcs: ["common/**/*.java"], + libs: [ + "androidx.annotation_annotation", + ], + sdk_version: "system_current", +} + java_defaults { name: "NetworkStackCommon", sdk_version: "system_current", @@ -35,6 +44,7 @@ android_library { "networkstack-aidl-interfaces-java", "datastallprotosnano", "networkstackprotosnano", + "captiveportal-lib", ], manifest: "AndroidManifestBase.xml", } diff --git a/core/java/android/net/captiveportal/CaptivePortalProbeResult.java b/packages/NetworkStack/common/CaptivePortalProbeResult.java index a1d3de248a96..48cd48b30085 100644 --- a/core/java/android/net/captiveportal/CaptivePortalProbeResult.java +++ b/packages/NetworkStack/common/CaptivePortalProbeResult.java @@ -16,17 +16,13 @@ package android.net.captiveportal; -import android.annotation.NonNull; -import android.annotation.Nullable; -import android.annotation.SystemApi; -import android.annotation.TestApi; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; /** * Result of calling isCaptivePortal(). * @hide */ -@SystemApi -@TestApi public final class CaptivePortalProbeResult { public static final int SUCCESS_CODE = 204; public static final int FAILED_CODE = 599; diff --git a/core/java/android/net/captiveportal/CaptivePortalProbeSpec.java b/packages/NetworkStack/common/CaptivePortalProbeSpec.java index b354607b8856..bf983a50ab51 100644 --- a/core/java/android/net/captiveportal/CaptivePortalProbeSpec.java +++ b/packages/NetworkStack/common/CaptivePortalProbeSpec.java @@ -19,16 +19,12 @@ package android.net.captiveportal; import static android.net.captiveportal.CaptivePortalProbeResult.PORTAL_CODE; import static android.net.captiveportal.CaptivePortalProbeResult.SUCCESS_CODE; -import static com.android.internal.util.Preconditions.checkNotNull; - -import android.annotation.NonNull; -import android.annotation.Nullable; -import android.annotation.SystemApi; -import android.annotation.TestApi; import android.text.TextUtils; import android.util.Log; -import com.android.internal.annotations.VisibleForTesting; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.annotation.VisibleForTesting; import java.net.MalformedURLException; import java.net.URL; @@ -40,8 +36,6 @@ import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; /** @hide */ -@SystemApi -@TestApi public abstract class CaptivePortalProbeSpec { private static final String TAG = CaptivePortalProbeSpec.class.getSimpleName(); private static final String REGEX_SEPARATOR = "@@/@@"; @@ -192,4 +186,10 @@ public abstract class CaptivePortalProbeSpec { // No value is a match ("no location header" passes the location rule for non-redirects) return pattern == null || TextUtils.isEmpty(value) || pattern.matcher(value).matches(); } + + // Throws NullPointerException if the input is null. + private static <T> T checkNotNull(T object) { + if (object == null) throw new NullPointerException(); + return object; + } } diff --git a/tests/net/java/android/net/captiveportal/CaptivePortalProbeSpecTest.java b/packages/NetworkStack/tests/src/android/net/captiveportal/CaptivePortalProbeSpecTest.java index f948086ac79b..f948086ac79b 100644 --- a/tests/net/java/android/net/captiveportal/CaptivePortalProbeSpecTest.java +++ b/packages/NetworkStack/tests/src/android/net/captiveportal/CaptivePortalProbeSpecTest.java diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index 31d8113bbb54..fc9d6f8668b2 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -951,7 +951,7 @@ public class ConnectivityService extends IConnectivityManager.Stub mTethering = makeTethering(); - mPermissionMonitor = new PermissionMonitor(mContext, mNMS); + mPermissionMonitor = new PermissionMonitor(mContext, mNMS, mNetd); // Set up the listener for user state for creating user VPNs. // Should run on mHandler to avoid any races. @@ -6389,6 +6389,11 @@ public class ConnectivityService extends IConnectivityManager.Stub Slog.wtf(TAG, networkAgent.name() + " connected with null LinkProperties"); } + // NetworkCapabilities need to be set before sending the private DNS config to + // NetworkMonitor, otherwise NetworkMonitor cannot determine if validation is required. + synchronized (networkAgent) { + networkAgent.setNetworkCapabilities(networkAgent.networkCapabilities); + } handlePerNetworkPrivateDnsConfig(networkAgent, mDnsManager.getPrivateDnsConfig()); updateLinkProperties(networkAgent, new LinkProperties(networkAgent.linkProperties), null); diff --git a/services/core/java/com/android/server/connectivity/PermissionMonitor.java b/services/core/java/com/android/server/connectivity/PermissionMonitor.java index 0c559346bc42..da1360d59539 100644 --- a/services/core/java/com/android/server/connectivity/PermissionMonitor.java +++ b/services/core/java/com/android/server/connectivity/PermissionMonitor.java @@ -37,7 +37,6 @@ import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.PackageManagerInternal; import android.content.pm.UserInfo; import android.net.INetd; -import android.net.util.NetdService; import android.os.Build; import android.os.INetworkManagementService; import android.os.RemoteException; @@ -77,7 +76,8 @@ public class PermissionMonitor { private final Context mContext; private final PackageManager mPackageManager; private final UserManager mUserManager; - private final INetworkManagementService mNetd; + private final INetworkManagementService mNMS; + private final INetd mNetd; // Values are User IDs. private final Set<Integer> mUsers = new HashSet<>(); @@ -100,6 +100,9 @@ public class PermissionMonitor { app.requestedPermissionsFlags); } } + } else { + // The last package of this uid is removed from device. Clean the package up. + permission = INetd.PERMISSION_UNINSTALLED; } return permission; } @@ -115,11 +118,12 @@ public class PermissionMonitor { } } - public PermissionMonitor(Context context, INetworkManagementService netd) { + public PermissionMonitor(Context context, INetworkManagementService nms, INetd netdService) { mContext = context; mPackageManager = context.getPackageManager(); mUserManager = UserManager.get(context); - mNetd = netd; + mNMS = nms; + mNetd = netdService; } // Intended to be called only once at startup, after the system is ready. Installs a broadcast @@ -285,11 +289,11 @@ public class PermissionMonitor { } try { if (add) { - mNetd.setPermission("NETWORK", toIntArray(network)); - mNetd.setPermission("SYSTEM", toIntArray(system)); + mNMS.setPermission("NETWORK", toIntArray(network)); + mNMS.setPermission("SYSTEM", toIntArray(system)); } else { - mNetd.clearPermission(toIntArray(network)); - mNetd.clearPermission(toIntArray(system)); + mNMS.clearPermission(toIntArray(network)); + mNMS.clearPermission(toIntArray(system)); } } catch (RemoteException e) { loge("Exception when updating permissions: " + e); @@ -447,7 +451,8 @@ public class PermissionMonitor { * * @hide */ - private void sendPackagePermissionsForUid(int uid, int permissions) { + @VisibleForTesting + void sendPackagePermissionsForUid(int uid, int permissions) { SparseIntArray netdPermissionsAppIds = new SparseIntArray(); netdPermissionsAppIds.put(uid, permissions); sendPackagePermissionsToNetd(netdPermissionsAppIds); @@ -462,15 +467,13 @@ public class PermissionMonitor { * * @hide */ - private void sendPackagePermissionsToNetd(SparseIntArray netdPermissionsAppIds) { - INetd netdService = NetdService.getInstance(); - if (netdService == null) { - Log.e(TAG, "Failed to get the netd service"); - return; - } + @VisibleForTesting + void sendPackagePermissionsToNetd(SparseIntArray netdPermissionsAppIds) { + ArrayList<Integer> allPermissionAppIds = new ArrayList<>(); ArrayList<Integer> internetPermissionAppIds = new ArrayList<>(); ArrayList<Integer> updateStatsPermissionAppIds = new ArrayList<>(); + ArrayList<Integer> noPermissionAppIds = new ArrayList<>(); ArrayList<Integer> uninstalledAppIds = new ArrayList<>(); for (int i = 0; i < netdPermissionsAppIds.size(); i++) { int permissions = netdPermissionsAppIds.valueAt(i); @@ -485,8 +488,10 @@ public class PermissionMonitor { updateStatsPermissionAppIds.add(netdPermissionsAppIds.keyAt(i)); break; case INetd.NO_PERMISSIONS: - uninstalledAppIds.add(netdPermissionsAppIds.keyAt(i)); + noPermissionAppIds.add(netdPermissionsAppIds.keyAt(i)); break; + case INetd.PERMISSION_UNINSTALLED: + uninstalledAppIds.add(netdPermissionsAppIds.keyAt(i)); default: Log.e(TAG, "unknown permission type: " + permissions + "for uid: " + netdPermissionsAppIds.keyAt(i)); @@ -495,20 +500,24 @@ public class PermissionMonitor { try { // TODO: add a lock inside netd to protect IPC trafficSetNetPermForUids() if (allPermissionAppIds.size() != 0) { - netdService.trafficSetNetPermForUids( + mNetd.trafficSetNetPermForUids( INetd.PERMISSION_INTERNET | INetd.PERMISSION_UPDATE_DEVICE_STATS, ArrayUtils.convertToIntArray(allPermissionAppIds)); } if (internetPermissionAppIds.size() != 0) { - netdService.trafficSetNetPermForUids(INetd.PERMISSION_INTERNET, + mNetd.trafficSetNetPermForUids(INetd.PERMISSION_INTERNET, ArrayUtils.convertToIntArray(internetPermissionAppIds)); } if (updateStatsPermissionAppIds.size() != 0) { - netdService.trafficSetNetPermForUids(INetd.PERMISSION_UPDATE_DEVICE_STATS, + mNetd.trafficSetNetPermForUids(INetd.PERMISSION_UPDATE_DEVICE_STATS, ArrayUtils.convertToIntArray(updateStatsPermissionAppIds)); } + if (noPermissionAppIds.size() != 0) { + mNetd.trafficSetNetPermForUids(INetd.NO_PERMISSIONS, + ArrayUtils.convertToIntArray(noPermissionAppIds)); + } if (uninstalledAppIds.size() != 0) { - netdService.trafficSetNetPermForUids(INetd.NO_PERMISSIONS, + mNetd.trafficSetNetPermForUids(INetd.PERMISSION_UNINSTALLED, ArrayUtils.convertToIntArray(uninstalledAppIds)); } } catch (RemoteException e) { diff --git a/services/core/java/com/android/server/connectivity/tethering/EntitlementManager.java b/services/core/java/com/android/server/connectivity/tethering/EntitlementManager.java index 764a6ebc2d98..b0bbd72794d9 100644 --- a/services/core/java/com/android/server/connectivity/tethering/EntitlementManager.java +++ b/services/core/java/com/android/server/connectivity/tethering/EntitlementManager.java @@ -52,7 +52,6 @@ import android.os.UserHandle; import android.provider.Settings; import android.telephony.CarrierConfigManager; import android.util.ArraySet; -import android.util.Log; import android.util.SparseIntArray; import com.android.internal.annotations.VisibleForTesting; @@ -231,7 +230,7 @@ public class EntitlementManager { private void handleNotifyUpstream(boolean isCellular) { if (DBG) { - Log.d(TAG, "notifyUpstream: " + isCellular + mLog.i("notifyUpstream: " + isCellular + ", mCellularUpstreamPermitted: " + mCellularUpstreamPermitted + ", mNeedReRunProvisioningUi: " + mNeedReRunProvisioningUi); } @@ -294,7 +293,7 @@ public class EntitlementManager { * masterHandler to avoid race conditions. */ public void reevaluateSimCardProvisioning() { - if (DBG) Log.d(TAG, "reevaluateSimCardProvisioning"); + if (DBG) mLog.i("reevaluateSimCardProvisioning"); if (!mHandler.getLooper().isCurrentThread()) { // Except for test, this log should not appear in normal flow. @@ -351,7 +350,7 @@ public class EntitlementManager { * @param type tethering type from ConnectivityManager.TETHERING_{@code *} */ protected void runSilentTetherProvisioning(int type) { - if (DBG) Log.d(TAG, "runSilentTetherProvisioning: " + type); + if (DBG) mLog.i("runSilentTetherProvisioning: " + type); // For silent provisioning, settings would stop tethering when entitlement fail. ResultReceiver receiver = buildProxyReceiver(type, false/* notifyFail */, null); @@ -382,7 +381,7 @@ public class EntitlementManager { @VisibleForTesting protected void runUiTetherProvisioning(int type, ResultReceiver receiver) { - if (DBG) Log.d(TAG, "runUiTetherProvisioning: " + type); + if (DBG) mLog.i("runUiTetherProvisioning: " + type); Intent intent = new Intent(Settings.ACTION_TETHER_PROVISIONING); intent.putExtra(EXTRA_ADD_TETHER_TYPE, type); @@ -428,7 +427,7 @@ public class EntitlementManager { || mCellularPermitted.indexOfValue(TETHER_ERROR_NO_ERROR) > -1); if (DBG) { - Log.d(TAG, "Cellular permission change from " + oldPermitted + mLog.i("Cellular permission change from " + oldPermitted + " to " + mCellularUpstreamPermitted); } @@ -453,10 +452,8 @@ public class EntitlementManager { * @param resultCode Provisioning result */ protected void addDownstreamMapping(int type, int resultCode) { - if (DBG) { - Log.d(TAG, "addDownstreamMapping: " + type + ", result: " + resultCode - + " ,TetherTypeRequested: " + mCurrentTethers.contains(type)); - } + mLog.i("addDownstreamMapping: " + type + ", result: " + resultCode + + " ,TetherTypeRequested: " + mCurrentTethers.contains(type)); if (!mCurrentTethers.contains(type)) return; mCellularPermitted.put(type, resultCode); @@ -468,7 +465,7 @@ public class EntitlementManager { * @param type tethering type from ConnectivityManager.TETHERING_{@code *} */ protected void removeDownstreamMapping(int type) { - if (DBG) Log.d(TAG, "removeDownstreamMapping: " + type); + mLog.i("removeDownstreamMapping: " + type); mCellularPermitted.delete(type); evaluateCellularPermission(); } @@ -617,7 +614,7 @@ public class EntitlementManager { */ private int updateEntitlementCacheValue(int type, int resultCode) { if (DBG) { - Log.d(TAG, "updateEntitlementCacheValue: " + type + ", result: " + resultCode); + mLog.i("updateEntitlementCacheValue: " + type + ", result: " + resultCode); } if (resultCode == TETHER_ERROR_NO_ERROR) { mEntitlementCacheValue.put(type, resultCode); diff --git a/services/core/java/com/android/server/pm/PackageDexOptimizer.java b/services/core/java/com/android/server/pm/PackageDexOptimizer.java index 8018c2b7c27d..662352679c3b 100644 --- a/services/core/java/com/android/server/pm/PackageDexOptimizer.java +++ b/services/core/java/com/android/server/pm/PackageDexOptimizer.java @@ -150,51 +150,6 @@ public class PackageDexOptimizer { } } - int performDexOpt(SharedLibraryInfo info, String[] instructionSets, DexoptOptions options) { - String classLoaderContext = DexoptUtils.getClassLoaderContext(info); - final String[] dexCodeInstructionSets = getDexCodeInstructionSets(instructionSets); - String compilerFilter = PackageManagerServiceCompilerMapping.getCompilerFilterForReason( - PackageManagerService.REASON_SHARED); - int result = DEX_OPT_SKIPPED; - for (String instructionSet : dexCodeInstructionSets) { - int dexoptNeeded = getDexoptNeeded( - info.getPath(), instructionSet, compilerFilter, - classLoaderContext, false /* newProfile */, - false /* downgrade */); - if (Math.abs(dexoptNeeded) == DexFile.NO_DEXOPT_NEEDED) { - continue; - } - // Special string recognized by installd. - final String packageName = "*"; - final String outputPath = null; - int dexFlags = DEXOPT_PUBLIC - | (options.isBootComplete() ? DEXOPT_BOOTCOMPLETE : 0) - | (options.isDexoptIdleBackgroundJob() ? DEXOPT_IDLE_BACKGROUND_JOB : 0); - dexFlags = adjustDexoptFlags(dexFlags); - final String uuid = StorageManager.UUID_SYSTEM; - final String seInfo = null; - final int targetSdkVersion = 0; // Builtin libraries targets the system's SDK version - try { - mInstaller.dexopt(info.getPath(), Process.SYSTEM_UID, packageName, - instructionSet, dexoptNeeded, outputPath, dexFlags, compilerFilter, - uuid, classLoaderContext, seInfo, false /* downgrade */, - targetSdkVersion, /*profileName*/ null, /*dexMetadataPath*/ null, - getReasonName(options.getCompilationReason())); - // The end result is: - // - FAILED if any path failed, - // - PERFORMED if at least one path needed compilation, - // - SKIPPED when all paths are up to date - if (result != DEX_OPT_FAILED) { - result = DEX_OPT_PERFORMED; - } - } catch (InstallerException e) { - Slog.w(TAG, "Failed to dexopt", e); - result = DEX_OPT_FAILED; - } - } - return result; - } - /** * Performs dexopt on all code paths of the given package. * It assumes the install lock is held. diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 790e6e1431ef..2066478aea52 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -9463,7 +9463,7 @@ public class PackageManagerService extends IPackageManager.Stub mDexManager.getPackageUseInfoOrDefault(depPackage.packageName), libraryOptions); } else { - pdo.performDexOpt(info, instructionSets, libraryOptions); + // TODO(ngeoffray): Support dexopting system shared libraries. } } } diff --git a/startop/iorap/tests/Android.bp b/startop/iorap/tests/Android.bp index 76057846e896..2b810f3c862d 100644 --- a/startop/iorap/tests/Android.bp +++ b/startop/iorap/tests/Android.bp @@ -16,7 +16,6 @@ java_library { name: "libiorap-java-test-lib", srcs: ["src/**/*.kt"], - static_libs: [ // non-test dependencies "libiorap-java", @@ -28,13 +27,33 @@ java_library { // "mockito-target-minus-junit4", // Mockito also requires JNI (see Android.mk) // and android:debuggable=true (see AndroidManifest.xml) - "truth-prebuilt", + "truth-prebuilt", ], - // sdk_version: "current", // certificate: "platform", - - libs: ["android.test.base", "android.test.runner"], - + libs: [ + "android.test.base", + "android.test.runner", + ], // test_suites: ["device-tests"], } + +android_test { + name: "libiorap-java-tests", + dxflags: ["--multi-dex"], + test_suites: ["device-tests"], + static_libs: ["libiorap-java-test-lib"], + compile_multilib: "both", + jni_libs: [ + "libdexmakerjvmtiagent", + "libstaticjvmtiagent", + "libmultiplejvmtiagentsinterferenceagent", + ], + libs: [ + "android.test.base", + "android.test.runner", + ], + // Use private APIs + certificate: "platform", + platform_apis: true, +} diff --git a/startop/iorap/tests/Android.mk b/startop/iorap/tests/Android.mk deleted file mode 100644 index 1b2aa46a6418..000000000000 --- a/startop/iorap/tests/Android.mk +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright (C) 2018 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 does not support JNI libraries -# TODO: once b/80095087 is fixed, rewrite this back to android_test -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE_TAGS := tests - -LOCAL_JACK_FLAGS := --multi-dex native -LOCAL_DX_FLAGS := --multi-dex - -LOCAL_PACKAGE_NAME := libiorap-java-tests -LOCAL_COMPATIBILITY_SUITE := device-tests - -LOCAL_STATIC_JAVA_LIBRARIES := \ - libiorap-java-test-lib - -LOCAL_MULTILIB := both - -LOCAL_JNI_SHARED_LIBRARIES := \ - libdexmakerjvmtiagent \ - libstaticjvmtiagent \ - libmultiplejvmtiagentsinterferenceagent - -LOCAL_JAVA_LIBRARIES := \ - android.test.base \ - android.test.runner - -# Use private APIs -LOCAL_CERTIFICATE := platform -LOCAL_PRIVATE_PLATFORM_APIS := true - -include $(BUILD_PACKAGE) diff --git a/telephony/java/android/provider/Telephony.java b/telephony/java/android/provider/Telephony.java index 983d1341400e..6dd683a1376e 100644 --- a/telephony/java/android/provider/Telephony.java +++ b/telephony/java/android/provider/Telephony.java @@ -35,6 +35,7 @@ import android.database.Cursor; import android.database.sqlite.SqliteWrapper; import android.net.Uri; import android.os.Build; +import android.os.Parcel; import android.telephony.Rlog; import android.telephony.ServiceState; import android.telephony.SmsMessage; @@ -4066,32 +4067,24 @@ public final class Telephony { */ public static ContentValues getContentValuesForServiceState(ServiceState state) { ContentValues values = new ContentValues(); - values.put(VOICE_REG_STATE, state.getVoiceRegState()); - values.put(DATA_REG_STATE, state.getDataRegState()); - values.put(VOICE_ROAMING_TYPE, state.getVoiceRoamingType()); - values.put(DATA_ROAMING_TYPE, state.getDataRoamingType()); - values.put(VOICE_OPERATOR_ALPHA_LONG, state.getVoiceOperatorAlphaLong()); - values.put(VOICE_OPERATOR_ALPHA_SHORT, state.getVoiceOperatorAlphaShort()); - values.put(VOICE_OPERATOR_NUMERIC, state.getVoiceOperatorNumeric()); - values.put(DATA_OPERATOR_ALPHA_LONG, state.getDataOperatorAlphaLong()); - values.put(DATA_OPERATOR_ALPHA_SHORT, state.getDataOperatorAlphaShort()); - values.put(DATA_OPERATOR_NUMERIC, state.getDataOperatorNumeric()); - values.put(IS_MANUAL_NETWORK_SELECTION, state.getIsManualSelection()); - values.put(RIL_VOICE_RADIO_TECHNOLOGY, state.getRilVoiceRadioTechnology()); - values.put(RIL_DATA_RADIO_TECHNOLOGY, state.getRilDataRadioTechnology()); - values.put(CSS_INDICATOR, state.getCssIndicator()); - values.put(NETWORK_ID, state.getCdmaNetworkId()); - values.put(SYSTEM_ID, state.getCdmaSystemId()); - values.put(CDMA_ROAMING_INDICATOR, state.getCdmaRoamingIndicator()); - values.put(CDMA_DEFAULT_ROAMING_INDICATOR, state.getCdmaDefaultRoamingIndicator()); - values.put(CDMA_ERI_ICON_INDEX, state.getCdmaEriIconIndex()); - values.put(CDMA_ERI_ICON_MODE, state.getCdmaEriIconMode()); - values.put(IS_EMERGENCY_ONLY, state.isEmergencyOnly()); - values.put(IS_USING_CARRIER_AGGREGATION, state.isUsingCarrierAggregation()); + final Parcel p = Parcel.obtain(); + state.writeToParcel(p, 0); + // Turn the parcel to byte array. Safe to do this because the content values were never + // written into a persistent storage. ServiceStateProvider keeps values in the memory. + values.put(SERVICE_STATE, p.marshall()); return values; } /** + * The current service state. + * + * This is the entire {@link ServiceState} object in byte array. + * + * @hide + */ + public static final String SERVICE_STATE = "service_state"; + + /** * An integer value indicating the current voice service state. * <p> * Valid values: {@link ServiceState#STATE_IN_SERVICE}, diff --git a/telephony/java/android/telephony/DataSpecificRegistrationInfo.java b/telephony/java/android/telephony/DataSpecificRegistrationInfo.java index fbf488e590fd..465c2b1be3d9 100644 --- a/telephony/java/android/telephony/DataSpecificRegistrationInfo.java +++ b/telephony/java/android/telephony/DataSpecificRegistrationInfo.java @@ -74,16 +74,25 @@ public final class DataSpecificRegistrationInfo implements Parcelable { private final LteVopsSupportInfo mLteVopsSupportInfo; /** + * Indicates if it's using carrier aggregation + * + * @hide + */ + public final boolean isUsingCarrierAggregation; + + /** * @hide */ DataSpecificRegistrationInfo( int maxDataCalls, boolean isDcNrRestricted, boolean isNrAvailable, - boolean isEnDcAvailable, LteVopsSupportInfo lteVops) { + boolean isEnDcAvailable, LteVopsSupportInfo lteVops, + boolean isUsingCarrierAggregation) { this.maxDataCalls = maxDataCalls; this.isDcNrRestricted = isDcNrRestricted; this.isNrAvailable = isNrAvailable; this.isEnDcAvailable = isEnDcAvailable; this.mLteVopsSupportInfo = lteVops; + this.isUsingCarrierAggregation = isUsingCarrierAggregation; } private DataSpecificRegistrationInfo(Parcel source) { @@ -92,6 +101,7 @@ public final class DataSpecificRegistrationInfo implements Parcelable { isNrAvailable = source.readBoolean(); isEnDcAvailable = source.readBoolean(); mLteVopsSupportInfo = LteVopsSupportInfo.CREATOR.createFromParcel(source); + isUsingCarrierAggregation = source.readBoolean(); } @Override @@ -101,6 +111,7 @@ public final class DataSpecificRegistrationInfo implements Parcelable { dest.writeBoolean(isNrAvailable); dest.writeBoolean(isEnDcAvailable); mLteVopsSupportInfo.writeToParcel(dest, flags); + dest.writeBoolean(isUsingCarrierAggregation); } @Override @@ -116,7 +127,8 @@ public final class DataSpecificRegistrationInfo implements Parcelable { .append(" isDcNrRestricted = " + isDcNrRestricted) .append(" isNrAvailable = " + isNrAvailable) .append(" isEnDcAvailable = " + isEnDcAvailable) - .append(mLteVopsSupportInfo.toString()) + .append(" " + mLteVopsSupportInfo.toString()) + .append(" isUsingCarrierAggregation = " + isUsingCarrierAggregation) .append(" }") .toString(); } @@ -124,7 +136,7 @@ public final class DataSpecificRegistrationInfo implements Parcelable { @Override public int hashCode() { return Objects.hash(maxDataCalls, isDcNrRestricted, isNrAvailable, isEnDcAvailable, - mLteVopsSupportInfo); + mLteVopsSupportInfo, isUsingCarrierAggregation); } @Override @@ -138,7 +150,8 @@ public final class DataSpecificRegistrationInfo implements Parcelable { && this.isDcNrRestricted == other.isDcNrRestricted && this.isNrAvailable == other.isNrAvailable && this.isEnDcAvailable == other.isEnDcAvailable - && this.mLteVopsSupportInfo.equals(other.mLteVopsSupportInfo); + && this.mLteVopsSupportInfo.equals(other.mLteVopsSupportInfo) + && this.isUsingCarrierAggregation == other.isUsingCarrierAggregation; } public static final @NonNull Parcelable.Creator<DataSpecificRegistrationInfo> CREATOR = diff --git a/telephony/java/android/telephony/NetworkRegistrationInfo.java b/telephony/java/android/telephony/NetworkRegistrationInfo.java index 1dc29979dc61..2bb02e7af1e0 100644 --- a/telephony/java/android/telephony/NetworkRegistrationInfo.java +++ b/telephony/java/android/telephony/NetworkRegistrationInfo.java @@ -251,12 +251,13 @@ public final class NetworkRegistrationInfo implements Parcelable { @Nullable CellIdentity cellIdentity, int maxDataCalls, boolean isDcNrRestricted, boolean isNrAvailable, boolean isEndcAvailable, - LteVopsSupportInfo lteVopsSupportInfo) { + LteVopsSupportInfo lteVopsSupportInfo, + boolean isUsingCarrierAggregation) { this(domain, transportType, registrationState, accessNetworkTechnology, rejectCause, emergencyOnly, availableServices, cellIdentity); - mDataSpecificInfo = new DataSpecificRegistrationInfo( - maxDataCalls, isDcNrRestricted, isNrAvailable, isEndcAvailable, lteVopsSupportInfo); + maxDataCalls, isDcNrRestricted, isNrAvailable, isEndcAvailable, lteVopsSupportInfo, + isUsingCarrierAggregation); updateNrState(mDataSpecificInfo); } diff --git a/telephony/java/android/telephony/PhoneNumberUtils.java b/telephony/java/android/telephony/PhoneNumberUtils.java index 549c04420ce0..b75e51577fdb 100644 --- a/telephony/java/android/telephony/PhoneNumberUtils.java +++ b/telephony/java/android/telephony/PhoneNumberUtils.java @@ -2016,7 +2016,16 @@ public class PhoneNumberUtils { private static boolean isEmergencyNumberInternal(int subId, String number, String defaultCountryIso, boolean useExactMatch) { - return TelephonyManager.getDefault().isEmergencyNumber(number); + try { + if (useExactMatch) { + return TelephonyManager.getDefault().isEmergencyNumber(number); + } else { + return TelephonyManager.getDefault().isPotentialEmergencyNumber(number); + } + } catch (RuntimeException ex) { + Rlog.e(LOG_TAG, "isEmergencyNumberInternal: RuntimeException: " + ex); + } + return false; } /** diff --git a/tests/net/java/com/android/server/connectivity/PermissionMonitorTest.java b/tests/net/java/com/android/server/connectivity/PermissionMonitorTest.java index 354c08f12e10..106cd1fba869 100644 --- a/tests/net/java/com/android/server/connectivity/PermissionMonitorTest.java +++ b/tests/net/java/com/android/server/connectivity/PermissionMonitorTest.java @@ -20,10 +20,13 @@ import static android.Manifest.permission.CHANGE_NETWORK_STATE; import static android.Manifest.permission.CHANGE_WIFI_STATE; import static android.Manifest.permission.CONNECTIVITY_INTERNAL; import static android.Manifest.permission.CONNECTIVITY_USE_RESTRICTED_NETWORKS; +import static android.Manifest.permission.INTERNET; import static android.Manifest.permission.NETWORK_STACK; +import static android.Manifest.permission.UPDATE_DEVICE_STATS; import static android.content.pm.ApplicationInfo.PRIVATE_FLAG_OEM; import static android.content.pm.ApplicationInfo.PRIVATE_FLAG_PRODUCT; import static android.content.pm.ApplicationInfo.PRIVATE_FLAG_VENDOR; +import static android.content.pm.PackageInfo.REQUESTED_PERMISSION_GRANTED; import static android.content.pm.PackageManager.GET_PERMISSIONS; import static android.os.Process.SYSTEM_UID; @@ -41,26 +44,35 @@ import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; +import android.content.pm.PackageList; import android.content.pm.PackageManager; +import android.content.pm.PackageManagerInternal; +import android.net.INetd; import android.os.Build; import android.os.INetworkManagementService; import android.os.UserHandle; +import android.util.SparseIntArray; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; +import com.android.server.LocalServices; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.mockito.invocation.InvocationOnMock; +import java.util.ArrayList; import java.util.HashMap; @RunWith(AndroidJUnit4.class) @@ -69,7 +81,11 @@ public class PermissionMonitorTest { private static final int MOCK_USER1 = 0; private static final int MOCK_USER2 = 1; private static final int MOCK_UID1 = 10001; + private static final int MOCK_UID2 = 10086; + private static final int SYSTEM_UID1 = 1000; + private static final int SYSTEM_UID2 = 1008; private static final String MOCK_PACKAGE1 = "appName1"; + private static final String MOCK_PACKAGE2 = "appName2"; private static final String SYSTEM_PACKAGE1 = "sysName1"; private static final String SYSTEM_PACKAGE2 = "sysName2"; private static final String PARTITION_SYSTEM = "system"; @@ -82,14 +98,29 @@ public class PermissionMonitorTest { @Mock private Context mContext; @Mock private PackageManager mPackageManager; @Mock private INetworkManagementService mNMS; + @Mock private INetd mNetdService; + @Mock private PackageManagerInternal mMockPmi; + private PackageManagerInternal.PackageListObserver mObserver; private PermissionMonitor mPermissionMonitor; @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); when(mContext.getPackageManager()).thenReturn(mPackageManager); - mPermissionMonitor = spy(new PermissionMonitor(mContext, mNMS)); + mPermissionMonitor = spy(new PermissionMonitor(mContext, mNMS, mNetdService)); + + LocalServices.removeServiceForTest(PackageManagerInternal.class); + LocalServices.addService(PackageManagerInternal.class, mMockPmi); + when(mMockPmi.getPackageList(any())).thenReturn(new PackageList(new ArrayList<String>(), + /* observer */ null)); + when(mPackageManager.getInstalledPackages(anyInt())).thenReturn(/* empty app list */ null); + mPermissionMonitor.startMonitoring(); + + final ArgumentCaptor<PackageManagerInternal.PackageListObserver> observerCaptor = + ArgumentCaptor.forClass(PackageManagerInternal.PackageListObserver.class); + verify(mMockPmi).getPackageList(observerCaptor.capture()); + mObserver = observerCaptor.getValue(); } private boolean hasBgPermission(String partition, int targetSdkVersion, int uid, @@ -104,9 +135,20 @@ public class PermissionMonitorTest { } private PackageInfo packageInfoWithPermissions(String[] permissions, String partition) { + int[] requestedPermissionsFlags = new int[permissions.length]; + for (int i = 0; i < permissions.length; i++) { + requestedPermissionsFlags[i] = REQUESTED_PERMISSION_GRANTED; + } + return packageInfoWithPermissions(permissions, partition, + requestedPermissionsFlags); + } + + private PackageInfo packageInfoWithPermissions(String[] permissions, String partition, + int[] requestedPermissionsFlags) { final PackageInfo packageInfo = new PackageInfo(); packageInfo.requestedPermissions = permissions; packageInfo.applicationInfo = new ApplicationInfo(); + packageInfo.requestedPermissionsFlags = requestedPermissionsFlags; int privateFlags = 0; switch (partition) { case PARTITION_OEM: @@ -337,4 +379,164 @@ public class PermissionMonitorTest { mPermissionMonitor.onPackageRemoved(UserHandle.getUid(user, uid)); } } + + private class NetdServiceMonitor { + private final HashMap<Integer, Integer> mPermissions = new HashMap<>(); + + NetdServiceMonitor(INetd mockNetdService) throws Exception { + // Add hook to verify and track result of setPermission. + doAnswer((InvocationOnMock invocation) -> { + final Object[] args = invocation.getArguments(); + final int permission = (int) args[0]; + for (final int uid : (int[]) args[1]) { + mPermissions.put(uid, permission); + } + return null; + }).when(mockNetdService).trafficSetNetPermForUids(anyInt(), any(int[].class)); + } + + public void expectPermission(int permission, int[] apps) { + for (final int app : apps) { + if (!mPermissions.containsKey(app)) { + fail("uid " + app + " does not exist."); + } + if (mPermissions.get(app) != permission) { + fail("uid " + app + " has wrong permission: " + mPermissions.get(app)); + } + } + } + } + + @Test + public void testPackagePermissionUpdate() throws Exception { + final NetdServiceMonitor mNetdServiceMonitor = new NetdServiceMonitor(mNetdService); + // MOCK_UID1: MOCK_PACKAGE1 only has internet permission. + // MOCK_UID2: MOCK_PACKAGE2 does not have any permission. + // SYSTEM_UID1: SYSTEM_PACKAGE1 has internet permission and update device stats permission. + // SYSTEM_UID2: SYSTEM_PACKAGE2 has only update device stats permission. + + SparseIntArray netdPermissionsAppIds = new SparseIntArray(); + netdPermissionsAppIds.put(MOCK_UID1, INetd.PERMISSION_INTERNET); + netdPermissionsAppIds.put(MOCK_UID2, INetd.NO_PERMISSIONS); + netdPermissionsAppIds.put(SYSTEM_UID1, INetd.PERMISSION_INTERNET + | INetd.PERMISSION_UPDATE_DEVICE_STATS); + netdPermissionsAppIds.put(SYSTEM_UID2, INetd.PERMISSION_UPDATE_DEVICE_STATS); + + // Send the permission information to netd, expect permission updated. + mPermissionMonitor.sendPackagePermissionsToNetd(netdPermissionsAppIds); + + mNetdServiceMonitor.expectPermission(INetd.PERMISSION_INTERNET, + new int[]{MOCK_UID1}); + mNetdServiceMonitor.expectPermission(INetd.NO_PERMISSIONS, new int[]{MOCK_UID2}); + mNetdServiceMonitor.expectPermission(INetd.PERMISSION_INTERNET + | INetd.PERMISSION_UPDATE_DEVICE_STATS, new int[]{SYSTEM_UID1}); + mNetdServiceMonitor.expectPermission(INetd.PERMISSION_UPDATE_DEVICE_STATS, + new int[]{SYSTEM_UID2}); + + // Update permission of MOCK_UID1, expect new permission show up. + mPermissionMonitor.sendPackagePermissionsForUid(MOCK_UID1, + INetd.PERMISSION_INTERNET | INetd.PERMISSION_UPDATE_DEVICE_STATS); + mNetdServiceMonitor.expectPermission(INetd.PERMISSION_INTERNET + | INetd.PERMISSION_UPDATE_DEVICE_STATS, new int[]{MOCK_UID1}); + + // Change permissions of SYSTEM_UID2, expect new permission show up and old permission + // revoked. + mPermissionMonitor.sendPackagePermissionsForUid(SYSTEM_UID2, + INetd.PERMISSION_INTERNET); + mNetdServiceMonitor.expectPermission(INetd.PERMISSION_INTERNET, new int[]{SYSTEM_UID2}); + + // Revoke permission from SYSTEM_UID1, expect no permission stored. + mPermissionMonitor.sendPackagePermissionsForUid(SYSTEM_UID1, INetd.NO_PERMISSIONS); + mNetdServiceMonitor.expectPermission(INetd.NO_PERMISSIONS, new int[]{SYSTEM_UID1}); + } + + private PackageInfo addPackage(String packageName, int uid, String[] permissions) + throws Exception { + PackageInfo packageInfo = packageInfoWithPermissions(permissions, PARTITION_SYSTEM); + when(mPackageManager.getPackageInfo(eq(packageName), anyInt())).thenReturn(packageInfo); + when(mPackageManager.getPackagesForUid(eq(uid))).thenReturn(new String[]{packageName}); + mObserver.onPackageAdded(packageName, uid); + return packageInfo; + } + + @Test + public void testPackageInstall() throws Exception { + final NetdServiceMonitor mNetdServiceMonitor = new NetdServiceMonitor(mNetdService); + + addPackage(MOCK_PACKAGE1, MOCK_UID1, new String[] {INTERNET, UPDATE_DEVICE_STATS}); + mNetdServiceMonitor.expectPermission(INetd.PERMISSION_INTERNET + | INetd.PERMISSION_UPDATE_DEVICE_STATS, new int[]{MOCK_UID1}); + + addPackage(MOCK_PACKAGE2, MOCK_UID2, new String[] {INTERNET}); + mNetdServiceMonitor.expectPermission(INetd.PERMISSION_INTERNET, new int[]{MOCK_UID2}); + } + + @Test + public void testPackageInstallSharedUid() throws Exception { + final NetdServiceMonitor mNetdServiceMonitor = new NetdServiceMonitor(mNetdService); + + PackageInfo packageInfo1 = addPackage(MOCK_PACKAGE1, MOCK_UID1, + new String[] {INTERNET, UPDATE_DEVICE_STATS}); + mNetdServiceMonitor.expectPermission(INetd.PERMISSION_INTERNET + | INetd.PERMISSION_UPDATE_DEVICE_STATS, new int[]{MOCK_UID1}); + + // Install another package with the same uid and no permissions should not cause the UID to + // lose permissions. + PackageInfo packageInfo2 = packageInfoWithPermissions(new String[]{}, PARTITION_SYSTEM); + when(mPackageManager.getPackageInfo(eq(MOCK_PACKAGE2), anyInt())).thenReturn(packageInfo2); + when(mPackageManager.getPackagesForUid(MOCK_UID1)) + .thenReturn(new String[]{MOCK_PACKAGE1, MOCK_PACKAGE2}); + mObserver.onPackageAdded(MOCK_PACKAGE2, MOCK_UID1); + mNetdServiceMonitor.expectPermission(INetd.PERMISSION_INTERNET + | INetd.PERMISSION_UPDATE_DEVICE_STATS, new int[]{MOCK_UID1}); + } + + @Test + public void testPackageUninstallBasic() throws Exception { + final NetdServiceMonitor mNetdServiceMonitor = new NetdServiceMonitor(mNetdService); + + addPackage(MOCK_PACKAGE1, MOCK_UID1, new String[] {INTERNET, UPDATE_DEVICE_STATS}); + mNetdServiceMonitor.expectPermission(INetd.PERMISSION_INTERNET + | INetd.PERMISSION_UPDATE_DEVICE_STATS, new int[]{MOCK_UID1}); + + when(mPackageManager.getPackagesForUid(MOCK_UID1)).thenReturn(new String[]{}); + mObserver.onPackageRemoved(MOCK_PACKAGE1, MOCK_UID1); + mNetdServiceMonitor.expectPermission(INetd.PERMISSION_UNINSTALLED, new int[]{MOCK_UID1}); + } + + @Test + public void testPackageUpdate() throws Exception { + final NetdServiceMonitor mNetdServiceMonitor = new NetdServiceMonitor(mNetdService); + + addPackage(MOCK_PACKAGE1, MOCK_UID1, new String[] {INTERNET, UPDATE_DEVICE_STATS}); + mNetdServiceMonitor.expectPermission(INetd.PERMISSION_INTERNET + | INetd.PERMISSION_UPDATE_DEVICE_STATS, new int[]{MOCK_UID1}); + + // Remove and install the same package to simulate the update action + when(mPackageManager.getPackagesForUid(MOCK_UID1)).thenReturn(new String[]{}); + mObserver.onPackageRemoved(MOCK_PACKAGE1, MOCK_UID1); + mNetdServiceMonitor.expectPermission(INetd.PERMISSION_UNINSTALLED, new int[]{MOCK_UID1}); + + addPackage(MOCK_PACKAGE1, MOCK_UID1, new String[] {INTERNET}); + mNetdServiceMonitor.expectPermission(INetd.PERMISSION_INTERNET, new int[]{MOCK_UID1}); + } + + @Test + public void testPackageUninstallWithMultiplePackages() throws Exception { + final NetdServiceMonitor mNetdServiceMonitor = new NetdServiceMonitor(mNetdService); + + addPackage(MOCK_PACKAGE1, MOCK_UID1, new String[] {INTERNET, UPDATE_DEVICE_STATS}); + mNetdServiceMonitor.expectPermission(INetd.PERMISSION_INTERNET + | INetd.PERMISSION_UPDATE_DEVICE_STATS, new int[]{MOCK_UID1}); + + // Mock another package with the same uid but different permissions. + PackageInfo packageInfo2 = packageInfoWithPermissions(new String[] {INTERNET}, + PARTITION_SYSTEM); + when(mPackageManager.getPackageInfo(eq(MOCK_PACKAGE2), anyInt())).thenReturn(packageInfo2); + when(mPackageManager.getPackagesForUid(MOCK_UID1)).thenReturn(new String[]{ + MOCK_PACKAGE2}); + + mObserver.onPackageRemoved(MOCK_PACKAGE1, MOCK_UID1); + mNetdServiceMonitor.expectPermission(INetd.PERMISSION_INTERNET, new int[]{MOCK_UID1}); + } } diff --git a/tests/net/java/com/android/server/connectivity/tethering/TetheringConfigurationTest.java b/tests/net/java/com/android/server/connectivity/tethering/TetheringConfigurationTest.java index 36a1b7c000d9..21403225c600 100644 --- a/tests/net/java/com/android/server/connectivity/tethering/TetheringConfigurationTest.java +++ b/tests/net/java/com/android/server/connectivity/tethering/TetheringConfigurationTest.java @@ -122,7 +122,7 @@ public class TetheringConfigurationTest { mMockContext = new MockContext(mContext); } - private TetheringConfiguration getTetheringConfiguration(int[] legacyTetherUpstreamTypes) { + private TetheringConfiguration getTetheringConfiguration(int... legacyTetherUpstreamTypes) { when(mResources.getIntArray(config_tether_upstream_types)).thenReturn( legacyTetherUpstreamTypes); return new TetheringConfiguration(mMockContext, mLog, INVALID_SUBSCRIPTION_ID); @@ -143,13 +143,13 @@ public class TetheringConfigurationTest { public void testDunFromTelephonyManagerMeansDun() { when(mTelephonyManager.getTetherApnRequired()).thenReturn(true); - final TetheringConfiguration cfgWifi = getTetheringConfiguration(new int[]{TYPE_WIFI}); + final TetheringConfiguration cfgWifi = getTetheringConfiguration(TYPE_WIFI); final TetheringConfiguration cfgMobileWifiHipri = getTetheringConfiguration( - new int[]{TYPE_MOBILE, TYPE_WIFI, TYPE_MOBILE_HIPRI}); + TYPE_MOBILE, TYPE_WIFI, TYPE_MOBILE_HIPRI); final TetheringConfiguration cfgWifiDun = getTetheringConfiguration( - new int[]{TYPE_WIFI, TYPE_MOBILE_DUN}); + TYPE_WIFI, TYPE_MOBILE_DUN); final TetheringConfiguration cfgMobileWifiHipriDun = getTetheringConfiguration( - new int[]{TYPE_MOBILE, TYPE_WIFI, TYPE_MOBILE_HIPRI, TYPE_MOBILE_DUN}); + TYPE_MOBILE, TYPE_WIFI, TYPE_MOBILE_HIPRI, TYPE_MOBILE_DUN); for (TetheringConfiguration cfg : Arrays.asList(cfgWifi, cfgMobileWifiHipri, cfgWifiDun, cfgMobileWifiHipriDun)) { @@ -167,20 +167,20 @@ public class TetheringConfigurationTest { public void testDunNotRequiredFromTelephonyManagerMeansNoDun() { when(mTelephonyManager.getTetherApnRequired()).thenReturn(false); - final TetheringConfiguration cfgWifi = getTetheringConfiguration(new int[]{TYPE_WIFI}); + final TetheringConfiguration cfgWifi = getTetheringConfiguration(TYPE_WIFI); final TetheringConfiguration cfgMobileWifiHipri = getTetheringConfiguration( - new int[]{TYPE_MOBILE, TYPE_WIFI, TYPE_MOBILE_HIPRI}); + TYPE_MOBILE, TYPE_WIFI, TYPE_MOBILE_HIPRI); final TetheringConfiguration cfgWifiDun = getTetheringConfiguration( - new int[]{TYPE_WIFI, TYPE_MOBILE_DUN}); + TYPE_WIFI, TYPE_MOBILE_DUN); final TetheringConfiguration cfgWifiMobile = getTetheringConfiguration( - new int[]{TYPE_WIFI, TYPE_MOBILE}); + TYPE_WIFI, TYPE_MOBILE); final TetheringConfiguration cfgWifiHipri = getTetheringConfiguration( - new int[]{TYPE_WIFI, TYPE_MOBILE_HIPRI}); + TYPE_WIFI, TYPE_MOBILE_HIPRI); final TetheringConfiguration cfgMobileWifiHipriDun = getTetheringConfiguration( - new int[]{TYPE_MOBILE, TYPE_WIFI, TYPE_MOBILE_HIPRI, TYPE_MOBILE_DUN}); + TYPE_MOBILE, TYPE_WIFI, TYPE_MOBILE_HIPRI, TYPE_MOBILE_DUN); String msg; - // TYPE_MOBILE_DUN should not be present in all of the combinations. + // TYPE_MOBILE_DUN should be present in none of the combinations. // TYPE_WIFI should not be affected. for (TetheringConfiguration cfg : Arrays.asList(cfgWifi, cfgMobileWifiHipri, cfgWifiDun, cfgWifiMobile, cfgWifiHipri, cfgMobileWifiHipriDun)) { |