Remove unnecessary code and APIs.
This stuff has been replaced by setNetworkForUser() in NetdClient. Change-Id: If525ee259b74314191d1913f7c2a3e828e05c38f
This commit is contained in:
@@ -42,9 +42,6 @@ import com.android.internal.net.VpnProfile;
|
|||||||
/** {@hide} */
|
/** {@hide} */
|
||||||
interface IConnectivityManager
|
interface IConnectivityManager
|
||||||
{
|
{
|
||||||
// Keep this in sync with framework/native/services/connectivitymanager/ConnectivityManager.h
|
|
||||||
void markSocketAsUser(in ParcelFileDescriptor socket, int uid);
|
|
||||||
|
|
||||||
NetworkInfo getActiveNetworkInfo();
|
NetworkInfo getActiveNetworkInfo();
|
||||||
NetworkInfo getActiveNetworkInfoForUid(int uid);
|
NetworkInfo getActiveNetworkInfoForUid(int uid);
|
||||||
NetworkInfo getNetworkInfo(int networkType);
|
NetworkInfo getNetworkInfo(int networkType);
|
||||||
|
|||||||
@@ -105,11 +105,6 @@ public class NetworkUtils {
|
|||||||
*/
|
*/
|
||||||
public native static String getDhcpError();
|
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
|
* 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
|
* in the future (and not explicitly bound via a bound {@link SocketFactory} (see
|
||||||
|
|||||||
@@ -246,13 +246,6 @@ static jstring android_net_utils_getDhcpError(JNIEnv* env, jobject clazz)
|
|||||||
return env->NewStringUTF(::dhcp_get_errmsg());
|
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)
|
static jboolean android_net_utils_bindProcessToNetwork(JNIEnv *env, jobject thiz, jint netId)
|
||||||
{
|
{
|
||||||
return (jboolean) !setNetworkForProcess(netId);
|
return (jboolean) !setNetworkForProcess(netId);
|
||||||
@@ -296,7 +289,6 @@ static JNINativeMethod gNetworkUtilMethods[] = {
|
|||||||
{ "stopDhcp", "(Ljava/lang/String;)Z", (void *)android_net_utils_stopDhcp },
|
{ "stopDhcp", "(Ljava/lang/String;)Z", (void *)android_net_utils_stopDhcp },
|
||||||
{ "releaseDhcpLease", "(Ljava/lang/String;)Z", (void *)android_net_utils_releaseDhcpLease },
|
{ "releaseDhcpLease", "(Ljava/lang/String;)Z", (void *)android_net_utils_releaseDhcpLease },
|
||||||
{ "getDhcpError", "()Ljava/lang/String;", (void*) android_net_utils_getDhcpError },
|
{ "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 },
|
{ "bindProcessToNetwork", "(I)Z", (void*) android_net_utils_bindProcessToNetwork },
|
||||||
{ "getNetworkBoundToProcess", "()I", (void*) android_net_utils_getNetworkBoundToProcess },
|
{ "getNetworkBoundToProcess", "()I", (void*) android_net_utils_getNetworkBoundToProcess },
|
||||||
{ "bindProcessToNetworkForHostResolution", "(I)Z", (void*) android_net_utils_bindProcessToNetworkForHostResolution },
|
{ "bindProcessToNetworkForHostResolution", "(I)Z", (void*) android_net_utils_bindProcessToNetworkForHostResolution },
|
||||||
|
|||||||
@@ -2122,16 +2122,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
"ConnectivityService");
|
"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
|
* 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
|
* 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
|
* Configure a TUN interface and return its file descriptor. Parameters
|
||||||
* are encoded and opaque to this class. This method is used by VpnBuilder
|
* are encoded and opaque to this class. This method is used by VpnBuilder
|
||||||
|
|||||||
Reference in New Issue
Block a user