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
Show 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 {
implementation
'androidx.constraintlayout:constraintlayout:1.1.3'
implementation
'com.google.android.gms:play-services-vision:17.0.2'
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.twofortyfouram:android-plugin-api-for-locale:1.0.4'
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
import
android.content.pm.PackageManager
import
android.graphics.drawable.Drawable
import
android.os.Bundle
import
android.util.SparseBooleanArray
import
android.view.*
import
android.widget.Filter
import
android.widget.Filterable
...
...
@@ -39,6 +40,7 @@ import android.widget.SearchView
import
androidx.annotation.UiThread
import
androidx.appcompat.app.AppCompatActivity
import
androidx.core.content.getSystemService
import
androidx.core.util.set
import
androidx.recyclerview.widget.DefaultItemAnimator
import
androidx.recyclerview.widget.LinearLayoutManager
import
androidx.recyclerview.widget.RecyclerView
...
...
@@ -48,8 +50,6 @@ import com.github.shadowsocks.preference.DataStore
import
com.github.shadowsocks.utils.DirectBoot
import
com.github.shadowsocks.utils.Key
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_item.view.*
import
kotlinx.coroutines.*
...
...
@@ -60,8 +60,8 @@ class AppManager : AppCompatActivity() {
private
var
instance
:
AppManager
?
=
null
private
var
receiver
:
BroadcastReceiver
?
=
null
private
var
cachedApps
:
List
<
PackageInfo
>?
=
null
private
suspend
fun
get
Apps
(
pm
:
PackageManager
)
=
synchronized
(
AppManager
)
{
private
var
cachedApps
:
Map
<
String
,
PackageInfo
>?
=
null
private
fun
getCached
Apps
(
pm
:
PackageManager
)
=
synchronized
(
AppManager
)
{
if
(
receiver
==
null
)
receiver
=
Core
.
listenForPackageChanges
{
synchronized
(
AppManager
)
{
receiver
=
null
...
...
@@ -75,14 +75,16 @@ class AppManager : AppCompatActivity() {
when
(
it
.
packageName
)
{
app
.
packageName
->
false
"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
cachedApps
}.
map
{
}
private
suspend
fun
getApps
(
pm
:
PackageManager
)
=
getCachedApps
(
pm
).
map
{
(
packageName
,
packageInfo
)
->
yield
()
ProxiedApp
(
pm
,
it
.
applicationInfo
,
it
.
packageName
)
ProxiedApp
(
pm
,
packageInfo
.
applicationInfo
,
packageName
)
}
}
...
...
@@ -113,14 +115,8 @@ class AppManager : AppCompatActivity() {
}
override
fun
onClick
(
v
:
View
?)
{
if
(
isProxiedApp
(
item
))
{
val
list
=
proxiedUidMap
.
removeAll
(
item
.
uid
)
proxiedApps
.
removeAll
(
list
)
}
else
{
proxiedApps
.
add
(
item
.
packageName
)
proxiedUidMap
.
put
(
item
.
uid
,
item
.
packageName
)
}
DataStore
.
individual
=
proxiedApps
.
joinToString
(
"\n"
)
if
(
isProxiedApp
(
item
))
proxiedUids
.
delete
(
item
.
uid
)
else
proxiedUids
[
item
.
uid
]
=
true
DataStore
.
individual
=
apps
.
filter
{
isProxiedApp
(
it
)
}.
joinToString
(
"\n"
)
{
it
.
packageName
}
DataStore
.
dirty
=
true
appsAdapter
.
notifyItemRangeChanged
(
0
,
appsAdapter
.
itemCount
,
"switch"
)
...
...
@@ -132,15 +128,6 @@ class AppManager : AppCompatActivity() {
suspend
fun
reload
()
{
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
()
}))
filteredApps
=
apps
}
...
...
@@ -183,12 +170,11 @@ class AppManager : AppCompatActivity() {
}
}
private
lateinit
var
proxiedApps
:
HashSet
<
String
>
private
lateinit
var
proxiedUidMap
:
Multimap
<
Int
,
String
>
private
val
proxiedUids
=
SparseBooleanArray
()
private
lateinit
var
appsAdapter
:
AppsAdapter
private
val
clipboard
by
lazy
{
getSystemService
<
ClipboardManager
>()
!!
}
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
fun
View
.
crossFadeFrom
(
other
:
View
)
{
...
...
@@ -205,11 +191,13 @@ class AppManager : AppCompatActivity() {
}).
duration
=
shortAnimTime
}
private
fun
initProxiedApps
(
str
:
String
=
DataStore
.
individual
)
{
proxiedApps
=
str
.
split
(
'\n'
).
toHashSet
()
private
fun
initProxiedUids
(
str
:
String
=
DataStore
.
individual
)
{
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
private
fun
loadApps
()
{
...
...
@@ -254,7 +242,7 @@ class AppManager : AppCompatActivity() {
}
}
initProxied
App
s
()
initProxied
Uid
s
()
list
.
layoutManager
=
LinearLayoutManager
(
this
,
RecyclerView
.
VERTICAL
,
false
)
list
.
itemAnimator
=
DefaultItemAnimator
()
appsAdapter
=
AppsAdapter
()
...
...
@@ -305,8 +293,8 @@ class AppManager : AppCompatActivity() {
DataStore
.
individual
=
apps
DataStore
.
dirty
=
true
Snackbar
.
make
(
list
,
R
.
string
.
action_import_msg
,
Snackbar
.
LENGTH_LONG
).
show
()
initProxied
App
s
(
apps
)
loadApps
()
initProxied
Uid
s
(
apps
)
appsAdapter
.
notifyDataSetChanged
()
return
true
}
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