diff options
author | Chia-chi Yeh <chiachi@android.com> | 2011-07-03 18:00:47 -0700 |
---|---|---|
committer | Chia-chi Yeh <chiachi@android.com> | 2011-07-03 18:00:47 -0700 |
commit | c2b8aa0b4c822b0e307f62131650f4a6ee89bb66 (patch) | |
tree | de5998a2db403a13ba4dee000fec8036afba06df | |
parent | e96aae1f4958bbc434b640b95a308757db8f8bed (diff) | |
download | frameworks_base-c2b8aa0b4c822b0e307f62131650f4a6ee89bb66.zip frameworks_base-c2b8aa0b4c822b0e307f62131650f4a6ee89bb66.tar.gz frameworks_base-c2b8aa0b4c822b0e307f62131650f4a6ee89bb66.tar.bz2 |
VPN: rename some variables.
Change-Id: I7f15b5ab30f591e26242fca27af25f578809534c
-rw-r--r-- | services/java/com/android/server/connectivity/Vpn.java | 70 | ||||
-rw-r--r-- | services/jni/com_android_server_connectivity_Vpn.cpp | 22 |
2 files changed, 46 insertions, 46 deletions
diff --git a/services/java/com/android/server/connectivity/Vpn.java b/services/java/com/android/server/connectivity/Vpn.java index 4ae12bc..bb3ce28 100644 --- a/services/java/com/android/server/connectivity/Vpn.java +++ b/services/java/com/android/server/connectivity/Vpn.java @@ -55,8 +55,8 @@ public class Vpn extends INetworkManagementEventObserver.Stub { private final Context mContext; private final VpnCallback mCallback; - private String mPackageName = VpnConfig.LEGACY_VPN; - private String mInterfaceName; + private String mPackage = VpnConfig.LEGACY_VPN; + private String mInterface; private LegacyVpnRunner mLegacyVpnRunner; public Vpn(Context context, VpnCallback callback) { @@ -71,10 +71,10 @@ public class Vpn extends INetworkManagementEventObserver.Stub { * @param socket The socket to be bound. * @param name The name of the interface. */ - public void protect(ParcelFileDescriptor socket, String name) { + public void protect(ParcelFileDescriptor socket, String interfaze) { try { mContext.enforceCallingPermission(VPN, "protect"); - jniProtectSocket(socket.getFd(), name); + jniProtect(socket.getFd(), interfaze); } finally { try { socket.close(); @@ -104,13 +104,13 @@ public class Vpn extends INetworkManagementEventObserver.Stub { */ public synchronized boolean prepare(String oldPackage, String newPackage) { // Return false if the package does not match. - if (oldPackage != null && !oldPackage.equals(mPackageName)) { + if (oldPackage != null && !oldPackage.equals(mPackage)) { return false; } // Return true if we do not need to revoke. if (newPackage == null || - (newPackage.equals(mPackageName) && !newPackage.equals(VpnConfig.LEGACY_VPN))) { + (newPackage.equals(mPackage) && !newPackage.equals(VpnConfig.LEGACY_VPN))) { return true; } @@ -127,17 +127,17 @@ public class Vpn extends INetworkManagementEventObserver.Stub { } // Reset the interface and hide the notification. - if (mInterfaceName != null) { - jniResetInterface(mInterfaceName); + if (mInterface != null) { + jniReset(mInterface); mCallback.restore(); hideNotification(); - mInterfaceName = null; + mInterface = null; } // Send out the broadcast or stop LegacyVpnRunner. - if (!mPackageName.equals(VpnConfig.LEGACY_VPN)) { + if (!mPackage.equals(VpnConfig.LEGACY_VPN)) { Intent intent = new Intent(VpnConfig.ACTION_VPN_REVOKED); - intent.setPackage(mPackageName); + intent.setPackage(mPackage); intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); mContext.sendBroadcast(intent); } else if (mLegacyVpnRunner != null) { @@ -145,8 +145,8 @@ public class Vpn extends INetworkManagementEventObserver.Stub { mLegacyVpnRunner = null; } - Log.i(TAG, "Switched from " + mPackageName + " to " + newPackage); - mPackageName = newPackage; + Log.i(TAG, "Switched from " + mPackage + " to " + newPackage); + mPackage = newPackage; return true; } @@ -166,7 +166,7 @@ public class Vpn extends INetworkManagementEventObserver.Stub { PackageManager pm = mContext.getPackageManager(); ApplicationInfo app = null; try { - app = pm.getApplicationInfo(mPackageName, 0); + app = pm.getApplicationInfo(mPackage, 0); } catch (Exception e) { return null; } @@ -191,17 +191,17 @@ public class Vpn extends INetworkManagementEventObserver.Stub { } // Configure the interface. Abort if any of these steps fails. - ParcelFileDescriptor descriptor = ParcelFileDescriptor.adoptFd( + ParcelFileDescriptor tun = ParcelFileDescriptor.adoptFd( jniConfigure(config.mtu, config.addresses, config.routes)); try { - String name = jniGetInterfaceName(descriptor.getFd()); - if (mInterfaceName != null && !mInterfaceName.equals(name)) { - jniResetInterface(mInterfaceName); + String interfaze = jniGetName(tun.getFd()); + if (mInterface != null && !mInterface.equals(interfaze)) { + jniReset(mInterface); } - mInterfaceName = name; + mInterface = interfaze; } catch (RuntimeException e) { try { - descriptor.close(); + tun.close(); } catch (Exception ex) { // ignore } @@ -212,32 +212,32 @@ public class Vpn extends INetworkManagementEventObserver.Stub { mCallback.override(config.dnsServers, config.searchDomains); // Fill more values. - config.packagz = mPackageName; - config.interfaze = mInterfaceName; + config.packagz = mPackage; + config.interfaze = mInterface; // Show the notification! showNotification(config, label, bitmap); - return descriptor; + return tun; } // INetworkManagementEventObserver.Stub - public void interfaceStatusChanged(String name, boolean up) { + public void interfaceStatusChanged(String interfaze, boolean up) { } // INetworkManagementEventObserver.Stub - public void interfaceLinkStateChanged(String name, boolean up) { + public void interfaceLinkStateChanged(String interfaze, boolean up) { } // INetworkManagementEventObserver.Stub - public void interfaceAdded(String name) { + public void interfaceAdded(String interfaze) { } // INetworkManagementEventObserver.Stub - public synchronized void interfaceRemoved(String name) { - if (name.equals(mInterfaceName) && jniCheckInterface(name) == 0) { + public synchronized void interfaceRemoved(String interfaze) { + if (interfaze.equals(mInterface) && jniCheck(interfaze) == 0) { mCallback.restore(); hideNotification(); - mInterfaceName = null; + mInterface = null; } } @@ -278,10 +278,10 @@ public class Vpn extends INetworkManagementEventObserver.Stub { } private native int jniConfigure(int mtu, String addresses, String routes); - private native String jniGetInterfaceName(int fd); - private native void jniResetInterface(String name); - private native int jniCheckInterface(String name); - private native void jniProtectSocket(int fd, String name); + private native String jniGetName(int tun); + private native void jniReset(String interfaze); + private native int jniCheck(String interfaze); + private native void jniProtect(int socket, String interfaze); /** * Handle a legacy VPN request. This method stops the daemons and restart @@ -484,12 +484,12 @@ public class Vpn extends INetworkManagementEventObserver.Stub { checkpoint(false); // Check if the interface is gone while we are waiting. - if (jniCheckInterface(mConfig.interfaze) == 0) { + if (jniCheck(mConfig.interfaze) == 0) { throw new IllegalStateException(mConfig.interfaze + " is gone"); } // Now INetworkManagementEventObserver is watching our back. - mInterfaceName = mConfig.interfaze; + mInterface = mConfig.interfaze; mCallback.override(mConfig.dnsServers, mConfig.searchDomains); showNotification(mConfig, null, null); } diff --git a/services/jni/com_android_server_connectivity_Vpn.cpp b/services/jni/com_android_server_connectivity_Vpn.cpp index 6d4f68f..5f920f1 100644 --- a/services/jni/com_android_server_connectivity_Vpn.cpp +++ b/services/jni/com_android_server_connectivity_Vpn.cpp @@ -289,9 +289,9 @@ static int check_interface(const char *name) return ifr4.ifr_flags; } -static int bind_to_interface(int fd, const char *name) +static int bind_to_interface(int socket, const char *name) { - if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, name, strlen(name))) { + if (setsockopt(socket, SOL_SOCKET, SO_BINDTODEVICE, name, strlen(name))) { LOGE("Cannot bind socket to %s: %s", name, strerror(errno)); return SYSTEM_ERROR; } @@ -358,7 +358,7 @@ error: return -1; } -static jstring getInterfaceName(JNIEnv *env, jobject thiz, jint tun) +static jstring getName(JNIEnv *env, jobject thiz, jint tun) { char name[IFNAMSIZ]; if (get_interface_name(name, tun) < 0) { @@ -368,7 +368,7 @@ static jstring getInterfaceName(JNIEnv *env, jobject thiz, jint tun) return env->NewStringUTF(name); } -static void resetInterface(JNIEnv *env, jobject thiz, jstring jName) +static void reset(JNIEnv *env, jobject thiz, jstring jName) { const char *name = jName ? env->GetStringUTFChars(jName, NULL) : NULL; if (!name) { @@ -381,7 +381,7 @@ static void resetInterface(JNIEnv *env, jobject thiz, jstring jName) env->ReleaseStringUTFChars(jName, name); } -static jint checkInterface(JNIEnv *env, jobject thiz, jstring jName) +static jint check(JNIEnv *env, jobject thiz, jstring jName) { const char *name = jName ? env->GetStringUTFChars(jName, NULL) : NULL; if (!name) { @@ -393,14 +393,14 @@ static jint checkInterface(JNIEnv *env, jobject thiz, jstring jName) return flags; } -static void protectSocket(JNIEnv *env, jobject thiz, jint fd, jstring jName) +static void protect(JNIEnv *env, jobject thiz, jint socket, jstring jName) { const char *name = jName ? env->GetStringUTFChars(jName, NULL) : NULL; if (!name) { jniThrowNullPointerException(env, "name"); return; } - if (bind_to_interface(fd, name) < 0) { + if (bind_to_interface(socket, name) < 0) { throwException(env, SYSTEM_ERROR, "Cannot protect socket"); } env->ReleaseStringUTFChars(jName, name); @@ -410,10 +410,10 @@ static void protectSocket(JNIEnv *env, jobject thiz, jint fd, jstring jName) static JNINativeMethod gMethods[] = { {"jniConfigure", "(ILjava/lang/String;Ljava/lang/String;)I", (void *)configure}, - {"jniGetInterfaceName", "(I)Ljava/lang/String;", (void *)getInterfaceName}, - {"jniResetInterface", "(Ljava/lang/String;)V", (void *)resetInterface}, - {"jniCheckInterface", "(Ljava/lang/String;)I", (void *)checkInterface}, - {"jniProtectSocket", "(ILjava/lang/String;)V", (void *)protectSocket}, + {"jniGetName", "(I)Ljava/lang/String;", (void *)getName}, + {"jniReset", "(Ljava/lang/String;)V", (void *)reset}, + {"jniCheck", "(Ljava/lang/String;)I", (void *)check}, + {"jniProtect", "(ILjava/lang/String;)V", (void *)protect}, }; int register_android_server_connectivity_Vpn(JNIEnv *env) |