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
9c1da29b
Commit
9c1da29b
authored
Mar 08, 2019
by
Mygod
Committed by
Max Lv
Mar 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix importing
parent
8298f891
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
34 deletions
+21
-34
mobile/build.gradle
mobile/build.gradle
+0
-1
mobile/src/main/java/com/github/shadowsocks/AppManager.kt
mobile/src/main/java/com/github/shadowsocks/AppManager.kt
+21
-33
No files found.
mobile/build.gradle
View file @
9c1da29b
...
@@ -60,7 +60,6 @@ dependencies {
...
@@ -60,7 +60,6 @@ dependencies {
implementation
'androidx.constraintlayout:constraintlayout:1.1.3'
implementation
'androidx.constraintlayout:constraintlayout:1.1.3'
implementation
'com.google.android.gms:play-services-vision:17.0.2'
implementation
'com.google.android.gms:play-services-vision:17.0.2'
implementation
'com.google.firebase:firebase-ads:17.1.3'
implementation
'com.google.firebase:firebase-ads:17.1.3'
implementation
'com.google.guava:guava:27.0.1-android'
implementation
"com.takisoft.preferencex:preferencex-simplemenu:$preferencexVersion"
implementation
"com.takisoft.preferencex:preferencex-simplemenu:$preferencexVersion"
implementation
'com.twofortyfouram:android-plugin-api-for-locale:1.0.4'
implementation
'com.twofortyfouram:android-plugin-api-for-locale:1.0.4'
implementation
'net.glxn.qrgen:android:2.0'
implementation
'net.glxn.qrgen:android:2.0'
...
...
mobile/src/main/java/com/github/shadowsocks/AppManager.kt
View file @
9c1da29b
...
@@ -32,6 +32,7 @@ import android.content.pm.PackageInfo
...
@@ -32,6 +32,7 @@ import android.content.pm.PackageInfo
import
android.content.pm.PackageManager
import
android.content.pm.PackageManager
import
android.graphics.drawable.Drawable
import
android.graphics.drawable.Drawable
import
android.os.Bundle
import
android.os.Bundle
import
android.util.SparseBooleanArray
import
android.view.*
import
android.view.*
import
android.widget.Filter
import
android.widget.Filter
import
android.widget.Filterable
import
android.widget.Filterable
...
@@ -39,6 +40,7 @@ import android.widget.SearchView
...
@@ -39,6 +40,7 @@ import android.widget.SearchView
import
androidx.annotation.UiThread
import
androidx.annotation.UiThread
import
androidx.appcompat.app.AppCompatActivity
import
androidx.appcompat.app.AppCompatActivity
import
androidx.core.content.getSystemService
import
androidx.core.content.getSystemService
import
androidx.core.util.set
import
androidx.recyclerview.widget.DefaultItemAnimator
import
androidx.recyclerview.widget.DefaultItemAnimator
import
androidx.recyclerview.widget.LinearLayoutManager
import
androidx.recyclerview.widget.LinearLayoutManager
import
androidx.recyclerview.widget.RecyclerView
import
androidx.recyclerview.widget.RecyclerView
...
@@ -48,8 +50,6 @@ import com.github.shadowsocks.preference.DataStore
...
@@ -48,8 +50,6 @@ import com.github.shadowsocks.preference.DataStore
import
com.github.shadowsocks.utils.DirectBoot
import
com.github.shadowsocks.utils.DirectBoot
import
com.github.shadowsocks.utils.Key
import
com.github.shadowsocks.utils.Key
import
com.google.android.material.snackbar.Snackbar
import
com.google.android.material.snackbar.Snackbar
import
com.google.common.collect.Multimap
import
com.google.common.collect.MultimapBuilder
import
kotlinx.android.synthetic.main.layout_apps.*
import
kotlinx.android.synthetic.main.layout_apps.*
import
kotlinx.android.synthetic.main.layout_apps_item.view.*
import
kotlinx.android.synthetic.main.layout_apps_item.view.*
import
kotlinx.coroutines.*
import
kotlinx.coroutines.*
...
@@ -60,8 +60,8 @@ class AppManager : AppCompatActivity() {
...
@@ -60,8 +60,8 @@ class AppManager : AppCompatActivity() {
private
var
instance
:
AppManager
?
=
null
private
var
instance
:
AppManager
?
=
null
private
var
receiver
:
BroadcastReceiver
?
=
null
private
var
receiver
:
BroadcastReceiver
?
=
null
private
var
cachedApps
:
List
<
PackageInfo
>?
=
null
private
var
cachedApps
:
Map
<
String
,
PackageInfo
>?
=
null
private
suspend
fun
get
Apps
(
pm
:
PackageManager
)
=
synchronized
(
AppManager
)
{
private
fun
getCached
Apps
(
pm
:
PackageManager
)
=
synchronized
(
AppManager
)
{
if
(
receiver
==
null
)
receiver
=
Core
.
listenForPackageChanges
{
if
(
receiver
==
null
)
receiver
=
Core
.
listenForPackageChanges
{
synchronized
(
AppManager
)
{
synchronized
(
AppManager
)
{
receiver
=
null
receiver
=
null
...
@@ -75,14 +75,16 @@ class AppManager : AppCompatActivity() {
...
@@ -75,14 +75,16 @@ class AppManager : AppCompatActivity() {
when
(
it
.
packageName
)
{
when
(
it
.
packageName
)
{
app
.
packageName
->
false
app
.
packageName
->
false
"android"
->
true
"android"
->
true
else
->
it
.
requestedPermissions
?.
contains
(
Manifest
.
permission
.
INTERNET
)
?:
fals
e
else
->
it
.
requestedPermissions
?.
contains
(
Manifest
.
permission
.
INTERNET
)
==
tru
e
}
}
}
}
.
associateBy
{
it
.
packageName
}
this
.
cachedApps
=
cachedApps
this
.
cachedApps
=
cachedApps
cachedApps
cachedApps
}.
map
{
}
private
suspend
fun
getApps
(
pm
:
PackageManager
)
=
getCachedApps
(
pm
).
map
{
(
packageName
,
packageInfo
)
->
yield
()
yield
()
ProxiedApp
(
pm
,
it
.
applicationInfo
,
it
.
packageName
)
ProxiedApp
(
pm
,
packageInfo
.
applicationInfo
,
packageName
)
}
}
}
}
...
@@ -113,14 +115,8 @@ class AppManager : AppCompatActivity() {
...
@@ -113,14 +115,8 @@ class AppManager : AppCompatActivity() {
}
}
override
fun
onClick
(
v
:
View
?)
{
override
fun
onClick
(
v
:
View
?)
{
if
(
isProxiedApp
(
item
))
{
if
(
isProxiedApp
(
item
))
proxiedUids
.
delete
(
item
.
uid
)
else
proxiedUids
[
item
.
uid
]
=
true
val
list
=
proxiedUidMap
.
removeAll
(
item
.
uid
)
DataStore
.
individual
=
apps
.
filter
{
isProxiedApp
(
it
)
}.
joinToString
(
"\n"
)
{
it
.
packageName
}
proxiedApps
.
removeAll
(
list
)
}
else
{
proxiedApps
.
add
(
item
.
packageName
)
proxiedUidMap
.
put
(
item
.
uid
,
item
.
packageName
)
}
DataStore
.
individual
=
proxiedApps
.
joinToString
(
"\n"
)
DataStore
.
dirty
=
true
DataStore
.
dirty
=
true
appsAdapter
.
notifyItemRangeChanged
(
0
,
appsAdapter
.
itemCount
,
"switch"
)
appsAdapter
.
notifyItemRangeChanged
(
0
,
appsAdapter
.
itemCount
,
"switch"
)
...
@@ -132,15 +128,6 @@ class AppManager : AppCompatActivity() {
...
@@ -132,15 +128,6 @@ class AppManager : AppCompatActivity() {
suspend
fun
reload
()
{
suspend
fun
reload
()
{
val
list
=
getApps
(
packageManager
)
val
list
=
getApps
(
packageManager
)
val
map
=
MultimapBuilder
.
treeKeys
().
arrayListValues
().
build
<
Int
,
String
>()
list
.
filter
{
app
->
app
.
packageName
in
proxiedApps
}.
forEach
{
app
->
map
.
put
(
app
.
uid
,
app
.
packageName
)
}
proxiedUidMap
=
map
apps
=
list
.
sortedWith
(
compareBy
({
!
isProxiedApp
(
it
)
},
{
it
.
name
.
toString
()
}))
apps
=
list
.
sortedWith
(
compareBy
({
!
isProxiedApp
(
it
)
},
{
it
.
name
.
toString
()
}))
filteredApps
=
apps
filteredApps
=
apps
}
}
...
@@ -183,12 +170,11 @@ class AppManager : AppCompatActivity() {
...
@@ -183,12 +170,11 @@ class AppManager : AppCompatActivity() {
}
}
}
}
private
lateinit
var
proxiedApps
:
HashSet
<
String
>
private
val
proxiedUids
=
SparseBooleanArray
()
private
lateinit
var
proxiedUidMap
:
Multimap
<
Int
,
String
>
private
lateinit
var
appsAdapter
:
AppsAdapter
private
lateinit
var
appsAdapter
:
AppsAdapter
private
val
clipboard
by
lazy
{
getSystemService
<
ClipboardManager
>()
!!
}
private
val
clipboard
by
lazy
{
getSystemService
<
ClipboardManager
>()
!!
}
private
var
loader
:
Job
?
=
null
private
var
loader
:
Job
?
=
null
private
var
apps
=
listOf
<
ProxiedApp
>()
private
var
apps
=
emptyList
<
ProxiedApp
>()
private
val
shortAnimTime
by
lazy
{
resources
.
getInteger
(
android
.
R
.
integer
.
config_shortAnimTime
).
toLong
()
}
private
val
shortAnimTime
by
lazy
{
resources
.
getInteger
(
android
.
R
.
integer
.
config_shortAnimTime
).
toLong
()
}
private
fun
View
.
crossFadeFrom
(
other
:
View
)
{
private
fun
View
.
crossFadeFrom
(
other
:
View
)
{
...
@@ -205,11 +191,13 @@ class AppManager : AppCompatActivity() {
...
@@ -205,11 +191,13 @@ class AppManager : AppCompatActivity() {
}).
duration
=
shortAnimTime
}).
duration
=
shortAnimTime
}
}
private
fun
initProxiedApps
(
str
:
String
=
DataStore
.
individual
)
{
private
fun
initProxiedUids
(
str
:
String
=
DataStore
.
individual
)
{
proxiedApps
=
str
.
split
(
'\n'
).
toHashSet
()
proxiedUids
.
clear
()
val
apps
=
getCachedApps
(
packageManager
)
for
(
line
in
str
.
lineSequence
())
proxiedUids
[(
apps
[
line
]
?:
continue
).
applicationInfo
.
uid
]
=
true
}
}
private
fun
isProxiedApp
(
app
:
ProxiedApp
)
=
proxiedUid
Map
.
containsKey
(
app
.
uid
)
private
fun
isProxiedApp
(
app
:
ProxiedApp
)
=
proxiedUid
s
[
app
.
uid
]
@UiThread
@UiThread
private
fun
loadApps
()
{
private
fun
loadApps
()
{
...
@@ -254,7 +242,7 @@ class AppManager : AppCompatActivity() {
...
@@ -254,7 +242,7 @@ class AppManager : AppCompatActivity() {
}
}
}
}
initProxied
App
s
()
initProxied
Uid
s
()
list
.
layoutManager
=
LinearLayoutManager
(
this
,
RecyclerView
.
VERTICAL
,
false
)
list
.
layoutManager
=
LinearLayoutManager
(
this
,
RecyclerView
.
VERTICAL
,
false
)
list
.
itemAnimator
=
DefaultItemAnimator
()
list
.
itemAnimator
=
DefaultItemAnimator
()
appsAdapter
=
AppsAdapter
()
appsAdapter
=
AppsAdapter
()
...
@@ -305,8 +293,8 @@ class AppManager : AppCompatActivity() {
...
@@ -305,8 +293,8 @@ class AppManager : AppCompatActivity() {
DataStore
.
individual
=
apps
DataStore
.
individual
=
apps
DataStore
.
dirty
=
true
DataStore
.
dirty
=
true
Snackbar
.
make
(
list
,
R
.
string
.
action_import_msg
,
Snackbar
.
LENGTH_LONG
).
show
()
Snackbar
.
make
(
list
,
R
.
string
.
action_import_msg
,
Snackbar
.
LENGTH_LONG
).
show
()
initProxied
App
s
(
apps
)
initProxied
Uid
s
(
apps
)
loadApps
()
appsAdapter
.
notifyDataSetChanged
()
return
true
return
true
}
catch
(
_
:
IllegalArgumentException
)
{
}
}
catch
(
_
:
IllegalArgumentException
)
{
}
}
}
...
...
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