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
95916bcd
Commit
95916bcd
authored
Aug 03, 2013
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add flush dns cache
parent
1bed08a7
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
251 additions
and
26 deletions
+251
-26
project/Build.scala
project/Build.scala
+2
-2
src/main/AndroidManifest.xml
src/main/AndroidManifest.xml
+1
-0
src/main/res/values/strings.xml
src/main/res/values/strings.xml
+2
-1
src/main/scala/com/github/shadowsocks/AppManager.scala
src/main/scala/com/github/shadowsocks/AppManager.scala
+5
-4
src/main/scala/com/github/shadowsocks/ShadowVpnActivity.scala
...main/scala/com/github/shadowsocks/ShadowVpnActivity.scala
+39
-0
src/main/scala/com/github/shadowsocks/ShadowVpnService.scala
src/main/scala/com/github/shadowsocks/ShadowVpnService.scala
+4
-2
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
+26
-5
src/main/scala/com/github/shadowsocks/ShadowsocksApplication.scala
...scala/com/github/shadowsocks/ShadowsocksApplication.scala
+4
-3
src/main/scala/com/github/shadowsocks/ShadowsocksBackupAgent.scala
...scala/com/github/shadowsocks/ShadowsocksBackupAgent.scala
+39
-0
src/main/scala/com/github/shadowsocks/ShadowsocksReceiver.scala
...in/scala/com/github/shadowsocks/ShadowsocksReceiver.scala
+4
-3
src/main/scala/com/github/shadowsocks/ShadowsocksService.scala
...ain/scala/com/github/shadowsocks/ShadowsocksService.scala
+4
-2
src/main/scala/com/github/shadowsocks/Utils.scala
src/main/scala/com/github/shadowsocks/Utils.scala
+41
-2
src/main/scala/com/github/shadowsocks/preferences/PasswordEditTextPreference.scala
.../shadowsocks/preferences/PasswordEditTextPreference.scala
+40
-1
src/main/scala/com/github/shadowsocks/preferences/SummaryEditTextPreference.scala
...b/shadowsocks/preferences/SummaryEditTextPreference.scala
+40
-1
No files found.
project/Build.scala
View file @
95916bcd
...
...
@@ -5,8 +5,8 @@ import sbtandroid._
import
sbtandroid.AndroidKeys._
object
App
{
val
version
=
"1.
7.7
"
val
versionCode
=
4
4
val
version
=
"1.
8.0
"
val
versionCode
=
4
5
}
object
General
{
...
...
src/main/AndroidManifest.xml
View file @
95916bcd
...
...
@@ -6,6 +6,7 @@
<uses-permission
android:name=
"android.permission.WAKE_LOCK"
/>
<uses-permission
android:name=
"android.permission.RECEIVE_BOOT_COMPLETED"
/>
<uses-permission
android:name=
"android.permission.ACCESS_SUPERUSER"
/>
<uses-permission
android:name=
"android.permission.WRITE_SETTINGS"
/>
<uses-feature
android:name=
"android.hardware.touchscreen"
...
...
src/main/res/values/strings.xml
View file @
95916bcd
...
...
@@ -73,6 +73,7 @@
<string
name=
"about_title"
>
Shadowsocks %s
</string>
<string
name=
"donate"
>
Donate
</string>
<string
name=
"donate_address"
>
http://buildbot.sinaapp.com/donate.html
</string>
<string
name=
"flush_dnscache"
>
Flush DNS Cache
</string>
<string
name=
"flushing"
>
Flushing
</string>
</resources>
src/main/scala/com/github/shadowsocks/AppManager.scala
View file @
95916bcd
/* Shadowsocks - A shadowsocks client for Android
* Copyright (C) 2012 <max.c.lv@gmail.com>
/*
* Shadowsocks - A shadowsocks client for Android
* Copyright (C) 2013 <max.c.lv@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
...
...
@@ -277,7 +278,7 @@ class AppManager extends SherlockActivity with OnCheckedChangeListener with OnCl
appListView
.
setAdapter
(
adapter
)
appListView
.
setOnScrollListener
(
new
AbsListView
.
OnScrollListener
{
def
onScroll
(
view
:
AbsListView
,
firstVisibleItem
:
Int
,
visibleItemCount
:
Int
,
totalItemCount
:
Int
)
{
totalItemCount
:
Int
)
{
if
(
visible
)
{
val
name
:
String
=
apps
(
firstVisibleItem
).
name
if
(
name
!=
null
&&
name
.
length
>
1
)
{
...
...
@@ -325,4 +326,4 @@ class AppManager extends SherlockActivity with OnCheckedChangeListener with OnCl
}
}
}
\ No newline at end of file
}
src/main/scala/com/github/shadowsocks/ShadowVpnActivity.scala
View file @
95916bcd
/*
* Shadowsocks - A shadowsocks client for Android
* Copyright (C) 2013 <max.c.lv@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
* ___====-_ _-====___
* _--^^^#####// \\#####^^^--_
* _-^##########// ( ) \\##########^-_
* -############// |\^^/| \\############-
* _/############// (@::@) \\############\_
* /#############(( \\// ))#############\
* -###############\\ (oo) //###############-
* -#################\\ / VV \ //#################-
* -###################\\/ \//###################-
* _#/|##########/\######( /\ )######/\##########|\#_
* |/ |#/\#/\#/\/ \#/\##\ | | /##/\#/ \/\#/\#/\#| \|
* ` |/ V V ` V \#\| | | |/#/ V ' V V \| '
* ` ` ` ` / | | | | \ ' ' ' '
* ( | | | | )
* __\ | | | | /__
* (vvv(VVV)(VVV)vvv)
*
* HERE BE DRAGONS
*
*/
package
com.github.shadowsocks
import
android.app.Activity
...
...
src/main/scala/com/github/shadowsocks/ShadowVpnService.scala
View file @
95916bcd
/* Shadowsocks - A shadowsocks client for Android
* Copyright (C) 2012 <max.c.lv@gmail.com>
/*
* Shadowsocks - A shadowsocks client for Android
* Copyright (C) 2013 <max.c.lv@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
...
...
@@ -35,6 +36,7 @@
* HERE BE DRAGONS
*
*/
package
com.github.shadowsocks
import
android.app._
...
...
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
View file @
95916bcd
/* Shadowsocks - A shadowsocks client for Android
/*
* Shadowsocks - A shadowsocks client for Android
* Copyright (C) 2012 <max.c.lv@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
...
...
@@ -124,7 +125,7 @@ object Shadowsocks {
}
}
class
FeatureFragment
extends
UnifiedPreferenceFragment
with
OnSharedPreferenceChangeListener
{
class
FeatureFragment
extends
UnifiedPreferenceFragment
with
OnSharedPreferenceChangeListener
{
var
receiver
:
BroadcastReceiver
=
null
...
...
@@ -269,7 +270,7 @@ class Shadowsocks
private
def
copyFile
(
in
:
InputStream
,
out
:
OutputStream
)
{
val
buffer
:
Array
[
Byte
]
=
new
Array
[
Byte
](
1024
)
var
read
:
Int
=
0
while
({
while
(
{
read
=
in
.
read
(
buffer
)
read
}
!=
-
1
)
{
...
...
@@ -363,8 +364,6 @@ class Shadowsocks
setHeaderRes
(
R
.
xml
.
shadowsocks_headers
)
super
.
onCreate
(
savedInstanceState
)
val
switchLayout
=
getLayoutInflater
.
inflate
(
R
.
layout
.
layout_switch
,
null
)
.
asInstanceOf
[
RelativeLayout
]
...
...
@@ -427,6 +426,10 @@ class Shadowsocks
.
add
(
0
,
1
,
1
,
R
.
string
.
about
)
.
setIcon
(
android
.
R
.
drawable
.
ic_menu_info_details
)
.
setShowAsAction
(
MenuItem
.
SHOW_AS_ACTION_WITH_TEXT
)
menu
.
add
(
0
,
2
,
2
,
R
.
string
.
flush_dnscache
)
.
setIcon
(
android
.
R
.
drawable
.
ic_menu_revert
)
.
setShowAsAction
(
MenuItem
.
SHOW_AS_ACTION_WITH_TEXT
)
true
}
...
...
@@ -453,6 +456,10 @@ class Shadowsocks
EasyTracker
.
getTracker
.
sendEvent
(
Shadowsocks
.
TAG
,
"about"
,
getVersionName
,
0L
)
showAbout
()
}
case
2
=>
{
EasyTracker
.
getTracker
.
sendEvent
(
Shadowsocks
.
TAG
,
"flush_dnscache"
,
getVersionName
,
0L
)
flushDnsCache
()
}
}
super
.
onOptionsItemSelected
(
item
)
}
...
...
@@ -559,6 +566,20 @@ class Shadowsocks
}
}
private
def
flushDnsCache
()
{
clearDialog
()
progressDialog
=
ProgressDialog
.
show
(
this
,
""
,
getString
(
R
.
string
.
flushing
),
true
,
true
)
val
h
:
Handler
=
new
Handler
{
override
def
handleMessage
(
msg
:
Message
)
{
clearDialog
()
}
}
spawn
{
Utils
.
toggleAirplaneMode
(
getBaseContext
)
h
.
sendEmptyMessage
(
0
)
}
}
override
def
onActivityResult
(
requestCode
:
Int
,
resultCode
:
Int
,
data
:
Intent
)
{
resultCode
match
{
case
Activity
.
RESULT_OK
=>
{
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksApplication.scala
View file @
95916bcd
/* Shadowsocks - A shadowsocks client for Android
* Copyright (C) 2012 <max.c.lv@gmail.com>
/*
* Shadowsocks - A shadowsocks client for Android
* Copyright (C) 2013 <max.c.lv@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
...
...
@@ -44,4 +45,4 @@ class ShadowsocksApplication extends Application {
override
def
onCreate
()
{
EasyTracker
.
getInstance
.
setContext
(
this
)
}
}
\ No newline at end of file
}
src/main/scala/com/github/shadowsocks/ShadowsocksBackupAgent.scala
View file @
95916bcd
/*
* Shadowsocks - A shadowsocks client for Android
* Copyright (C) 2013 <max.c.lv@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
* ___====-_ _-====___
* _--^^^#####// \\#####^^^--_
* _-^##########// ( ) \\##########^-_
* -############// |\^^/| \\############-
* _/############// (@::@) \\############\_
* /#############(( \\// ))#############\
* -###############\\ (oo) //###############-
* -#################\\ / VV \ //#################-
* -###################\\/ \//###################-
* _#/|##########/\######( /\ )######/\##########|\#_
* |/ |#/\#/\#/\/ \#/\##\ | | /##/\#/ \/\#/\#/\#| \|
* ` |/ V V ` V \#\| | | |/#/ V ' V V \| '
* ` ` ` ` / | | | | \ ' ' ' '
* ( | | | | )
* __\ | | | | /__
* (vvv(VVV)(VVV)vvv)
*
* HERE BE DRAGONS
*
*/
package
com.github.shadowsocks
import
android.app.backup.
{
SharedPreferencesBackupHelper
,
BackupAgentHelper
}
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksReceiver.scala
View file @
95916bcd
/* Shadowsocks - A shadowsocks client for Android
* Copyright (C) 2012 <max.c.lv@gmail.com>
/*
* Shadowsocks - A shadowsocks client for Android
* Copyright (C) 2013 <max.c.lv@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
...
...
@@ -82,4 +83,4 @@ class ShadowsocksReceiver extends BroadcastReceiver {
}
}
}
}
\ No newline at end of file
}
src/main/scala/com/github/shadowsocks/ShadowsocksService.scala
View file @
95916bcd
/* Shadowsocks - A shadowsocks client for Android
* Copyright (C) 2012 <max.c.lv@gmail.com>
/*
* Shadowsocks - A shadowsocks client for Android
* Copyright (C) 2013 <max.c.lv@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
...
...
@@ -35,6 +36,7 @@
* HERE BE DRAGONS
*
*/
package
com.github.shadowsocks
import
android.app.Notification
...
...
src/main/scala/com/github/shadowsocks/Utils.scala
View file @
95916bcd
/* Shadowsocks - A shadowsocks client for Android
/*
* Shadowsocks - A shadowsocks client for Android
* Copyright (C) 2012 <max.c.lv@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
...
...
@@ -50,6 +51,8 @@ import org.xbill.DNS._
import
scala.Some
import
android.graphics.
{
Canvas
,
Bitmap
}
import
android.app.ActivityManager
import
android.os.Build
import
android.provider.Settings
object
Config
{
val
SHADOWSOCKS
=
"{\"server\": [%s], \"server_port\": %d, \"local_port\": %d, \"password\": %s, \"timeout\": %d}"
...
...
@@ -100,7 +103,11 @@ object Config {
def
printToFile
(
f
:
java.io.File
)(
op
:
java.io.PrintWriter
=>
Unit
)
{
val
p
=
new
java
.
io
.
PrintWriter
(
f
)
try
{
op
(
p
)
}
finally
{
p
.
close
()
}
try
{
op
(
p
)
}
finally
{
p
.
close
()
}
}
}
...
...
@@ -252,6 +259,38 @@ object Utils {
var
data_path
:
String
=
null
var
rootTries
=
0
// Blocked > 3 seconds
def
toggleAirplaneMode
(
context
:
Context
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
17
)
{
toggleAboveApiLevel17
()
}
else
{
toggleBelowApiLevel17
(
context
)
}
}
private
def
toggleAboveApiLevel17
()
{
// Android 4.2 and above
Utils
.
runRootCommand
(
"settings put global airplane_mode_on 1\n"
+
"am broadcast -a android.intent.action.AIRPLANE_MODE --ez state true\n"
+
"settings put global airplane_mode_on 0\n"
+
"am broadcast -a android.intent.action.AIRPLANE_MODE --ez state false\n"
)
}
private
def
toggleBelowApiLevel17
(
context
:
Context
)
{
// Android 4.2 below
Settings
.
System
.
putInt
(
context
.
getContentResolver
,
Settings
.
System
.
AIRPLANE_MODE_ON
,
1
)
val
enableIntent
=
new
Intent
(
Intent
.
ACTION_AIRPLANE_MODE_CHANGED
)
enableIntent
.
putExtra
(
"state"
,
true
)
context
.
sendBroadcast
(
enableIntent
)
Thread
.
sleep
(
3000
)
Settings
.
System
.
putInt
(
context
.
getContentResolver
,
Settings
.
System
.
AIRPLANE_MODE_ON
,
0
)
val
disableIntent
=
new
Intent
(
Intent
.
ACTION_AIRPLANE_MODE_CHANGED
)
disableIntent
.
putExtra
(
"state"
,
false
)
context
.
sendBroadcast
(
disableIntent
)
}
def
isServiceStarted
(
name
:
String
,
context
:
Context
)
:
Boolean
=
{
import
scala.collection.JavaConversions._
...
...
src/main/scala/com/github/shadowsocks/preferences/PasswordEditTextPreference.scala
View file @
95916bcd
/*
* Shadowsocks - A shadowsocks client for Android
* Copyright (C) 2013 <max.c.lv@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
* ___====-_ _-====___
* _--^^^#####// \\#####^^^--_
* _-^##########// ( ) \\##########^-_
* -############// |\^^/| \\############-
* _/############// (@::@) \\############\_
* /#############(( \\// ))#############\
* -###############\\ (oo) //###############-
* -#################\\ / VV \ //#################-
* -###################\\/ \//###################-
* _#/|##########/\######( /\ )######/\##########|\#_
* |/ |#/\#/\#/\/ \#/\##\ | | /##/\#/ \/\#/\#/\#| \|
* ` |/ V V ` V \#\| | | |/#/ V ' V V \| '
* ` ` ` ` / | | | | \ ' ' ' '
* ( | | | | )
* __\ | | | | /__
* (vvv(VVV)(VVV)vvv)
*
* HERE BE DRAGONS
*
*/
package
com.github.shadowsocks.preferences
import
android.content.Context
...
...
@@ -21,4 +60,4 @@ class PasswordEditTextPreference(context: Context, attrs: AttributeSet, defStyle
}
private
var
mDefaultSummary
:
CharSequence
=
getSummary
}
\ No newline at end of file
}
src/main/scala/com/github/shadowsocks/preferences/SummaryEditTextPreference.scala
View file @
95916bcd
/*
* Shadowsocks - A shadowsocks client for Android
* Copyright (C) 2013 <max.c.lv@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
* ___====-_ _-====___
* _--^^^#####// \\#####^^^--_
* _-^##########// ( ) \\##########^-_
* -############// |\^^/| \\############-
* _/############// (@::@) \\############\_
* /#############(( \\// ))#############\
* -###############\\ (oo) //###############-
* -#################\\ / VV \ //#################-
* -###################\\/ \//###################-
* _#/|##########/\######( /\ )######/\##########|\#_
* |/ |#/\#/\#/\/ \#/\##\ | | /##/\#/ \/\#/\#/\#| \|
* ` |/ V V ` V \#\| | | |/#/ V ' V V \| '
* ` ` ` ` / | | | | \ ' ' ' '
* ( | | | | )
* __\ | | | | /__
* (vvv(VVV)(VVV)vvv)
*
* HERE BE DRAGONS
*
*/
package
com.github.shadowsocks.preferences
import
android.content.Context
...
...
@@ -21,4 +60,4 @@ class SummaryEditTextPreference(context: Context, attrs: AttributeSet, defStyle:
}
private
var
mDefaultSummary
:
CharSequence
=
getSummary
}
\ No newline at end of file
}
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