@@ -23,9 +23,8 @@ package com.github.shadowsocks.utils
|
||||
import java.io.File
|
||||
import java.net._
|
||||
import java.security.MessageDigest
|
||||
import java.util.{Scanner, StringTokenizer}
|
||||
import java.util.Scanner
|
||||
|
||||
import android.animation.{Animator, AnimatorListenerAdapter}
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.{Context, Intent}
|
||||
import android.graphics._
|
||||
@@ -39,7 +38,6 @@ import com.github.shadowsocks.{BuildConfig, ShadowsocksRunnerService}
|
||||
import org.xbill.DNS._
|
||||
|
||||
import scala.collection.JavaConversions._
|
||||
import scala.collection.mutable.ArrayBuffer
|
||||
import scala.concurrent.ExecutionContext.Implicits.global
|
||||
import scala.concurrent.Future
|
||||
import scala.util.{Failure, Try}
|
||||
@@ -98,48 +96,6 @@ object Utils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Crack a command line.
|
||||
* Based on: https://github.com/apache/ant/blob/588ce1f/src/main/org/apache/tools/ant/types/Commandline.java#L471
|
||||
* @param toProcess the command line to process.
|
||||
* @return the command line broken into strings.
|
||||
* An empty or null toProcess parameter results in a zero sized ArrayBuffer.
|
||||
*/
|
||||
def translateCommandline(toProcess: String): ArrayBuffer[String] = {
|
||||
if (toProcess == null || toProcess.length == 0) return ArrayBuffer[String]()
|
||||
val tok = new StringTokenizer(toProcess, "\"' ", true)
|
||||
val result = ArrayBuffer[String]()
|
||||
val current = new StringBuilder()
|
||||
var quote = ' '
|
||||
var last = " "
|
||||
while (tok.hasMoreTokens) {
|
||||
val nextTok = tok.nextToken
|
||||
quote match {
|
||||
case '\'' => nextTok match {
|
||||
case "'" => quote = ' '
|
||||
case _ => current.append(nextTok)
|
||||
}
|
||||
case '"' => nextTok match {
|
||||
case "\"" => quote = ' '
|
||||
case _ => current.append(nextTok)
|
||||
}
|
||||
case _ => nextTok match {
|
||||
case "'" => quote = '\''
|
||||
case "\"" => quote = '"'
|
||||
case " " => if (last != " ") {
|
||||
result.append(current.toString)
|
||||
current.setLength(0)
|
||||
}
|
||||
case _ => current.append(nextTok)
|
||||
}
|
||||
}
|
||||
last = nextTok
|
||||
}
|
||||
if (current.nonEmpty) result.append(current.toString)
|
||||
if (quote == '\'' || quote == '"') throw new Exception("Unbalanced quotes in " + toProcess)
|
||||
result
|
||||
}
|
||||
|
||||
def resolve(host: String, addrType: Int): Option[String] = {
|
||||
try {
|
||||
val lookup = new Lookup(host, addrType)
|
||||
|
||||
Reference in New Issue
Block a user