Remove ProcessUtils

It's safe to say that Shadowsocks is only instantialized in the main process, so boom, problem solved.
This commit is contained in:
Mygod
2016-03-11 20:18:22 +08:00
parent 270d436017
commit fcdeb5144a
2 changed files with 2 additions and 42 deletions
@@ -1,35 +0,0 @@
package com.github.shadowsocks.utils
import java.io.{BufferedReader, FileInputStream, InputStreamReader}
import android.content.Context
import com.github.shadowsocks.utils.CloseUtils._
/**
* @author chentaov5@gmail.com
*/
object ProcessUtils {
def getCurrentProcessName = autoClose(new FileInputStream("/proc/self/cmdline")) { inputStream =>
autoClose(new BufferedReader(new InputStreamReader(inputStream))) { reader =>
val sb = new StringBuilder
var c = 0
while ({c = reader.read(); c > 0}) sb.append(c.asInstanceOf[Char])
sb.toString()
}
}
def inShadowsocks(context: Context)(fun: => Unit) {
if (context != null && getCurrentProcessName.equals(context.getPackageName)) fun
}
def inVpn(context: Context)(fun: => Unit) {
if (context != null && getCurrentProcessName.equals(context.getPackageName + ":vpn")) fun
}
def inNat(context: Context)(fun: => Unit) {
if (context != null && getCurrentProcessName.equals(context.getPackageName + ":nat")) fun
}
}