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
4e5c67e8
Commit
4e5c67e8
authored
Nov 30, 2017
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move port default value to OrmLitePreferenceDataStore
parent
8c33345a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
11 deletions
+10
-11
mobile/src/main/scala/com/github/shadowsocks/ShadowsocksApplication.scala
...scala/com/github/shadowsocks/ShadowsocksApplication.scala
+2
-6
mobile/src/main/scala/com/github/shadowsocks/preference/OrmLitePreferenceDataStore.scala
...b/shadowsocks/preference/OrmLitePreferenceDataStore.scala
+8
-5
No files found.
mobile/src/main/scala/com/github/shadowsocks/ShadowsocksApplication.scala
View file @
4e5c67e8
...
...
@@ -28,7 +28,7 @@ import android.app.{Application, NotificationChannel, NotificationManager}
import
android.content._
import
android.content.pm.
{
PackageInfo
,
PackageManager
}
import
android.content.res.Configuration
import
android.os.
{
B
inder
,
B
uild
,
LocaleList
}
import
android.os.
{
Build
,
LocaleList
}
import
android.support.v7.app.AppCompatDelegate
import
android.util.Log
import
com.evernote.android.job.JobManager
...
...
@@ -163,11 +163,7 @@ class ShadowsocksApplication extends Application {
TcpFastOpen
.
enabled
(
dataStore
.
getBoolean
(
Key
.
tfo
,
TcpFastOpen
.
sendEnabled
))
if
(
dataStore
.
getLong
(
Key
.
assetUpdateTime
,
-
1
)
!=
info
.
lastUpdateTime
)
copyAssets
()
// hopefully hashCode = mHandle doesn't change, currently this is true from KitKat to Nougat
lazy
val
userIndex
=
Binder
.
getCallingUserHandle
.
hashCode
if
(!(
1025
to
65535
contains
dataStore
.
portProxy
))
dataStore
.
putInt
(
Key
.
portProxy
,
1080
+
userIndex
)
if
(!(
1025
to
65535
contains
dataStore
.
portLocalDns
))
dataStore
.
putInt
(
Key
.
portLocalDns
,
5450
+
userIndex
)
if
(!(
1025
to
65535
contains
dataStore
.
portTransproxy
))
dataStore
.
putInt
(
Key
.
portTransproxy
,
8200
+
userIndex
)
(
dataStore
.
portProxy
,
dataStore
.
portLocalDns
,
dataStore
.
portTransproxy
)
// initialize ports for UI
if
(
Build
.
VERSION
.
SDK_INT
>=
26
)
{
val
nm
=
getSystemService
(
classOf
[
NotificationManager
])
...
...
mobile/src/main/scala/com/github/shadowsocks/preference/OrmLitePreferenceDataStore.scala
View file @
4e5c67e8
...
...
@@ -4,6 +4,7 @@ import java.io.ByteArrayOutputStream
import
java.nio.ByteBuffer
import
java.util
import
android.os.Binder
import
android.support.v7.preference.PreferenceDataStore
import
com.github.shadowsocks.database.
{
DBHelper
,
KeyValuePair
}
import
com.github.shadowsocks.utils.
{
Key
,
Utils
}
...
...
@@ -98,8 +99,10 @@ final class OrmLitePreferenceDataStore(dbHelper: DBHelper) extends PreferenceDat
def
registerChangeListener
(
listener
:
OnPreferenceDataStoreChangeListener
)
:
Unit
=
listeners
+=
listener
def
unregisterChangeListener
(
listener
:
OnPreferenceDataStoreChangeListener
)
:
Unit
=
listeners
-=
listener
private
def
getLocalPort
(
key
:
String
)
=
getInt
(
key
,
0
)
match
{
case
0
=>
Utils
.
parsePort
(
getString
(
key
),
0
)
// hopefully hashCode = mHandle doesn't change, currently this is true from KitKat to Nougat
private
lazy
val
userIndex
=
Binder
.
getCallingUserHandle
.
hashCode
private
def
getLocalPort
(
key
:
String
,
default
:
Int
)
=
getInt
(
key
,
0
)
match
{
case
0
=>
Utils
.
parsePort
(
getString
(
key
),
default
+
userIndex
)
case
value
=>
putString
(
key
,
value
.
toString
)
value
...
...
@@ -108,9 +111,9 @@ final class OrmLitePreferenceDataStore(dbHelper: DBHelper) extends PreferenceDat
def
profileId
:
Int
=
getInt
(
Key
.
id
,
0
)
def
profileId_=
(
i
:
Int
)
:
Unit
=
putInt
(
Key
.
id
,
i
)
def
serviceMode
:
String
=
getString
(
Key
.
serviceMode
,
Key
.
modeVpn
)
def
portProxy
:
Int
=
getLocalPort
(
Key
.
portProxy
)
def
portLocalDns
:
Int
=
getLocalPort
(
Key
.
portLocalDns
)
def
portTransproxy
:
Int
=
getLocalPort
(
Key
.
portTransproxy
)
def
portProxy
:
Int
=
getLocalPort
(
Key
.
portProxy
,
1080
)
def
portLocalDns
:
Int
=
getLocalPort
(
Key
.
portLocalDns
,
5450
)
def
portTransproxy
:
Int
=
getLocalPort
(
Key
.
portTransproxy
,
8200
)
def
proxyApps
:
Boolean
=
getBoolean
(
Key
.
proxyApps
)
def
proxyApps_=
(
value
:
Boolean
)
:
Unit
=
putBoolean
(
Key
.
proxyApps
,
value
)
...
...
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