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
26acea8e
Commit
26acea8e
authored
Mar 30, 2018
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix code style issues
parent
a7d77461
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
65 additions
and
51 deletions
+65
-51
detekt.yml
detekt.yml
+26
-16
mobile/src/main/java/com/github/shadowsocks/AppManager.kt
mobile/src/main/java/com/github/shadowsocks/AppManager.kt
+14
-16
mobile/src/main/java/com/github/shadowsocks/bg/BaseService.kt
...le/src/main/java/com/github/shadowsocks/bg/BaseService.kt
+12
-3
mobile/src/main/java/com/github/shadowsocks/plugin/PluginManager.kt
.../main/java/com/github/shadowsocks/plugin/PluginManager.kt
+11
-13
mobile/src/main/java/com/github/shadowsocks/preference/DataStore.kt
.../main/java/com/github/shadowsocks/preference/DataStore.kt
+0
-1
mobile/src/main/java/com/github/shadowsocks/tasker/Settings.kt
...e/src/main/java/com/github/shadowsocks/tasker/Settings.kt
+2
-2
No files found.
detekt.yml
View file @
26acea8e
# https://github.com/arturbosch/detekt/blob/
801994bd60cc759b181649356cea045b8125301b
/detekt-cli/src/main/resources/default-detekt-config.yml
# https://github.com/arturbosch/detekt/blob/
RC6-4
/detekt-cli/src/main/resources/default-detekt-config.yml
comments
:
comments
:
active
:
false
active
:
false
...
@@ -7,7 +7,7 @@ complexity:
...
@@ -7,7 +7,7 @@ complexity:
active
:
true
active
:
true
ComplexCondition
:
ComplexCondition
:
active
:
true
active
:
true
threshold
:
3
threshold
:
4
ComplexInterface
:
ComplexInterface
:
active
:
true
active
:
true
threshold
:
10
threshold
:
10
...
@@ -15,6 +15,7 @@ complexity:
...
@@ -15,6 +15,7 @@ complexity:
ComplexMethod
:
ComplexMethod
:
active
:
true
active
:
true
threshold
:
10
threshold
:
10
ignoreSingleWhenExpression
:
false
LabeledExpression
:
LabeledExpression
:
active
:
true
active
:
true
LargeClass
:
LargeClass
:
...
@@ -25,31 +26,32 @@ complexity:
...
@@ -25,31 +26,32 @@ complexity:
threshold
:
20
threshold
:
20
LongParameterList
:
LongParameterList
:
active
:
true
active
:
true
threshold
:
5
threshold
:
6
ignoreDefaultParameters
:
true
ignoreDefaultParameters
:
true
MethodOverloading
:
MethodOverloading
:
active
:
false
active
:
false
NestedBlockDepth
:
NestedBlockDepth
:
active
:
true
active
:
true
threshold
:
3
threshold
:
4
StringLiteralDuplication
:
StringLiteralDuplication
:
active
:
true
active
:
true
threshold
:
2
threshold
:
3
ignoreAnnotation
:
true
ignoreAnnotation
:
true
excludeStringsWithLessThan5Characters
:
true
excludeStringsWithLessThan5Characters
:
true
ignoreStringsRegex
:
'
$^'
ignoreStringsRegex
:
'
$^'
TooManyFunctions
:
TooManyFunctions
:
active
:
true
active
:
true
thresholdInFiles
:
1
0
thresholdInFiles
:
1
1
thresholdInClasses
:
1
0
thresholdInClasses
:
1
1
thresholdInInterfaces
:
1
0
thresholdInInterfaces
:
1
1
thresholdInObjects
:
1
0
thresholdInObjects
:
1
1
thresholdInEnums
:
1
0
thresholdInEnums
:
1
1
empty-blocks
:
empty-blocks
:
active
:
true
active
:
true
EmptyCatchBlock
:
EmptyCatchBlock
:
active
:
false
active
:
true
allowedExceptionNameRegex
:
"
^(_|ignore|expected).*"
EmptyClassBlock
:
EmptyClassBlock
:
active
:
true
active
:
true
EmptyDefaultConstructor
:
EmptyDefaultConstructor
:
...
@@ -64,6 +66,7 @@ empty-blocks:
...
@@ -64,6 +66,7 @@ empty-blocks:
active
:
true
active
:
true
EmptyFunctionBlock
:
EmptyFunctionBlock
:
active
:
true
active
:
true
ignoreOverriddenFunctions
:
false
EmptyIfBlock
:
EmptyIfBlock
:
active
:
true
active
:
true
EmptyInitBlock
:
EmptyInitBlock
:
...
@@ -105,7 +108,7 @@ exceptions:
...
@@ -105,7 +108,7 @@ exceptions:
active
:
true
active
:
true
TooGenericExceptionCaught
:
TooGenericExceptionCaught
:
active
:
true
active
:
true
exceptions
:
exception
Name
s
:
-
ArrayIndexOutOfBoundsException
-
ArrayIndexOutOfBoundsException
-
Error
-
Error
-
Exception
-
Exception
...
@@ -116,10 +119,9 @@ exceptions:
...
@@ -116,10 +119,9 @@ exceptions:
-
Throwable
-
Throwable
TooGenericExceptionThrown
:
TooGenericExceptionThrown
:
active
:
true
active
:
true
exceptions
:
exception
Name
s
:
-
Error
-
Error
-
Exception
-
Exception
-
NullPointerException
-
Throwable
-
Throwable
-
RuntimeException
-
RuntimeException
...
@@ -143,6 +145,7 @@ naming:
...
@@ -143,6 +145,7 @@ naming:
FunctionNaming
:
FunctionNaming
:
active
:
true
active
:
true
functionPattern
:
'
^([a-z$][a-zA-Z$0-9]*)|(`.*`)$'
functionPattern
:
'
^([a-z$][a-zA-Z$0-9]*)|(`.*`)$'
excludeClassPattern
:
'
$^'
MatchingDeclarationName
:
MatchingDeclarationName
:
active
:
true
active
:
true
MemberNameEqualsClassName
:
MemberNameEqualsClassName
:
...
@@ -167,6 +170,7 @@ naming:
...
@@ -167,6 +170,7 @@ naming:
active
:
true
active
:
true
variablePattern
:
'
[a-z][A-Za-z0-9]*'
variablePattern
:
'
[a-z][A-Za-z0-9]*'
privateVariablePattern
:
'
(_)?[a-z][A-Za-z0-9]*'
privateVariablePattern
:
'
(_)?[a-z][A-Za-z0-9]*'
excludeClassPattern
:
'
$^'
performance
:
performance
:
active
:
true
active
:
true
...
@@ -239,15 +243,17 @@ style:
...
@@ -239,15 +243,17 @@ style:
maxLineLength
:
120
maxLineLength
:
120
excludePackageStatements
:
false
excludePackageStatements
:
false
excludeImportStatements
:
false
excludeImportStatements
:
false
MayBeConst
:
active
:
true
ModifierOrder
:
ModifierOrder
:
active
:
true
active
:
true
NestedClassesVisibility
:
NestedClassesVisibility
:
active
:
true
active
:
true
NewLineAtEndOfFile
:
NewLineAtEndOfFile
:
active
:
true
active
:
true
OptionalAbstractKeyword
:
NoTabs
:
active
:
true
active
:
true
Optional
Return
Keyword
:
Optional
Abstract
Keyword
:
active
:
true
active
:
true
OptionalUnit
:
OptionalUnit
:
active
:
true
active
:
true
...
@@ -268,6 +274,8 @@ style:
...
@@ -268,6 +274,8 @@ style:
ThrowsCount
:
ThrowsCount
:
active
:
true
active
:
true
max
:
2
max
:
2
TrailingWhitespace
:
active
:
true
UnnecessaryAbstractClass
:
UnnecessaryAbstractClass
:
active
:
true
active
:
true
UnnecessaryInheritance
:
UnnecessaryInheritance
:
...
@@ -278,6 +286,8 @@ style:
...
@@ -278,6 +286,8 @@ style:
active
:
true
active
:
true
UnusedImports
:
UnusedImports
:
active
:
true
active
:
true
UnusedPrivateMember
:
active
:
true
UseDataClass
:
UseDataClass
:
active
:
false
active
:
false
UtilityClassWithPublicConstructor
:
UtilityClassWithPublicConstructor
:
...
...
mobile/src/main/java/com/github/shadowsocks/AppManager.kt
View file @
26acea8e
...
@@ -62,23 +62,21 @@ class AppManager : AppCompatActivity(), Toolbar.OnMenuItemClickListener {
...
@@ -62,23 +62,21 @@ class AppManager : AppCompatActivity(), Toolbar.OnMenuItemClickListener {
private
var
receiver
:
BroadcastReceiver
?
=
null
private
var
receiver
:
BroadcastReceiver
?
=
null
private
var
cachedApps
:
List
<
PackageInfo
>?
=
null
private
var
cachedApps
:
List
<
PackageInfo
>?
=
null
private
fun
getApps
(
pm
:
PackageManager
):
List
<
ProxiedApp
>
{
private
fun
getApps
(
pm
:
PackageManager
)
=
synchronized
(
AppManager
)
{
return
synchronized
(
AppManager
)
{
if
(
receiver
==
null
)
receiver
=
app
.
listenForPackageChanges
{
if
(
receiver
==
null
)
receiver
=
app
.
listenForPackageChanges
{
synchronized
(
AppManager
)
{
synchronized
(
AppManager
)
{
receiver
=
null
receiver
=
null
cachedApps
=
null
cachedApps
=
null
}
AppManager
.
instance
?.
reloadApps
()
}
}
// Labels and icons can change on configuration (locale, etc.) changes, therefore they are not cached.
AppManager
.
instance
?.
reloadApps
()
val
cachedApps
=
cachedApps
?:
pm
.
getInstalledPackages
(
PackageManager
.
GET_PERMISSIONS
)
}
.
filter
{
it
.
packageName
!=
app
.
packageName
&&
// Labels and icons can change on configuration (locale, etc.) changes, therefore they are not cached.
it
.
requestedPermissions
?.
contains
(
Manifest
.
permission
.
INTERNET
)
?:
false
}
val
cachedApps
=
cachedApps
?:
pm
.
getInstalledPackages
(
PackageManager
.
GET_PERMISSIONS
)
this
.
cachedApps
=
cachedApps
.
filter
{
it
.
packageName
!=
app
.
packageName
&&
cachedApps
it
.
requestedPermissions
?.
contains
(
Manifest
.
permission
.
INTERNET
)
?:
false
}
}.
map
{
ProxiedApp
(
pm
,
it
.
applicationInfo
,
it
.
packageName
)
}
this
.
cachedApps
=
cachedApps
}
cachedApps
}.
map
{
ProxiedApp
(
pm
,
it
.
applicationInfo
,
it
.
packageName
)
}
}
}
private
class
ProxiedApp
(
private
val
pm
:
PackageManager
,
private
val
appInfo
:
ApplicationInfo
,
private
class
ProxiedApp
(
private
val
pm
:
PackageManager
,
private
val
appInfo
:
ApplicationInfo
,
...
...
mobile/src/main/java/com/github/shadowsocks/bg/BaseService.kt
View file @
26acea8e
...
@@ -117,7 +117,10 @@ object BaseService {
...
@@ -117,7 +117,10 @@ object BaseService {
val
item
=
callbacks
.
getBroadcastItem
(
i
)
val
item
=
callbacks
.
getBroadcastItem
(
i
)
if
(
bandwidthListeners
.
contains
(
item
.
asBinder
()))
if
(
bandwidthListeners
.
contains
(
item
.
asBinder
()))
item
.
trafficUpdated
(
profile
!!
.
id
,
txRate
,
rxRate
,
txTotal
,
rxTotal
)
item
.
trafficUpdated
(
profile
!!
.
id
,
txRate
,
rxRate
,
txTotal
,
rxTotal
)
}
catch
(
_
:
Exception
)
{
}
// ignore
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
app
.
track
(
e
)
}
callbacks
.
finishBroadcast
()
callbacks
.
finishBroadcast
()
}
}
}
}
...
@@ -159,7 +162,10 @@ object BaseService {
...
@@ -159,7 +162,10 @@ object BaseService {
try
{
try
{
val
item
=
callbacks
.
getBroadcastItem
(
i
)
val
item
=
callbacks
.
getBroadcastItem
(
i
)
if
(
bandwidthListeners
.
contains
(
item
.
asBinder
()))
item
.
trafficPersisted
(
profile
.
id
)
if
(
bandwidthListeners
.
contains
(
item
.
asBinder
()))
item
.
trafficPersisted
(
profile
.
id
)
}
catch
(
_
:
Exception
)
{
}
// ignore
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
app
.
track
(
e
)
}
}
}
callbacks
.
finishBroadcast
()
callbacks
.
finishBroadcast
()
}
}
...
@@ -211,7 +217,10 @@ object BaseService {
...
@@ -211,7 +217,10 @@ object BaseService {
val
n
=
callbacks
.
beginBroadcast
()
val
n
=
callbacks
.
beginBroadcast
()
for
(
i
in
0
until
n
)
try
{
for
(
i
in
0
until
n
)
try
{
callbacks
.
getBroadcastItem
(
i
).
stateChanged
(
s
,
binder
.
profileName
,
msg
)
callbacks
.
getBroadcastItem
(
i
).
stateChanged
(
s
,
binder
.
profileName
,
msg
)
}
catch
(
_
:
Exception
)
{
}
// ignore
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
app
.
track
(
e
)
}
callbacks
.
finishBroadcast
()
callbacks
.
finishBroadcast
()
}
}
state
=
s
state
=
s
...
...
mobile/src/main/java/com/github/shadowsocks/plugin/PluginManager.kt
View file @
26acea8e
...
@@ -87,21 +87,19 @@ object PluginManager {
...
@@ -87,21 +87,19 @@ object PluginManager {
private
var
receiver
:
BroadcastReceiver
?
=
null
private
var
receiver
:
BroadcastReceiver
?
=
null
private
var
cachedPlugins
:
Map
<
String
,
Plugin
>?
=
null
private
var
cachedPlugins
:
Map
<
String
,
Plugin
>?
=
null
fun
fetchPlugins
():
Map
<
String
,
Plugin
>
{
fun
fetchPlugins
():
Map
<
String
,
Plugin
>
=
synchronized
(
this
)
{
return
synchronized
(
this
)
{
if
(
receiver
==
null
)
receiver
=
app
.
listenForPackageChanges
{
if
(
receiver
==
null
)
receiver
=
app
.
listenForPackageChanges
{
synchronized
(
this
)
{
synchronized
(
this
)
{
receiver
=
null
receiver
=
null
cachedPlugins
=
null
cachedPlugins
=
null
}
}
if
(
cachedPlugins
==
null
)
{
val
pm
=
app
.
packageManager
cachedPlugins
=
(
pm
.
queryIntentContentProviders
(
Intent
(
PluginContract
.
ACTION_NATIVE_PLUGIN
),
PackageManager
.
GET_META_DATA
).
map
{
NativePlugin
(
it
)
}
+
NoPlugin
).
associate
{
it
.
id
to
it
}
}
}
cachedPlugins
!!
}
}
if
(
cachedPlugins
==
null
)
{
val
pm
=
app
.
packageManager
cachedPlugins
=
(
pm
.
queryIntentContentProviders
(
Intent
(
PluginContract
.
ACTION_NATIVE_PLUGIN
),
PackageManager
.
GET_META_DATA
).
map
{
NativePlugin
(
it
)
}
+
NoPlugin
).
associate
{
it
.
id
to
it
}
}
cachedPlugins
!!
}
}
private
fun
buildUri
(
id
:
String
)
=
Uri
.
Builder
()
private
fun
buildUri
(
id
:
String
)
=
Uri
.
Builder
()
...
...
mobile/src/main/java/com/github/shadowsocks/preference/DataStore.kt
View file @
26acea8e
...
@@ -22,7 +22,6 @@ package com.github.shadowsocks.preference
...
@@ -22,7 +22,6 @@ package com.github.shadowsocks.preference
import
android.os.Binder
import
android.os.Binder
import
com.github.shadowsocks.App.Companion.app
import
com.github.shadowsocks.App.Companion.app
import
com.github.shadowsocks.BootReceiver
import
com.github.shadowsocks.database.PrivateDatabase
import
com.github.shadowsocks.database.PrivateDatabase
import
com.github.shadowsocks.database.PublicDatabase
import
com.github.shadowsocks.database.PublicDatabase
import
com.github.shadowsocks.utils.DirectBoot
import
com.github.shadowsocks.utils.DirectBoot
...
...
mobile/src/main/java/com/github/shadowsocks/tasker/Settings.kt
View file @
26acea8e
...
@@ -29,8 +29,8 @@ import com.twofortyfouram.locale.api.Intent as ApiIntent
...
@@ -29,8 +29,8 @@ import com.twofortyfouram.locale.api.Intent as ApiIntent
class
Settings
(
bundle
:
Bundle
?)
{
class
Settings
(
bundle
:
Bundle
?)
{
companion
object
{
companion
object
{
private
val
KEY_SWITCH_ON
=
"switch_on"
private
const
val
KEY_SWITCH_ON
=
"switch_on"
private
val
KEY_PROFILE_ID
=
"profile_id"
private
const
val
KEY_PROFILE_ID
=
"profile_id"
fun
fromIntent
(
intent
:
Intent
)
=
Settings
(
intent
.
getBundleExtra
(
ApiIntent
.
EXTRA_BUNDLE
))
fun
fromIntent
(
intent
:
Intent
)
=
Settings
(
intent
.
getBundleExtra
(
ApiIntent
.
EXTRA_BUNDLE
))
}
}
...
...
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