Commit 2ac9369d authored by liusheng's avatar liusheng

处理vip过期

parent f1e1acbe
...@@ -241,7 +241,10 @@ class AccelertorFragment : XPageFragment() { ...@@ -241,7 +241,10 @@ class AccelertorFragment : XPageFragment() {
binding.btnQuick.isEnabled = false binding.btnQuick.isEnabled = false
startAnim() startAnim()
} else { } else {
MemberDialog(this@AccelertorFragment).show<MemberDialog>() //MemberDialog(this@AccelertorFragment).show<MemberDialog>()
//TODO 测试
binding.btnQuick.isEnabled = false
startAnim()
} }
} }
} else { } else {
......
...@@ -57,6 +57,10 @@ object AcceleratorUtils { ...@@ -57,6 +57,10 @@ object AcceleratorUtils {
} }
var vipExpireListener: () -> Unit = { ->
}
fun getGameList(xPageFragment: XPageFragment, callback: (Boolean) -> Unit) { fun getGameList(xPageFragment: XPageFragment, callback: (Boolean) -> Unit) {
game?.let { game?.let {
callback(true) callback(true)
...@@ -191,6 +195,8 @@ object AcceleratorUtils { ...@@ -191,6 +195,8 @@ object AcceleratorUtils {
} }
} }
fun stopAccelerator() { fun stopAccelerator() {
Core.stopService() Core.stopService()
} }
...@@ -200,9 +206,13 @@ object AcceleratorUtils { ...@@ -200,9 +206,13 @@ object AcceleratorUtils {
AcceleratorUtils.state = state AcceleratorUtils.state = state
stateListener(state, getAccTime(), null) stateListener(state, getAccTime(), null)
if (state == BaseService.State.Stopped && !msg.isNullOrBlank()) { if (state == BaseService.State.Stopped && !msg.isNullOrBlank()) {
if("vip到期".equals(msg)){
}else{
ToastUtils.show(msg) ToastUtils.show(msg)
} }
} }
}
override fun onServiceConnected(service: IShadowsocksService) { override fun onServiceConnected(service: IShadowsocksService) {
try { try {
......
package com.github.shadowsocks.bg package com.github.shadowsocks.bg
import android.os.Build import android.os.Build
import android.util.Log
import com.github.shadowsocks.Core import com.github.shadowsocks.Core
import com.github.shadowsocks.database.Profile import com.github.shadowsocks.database.Profile
import com.github.shadowsocks.database.ProfileManager import com.github.shadowsocks.database.ProfileManager
...@@ -89,16 +90,18 @@ object AuthManager { ...@@ -89,16 +90,18 @@ object AuthManager {
suspend fun initAuthProfile(profile: Profile) { suspend fun initAuthProfile(profile: Profile) {
withContext(Dispatchers.IO) { withContext(Dispatchers.IO) {
getLineConfig()?.let { getLineConfig()?.let {
if (it.code != 200) { if(it.code==1001){//vip过期
return@withContext throw AuthException(it.error)
}else if(it.code==1001){//vip过期 }else if (it.code != 200) {
throw AuthException(it.error)
} }
profile.host = it.data.host profile.host = it.data.host
profile.token = it.data.token profile.token = it.data.token
profile.remotePort = it.data.port profile.remotePort = it.data.port
Timber.d("start vpn with games: ${profile.individual}, profileId: ${profile.id}, route: ${profile.route}") Timber.d("start vpn with games: ${profile.individual}, profileId: ${profile.id}, route: ${profile.route}")
ProfileManager.updateProfile(profile) ProfileManager.updateProfile(profile)
}?: let {
throw AuthException("未知错误")
} }
} }
} }
...@@ -166,6 +169,8 @@ object AuthManager { ...@@ -166,6 +169,8 @@ object AuthManager {
val response: Response = call.execute() val response: Response = call.execute()
if (response.isSuccessful) { if (response.isSuccessful) {
val string = response.body?.string() val string = response.body?.string()
Log.e("postSync","=====url:"+HttpConfig.baseUrl + url)
Log.e("postSync","=====result:"+string)
println(string) println(string)
val type = object : TypeToken<T>() {}.type val type = object : TypeToken<T>() {}.type
return gson.fromJson(string, type) return gson.fromJson(string, type)
......
...@@ -2,7 +2,8 @@ package com.github.shadowsocks.http ...@@ -2,7 +2,8 @@ package com.github.shadowsocks.http
data class LineConfig( data class LineConfig(
val code: Int, val code: Int,
val `data`: Data val `data`: Data,
val error:String
) )
data class Data( data class Data(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment