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
30a53c08
Commit
30a53c08
authored
Jul 21, 2018
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix direct boot with Crashlytics
parent
f053a62f
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
27 additions
and
21 deletions
+27
-21
mobile/src/main/java/com/github/shadowsocks/App.kt
mobile/src/main/java/com/github/shadowsocks/App.kt
+7
-7
mobile/src/main/java/com/github/shadowsocks/acl/Acl.kt
mobile/src/main/java/com/github/shadowsocks/acl/Acl.kt
+1
-1
mobile/src/main/java/com/github/shadowsocks/bg/BaseService.kt
...le/src/main/java/com/github/shadowsocks/bg/BaseService.kt
+1
-1
mobile/src/main/java/com/github/shadowsocks/bg/GuardedProcessPool.kt
...main/java/com/github/shadowsocks/bg/GuardedProcessPool.kt
+1
-1
mobile/src/main/java/com/github/shadowsocks/bg/LocalDnsService.kt
...rc/main/java/com/github/shadowsocks/bg/LocalDnsService.kt
+1
-1
mobile/src/main/java/com/github/shadowsocks/bg/TrafficMonitorThread.kt
...in/java/com/github/shadowsocks/bg/TrafficMonitorThread.kt
+1
-1
mobile/src/main/java/com/github/shadowsocks/bg/TransproxyService.kt
.../main/java/com/github/shadowsocks/bg/TransproxyService.kt
+1
-1
mobile/src/main/java/com/github/shadowsocks/bg/VpnService.kt
mobile/src/main/java/com/github/shadowsocks/bg/VpnService.kt
+2
-2
mobile/src/main/java/com/github/shadowsocks/database/PublicDatabase.kt
...in/java/com/github/shadowsocks/database/PublicDatabase.kt
+1
-1
mobile/src/main/java/com/github/shadowsocks/plugin/PluginManager.kt
.../main/java/com/github/shadowsocks/plugin/PluginManager.kt
+1
-1
mobile/src/main/java/com/github/shadowsocks/utils/DeviceStorageApp.kt
...ain/java/com/github/shadowsocks/utils/DeviceStorageApp.kt
+8
-2
mobile/src/main/java/com/github/shadowsocks/utils/DirectBoot.kt
.../src/main/java/com/github/shadowsocks/utils/DirectBoot.kt
+2
-2
No files found.
mobile/src/main/java/com/github/shadowsocks/App.kt
View file @
30a53c08
...
@@ -64,9 +64,9 @@ class App : Application() {
...
@@ -64,9 +64,9 @@ class App : Application() {
}
}
val
handler
by
lazy
{
Handler
(
Looper
.
getMainLooper
())
}
val
handler
by
lazy
{
Handler
(
Looper
.
getMainLooper
())
}
val
device
Context
:
Context
by
lazy
{
if
(
Build
.
VERSION
.
SDK_INT
<
24
)
this
else
DeviceContext
(
this
)
}
val
device
Storage
by
lazy
{
if
(
Build
.
VERSION
.
SDK_INT
<
24
)
this
else
DeviceStorageApp
(
this
)
}
val
remoteConfig
:
FirebaseRemoteConfig
by
lazy
{
FirebaseRemoteConfig
.
getInstance
()
}
val
remoteConfig
:
FirebaseRemoteConfig
by
lazy
{
FirebaseRemoteConfig
.
getInstance
()
}
val
analytics
:
FirebaseAnalytics
by
lazy
{
FirebaseAnalytics
.
getInstance
(
device
Context
)
}
val
analytics
:
FirebaseAnalytics
by
lazy
{
FirebaseAnalytics
.
getInstance
(
device
Storage
)
}
val
info
:
PackageInfo
by
lazy
{
getPackageInfo
(
packageName
)
}
val
info
:
PackageInfo
by
lazy
{
getPackageInfo
(
packageName
)
}
val
directBootSupported
by
lazy
{
val
directBootSupported
by
lazy
{
Build
.
VERSION
.
SDK_INT
>=
24
&&
getSystemService
<
DevicePolicyManager
>()
?.
storageEncryptionStatus
==
Build
.
VERSION
.
SDK_INT
>=
24
&&
getSystemService
<
DevicePolicyManager
>()
?.
storageEncryptionStatus
==
...
@@ -96,13 +96,12 @@ class App : Application() {
...
@@ -96,13 +96,12 @@ class App : Application() {
override
fun
onCreate
()
{
override
fun
onCreate
()
{
super
.
onCreate
()
super
.
onCreate
()
app
=
this
app
=
this
Fabric
.
with
(
this
,
Crashlytics
())
// multiple processes needs manual set-up
AppCompatDelegate
.
setCompatVectorFromResourcesEnabled
(
true
)
AppCompatDelegate
.
setCompatVectorFromResourcesEnabled
(
true
)
PreferenceFragmentCompat
.
registerPreferenceFragment
(
IconListPreference
::
class
.
java
,
PreferenceFragmentCompat
.
registerPreferenceFragment
(
IconListPreference
::
class
.
java
,
BottomSheetPreferenceDialogFragment
::
class
.
java
)
BottomSheetPreferenceDialogFragment
::
class
.
java
)
if
(
Build
.
VERSION
.
SDK_INT
>=
24
)
{
// migrate old files
if
(
Build
.
VERSION
.
SDK_INT
>=
24
)
{
// migrate old files
device
Context
.
moveDatabaseFrom
(
this
,
Key
.
DB_PUBLIC
)
device
Storage
.
moveDatabaseFrom
(
this
,
Key
.
DB_PUBLIC
)
val
old
=
Acl
.
getFile
(
Acl
.
CUSTOM_RULES
,
this
)
val
old
=
Acl
.
getFile
(
Acl
.
CUSTOM_RULES
,
this
)
if
(
old
.
canRead
())
{
if
(
old
.
canRead
())
{
Acl
.
getFile
(
Acl
.
CUSTOM_RULES
).
writeText
(
old
.
readText
())
Acl
.
getFile
(
Acl
.
CUSTOM_RULES
).
writeText
(
old
.
readText
())
...
@@ -110,7 +109,8 @@ class App : Application() {
...
@@ -110,7 +109,8 @@ class App : Application() {
}
}
}
}
FirebaseApp
.
initializeApp
(
deviceContext
)
Fabric
.
with
(
deviceStorage
,
Crashlytics
())
// multiple processes needs manual set-up
FirebaseApp
.
initializeApp
(
deviceStorage
)
remoteConfig
.
setDefaults
(
R
.
xml
.
default_configs
)
remoteConfig
.
setDefaults
(
R
.
xml
.
default_configs
)
remoteConfig
.
fetch
().
addOnCompleteListener
{
remoteConfig
.
fetch
().
addOnCompleteListener
{
if
(
it
.
isSuccessful
)
remoteConfig
.
activateFetched
()
else
{
if
(
it
.
isSuccessful
)
remoteConfig
.
activateFetched
()
else
{
...
@@ -118,7 +118,7 @@ class App : Application() {
...
@@ -118,7 +118,7 @@ class App : Application() {
Crashlytics
.
logException
(
it
.
exception
)
Crashlytics
.
logException
(
it
.
exception
)
}
}
}
}
WorkManager
.
initialize
(
device
Context
,
androidx
.
work
.
Configuration
.
Builder
().
build
())
WorkManager
.
initialize
(
device
Storage
,
androidx
.
work
.
Configuration
.
Builder
().
build
())
// handle data restored/crash
// handle data restored/crash
if
(
Build
.
VERSION
.
SDK_INT
>=
24
&&
DataStore
.
directBootAware
&&
if
(
Build
.
VERSION
.
SDK_INT
>=
24
&&
DataStore
.
directBootAware
&&
...
@@ -129,7 +129,7 @@ class App : Application() {
...
@@ -129,7 +129,7 @@ class App : Application() {
for
(
dir
in
arrayOf
(
"acl"
,
"overture"
))
for
(
dir
in
arrayOf
(
"acl"
,
"overture"
))
try
{
try
{
for
(
file
in
assetManager
.
list
(
dir
))
assetManager
.
open
(
"$dir/$file"
).
use
{
input
->
for
(
file
in
assetManager
.
list
(
dir
))
assetManager
.
open
(
"$dir/$file"
).
use
{
input
->
File
(
device
Context
.
filesDir
,
file
).
outputStream
().
use
{
output
->
input
.
copyTo
(
output
)
}
File
(
device
Storage
.
filesDir
,
file
).
outputStream
().
use
{
output
->
input
.
copyTo
(
output
)
}
}
}
}
catch
(
e
:
IOException
)
{
}
catch
(
e
:
IOException
)
{
printLog
(
e
)
printLog
(
e
)
...
...
mobile/src/main/java/com/github/shadowsocks/acl/Acl.kt
View file @
30a53c08
...
@@ -46,7 +46,7 @@ class Acl {
...
@@ -46,7 +46,7 @@ class Acl {
val
networkAclParser
=
"^IMPORT_URL\\s*<(.+)>\\s*$"
.
toRegex
()
val
networkAclParser
=
"^IMPORT_URL\\s*<(.+)>\\s*$"
.
toRegex
()
fun
getFile
(
id
:
String
,
context
:
Context
=
app
.
device
Context
)
=
File
(
context
.
filesDir
,
id
+
".acl"
)
fun
getFile
(
id
:
String
,
context
:
Context
=
app
.
device
Storage
)
=
File
(
context
.
filesDir
,
id
+
".acl"
)
var
customRules
:
Acl
var
customRules
:
Acl
get
()
{
get
()
{
...
...
mobile/src/main/java/com/github/shadowsocks/bg/BaseService.kt
View file @
30a53c08
...
@@ -201,7 +201,7 @@ object BaseService {
...
@@ -201,7 +201,7 @@ object BaseService {
}
}
// sensitive Shadowsocks config is stored in
// sensitive Shadowsocks config is stored in
val
file
=
File
(
if
(
UserManagerCompat
.
isUserUnlocked
(
app
))
app
.
filesDir
else
@TargetApi
(
24
)
{
val
file
=
File
(
if
(
UserManagerCompat
.
isUserUnlocked
(
app
))
app
.
filesDir
else
@TargetApi
(
24
)
{
app
.
device
Context
.
noBackupFilesDir
// only API 24+ will be in locked state
app
.
device
Storage
.
noBackupFilesDir
// only API 24+ will be in locked state
},
CONFIG_FILE
)
},
CONFIG_FILE
)
shadowsocksConfigFile
=
file
shadowsocksConfigFile
=
file
file
.
writeText
(
config
.
toString
())
file
.
writeText
(
config
.
toString
())
...
...
mobile/src/main/java/com/github/shadowsocks/bg/GuardedProcessPool.kt
View file @
30a53c08
...
@@ -67,7 +67,7 @@ class GuardedProcessPool {
...
@@ -67,7 +67,7 @@ class GuardedProcessPool {
process
=
ProcessBuilder
(
cmd
)
process
=
ProcessBuilder
(
cmd
)
.
redirectErrorStream
(
true
)
.
redirectErrorStream
(
true
)
.
directory
(
app
.
device
Context
.
filesDir
)
.
directory
(
app
.
device
Storage
.
filesDir
)
.
start
()
.
start
()
streamLogger
(
process
.
inputStream
,
Log
::
i
)
streamLogger
(
process
.
inputStream
,
Log
::
i
)
...
...
mobile/src/main/java/com/github/shadowsocks/bg/LocalDnsService.kt
View file @
30a53c08
...
@@ -82,7 +82,7 @@ object LocalDnsService {
...
@@ -82,7 +82,7 @@ object LocalDnsService {
// no need to setup AlternativeDNS in Acl.ALL/BYPASS_LAN mode
// no need to setup AlternativeDNS in Acl.ALL/BYPASS_LAN mode
.
put
(
"OnlyPrimaryDNS"
,
true
)
.
put
(
"OnlyPrimaryDNS"
,
true
)
}
}
File
(
app
.
device
Context
.
filesDir
,
file
).
writeText
(
config
.
toString
())
File
(
app
.
device
Storage
.
filesDir
,
file
).
writeText
(
config
.
toString
())
return
file
return
file
}
}
...
...
mobile/src/main/java/com/github/shadowsocks/bg/TrafficMonitorThread.kt
View file @
30a53c08
...
@@ -29,7 +29,7 @@ import java.nio.ByteBuffer
...
@@ -29,7 +29,7 @@ import java.nio.ByteBuffer
import
java.nio.ByteOrder
import
java.nio.ByteOrder
class
TrafficMonitorThread
:
LocalSocketListener
(
"TrafficMonitorThread"
)
{
class
TrafficMonitorThread
:
LocalSocketListener
(
"TrafficMonitorThread"
)
{
override
val
socketFile
=
File
(
app
.
device
Context
.
filesDir
,
"stat_path"
)
override
val
socketFile
=
File
(
app
.
device
Storage
.
filesDir
,
"stat_path"
)
override
fun
accept
(
socket
:
LocalSocket
)
{
override
fun
accept
(
socket
:
LocalSocket
)
{
try
{
try
{
...
...
mobile/src/main/java/com/github/shadowsocks/bg/TransproxyService.kt
View file @
30a53c08
...
@@ -51,7 +51,7 @@ class TransproxyService : Service(), LocalDnsService.Interface {
...
@@ -51,7 +51,7 @@ class TransproxyService : Service(), LocalDnsService.Interface {
}
}
private
fun
startRedsocksDaemon
()
{
private
fun
startRedsocksDaemon
()
{
File
(
app
.
device
Context
.
filesDir
,
"redsocks.conf"
).
writeText
(
"""base {
File
(
app
.
device
Storage
.
filesDir
,
"redsocks.conf"
).
writeText
(
"""base {
log_debug = off;
log_debug = off;
log_info = off;
log_info = off;
log = stderr;
log = stderr;
...
...
mobile/src/main/java/com/github/shadowsocks/bg/VpnService.kt
View file @
30a53c08
...
@@ -71,7 +71,7 @@ class VpnService : BaseVpnService(), LocalDnsService.Interface {
...
@@ -71,7 +71,7 @@ class VpnService : BaseVpnService(), LocalDnsService.Interface {
}
}
private
inner
class
ProtectWorker
:
LocalSocketListener
(
"ShadowsocksVpnThread"
)
{
private
inner
class
ProtectWorker
:
LocalSocketListener
(
"ShadowsocksVpnThread"
)
{
override
val
socketFile
:
File
=
File
(
app
.
device
Context
.
filesDir
,
"protect_path"
)
override
val
socketFile
:
File
=
File
(
app
.
device
Storage
.
filesDir
,
"protect_path"
)
override
fun
accept
(
socket
:
LocalSocket
)
{
override
fun
accept
(
socket
:
LocalSocket
)
{
try
{
try
{
...
@@ -250,7 +250,7 @@ class VpnService : BaseVpnService(), LocalDnsService.Interface {
...
@@ -250,7 +250,7 @@ class VpnService : BaseVpnService(), LocalDnsService.Interface {
var
tries
=
0
var
tries
=
0
while
(
tries
<
10
)
{
while
(
tries
<
10
)
{
Thread
.
sleep
(
30L
shl
tries
)
Thread
.
sleep
(
30L
shl
tries
)
if
(
JniHelper
.
sendFd
(
fd
,
File
(
app
.
device
Context
.
filesDir
,
"sock_path"
).
absolutePath
)
!=
-
1
)
return
true
if
(
JniHelper
.
sendFd
(
fd
,
File
(
app
.
device
Storage
.
filesDir
,
"sock_path"
).
absolutePath
)
!=
-
1
)
return
true
tries
+=
1
tries
+=
1
}
}
}
}
...
...
mobile/src/main/java/com/github/shadowsocks/database/PublicDatabase.kt
View file @
30a53c08
...
@@ -31,7 +31,7 @@ import com.github.shadowsocks.utils.Key
...
@@ -31,7 +31,7 @@ import com.github.shadowsocks.utils.Key
abstract
class
PublicDatabase
:
RoomDatabase
()
{
abstract
class
PublicDatabase
:
RoomDatabase
()
{
companion
object
{
companion
object
{
private
val
instance
by
lazy
{
private
val
instance
by
lazy
{
Room
.
databaseBuilder
(
app
.
device
Context
,
PublicDatabase
::
class
.
java
,
Key
.
DB_PUBLIC
)
Room
.
databaseBuilder
(
app
.
device
Storage
,
PublicDatabase
::
class
.
java
,
Key
.
DB_PUBLIC
)
.
allowMainThreadQueries
()
.
allowMainThreadQueries
()
.
addMigrations
(
.
addMigrations
(
Migration3
Migration3
...
...
mobile/src/main/java/com/github/shadowsocks/plugin/PluginManager.kt
View file @
30a53c08
...
@@ -162,7 +162,7 @@ object PluginManager {
...
@@ -162,7 +162,7 @@ object PluginManager {
var
initialized
=
false
var
initialized
=
false
fun
entryNotFound
():
Nothing
=
throw
IndexOutOfBoundsException
(
"Plugin entry binary not found"
)
fun
entryNotFound
():
Nothing
=
throw
IndexOutOfBoundsException
(
"Plugin entry binary not found"
)
val
list
=
ArrayList
<
String
>()
val
list
=
ArrayList
<
String
>()
val
pluginDir
=
File
(
app
.
device
Context
.
filesDir
,
"plugin"
)
val
pluginDir
=
File
(
app
.
device
Storage
.
filesDir
,
"plugin"
)
(
cr
.
query
(
uri
,
arrayOf
(
PluginContract
.
COLUMN_PATH
,
PluginContract
.
COLUMN_MODE
),
null
,
null
,
null
)
(
cr
.
query
(
uri
,
arrayOf
(
PluginContract
.
COLUMN_PATH
,
PluginContract
.
COLUMN_MODE
),
null
,
null
,
null
)
?:
return
null
).
use
{
cursor
->
?:
return
null
).
use
{
cursor
->
if
(!
cursor
.
moveToFirst
())
entryNotFound
()
if
(!
cursor
.
moveToFirst
())
entryNotFound
()
...
...
mobile/src/main/java/com/github/shadowsocks/utils/Device
Context
.kt
→
mobile/src/main/java/com/github/shadowsocks/utils/Device
StorageApp
.kt
View file @
30a53c08
...
@@ -20,12 +20,18 @@
...
@@ -20,12 +20,18 @@
package
com.github.shadowsocks.utils
package
com.github.shadowsocks.utils
import
android.annotation.SuppressLint
import
android.annotation.TargetApi
import
android.annotation.TargetApi
import
android.app.Application
import
android.content.Context
import
android.content.Context
import
android.content.ContextWrapper
@SuppressLint
(
"Registered"
)
@TargetApi
(
24
)
@TargetApi
(
24
)
class
DeviceContext
(
context
:
Context
)
:
ContextWrapper
(
context
.
createDeviceProtectedStorageContext
())
{
class
DeviceStorageApp
(
context
:
Context
)
:
Application
()
{
init
{
attachBaseContext
(
context
.
createDeviceProtectedStorageContext
())
}
/**
/**
* Thou shalt not get the REAL underlying application context which would no longer be operating under device
* Thou shalt not get the REAL underlying application context which would no longer be operating under device
* protected storage.
* protected storage.
...
...
mobile/src/main/java/com/github/shadowsocks/utils/DirectBoot.kt
View file @
30a53c08
...
@@ -17,7 +17,7 @@ import java.io.ObjectOutputStream
...
@@ -17,7 +17,7 @@ import java.io.ObjectOutputStream
@TargetApi
(
24
)
@TargetApi
(
24
)
object
DirectBoot
:
BroadcastReceiver
()
{
object
DirectBoot
:
BroadcastReceiver
()
{
private
val
file
=
File
(
app
.
device
Context
.
noBackupFilesDir
,
"directBootProfile"
)
private
val
file
=
File
(
app
.
device
Storage
.
noBackupFilesDir
,
"directBootProfile"
)
private
var
registered
=
false
private
var
registered
=
false
fun
getDeviceProfile
():
Profile
?
=
try
{
fun
getDeviceProfile
():
Profile
?
=
try
{
...
@@ -26,7 +26,7 @@ object DirectBoot : BroadcastReceiver() {
...
@@ -26,7 +26,7 @@ object DirectBoot : BroadcastReceiver() {
fun
clean
()
{
fun
clean
()
{
file
.
delete
()
file
.
delete
()
File
(
app
.
device
Context
.
noBackupFilesDir
,
BaseService
.
CONFIG_FILE
).
delete
()
File
(
app
.
device
Storage
.
noBackupFilesDir
,
BaseService
.
CONFIG_FILE
).
delete
()
}
}
/**
/**
...
...
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