Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.ccwangluo.accelerator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
com.ccwangluo.accelerator
Commits
8286a5df
Commit
8286a5df
authored
Mar 04, 2022
by
liusheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复加速AuthToken重新登录不刷新的问题
parent
3f146744
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
23 deletions
+13
-23
app/src/main/java/com/ccwangluo/accelerator/ui/home/AccelertorFragment.kt
...a/com/ccwangluo/accelerator/ui/home/AccelertorFragment.kt
+0
-6
app/src/main/java/com/ccwangluo/accelerator/utils/AcceleratorUtils.kt
.../java/com/ccwangluo/accelerator/utils/AcceleratorUtils.kt
+1
-2
app/src/main/java/com/ccwangluo/accelerator/utils/LoginUtils.kt
...c/main/java/com/ccwangluo/accelerator/utils/LoginUtils.kt
+6
-10
core/src/main/java/com/github/shadowsocks/bg/AuthManager.kt
core/src/main/java/com/github/shadowsocks/bg/AuthManager.kt
+6
-5
No files found.
app/src/main/java/com/ccwangluo/accelerator/ui/home/AccelertorFragment.kt
View file @
8286a5df
...
...
@@ -137,12 +137,6 @@ class AccelertorFragment : XPageFragment() {
binding
.
progressArea
.
visibility
=
View
.
GONE
binding
.
btnQuick
.
isEnabled
=
true
binding
.
progressViewCircleSmall
.
progress
=
0F
binding
.
progressViewCircleSmall
.
postDelayed
({
Log
.
e
(
"onCircleProgressFinished"
,
"====="
+
state
.
toString
())
if
(
state
!=
BaseService
.
State
.
Connected
)
{
ToastUtils
.
show
(
"加速失败"
)
}
},
3000
)
AcceleratorUtils
.
startAccelerator
(
this
@AccelertorFragment
)
}
})
...
...
app/src/main/java/com/ccwangluo/accelerator/utils/AcceleratorUtils.kt
View file @
8286a5df
...
...
@@ -98,7 +98,7 @@ object AcceleratorUtils {
val
delay
=
NetUtils
.
tcpPing
(
split
[
0
],
split
[
1
].
toInt
(),
DataStore
.
portProxy
)
.
toInt
()
net
.
accNetDelay
=
(
delay
*
0.5
).
toInt
()
net
.
accNetDelay
=
delay
LoginUtils
.
getUserHasTimer
{
if
(!
it
)
{
//没有加速时长关闭服务
stopAccelerator
()
...
...
@@ -171,7 +171,6 @@ object AcceleratorUtils {
proxyGames
.
add
(
it
)
}
}
proxyGames
.
addAll
(
profile
.
individual
.
split
(
"\n"
))
profile
.
individual
=
proxyGames
.
joinToString
(
"\n"
)
profile
.
route
=
Acl
.
BYPASS_LAN
profile
.
password
=
"barfoo!"
...
...
app/src/main/java/com/ccwangluo/accelerator/utils/LoginUtils.kt
View file @
8286a5df
...
...
@@ -101,7 +101,7 @@ object LoginUtils {
timer
?.
schedule
(
timerTask
,
0
,
1000
);
}
fun
stopTimer
(){
fun
stopTimer
()
{
_phone
=
""
timer
?.
cancel
()
}
...
...
@@ -136,7 +136,7 @@ object LoginUtils {
context
,
PhoneLoginActivity
::
class
.
java
)
intent
.
addFlags
(
FLAG_ACTIVITY_NEW_TASK
)
intent
.
addFlags
(
FLAG_ACTIVITY_NEW_TASK
)
context
.
startActivity
(
intent
)
...
...
@@ -148,21 +148,17 @@ object LoginUtils {
fun
clearToken
()
{
Core
.
stopService
()
MMKV
.
defaultMMKV
().
remove
(
KEY_TOKEN
)
token
=
null
}
var
token
:
String
?
get
()
=
MMKV
.
defaultMMKV
().
decodeString
(
KEY_TOKEN
,
null
)
get
()
=
AuthManager
.
authToken
set
(
token
)
{
MMKV
.
defaultMMKV
().
putString
(
KEY_TOKEN
,
token
)
if
(
token
!=
null
)
{
AuthManager
.
loginAuthToken
=
token
Log
.
e
(
"LoginUtils"
,
"===loginAuthToken:"
+
AuthManager
.
loginAuthToken
)
}
AuthManager
.
authToken
=
token
}
fun
hasToken
():
Boolean
{
return
MMKV
.
defaultMMKV
().
containsKey
(
KEY_TOKEN
)
return
!
AuthManager
.
authToken
.
isNullOrBlank
(
)
}
fun
logout
()
{
...
...
core/src/main/java/com/github/shadowsocks/bg/AuthManager.kt
View file @
8286a5df
...
...
@@ -64,9 +64,9 @@ object AuthManager {
}
var
authToken
:
String
?
get
()
=
MMKV
.
defaultMMKV
(
).
decodeString
(
KEY_TOKEN
,
null
)
get
()
=
MMKV
.
mmkvWithID
(
"InterProcessKV"
,
MMKV
.
MULTI_PROCESS_MODE
).
decodeString
(
KEY_TOKEN
,
null
)
set
(
token
)
{
MMKV
.
defaultMMKV
(
).
putString
(
KEY_TOKEN
,
token
)
MMKV
.
mmkvWithID
(
"InterProcessKV"
,
MMKV
.
MULTI_PROCESS_MODE
).
putString
(
KEY_TOKEN
,
token
)
}
// 加速时长
...
...
@@ -87,7 +87,7 @@ object AuthManager {
suspend
fun
initAuthProfile
(
profile
:
Profile
)
{
withContext
(
Dispatchers
.
IO
)
{
val
gameId
:
Int
=
gameId
?.
toInt
()
?:
throw
AuthException
(
"游戏不存在"
)
val
lineConfigResult
=
postSync
<
LineConfig
>(
"/api/acc/line"
,
LineConfigReq
(
gameId
,
area
))
val
lineConfigResult
=
postSync
<
LineConfig
>(
"/api/acc/line"
,
authToken
,
LineConfigReq
(
gameId
,
area
))
if
(
lineConfigResult
.
isSuccessful
())
{
val
lineConfig
=
lineConfigResult
.
unwrapData
()
profile
.
host
=
lineConfig
.
host
...
...
@@ -119,7 +119,7 @@ object AuthManager {
if
(
data
.
state
==
BaseService
.
State
.
Connected
)
{
data
.
proxy
?.
let
{
proxyInstance
->
val
refreshTokenResult
=
postSync
<
RefreshTokenRes
>(
"/api/acc/line/refresh"
,
"/api/acc/line/refresh"
,
authToken
,
RefreshTokenReq
(
proxyInstance
.
profile
.
token
?:
""
)
)
Timber
.
d
(
"refreshTokenResult: $refreshTokenResult"
)
...
...
@@ -151,13 +151,14 @@ object AuthManager {
inline
fun
<
reified
T
>
postSync
(
url
:
String
,
token
:
String
?,
params
:
Any
):
ApiResult
<
T
>
{
val
body
:
RequestBody
=
gson
.
toJson
(
params
).
toString
().
toRequestBody
(
jsonType
)
val
request
=
Request
.
Builder
()
.
url
(
HttpConfig
.
baseUrl
+
url
)
.
post
(
body
)
authT
oken
?.
let
{
t
oken
?.
let
{
request
.
addHeader
(
"Authorization"
,
it
)
}
Log
.
e
(
"postSync"
,
"===authToken:"
+
authToken
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment