fix a crash
This commit is contained in:
@@ -28,7 +28,7 @@ libraryDependencies ++= Seq(
|
||||
)
|
||||
|
||||
libraryDependencies ++= Seq(
|
||||
"de.keyboardsurfer.android.widget" % "crouton" % "1.8.1" exclude("com.google.android", "support-v4"),
|
||||
"de.keyboardsurfer.android.widget" % "crouton" % "1.8.4" exclude("com.google.android", "support-v4"),
|
||||
"com.nostra13.universalimageloader" % "universal-image-loader" % "1.8.4",
|
||||
"com.j256.ormlite" % "ormlite-core" % "4.47",
|
||||
"com.j256.ormlite" % "ormlite-android" % "4.47"
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
<string name="forward_stop">后台服务已停止。</string>
|
||||
<string name="service_failed">请检查你的网络状态后并重试。</string>
|
||||
<string name="stop">停止服务</string>
|
||||
<string name="vpn_error">无法启动 VPN 服务:\"%s\"。看来和你的设备存在兼容性问题,请使用 Root 模式。</string>
|
||||
<string name="vpn_error">无法启动服务:\"%s\"。</string>
|
||||
<string name="ok_iknow">确定</string>
|
||||
<string name="port_alert">端口号应大于1024</string>
|
||||
<string name="port_empty">端口号不能为空</string>
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
<string name="forward_stop">Shadowsocks stopped.</string>
|
||||
<string name="service_failed">Please check your network status and try again.</string>
|
||||
<string name="stop">Stop the service</string>
|
||||
<string name="vpn_error">Unable to start VPN service: "%s". It seems to be a compatibility issue with your device. Please consider using ROOT mode instead.</string>
|
||||
<string name="vpn_error">Unable to start service: "%s".</string>
|
||||
|
||||
<!-- alert category -->
|
||||
<string name="ok_iknow">OK</string>
|
||||
|
||||
@@ -928,8 +928,6 @@ class Shadowsocks
|
||||
bgService.start(ConfigUtils.load(settings))
|
||||
|
||||
if (isVpnEnabled) {
|
||||
val style = new Style.Builder().setBackgroundColorValue(Style.holoBlueLight).build()
|
||||
val config = new Configuration.Builder().setDuration(Configuration.DURATION_LONG).build()
|
||||
changeSwitch(checked = false)
|
||||
}
|
||||
true
|
||||
@@ -995,7 +993,6 @@ class Shadowsocks
|
||||
changeSwitch(checked = false)
|
||||
Crouton.cancelAllCroutons()
|
||||
if (m != null) {
|
||||
Crouton.cancelAllCroutons()
|
||||
val style = new Style.Builder().setBackgroundColorValue(Style.holoRedLight).build()
|
||||
val config = new Configuration.Builder()
|
||||
.setDuration(Configuration.DURATION_LONG)
|
||||
|
||||
@@ -254,22 +254,6 @@ class ShadowsocksNatService extends Service with BaseService {
|
||||
startForegroundCompat(1, builder.build)
|
||||
}
|
||||
|
||||
def notifyAlert(title: String, info: String) {
|
||||
val openIntent: Intent = new Intent(this, classOf[Shadowsocks])
|
||||
openIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||
val contentIntent: PendingIntent = PendingIntent.getActivity(this, 0, openIntent, 0)
|
||||
val builder: NotificationCompat.Builder = new NotificationCompat.Builder(this)
|
||||
builder
|
||||
.setSmallIcon(R.drawable.ic_stat_shadowsocks)
|
||||
.setWhen(0)
|
||||
.setTicker(title)
|
||||
.setContentTitle(getString(R.string.app_name))
|
||||
.setContentText(info)
|
||||
.setContentIntent(contentIntent)
|
||||
.setAutoCancel(true)
|
||||
notificationManager.notify(1, builder.build)
|
||||
}
|
||||
|
||||
def onBind(intent: Intent): IBinder = {
|
||||
Log.d(TAG, "onBind")
|
||||
if (Action.SERVICE == intent.getAction) {
|
||||
@@ -492,44 +476,46 @@ class ShadowsocksNatService extends Service with BaseService {
|
||||
}
|
||||
|
||||
spawn {
|
||||
|
||||
if (config.proxy == "198.199.101.152") {
|
||||
val holder = application.containerHolder
|
||||
try {
|
||||
config = ConfigUtils.getPublicConfig(getBaseContext, holder.getContainer, config)
|
||||
} catch {
|
||||
case ex: Exception =>
|
||||
notifyAlert(getString(R.string.forward_fail), getString(R.string.service_failed))
|
||||
changeState(State.STOPPED, getString(R.string.service_failed))
|
||||
stopRunner()
|
||||
changeState(State.STOPPED)
|
||||
return
|
||||
config = null
|
||||
}
|
||||
}
|
||||
|
||||
killProcesses()
|
||||
if (config != null) {
|
||||
|
||||
var resolved: Boolean = false
|
||||
if (!InetAddressUtils.isIPv4Address(config.proxy) &&
|
||||
!InetAddressUtils.isIPv6Address(config.proxy)) {
|
||||
Utils.resolve(config.proxy, enableIPv6 = true) match {
|
||||
case Some(a) =>
|
||||
config.proxy = a
|
||||
resolved = true
|
||||
case None => resolved = false
|
||||
killProcesses()
|
||||
|
||||
var resolved: Boolean = false
|
||||
if (!InetAddressUtils.isIPv4Address(config.proxy) &&
|
||||
!InetAddressUtils.isIPv6Address(config.proxy)) {
|
||||
Utils.resolve(config.proxy, enableIPv6 = true) match {
|
||||
case Some(a) =>
|
||||
config.proxy = a
|
||||
resolved = true
|
||||
case None => resolved = false
|
||||
}
|
||||
} else {
|
||||
resolved = true
|
||||
}
|
||||
} else {
|
||||
resolved = true
|
||||
}
|
||||
|
||||
hasRedirectSupport = Utils.getHasRedirectSupport
|
||||
hasRedirectSupport = Utils.getHasRedirectSupport
|
||||
|
||||
if (resolved && handleConnection) {
|
||||
notifyForegroundAlert(getString(R.string.forward_success),
|
||||
getString(R.string.service_running).format(config.profileName))
|
||||
changeState(State.CONNECTED)
|
||||
} else {
|
||||
notifyAlert(getString(R.string.forward_fail), getString(R.string.service_failed))
|
||||
stopRunner()
|
||||
changeState(State.STOPPED)
|
||||
if (resolved && handleConnection) {
|
||||
notifyForegroundAlert(getString(R.string.forward_success),
|
||||
getString(R.string.service_running).format(config.profileName))
|
||||
changeState(State.CONNECTED)
|
||||
} else {
|
||||
changeState(State.STOPPED, getString(R.string.service_failed))
|
||||
stopRunner()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,18 +214,6 @@ class ShadowsocksVpnService extends VpnService with BaseService {
|
||||
true
|
||||
}
|
||||
|
||||
def notifyAlert(title: String, info: String) {
|
||||
val builder = new NotificationCompat.Builder(this)
|
||||
builder
|
||||
.setSmallIcon(R.drawable.ic_stat_shadowsocks)
|
||||
.setWhen(0)
|
||||
.setTicker(title)
|
||||
.setContentTitle(getString(R.string.app_name))
|
||||
.setContentText(info)
|
||||
.setAutoCancel(true)
|
||||
notificationManager.notify(1, builder.build)
|
||||
}
|
||||
|
||||
override def onBind(intent: Intent): IBinder = {
|
||||
val action = intent.getAction
|
||||
if (VpnService.SERVICE_INTERFACE == action) {
|
||||
@@ -297,36 +285,37 @@ class ShadowsocksVpnService extends VpnService with BaseService {
|
||||
config = ConfigUtils.getPublicConfig(getBaseContext, holder.getContainer, config)
|
||||
} catch {
|
||||
case ex: Exception =>
|
||||
notifyAlert(getString(R.string.forward_fail), getString(R.string.service_failed))
|
||||
changeState(State.STOPPED, getString(R.string.service_failed))
|
||||
stopRunner()
|
||||
changeState(State.STOPPED)
|
||||
return
|
||||
config = null
|
||||
}
|
||||
}
|
||||
|
||||
// reset the context
|
||||
killProcesses()
|
||||
if (config != null) {
|
||||
|
||||
// Resolve the server address
|
||||
var resolved: Boolean = false
|
||||
if (!InetAddressUtils.isIPv4Address(config.proxy) &&
|
||||
!InetAddressUtils.isIPv6Address(config.proxy)) {
|
||||
Utils.resolve(config.proxy, enableIPv6 = true) match {
|
||||
case Some(addr) =>
|
||||
config.proxy = addr
|
||||
resolved = true
|
||||
case None => resolved = false
|
||||
// reset the context
|
||||
killProcesses()
|
||||
|
||||
// Resolve the server address
|
||||
var resolved: Boolean = false
|
||||
if (!InetAddressUtils.isIPv4Address(config.proxy) &&
|
||||
!InetAddressUtils.isIPv6Address(config.proxy)) {
|
||||
Utils.resolve(config.proxy, enableIPv6 = true) match {
|
||||
case Some(addr) =>
|
||||
config.proxy = addr
|
||||
resolved = true
|
||||
case None => resolved = false
|
||||
}
|
||||
} else {
|
||||
resolved = true
|
||||
}
|
||||
} else {
|
||||
resolved = true
|
||||
}
|
||||
|
||||
if (resolved && handleConnection) {
|
||||
changeState(State.CONNECTED)
|
||||
} else {
|
||||
notifyAlert(getString(R.string.forward_fail), getString(R.string.service_failed))
|
||||
changeState(State.STOPPED)
|
||||
stopRunner()
|
||||
if (resolved && handleConnection) {
|
||||
changeState(State.CONNECTED)
|
||||
} else {
|
||||
changeState(State.STOPPED, getString(R.string.service_failed))
|
||||
stopRunner()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -362,9 +351,6 @@ class ShadowsocksVpnService extends VpnService with BaseService {
|
||||
unregisterReceiver(receiver)
|
||||
receiver = null
|
||||
}
|
||||
|
||||
// reset notifications
|
||||
notificationManager.cancel(1)
|
||||
}
|
||||
|
||||
override def stopBackgroundService() {
|
||||
|
||||
Reference in New Issue
Block a user