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
70457b42
Commit
70457b42
authored
Jun 11, 2020
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix unchecked cast
parent
072a11d2
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
19 additions
and
15 deletions
+19
-15
core/src/main/java/com/github/shadowsocks/Core.kt
core/src/main/java/com/github/shadowsocks/Core.kt
+1
-1
core/src/main/java/com/github/shadowsocks/UrlImportActivity.kt
...src/main/java/com/github/shadowsocks/UrlImportActivity.kt
+1
-1
core/src/main/java/com/github/shadowsocks/bg/BaseService.kt
core/src/main/java/com/github/shadowsocks/bg/BaseService.kt
+3
-3
core/src/main/java/com/github/shadowsocks/bg/TrafficMonitor.kt
...src/main/java/com/github/shadowsocks/bg/TrafficMonitor.kt
+1
-1
core/src/main/java/com/github/shadowsocks/database/ProfileManager.kt
...in/java/com/github/shadowsocks/database/ProfileManager.kt
+6
-2
core/src/main/java/com/github/shadowsocks/utils/DirectBoot.kt
.../src/main/java/com/github/shadowsocks/utils/DirectBoot.kt
+2
-2
mobile/src/main/java/com/github/shadowsocks/ProfilesFragment.kt
.../src/main/java/com/github/shadowsocks/ProfilesFragment.kt
+2
-2
mobile/src/main/java/com/github/shadowsocks/ScannerActivity.kt
...e/src/main/java/com/github/shadowsocks/ScannerActivity.kt
+2
-2
mobile/src/main/java/com/github/shadowsocks/acl/CustomRulesFragment.kt
...in/java/com/github/shadowsocks/acl/CustomRulesFragment.kt
+1
-1
No files found.
core/src/main/java/com/github/shadowsocks/Core.kt
View file @
70457b42
...
...
@@ -80,7 +80,7 @@ object Core {
val
activeProfileIds
get
()
=
ProfileManager
.
getProfile
(
DataStore
.
profileId
).
let
{
if
(
it
==
null
)
emptyList
()
else
listOfNotNull
(
it
.
id
,
it
.
udpFallback
)
}
val
currentProfile
:
P
air
<
Profile
,
Profile
?
>
?
get
()
{
val
currentProfile
:
P
rofileManager
.
ExpandedProfile
?
get
()
{
if
(
DataStore
.
directBootAware
)
DirectBoot
.
getDeviceProfile
()
?.
apply
{
return
this
}
return
ProfileManager
.
expand
(
ProfileManager
.
getProfile
(
DataStore
.
profileId
)
?:
return
null
)
}
...
...
core/src/main/java/com/github/shadowsocks/UrlImportActivity.kt
View file @
70457b42
...
...
@@ -67,7 +67,7 @@ class UrlImportActivity : AppCompatActivity() {
}
private
fun
handleShareIntent
()
=
intent
.
data
?.
toString
()
?.
let
{
sharedStr
->
val
profiles
=
Profile
.
findAllUrls
(
sharedStr
,
Core
.
currentProfile
?.
first
).
toList
()
val
profiles
=
Profile
.
findAllUrls
(
sharedStr
,
Core
.
currentProfile
?.
main
).
toList
()
if
(
profiles
.
isEmpty
())
null
else
ImportProfilesDialogFragment
().
withArg
(
ProfilesArg
(
profiles
))
}
}
core/src/main/java/com/github/shadowsocks/bg/BaseService.kt
View file @
70457b42
...
...
@@ -321,15 +321,15 @@ object BaseService {
fun
onStartCommand
(
intent
:
Intent
?,
flags
:
Int
,
startId
:
Int
):
Int
{
val
data
=
data
if
(
data
.
state
!=
State
.
Stopped
)
return
Service
.
START_NOT_STICKY
val
profilePair
=
Core
.
currentProfile
val
expanded
=
Core
.
currentProfile
this
as
Context
if
(
profilePair
==
null
)
{
if
(
expanded
==
null
)
{
// gracefully shutdown: https://stackoverflow.com/q/47337857/2245107
data
.
notification
=
createNotification
(
""
)
stopRunner
(
false
,
getString
(
R
.
string
.
profile_empty
))
return
Service
.
START_NOT_STICKY
}
val
(
profile
,
fallback
)
=
profilePair
val
(
profile
,
fallback
)
=
expanded
profile
.
name
=
profile
.
formattedName
// save name for later queries
val
proxy
=
ProxyInstance
(
profile
)
data
.
proxy
=
proxy
...
...
core/src/main/java/com/github/shadowsocks/bg/TrafficMonitor.kt
View file @
70457b42
...
...
@@ -96,7 +96,7 @@ class TrafficMonitor(statFile: File) {
ProfileManager
.
updateProfile
(
profile
)
}
catch
(
e
:
IOException
)
{
if
(!
DataStore
.
directBootAware
)
throw
e
// we should only reach here because we're in direct boot
val
profile
=
DirectBoot
.
getDeviceProfile
()
!!
.
toList
().
filterNotNull
().
single
{
it
.
id
==
id
}
val
profile
=
DirectBoot
.
getDeviceProfile
()
!!
.
toList
().
single
{
it
.
id
==
id
}
profile
.
tx
+=
current
.
txTotal
profile
.
rx
+=
current
.
rxTotal
profile
.
dirty
=
true
...
...
core/src/main/java/com/github/shadowsocks/database/ProfileManager.kt
View file @
70457b42
...
...
@@ -46,6 +46,10 @@ object ProfileManager {
}
var
listener
:
Listener
?
=
null
data class
ExpandedProfile
(
val
main
:
Profile
,
val
udpFallback
:
Profile
?)
{
fun
toList
()
=
listOfNotNull
(
main
,
udpFallback
)
}
@Throws
(
SQLException
::
class
)
fun
createProfile
(
profile
:
Profile
=
Profile
()):
Profile
{
profile
.
id
=
0
...
...
@@ -59,7 +63,7 @@ object ProfileManager {
val
profiles
=
if
(
replace
)
getAllProfiles
()
?.
associateBy
{
it
.
formattedAddress
}
else
null
val
feature
=
if
(
replace
)
{
profiles
?.
values
?.
singleOrNull
{
it
.
id
==
DataStore
.
profileId
}
}
else
Core
.
currentProfile
?.
first
}
else
Core
.
currentProfile
?.
main
val
lazyClear
=
lazy
{
clear
()
}
jsons
.
asIterable
().
forEachTry
{
json
->
Profile
.
parseJson
(
JsonStreamParser
(
json
.
bufferedReader
()).
asSequence
().
single
(),
feature
)
{
...
...
@@ -99,7 +103,7 @@ object ProfileManager {
}
@Throws
(
IOException
::
class
)
fun
expand
(
profile
:
Profile
)
:
Pair
<
Profile
,
Profile
?
>
=
Pair
(
profile
,
profile
.
udpFallback
?.
let
{
getProfile
(
it
)
})
fun
expand
(
profile
:
Profile
)
=
ExpandedProfile
(
profile
,
profile
.
udpFallback
?.
let
{
getProfile
(
it
)
})
@Throws
(
SQLException
::
class
)
fun
delProfile
(
id
:
Long
)
{
...
...
core/src/main/java/com/github/shadowsocks/utils/DirectBoot.kt
View file @
70457b42
...
...
@@ -21,8 +21,8 @@ object DirectBoot : BroadcastReceiver() {
private
val
file
=
File
(
Core
.
deviceStorage
.
noBackupFilesDir
,
"directBootProfile"
)
private
var
registered
=
false
fun
getDeviceProfile
():
P
air
<
Profile
,
Profile
?
>
?
=
try
{
ObjectInputStream
(
file
.
inputStream
()).
use
{
it
.
readObject
()
as
?
P
air
<
Profile
,
Profile
?
>
}
fun
getDeviceProfile
():
P
rofileManager
.
ExpandedProfile
?
=
try
{
ObjectInputStream
(
file
.
inputStream
()).
use
{
it
.
readObject
()
as
?
P
rofileManager
.
ExpandedProfile
}
}
catch
(
_
:
IOException
)
{
null
}
fun
clean
()
{
...
...
mobile/src/main/java/com/github/shadowsocks/ProfilesFragment.kt
View file @
70457b42
...
...
@@ -502,7 +502,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
try
{
val
profiles
=
Profile
.
findAllUrls
(
Core
.
clipboard
.
primaryClip
!!
.
getItemAt
(
0
).
text
,
Core
.
currentProfile
?.
first
Core
.
currentProfile
?.
main
).
toList
()
if
(
profiles
.
isNotEmpty
())
{
profiles
.
forEach
{
ProfileManager
.
createProfile
(
it
)
}
...
...
@@ -533,7 +533,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
}
R
.
id
.
action_manual_settings
->
{
startConfig
(
ProfileManager
.
createProfile
(
Profile
().
also
{
Core
.
currentProfile
?.
first
?.
copyFeatureSettingsTo
(
it
)
}))
Profile
().
also
{
Core
.
currentProfile
?.
main
?.
copyFeatureSettingsTo
(
it
)
}))
true
}
R
.
id
.
action_export_clipboard
->
{
...
...
mobile/src/main/java/com/github/shadowsocks/ScannerActivity.kt
View file @
70457b42
...
...
@@ -105,7 +105,7 @@ class ScannerActivity : AppCompatActivity(), BarcodeRetriever {
}
override
fun
onRetrieved
(
barcode
:
Barcode
)
=
runOnUiThread
{
Profile
.
findAllUrls
(
barcode
.
rawValue
,
Core
.
currentProfile
?.
first
).
forEach
{
ProfileManager
.
createProfile
(
it
)
}
Profile
.
findAllUrls
(
barcode
.
rawValue
,
Core
.
currentProfile
?.
main
).
forEach
{
ProfileManager
.
createProfile
(
it
)
}
onSupportNavigateUp
()
}
override
fun
onRetrievedMultiple
(
closetToClick
:
Barcode
?,
barcode
:
MutableList
<
BarcodeGraphic
>?)
=
check
(
false
)
...
...
@@ -141,7 +141,7 @@ class ScannerActivity : AppCompatActivity(), BarcodeRetriever {
override
fun
onActivityResult
(
requestCode
:
Int
,
resultCode
:
Int
,
data
:
Intent
?)
{
when
(
requestCode
)
{
REQUEST_IMPORT
,
REQUEST_IMPORT_OR_FINISH
->
if
(
resultCode
==
Activity
.
RESULT_OK
)
{
val
feature
=
Core
.
currentProfile
?.
first
val
feature
=
Core
.
currentProfile
?.
main
try
{
var
success
=
false
data
!!
.
datas
.
forEachTry
{
uri
->
...
...
mobile/src/main/java/com/github/shadowsocks/acl/CustomRulesFragment.kt
View file @
70457b42
...
...
@@ -362,7 +362,7 @@ class CustomRulesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener,
}
private
val
isEnabled
get
()
=
(
activity
as
?
MainActivity
)
?.
state
==
BaseService
.
State
.
Stopped
||
Core
.
currentProfile
?.
first
?.
route
!=
Acl
.
CUSTOM_RULES
Core
.
currentProfile
?.
main
?.
route
!=
Acl
.
CUSTOM_RULES
private
val
selectedItems
=
HashSet
<
Any
>()
private
val
adapter
by
lazy
{
AclRulesAdapter
()
}
...
...
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