Merge "APIs for 5G slicing" into sc-dev
diff --git a/framework/Android.bp b/framework/Android.bp
index 73e1511..c7e261c 100644
--- a/framework/Android.bp
+++ b/framework/Android.bp
@@ -14,6 +14,15 @@
// limitations under the License.
//
+package {
+ // See: http://go/android-license-faq
+ // A large-scale-change added 'default_applicable_licenses' to import
+ // all of the 'license_kinds' from "frameworks_base_license"
+ // to get the below license kinds:
+ // SPDX-license-identifier-Apache-2.0
+ default_applicable_licenses: ["frameworks_base_license"],
+}
+
filegroup {
name: "framework-connectivity-internal-sources",
srcs: [
@@ -48,4 +57,4 @@
"//frameworks/base",
"//packages/modules/Connectivity:__subpackages__",
],
-}
\ No newline at end of file
+}
diff --git a/framework/src/android/net/CaptivePortalData.java b/framework/src/android/net/CaptivePortalData.java
index f4b46e9..eafda4d 100644
--- a/framework/src/android/net/CaptivePortalData.java
+++ b/framework/src/android/net/CaptivePortalData.java
@@ -44,7 +44,7 @@
private final boolean mCaptive;
private final String mVenueFriendlyName;
private final int mVenueInfoUrlSource;
- private final int mTermsAndConditionsSource;
+ private final int mUserPortalUrlSource;
/** @hide */
@Retention(RetentionPolicy.SOURCE)
@@ -65,7 +65,7 @@
private CaptivePortalData(long refreshTimeMillis, Uri userPortalUrl, Uri venueInfoUrl,
boolean isSessionExtendable, long byteLimit, long expiryTimeMillis, boolean captive,
- String venueFriendlyName, int venueInfoUrlSource, int termsAndConditionsSource) {
+ String venueFriendlyName, int venueInfoUrlSource, int userPortalUrlSource) {
mRefreshTimeMillis = refreshTimeMillis;
mUserPortalUrl = userPortalUrl;
mVenueInfoUrl = venueInfoUrl;
@@ -75,7 +75,7 @@
mCaptive = captive;
mVenueFriendlyName = venueFriendlyName;
mVenueInfoUrlSource = venueInfoUrlSource;
- mTermsAndConditionsSource = termsAndConditionsSource;
+ mUserPortalUrlSource = userPortalUrlSource;
}
private CaptivePortalData(Parcel p) {
@@ -100,7 +100,7 @@
dest.writeBoolean(mCaptive);
dest.writeString(mVenueFriendlyName);
dest.writeInt(mVenueInfoUrlSource);
- dest.writeInt(mTermsAndConditionsSource);
+ dest.writeInt(mUserPortalUrlSource);
}
/**
@@ -130,7 +130,7 @@
public Builder(@Nullable CaptivePortalData data) {
if (data == null) return;
setRefreshTime(data.mRefreshTimeMillis)
- .setUserPortalUrl(data.mUserPortalUrl, data.mTermsAndConditionsSource)
+ .setUserPortalUrl(data.mUserPortalUrl, data.mUserPortalUrlSource)
.setVenueInfoUrl(data.mVenueInfoUrl, data.mVenueInfoUrlSource)
.setSessionExtendable(data.mIsSessionExtendable)
.setBytesRemaining(data.mByteLimit)
@@ -314,7 +314,7 @@
* @return The source that the user portal URL was obtained from
*/
public @CaptivePortalDataSource int getUserPortalUrlSource() {
- return mTermsAndConditionsSource;
+ return mUserPortalUrlSource;
}
/**
@@ -342,7 +342,7 @@
public int hashCode() {
return Objects.hash(mRefreshTimeMillis, mUserPortalUrl, mVenueInfoUrl,
mIsSessionExtendable, mByteLimit, mExpiryTimeMillis, mCaptive, mVenueFriendlyName,
- mVenueInfoUrlSource, mTermsAndConditionsSource);
+ mVenueInfoUrlSource, mUserPortalUrlSource);
}
@Override
@@ -358,7 +358,7 @@
&& mCaptive == other.mCaptive
&& Objects.equals(mVenueFriendlyName, other.mVenueFriendlyName)
&& mVenueInfoUrlSource == other.mVenueInfoUrlSource
- && mTermsAndConditionsSource == other.mTermsAndConditionsSource;
+ && mUserPortalUrlSource == other.mUserPortalUrlSource;
}
@Override
@@ -373,7 +373,7 @@
+ ", captive: " + mCaptive
+ ", venueFriendlyName: " + mVenueFriendlyName
+ ", venueInfoUrlSource: " + mVenueInfoUrlSource
- + ", termsAndConditionsSource: " + mTermsAndConditionsSource
+ + ", userPortalUrlSource: " + mUserPortalUrlSource
+ "}";
}
}
diff --git a/framework/src/android/net/ConnectivityManager.java b/framework/src/android/net/ConnectivityManager.java
index d7c8291..e7ab0a1 100644
--- a/framework/src/android/net/ConnectivityManager.java
+++ b/framework/src/android/net/ConnectivityManager.java
@@ -49,8 +49,6 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
-import android.os.INetworkActivityListener;
-import android.os.INetworkManagementService;
import android.os.Looper;
import android.os.Message;
import android.os.Messenger;
@@ -835,7 +833,6 @@
private final Context mContext;
- private INetworkManagementService mNMService;
private INetworkPolicyManager mNPManager;
private final TetheringManager mTetheringManager;
@@ -1070,58 +1067,6 @@
}
/**
- * Calls VpnManager#isAlwaysOnVpnPackageSupportedForUser.
- * @deprecated TODO: remove when callers have migrated to VpnManager.
- * @hide
- */
- @Deprecated
- public boolean isAlwaysOnVpnPackageSupportedForUser(int userId, @Nullable String vpnPackage) {
- return getVpnManager().isAlwaysOnVpnPackageSupportedForUser(userId, vpnPackage);
- }
-
- /**
- * Calls VpnManager#setAlwaysOnVpnPackageForUser.
- * @deprecated TODO: remove when callers have migrated to VpnManager.
- * @hide
- */
- @Deprecated
- public boolean setAlwaysOnVpnPackageForUser(int userId, @Nullable String vpnPackage,
- boolean lockdownEnabled, @Nullable List<String> lockdownAllowlist) {
- return getVpnManager().setAlwaysOnVpnPackageForUser(userId, vpnPackage, lockdownEnabled,
- lockdownAllowlist);
- }
-
- /**
- * Calls VpnManager#getAlwaysOnVpnPackageForUser.
- * @deprecated TODO: remove when callers have migrated to VpnManager.
- * @hide
- */
- @Deprecated
- public String getAlwaysOnVpnPackageForUser(int userId) {
- return getVpnManager().getAlwaysOnVpnPackageForUser(userId);
- }
-
- /**
- * Calls VpnManager#isVpnLockdownEnabled.
- * @deprecated TODO: remove when callers have migrated to VpnManager.
- * @hide
- */
- @Deprecated
- public boolean isVpnLockdownEnabled(int userId) {
- return getVpnManager().isVpnLockdownEnabled(userId);
- }
-
- /**
- * Calls VpnManager#getVpnLockdownAllowlist.
- * @deprecated TODO: remove when callers have migrated to VpnManager.
- * @hide
- */
- @Deprecated
- public List<String> getVpnLockdownAllowlist(int userId) {
- return getVpnManager().getVpnLockdownAllowlist(userId);
- }
-
- /**
* Adds or removes a requirement for given UID ranges to use the VPN.
*
* If set to {@code true}, informs the system that the UIDs in the specified ranges must not
@@ -2211,17 +2156,6 @@
void onNetworkActive();
}
- private INetworkManagementService getNetworkManagementService() {
- synchronized (this) {
- if (mNMService != null) {
- return mNMService;
- }
- IBinder b = ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE);
- mNMService = INetworkManagementService.Stub.asInterface(b);
- return mNMService;
- }
- }
-
private final ArrayMap<OnNetworkActiveListener, INetworkActivityListener>
mNetworkActivityListeners = new ArrayMap<>();
@@ -2246,7 +2180,7 @@
};
try {
- getNetworkManagementService().registerNetworkActivityListener(rl);
+ mService.registerNetworkActivityListener(rl);
mNetworkActivityListeners.put(l, rl);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
@@ -2263,7 +2197,7 @@
INetworkActivityListener rl = mNetworkActivityListeners.get(l);
Preconditions.checkArgument(rl != null, "Listener was not registered.");
try {
- getNetworkManagementService().unregisterNetworkActivityListener(rl);
+ mService.registerNetworkActivityListener(rl);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -2279,7 +2213,7 @@
*/
public boolean isDefaultNetworkActive() {
try {
- return getNetworkManagementService().isNetworkActive();
+ return mService.isDefaultNetworkActive();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -3167,16 +3101,6 @@
}
/**
- * Calls VpnManager#updateLockdownVpn.
- * @deprecated TODO: remove when callers have migrated to VpnManager.
- * @hide
- */
- @Deprecated
- public boolean updateLockdownVpn() {
- return getVpnManager().updateLockdownVpn();
- }
-
- /**
* Set sign in error notification to visible or invisible
*
* @hide
@@ -4537,8 +4461,6 @@
try {
mService.factoryReset();
mTetheringManager.stopAllTethering();
- // TODO: Migrate callers to VpnManager#factoryReset.
- getVpnManager().factoryReset();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -4832,15 +4754,6 @@
return new TestNetworkManager(ITestNetworkManager.Stub.asInterface(tnBinder));
}
- /**
- * Temporary hack to shim calls from ConnectivityManager to VpnManager. We cannot store a
- * private final mVpnManager because ConnectivityManager is initialized before VpnManager.
- * @hide TODO: remove.
- */
- public VpnManager getVpnManager() {
- return mContext.getSystemService(VpnManager.class);
- }
-
/** @hide */
public ConnectivityDiagnosticsManager createDiagnosticsManager() {
return new ConnectivityDiagnosticsManager(mContext, mService);
diff --git a/framework/src/android/net/IConnectivityManager.aidl b/framework/src/android/net/IConnectivityManager.aidl
index 6391802..160338d 100644
--- a/framework/src/android/net/IConnectivityManager.aidl
+++ b/framework/src/android/net/IConnectivityManager.aidl
@@ -21,6 +21,7 @@
import android.net.ConnectivityDiagnosticsManager;
import android.net.IConnectivityDiagnosticsCallback;
import android.net.IOnSetOemNetworkPreferenceListener;
+import android.net.INetworkActivityListener;
import android.net.IQosCallback;
import android.net.ISocketKeepaliveCallback;
import android.net.LinkProperties;
@@ -36,7 +37,6 @@
import android.net.QosSocketInfo;
import android.os.Bundle;
import android.os.IBinder;
-import android.os.INetworkActivityListener;
import android.os.Messenger;
import android.os.ParcelFileDescriptor;
import android.os.PersistableBundle;
diff --git a/framework/src/android/net/INetworkActivityListener.aidl b/framework/src/android/net/INetworkActivityListener.aidl
new file mode 100644
index 0000000..79687dd
--- /dev/null
+++ b/framework/src/android/net/INetworkActivityListener.aidl
@@ -0,0 +1,24 @@
+/* Copyright 2013, 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;
+
+/**
+ * @hide
+ */
+oneway interface INetworkActivityListener
+{
+ void onNetworkActive();
+}
diff --git a/framework/src/android/net/IpPrefix.java b/framework/src/android/net/IpPrefix.java
index bcb65fa..d2ee7d1 100644
--- a/framework/src/android/net/IpPrefix.java
+++ b/framework/src/android/net/IpPrefix.java
@@ -24,6 +24,8 @@
import android.os.Parcelable;
import android.util.Pair;
+import com.android.net.module.util.NetUtils;
+
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetAddress;
@@ -59,7 +61,7 @@
throw new IllegalArgumentException(
"IpPrefix has " + address.length + " bytes which is neither 4 nor 16");
}
- NetworkUtils.maskRawAddress(address, prefixLength);
+ NetUtils.maskRawAddress(address, prefixLength);
}
/**
@@ -190,7 +192,7 @@
if (addrBytes == null || addrBytes.length != this.address.length) {
return false;
}
- NetworkUtils.maskRawAddress(addrBytes, prefixLength);
+ NetUtils.maskRawAddress(addrBytes, prefixLength);
return Arrays.equals(this.address, addrBytes);
}
@@ -204,7 +206,7 @@
public boolean containsPrefix(@NonNull IpPrefix otherPrefix) {
if (otherPrefix.getPrefixLength() < prefixLength) return false;
final byte[] otherAddress = otherPrefix.getRawAddress();
- NetworkUtils.maskRawAddress(otherAddress, prefixLength);
+ NetUtils.maskRawAddress(otherAddress, prefixLength);
return Arrays.equals(otherAddress, address);
}
diff --git a/framework/src/android/net/NetworkUtils.java b/framework/src/android/net/NetworkUtils.java
index 8be4af7..9ccb04a 100644
--- a/framework/src/android/net/NetworkUtils.java
+++ b/framework/src/android/net/NetworkUtils.java
@@ -29,7 +29,6 @@
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.SocketException;
-import java.net.UnknownHostException;
import java.util.Locale;
import java.util.TreeSet;
@@ -232,46 +231,6 @@
}
/**
- * Masks a raw IP address byte array with the specified prefix length.
- */
- public static void maskRawAddress(byte[] array, int prefixLength) {
- if (prefixLength < 0 || prefixLength > array.length * 8) {
- throw new RuntimeException("IP address with " + array.length +
- " bytes has invalid prefix length " + prefixLength);
- }
-
- int offset = prefixLength / 8;
- int remainder = prefixLength % 8;
- byte mask = (byte)(0xFF << (8 - remainder));
-
- if (offset < array.length) array[offset] = (byte)(array[offset] & mask);
-
- offset++;
-
- for (; offset < array.length; offset++) {
- array[offset] = 0;
- }
- }
-
- /**
- * Get InetAddress masked with prefixLength. Will never return null.
- * @param address the IP address to mask with
- * @param prefixLength the prefixLength used to mask the IP
- */
- public static InetAddress getNetworkPart(InetAddress address, int prefixLength) {
- byte[] array = address.getAddress();
- maskRawAddress(array, prefixLength);
-
- InetAddress netPart = null;
- try {
- netPart = InetAddress.getByAddress(array);
- } catch (UnknownHostException e) {
- throw new RuntimeException("getNetworkPart error - " + e.toString());
- }
- return netPart;
- }
-
- /**
* Returns the implicit netmask of an IPv4 address, as was the custom before 1993.
*/
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
diff --git a/service/Android.bp b/service/Android.bp
index ed1716f..f20b89f 100644
--- a/service/Android.bp
+++ b/service/Android.bp
@@ -14,6 +14,15 @@
// limitations under the License.
//
+package {
+ // See: http://go/android-license-faq
+ // A large-scale-change added 'default_applicable_licenses' to import
+ // all of the 'license_kinds' from "frameworks_base_license"
+ // to get the below license kinds:
+ // SPDX-license-identifier-Apache-2.0
+ default_applicable_licenses: ["frameworks_base_license"],
+}
+
cc_library_shared {
name: "libservice-connectivity",
// TODO: build against the NDK (sdk_version: "30" for example)