diff --git a/core/java/android/net/IConnectivityManager.aidl b/core/java/android/net/IConnectivityManager.aidl index b9c6491da2..f61984ac33 100644 --- a/core/java/android/net/IConnectivityManager.aidl +++ b/core/java/android/net/IConnectivityManager.aidl @@ -42,9 +42,6 @@ import com.android.internal.net.VpnProfile; /** {@hide} */ interface IConnectivityManager { - // Keep this in sync with framework/native/services/connectivitymanager/ConnectivityManager.h - void markSocketAsUser(in ParcelFileDescriptor socket, int uid); - NetworkInfo getActiveNetworkInfo(); NetworkInfo getActiveNetworkInfoForUid(int uid); NetworkInfo getNetworkInfo(int networkType); diff --git a/core/java/android/net/NetworkUtils.java b/core/java/android/net/NetworkUtils.java index af860b0889..9b95305b1d 100644 --- a/core/java/android/net/NetworkUtils.java +++ b/core/java/android/net/NetworkUtils.java @@ -105,11 +105,6 @@ public class NetworkUtils { */ public native static String getDhcpError(); - /** - * Set the SO_MARK of {@code socketfd} to {@code mark} - */ - public native static void markSocket(int socketfd, int mark); - /** * Binds the current process to the network designated by {@code netId}. All sockets created * in the future (and not explicitly bound via a bound {@link SocketFactory} (see diff --git a/core/jni/android_net_NetUtils.cpp b/core/jni/android_net_NetUtils.cpp index 2325bc7e9a..760ed45259 100644 --- a/core/jni/android_net_NetUtils.cpp +++ b/core/jni/android_net_NetUtils.cpp @@ -246,13 +246,6 @@ static jstring android_net_utils_getDhcpError(JNIEnv* env, jobject clazz) return env->NewStringUTF(::dhcp_get_errmsg()); } -static void android_net_utils_markSocket(JNIEnv *env, jobject thiz, jint socket, jint mark) -{ - if (setsockopt(socket, SOL_SOCKET, SO_MARK, &mark, sizeof(mark)) < 0) { - jniThrowException(env, "java/lang/IllegalStateException", "Error marking socket"); - } -} - static jboolean android_net_utils_bindProcessToNetwork(JNIEnv *env, jobject thiz, jint netId) { return (jboolean) !setNetworkForProcess(netId); @@ -296,7 +289,6 @@ static JNINativeMethod gNetworkUtilMethods[] = { { "stopDhcp", "(Ljava/lang/String;)Z", (void *)android_net_utils_stopDhcp }, { "releaseDhcpLease", "(Ljava/lang/String;)Z", (void *)android_net_utils_releaseDhcpLease }, { "getDhcpError", "()Ljava/lang/String;", (void*) android_net_utils_getDhcpError }, - { "markSocket", "(II)V", (void*) android_net_utils_markSocket }, { "bindProcessToNetwork", "(I)Z", (void*) android_net_utils_bindProcessToNetwork }, { "getNetworkBoundToProcess", "()I", (void*) android_net_utils_getNetworkBoundToProcess }, { "bindProcessToNetworkForHostResolution", "(I)Z", (void*) android_net_utils_bindProcessToNetworkForHostResolution }, diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index b52aecf397..6554ed319c 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -2122,16 +2122,6 @@ public class ConnectivityService extends IConnectivityManager.Stub { "ConnectivityService"); } - private void enforceMarkNetworkSocketPermission() { - //Media server special case - if (Binder.getCallingUid() == Process.MEDIA_UID) { - return; - } - mContext.enforceCallingOrSelfPermission( - android.Manifest.permission.MARK_NETWORK_SOCKET, - "ConnectivityService"); - } - /** * Handle a {@code DISCONNECTED} event. If this pertains to the non-active * network, we ignore it. If it is for the active network, we send out a @@ -4084,23 +4074,6 @@ public class ConnectivityService extends IConnectivityManager.Stub { } } - @Override - public void markSocketAsUser(ParcelFileDescriptor socket, int uid) { - enforceMarkNetworkSocketPermission(); - final long token = Binder.clearCallingIdentity(); - try { - int mark = mNetd.getMarkForUid(uid); - // Clear the mark on the socket if no mark is needed to prevent socket reuse issues - if (mark == -1) { - mark = 0; - } - NetworkUtils.markSocket(socket.getFd(), mark); - } catch (RemoteException e) { - } finally { - Binder.restoreCallingIdentity(token); - } - } - /** * Configure a TUN interface and return its file descriptor. Parameters * are encoded and opaque to this class. This method is used by VpnBuilder