Merge "Replace withCleanCallingIdentity with [clear|restore]CallingIdentity"
diff --git a/framework/aidl-export/android/net/OemNetworkPreferences.aidl b/framework/aidl-export/android/net/OemNetworkPreferences.aidl
new file mode 100644
index 0000000..2b6a4ce
--- /dev/null
+++ b/framework/aidl-export/android/net/OemNetworkPreferences.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net;
+
+parcelable OemNetworkPreferences;
diff --git a/framework/api/module-lib-current.txt b/framework/api/module-lib-current.txt
index a9fd6f2..d2ed73e 100644
--- a/framework/api/module-lib-current.txt
+++ b/framework/api/module-lib-current.txt
@@ -6,6 +6,7 @@
}
public class ConnectivityManager {
+ method @NonNull @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK, android.Manifest.permission.NETWORK_SETTINGS}) public java.util.List<android.net.NetworkStateSnapshot> getAllNetworkStateSnapshot();
method @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_SETTINGS}) public void registerSystemDefaultNetworkCallback(@NonNull android.net.ConnectivityManager.NetworkCallback, @NonNull android.os.Handler);
method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.Manifest.permission.NETWORK_STACK, android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK}) public void requestBackgroundNetwork(@NonNull android.net.NetworkRequest, @Nullable android.os.Handler, @NonNull android.net.ConnectivityManager.NetworkCallback);
method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_TEST_NETWORKS, android.Manifest.permission.NETWORK_STACK}) public void simulateDataStall(int, long, @NonNull android.net.Network, @NonNull android.os.PersistableBundle);
diff --git a/framework/api/system-current.txt b/framework/api/system-current.txt
index 373fa3c..a732430 100644
--- a/framework/api/system-current.txt
+++ b/framework/api/system-current.txt
@@ -2,7 +2,7 @@
package android.net {
public class CaptivePortal implements android.os.Parcelable {
- method public void logEvent(int, @NonNull String);
+ method @Deprecated public void logEvent(int, @NonNull String);
method @RequiresPermission(android.Manifest.permission.NETWORK_STACK) public void reevaluateNetwork();
method public void useNetwork();
field public static final int APP_REQUEST_REEVALUATION_REQUIRED = 100; // 0x64
@@ -320,6 +320,26 @@
method @NonNull @RequiresPermission(android.Manifest.permission.NETWORK_SIGNAL_STRENGTH_WAKEUP) public android.net.NetworkRequest.Builder setSignalStrength(int);
}
+ public final class OemNetworkPreferences implements android.os.Parcelable {
+ method public int describeContents();
+ method @NonNull public java.util.Map<java.lang.String,java.lang.Integer> getNetworkPreferences();
+ method public void writeToParcel(@NonNull android.os.Parcel, int);
+ field @NonNull public static final android.os.Parcelable.Creator<android.net.OemNetworkPreferences> CREATOR;
+ field public static final int OEM_NETWORK_PREFERENCE_OEM_PAID = 1; // 0x1
+ field public static final int OEM_NETWORK_PREFERENCE_OEM_PAID_NO_FALLBACK = 2; // 0x2
+ field public static final int OEM_NETWORK_PREFERENCE_OEM_PAID_ONLY = 3; // 0x3
+ field public static final int OEM_NETWORK_PREFERENCE_OEM_PRIVATE_ONLY = 4; // 0x4
+ field public static final int OEM_NETWORK_PREFERENCE_UNINITIALIZED = 0; // 0x0
+ }
+
+ public static final class OemNetworkPreferences.Builder {
+ ctor public OemNetworkPreferences.Builder();
+ ctor public OemNetworkPreferences.Builder(@NonNull android.net.OemNetworkPreferences);
+ method @NonNull public android.net.OemNetworkPreferences.Builder addNetworkPreference(@NonNull String, int);
+ method @NonNull public android.net.OemNetworkPreferences build();
+ method @NonNull public android.net.OemNetworkPreferences.Builder clearNetworkPreference(@NonNull String);
+ }
+
public abstract class QosCallback {
ctor public QosCallback();
method public void onError(@NonNull android.net.QosCallbackException);
diff --git a/framework/src/android/net/CaptivePortal.java b/framework/src/android/net/CaptivePortal.java
index 269bbf2..4a7b601 100644
--- a/framework/src/android/net/CaptivePortal.java
+++ b/framework/src/android/net/CaptivePortal.java
@@ -160,12 +160,11 @@
* @param eventId one of the CAPTIVE_PORTAL_LOGIN_* constants in metrics_constants.proto.
* @param packageName captive portal application package name.
* @hide
+ * @deprecated The event will not be logged in Android S and above. The
+ * caller is migrating to statsd.
*/
+ @Deprecated
@SystemApi
public void logEvent(int eventId, @NonNull String packageName) {
- try {
- ICaptivePortal.Stub.asInterface(mBinder).logEvent(eventId, packageName);
- } catch (RemoteException e) {
- }
}
}
diff --git a/framework/src/android/net/ConnectivityManager.java b/framework/src/android/net/ConnectivityManager.java
index 1f2975c..45ed317 100644
--- a/framework/src/android/net/ConnectivityManager.java
+++ b/framework/src/android/net/ConnectivityManager.java
@@ -1259,6 +1259,25 @@
}
/**
+ * Return a list of {@link NetworkStateSnapshot}s, one for each network that is currently
+ * connected.
+ * @hide
+ */
+ @SystemApi(client = MODULE_LIBRARIES)
+ @RequiresPermission(anyOf = {
+ NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK,
+ android.Manifest.permission.NETWORK_STACK,
+ android.Manifest.permission.NETWORK_SETTINGS})
+ @NonNull
+ public List<NetworkStateSnapshot> getAllNetworkStateSnapshot() {
+ try {
+ return mService.getAllNetworkStateSnapshot();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
* Returns the {@link Network} object currently serving a given type, or
* null if the given type is not connected.
*
diff --git a/framework/src/android/net/ICaptivePortal.aidl b/framework/src/android/net/ICaptivePortal.aidl
index fe21905..e35f8d4 100644
--- a/framework/src/android/net/ICaptivePortal.aidl
+++ b/framework/src/android/net/ICaptivePortal.aidl
@@ -23,5 +23,4 @@
oneway interface ICaptivePortal {
void appRequest(int request);
void appResponse(int response);
- void logEvent(int eventId, String packageName);
}
diff --git a/framework/src/android/net/IConnectivityManager.aidl b/framework/src/android/net/IConnectivityManager.aidl
index 160338d..cd49258 100644
--- a/framework/src/android/net/IConnectivityManager.aidl
+++ b/framework/src/android/net/IConnectivityManager.aidl
@@ -31,6 +31,7 @@
import android.net.NetworkInfo;
import android.net.NetworkRequest;
import android.net.NetworkState;
+import android.net.NetworkStateSnapshot;
import android.net.OemNetworkPreferences;
import android.net.ProxyInfo;
import android.net.UidRange;
@@ -79,6 +80,8 @@
@UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
NetworkState[] getAllNetworkState();
+ List<NetworkStateSnapshot> getAllNetworkStateSnapshot();
+
boolean isActiveNetworkMetered();
boolean requestRouteToHostAddress(int networkType, in byte[] hostAddress,
diff --git a/framework/src/android/net/NetworkCapabilities.java b/framework/src/android/net/NetworkCapabilities.java
index cd76f40..c82cd3b 100644
--- a/framework/src/android/net/NetworkCapabilities.java
+++ b/framework/src/android/net/NetworkCapabilities.java
@@ -34,9 +34,9 @@
import android.util.proto.ProtoOutputStream;
import com.android.internal.annotations.VisibleForTesting;
-import com.android.internal.util.BitUtils;
import com.android.internal.util.Preconditions;
import com.android.net.module.util.CollectionUtils;
+import com.android.net.module.util.NetworkCapabilitiesUtils;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -610,7 +610,7 @@
*/
@UnsupportedAppUsage
public @NetCapability int[] getCapabilities() {
- return BitUtils.unpackBits(mNetworkCapabilities);
+ return NetworkCapabilitiesUtils.unpackBits(mNetworkCapabilities);
}
/**
@@ -620,7 +620,7 @@
* @hide
*/
public @NetCapability int[] getUnwantedCapabilities() {
- return BitUtils.unpackBits(mUnwantedNetworkCapabilities);
+ return NetworkCapabilitiesUtils.unpackBits(mUnwantedNetworkCapabilities);
}
@@ -632,8 +632,8 @@
*/
public void setCapabilities(@NetCapability int[] capabilities,
@NetCapability int[] unwantedCapabilities) {
- mNetworkCapabilities = BitUtils.packBits(capabilities);
- mUnwantedNetworkCapabilities = BitUtils.packBits(unwantedCapabilities);
+ mNetworkCapabilities = NetworkCapabilitiesUtils.packBits(capabilities);
+ mUnwantedNetworkCapabilities = NetworkCapabilitiesUtils.packBits(unwantedCapabilities);
}
/**
@@ -688,7 +688,7 @@
& NON_REQUESTABLE_CAPABILITIES;
if (nonRequestable != 0) {
- return capabilityNameOf(BitUtils.unpackBits(nonRequestable)[0]);
+ return capabilityNameOf(NetworkCapabilitiesUtils.unpackBits(nonRequestable)[0]);
}
if (mLinkUpBandwidthKbps != 0 || mLinkDownBandwidthKbps != 0) return "link bandwidth";
if (hasSignalStrength()) return "signalStrength";
@@ -946,7 +946,7 @@
*/
@SystemApi
@NonNull public @Transport int[] getTransportTypes() {
- return BitUtils.unpackBits(mTransportTypes);
+ return NetworkCapabilitiesUtils.unpackBits(mTransportTypes);
}
/**
@@ -956,7 +956,7 @@
* @hide
*/
public void setTransportTypes(@Transport int[] transportTypes) {
- mTransportTypes = BitUtils.packBits(transportTypes);
+ mTransportTypes = NetworkCapabilitiesUtils.packBits(transportTypes);
}
/**
@@ -1721,8 +1721,10 @@
long oldImmutableCapabilities = this.mNetworkCapabilities & mask;
long newImmutableCapabilities = that.mNetworkCapabilities & mask;
if (oldImmutableCapabilities != newImmutableCapabilities) {
- String before = capabilityNamesOf(BitUtils.unpackBits(oldImmutableCapabilities));
- String after = capabilityNamesOf(BitUtils.unpackBits(newImmutableCapabilities));
+ String before = capabilityNamesOf(NetworkCapabilitiesUtils.unpackBits(
+ oldImmutableCapabilities));
+ String after = capabilityNamesOf(NetworkCapabilitiesUtils.unpackBits(
+ newImmutableCapabilities));
joiner.add(String.format("immutable capabilities changed: %s -> %s", before, after));
}
@@ -1864,7 +1866,7 @@
final ArraySet<T> result = new ArraySet<>(size);
for (int i = 0; i < size; i++) {
final T value = in.readParcelable(loader);
- result.append(value);
+ result.add(value);
}
return result;
}
diff --git a/framework/src/android/net/NetworkState.java b/framework/src/android/net/NetworkState.java
new file mode 100644
index 0000000..d010265
--- /dev/null
+++ b/framework/src/android/net/NetworkState.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+package android.net;
+
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.compat.annotation.UnsupportedAppUsage;
+import android.os.Build;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.util.Slog;
+
+/**
+ * Snapshot of network state.
+ *
+ * @hide
+ */
+public class NetworkState implements Parcelable {
+ private static final boolean VALIDATE_ROAMING_STATE = false;
+
+ // TODO: remove and make members @NonNull.
+ public static final NetworkState EMPTY = new NetworkState();
+
+ public final NetworkInfo networkInfo;
+ public final LinkProperties linkProperties;
+ public final NetworkCapabilities networkCapabilities;
+ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
+ public final Network network;
+ public final String subscriberId;
+ public final int legacyNetworkType;
+
+ private NetworkState() {
+ networkInfo = null;
+ linkProperties = null;
+ networkCapabilities = null;
+ network = null;
+ subscriberId = null;
+ legacyNetworkType = 0;
+ }
+
+ public NetworkState(int legacyNetworkType, @NonNull LinkProperties linkProperties,
+ @NonNull NetworkCapabilities networkCapabilities, @NonNull Network network,
+ @Nullable String subscriberId) {
+ this(legacyNetworkType, new NetworkInfo(legacyNetworkType, 0, null, null), linkProperties,
+ networkCapabilities, network, subscriberId);
+ }
+
+ // Constructor that used internally in ConnectivityService mainline module.
+ public NetworkState(@NonNull NetworkInfo networkInfo, @NonNull LinkProperties linkProperties,
+ @NonNull NetworkCapabilities networkCapabilities, @NonNull Network network,
+ @Nullable String subscriberId) {
+ this(networkInfo.getType(), networkInfo, linkProperties,
+ networkCapabilities, network, subscriberId);
+ }
+
+ public NetworkState(int legacyNetworkType, @NonNull NetworkInfo networkInfo,
+ @NonNull LinkProperties linkProperties,
+ @NonNull NetworkCapabilities networkCapabilities, @NonNull Network network,
+ @Nullable String subscriberId) {
+ this.networkInfo = networkInfo;
+ this.linkProperties = linkProperties;
+ this.networkCapabilities = networkCapabilities;
+ this.network = network;
+ this.subscriberId = subscriberId;
+ this.legacyNetworkType = legacyNetworkType;
+
+ // This object is an atomic view of a network, so the various components
+ // should always agree on roaming state.
+ if (VALIDATE_ROAMING_STATE && networkInfo != null && networkCapabilities != null) {
+ if (networkInfo.isRoaming() == networkCapabilities
+ .hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_ROAMING)) {
+ Slog.wtf("NetworkState", "Roaming state disagreement between " + networkInfo
+ + " and " + networkCapabilities);
+ }
+ }
+ }
+
+ @UnsupportedAppUsage
+ public NetworkState(Parcel in) {
+ networkInfo = in.readParcelable(null);
+ linkProperties = in.readParcelable(null);
+ networkCapabilities = in.readParcelable(null);
+ network = in.readParcelable(null);
+ subscriberId = in.readString();
+ legacyNetworkType = in.readInt();
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeParcelable(networkInfo, flags);
+ out.writeParcelable(linkProperties, flags);
+ out.writeParcelable(networkCapabilities, flags);
+ out.writeParcelable(network, flags);
+ out.writeString(subscriberId);
+ out.writeInt(legacyNetworkType);
+ }
+
+ @UnsupportedAppUsage
+ @NonNull
+ public static final Creator<NetworkState> CREATOR = new Creator<NetworkState>() {
+ @Override
+ public NetworkState createFromParcel(Parcel in) {
+ return new NetworkState(in);
+ }
+
+ @Override
+ public NetworkState[] newArray(int size) {
+ return new NetworkState[size];
+ }
+ };
+}
diff --git a/framework/src/android/net/OemNetworkPreferences.java b/framework/src/android/net/OemNetworkPreferences.java
new file mode 100644
index 0000000..48bd297
--- /dev/null
+++ b/framework/src/android/net/OemNetworkPreferences.java
@@ -0,0 +1,239 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+
+package android.net;
+
+import android.annotation.IntDef;
+import android.annotation.NonNull;
+import android.annotation.SystemApi;
+import android.os.Bundle;
+import android.os.Parcelable;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * Network preferences to set the default active network on a per-application basis as per a given
+ * {@link OemNetworkPreference}. An example of this would be to set an application's network
+ * preference to {@link #OEM_NETWORK_PREFERENCE_OEM_PAID_NO_FALLBACK} which would have the default
+ * network for that application set to an unmetered network first if available and if not, it then
+ * set that application's default network to an OEM managed network if available.
+ *
+ * @hide
+ */
+@SystemApi
+public final class OemNetworkPreferences implements Parcelable {
+ /**
+ * Default in case this value is not set. Using it will result in an error.
+ */
+ public static final int OEM_NETWORK_PREFERENCE_UNINITIALIZED = 0;
+
+ /**
+ * If an unmetered network is available, use it.
+ * Otherwise, if a network with the OEM_PAID capability is available, use it.
+ * Otherwise, use the general default network.
+ */
+ public static final int OEM_NETWORK_PREFERENCE_OEM_PAID = 1;
+
+ /**
+ * If an unmetered network is available, use it.
+ * Otherwise, if a network with the OEM_PAID capability is available, use it.
+ * Otherwise, the app doesn't get a default network.
+ */
+ public static final int OEM_NETWORK_PREFERENCE_OEM_PAID_NO_FALLBACK = 2;
+
+ /**
+ * Use only NET_CAPABILITY_OEM_PAID networks.
+ */
+ public static final int OEM_NETWORK_PREFERENCE_OEM_PAID_ONLY = 3;
+
+ /**
+ * Use only NET_CAPABILITY_OEM_PRIVATE networks.
+ */
+ public static final int OEM_NETWORK_PREFERENCE_OEM_PRIVATE_ONLY = 4;
+
+ @NonNull
+ private final Bundle mNetworkMappings;
+
+ /**
+ * Return the currently built application package name to {@link OemNetworkPreference} mappings.
+ * @return the current network preferences map.
+ */
+ @NonNull
+ public Map<String, Integer> getNetworkPreferences() {
+ return convertToUnmodifiableMap(mNetworkMappings);
+ }
+
+ private OemNetworkPreferences(@NonNull final Bundle networkMappings) {
+ Objects.requireNonNull(networkMappings);
+ mNetworkMappings = (Bundle) networkMappings.clone();
+ }
+
+ @Override
+ public String toString() {
+ return "OemNetworkPreferences{" + "mNetworkMappings=" + mNetworkMappings + '}';
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ OemNetworkPreferences that = (OemNetworkPreferences) o;
+
+ return mNetworkMappings.size() == that.mNetworkMappings.size()
+ && mNetworkMappings.toString().equals(that.mNetworkMappings.toString());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(mNetworkMappings);
+ }
+
+ /**
+ * Builder used to create {@link OemNetworkPreferences} objects. Specify the preferred Network
+ * to package name mappings.
+ */
+ public static final class Builder {
+ private final Bundle mNetworkMappings;
+
+ public Builder() {
+ mNetworkMappings = new Bundle();
+ }
+
+ /**
+ * Constructor to populate the builder's values with an already built
+ * {@link OemNetworkPreferences}.
+ * @param preferences the {@link OemNetworkPreferences} to populate with.
+ */
+ public Builder(@NonNull final OemNetworkPreferences preferences) {
+ Objects.requireNonNull(preferences);
+ mNetworkMappings = (Bundle) preferences.mNetworkMappings.clone();
+ }
+
+ /**
+ * Add a network preference for a given package. Previously stored values for the given
+ * package will be overwritten.
+ *
+ * @param packageName full package name (e.g.: "com.google.apps.contacts") of the app
+ * to use the given preference
+ * @param preference the desired network preference to use
+ * @return The builder to facilitate chaining.
+ */
+ @NonNull
+ public Builder addNetworkPreference(@NonNull final String packageName,
+ @OemNetworkPreference final int preference) {
+ Objects.requireNonNull(packageName);
+ mNetworkMappings.putInt(packageName, preference);
+ return this;
+ }
+
+ /**
+ * Remove a network preference for a given package.
+ *
+ * @param packageName full package name (e.g.: "com.google.apps.contacts") of the app to
+ * remove a preference for.
+ * @return The builder to facilitate chaining.
+ */
+ @NonNull
+ public Builder clearNetworkPreference(@NonNull final String packageName) {
+ Objects.requireNonNull(packageName);
+ mNetworkMappings.remove(packageName);
+ return this;
+ }
+
+ /**
+ * Build {@link OemNetworkPreferences} return the current OEM network preferences.
+ */
+ @NonNull
+ public OemNetworkPreferences build() {
+ return new OemNetworkPreferences(mNetworkMappings);
+ }
+ }
+
+ private static Map<String, Integer> convertToUnmodifiableMap(@NonNull final Bundle bundle) {
+ final Map<String, Integer> networkPreferences = new HashMap<>();
+ for (final String key : bundle.keySet()) {
+ networkPreferences.put(key, bundle.getInt(key));
+ }
+ return Collections.unmodifiableMap(networkPreferences);
+ }
+
+ /** @hide */
+ @IntDef(prefix = "OEM_NETWORK_PREFERENCE_", value = {
+ OEM_NETWORK_PREFERENCE_UNINITIALIZED,
+ OEM_NETWORK_PREFERENCE_OEM_PAID,
+ OEM_NETWORK_PREFERENCE_OEM_PAID_NO_FALLBACK,
+ OEM_NETWORK_PREFERENCE_OEM_PAID_ONLY,
+ OEM_NETWORK_PREFERENCE_OEM_PRIVATE_ONLY
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface OemNetworkPreference {}
+
+ /**
+ * Return the string value for OemNetworkPreference
+ *
+ * @param value int value of OemNetworkPreference
+ * @return string version of OemNetworkPreference
+ *
+ * @hide
+ */
+ @NonNull
+ public static String oemNetworkPreferenceToString(@OemNetworkPreference int value) {
+ switch (value) {
+ case OEM_NETWORK_PREFERENCE_UNINITIALIZED:
+ return "OEM_NETWORK_PREFERENCE_UNINITIALIZED";
+ case OEM_NETWORK_PREFERENCE_OEM_PAID:
+ return "OEM_NETWORK_PREFERENCE_OEM_PAID";
+ case OEM_NETWORK_PREFERENCE_OEM_PAID_NO_FALLBACK:
+ return "OEM_NETWORK_PREFERENCE_OEM_PAID_NO_FALLBACK";
+ case OEM_NETWORK_PREFERENCE_OEM_PAID_ONLY:
+ return "OEM_NETWORK_PREFERENCE_OEM_PAID_ONLY";
+ case OEM_NETWORK_PREFERENCE_OEM_PRIVATE_ONLY:
+ return "OEM_NETWORK_PREFERENCE_OEM_PRIVATE_ONLY";
+ default:
+ return Integer.toHexString(value);
+ }
+ }
+
+ @Override
+ public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
+ dest.writeBundle(mNetworkMappings);
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @NonNull
+ public static final Parcelable.Creator<OemNetworkPreferences> CREATOR =
+ new Parcelable.Creator<OemNetworkPreferences>() {
+ @Override
+ public OemNetworkPreferences[] newArray(int size) {
+ return new OemNetworkPreferences[size];
+ }
+
+ @Override
+ public OemNetworkPreferences createFromParcel(@NonNull android.os.Parcel in) {
+ return new OemNetworkPreferences(
+ in.readBundle(getClass().getClassLoader()));
+ }
+ };
+}
diff --git a/framework/src/android/net/RouteInfo.java b/framework/src/android/net/RouteInfo.java
index 5b6684a..fad3144 100644
--- a/framework/src/android/net/RouteInfo.java
+++ b/framework/src/android/net/RouteInfo.java
@@ -26,6 +26,7 @@
import android.os.Parcelable;
import com.android.net.module.util.NetUtils;
+import com.android.net.module.util.NetworkStackConstants;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -181,9 +182,9 @@
if (destination == null) {
if (gateway != null) {
if (gateway instanceof Inet4Address) {
- destination = new IpPrefix(Inet4Address.ANY, 0);
+ destination = new IpPrefix(NetworkStackConstants.IPV4_ADDR_ANY, 0);
} else {
- destination = new IpPrefix(Inet6Address.ANY, 0);
+ destination = new IpPrefix(NetworkStackConstants.IPV6_ADDR_ANY, 0);
}
} else {
// no destination, no gateway. invalid.
@@ -196,9 +197,9 @@
// ConnectivityService) to stop doing things like r.getGateway().equals(), ... .
if (gateway == null) {
if (destination.getAddress() instanceof Inet4Address) {
- gateway = Inet4Address.ANY;
+ gateway = NetworkStackConstants.IPV4_ADDR_ANY;
} else {
- gateway = Inet6Address.ANY;
+ gateway = NetworkStackConstants.IPV6_ADDR_ANY;
}
}
mHasGateway = (!gateway.isAnyLocalAddress());
diff --git a/framework/src/android/net/util/DnsUtils.java b/framework/src/android/net/util/DnsUtils.java
index 7908353..3fe245e 100644
--- a/framework/src/android/net/util/DnsUtils.java
+++ b/framework/src/android/net/util/DnsUtils.java
@@ -29,8 +29,6 @@
import android.system.Os;
import android.util.Log;
-import com.android.internal.util.BitUtils;
-
import libcore.io.IoUtils;
import java.io.FileDescriptor;
@@ -332,7 +330,7 @@
if (srcByte[i] == dstByte[i]) {
continue;
}
- int x = BitUtils.uint8(srcByte[i]) ^ BitUtils.uint8(dstByte[i]);
+ int x = (srcByte[i] & 0xff) ^ (dstByte[i] & 0xff);
return i * CHAR_BIT + (Integer.numberOfLeadingZeros(x) - 24); // Java ints are 32 bits
}
return dstByte.length * CHAR_BIT;