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
333ee156
Commit
333ee156
authored
Jun 06, 2013
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix the crash_recover
parent
1403ef8a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
36 deletions
+16
-36
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
+6
-5
src/main/scala/com/github/shadowsocks/ShadowsocksReceiver.scala
...in/scala/com/github/shadowsocks/ShadowsocksReceiver.scala
+3
-3
src/main/scala/com/github/shadowsocks/Utils.scala
src/main/scala/com/github/shadowsocks/Utils.scala
+7
-28
No files found.
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
View file @
333ee156
...
@@ -209,6 +209,7 @@ class Shadowsocks
...
@@ -209,6 +209,7 @@ class Shadowsocks
private
var
switchButton
:
Switch
=
null
private
var
switchButton
:
Switch
=
null
private
var
progressDialog
:
ProgressDialog
=
null
private
var
progressDialog
:
ProgressDialog
=
null
private
var
settings
:
SharedPreferences
=
null
private
var
settings
:
SharedPreferences
=
null
private
var
status
:
SharedPreferences
=
null
private
var
prepared
=
false
private
var
prepared
=
false
private
var
state
=
State
.
INIT
private
var
state
=
State
.
INIT
private
var
receiver
:
StateBroadcastReceiver
=
null
private
var
receiver
:
StateBroadcastReceiver
=
null
...
@@ -218,7 +219,7 @@ class Shadowsocks
...
@@ -218,7 +219,7 @@ class Shadowsocks
msg
.
what
match
{
msg
.
what
match
{
case
MSG_CRASH_RECOVER
=>
case
MSG_CRASH_RECOVER
=>
Crouton
.
makeText
(
Shadowsocks
.
this
,
R
.
string
.
crash_alert
,
Style
.
ALERT
).
show
()
Crouton
.
makeText
(
Shadowsocks
.
this
,
R
.
string
.
crash_alert
,
Style
.
ALERT
).
show
()
s
ettings
.
edit
().
putBoolean
(
Key
.
isRunning
,
false
).
apply
()
s
tatus
.
edit
().
putBoolean
(
Key
.
isRunning
,
false
).
commit
()
case
MSG_INITIAL_FINISH
=>
case
MSG_INITIAL_FINISH
=>
clearDialog
()
clearDialog
()
}
}
...
@@ -367,6 +368,7 @@ class Shadowsocks
...
@@ -367,6 +368,7 @@ class Shadowsocks
switchButton
=
switchLayout
.
findViewById
(
R
.
id
.
switchButton
).
asInstanceOf
[
Switch
]
switchButton
=
switchLayout
.
findViewById
(
R
.
id
.
switchButton
).
asInstanceOf
[
Switch
]
settings
=
PreferenceManager
.
getDefaultSharedPreferences
(
this
)
settings
=
PreferenceManager
.
getDefaultSharedPreferences
(
this
)
status
=
getSharedPreferences
(
Key
.
status
,
Context
.
MODE_PRIVATE
)
receiver
=
new
StateBroadcastReceiver
()
receiver
=
new
StateBroadcastReceiver
()
registerReceiver
(
receiver
,
new
IntentFilter
(
Action
.
UPDATE_STATE
))
registerReceiver
(
receiver
,
new
IntentFilter
(
Action
.
UPDATE_STATE
))
...
@@ -377,9 +379,8 @@ class Shadowsocks
...
@@ -377,9 +379,8 @@ class Shadowsocks
}
}
spawn
{
spawn
{
settings
.
edit
().
putBoolean
(
Key
.
isRoot
,
Utils
.
getRoot
).
commit
()
settings
.
edit
().
putBoolean
(
Key
.
isRoot
,
Utils
.
getRoot
).
commit
()
val
update
=
getSharedPreferences
(
Key
.
update
,
Context
.
MODE_WORLD_WRITEABLE
)
if
(!
status
.
getBoolean
(
getVersionName
,
false
))
{
if
(!
update
.
getBoolean
(
getVersionName
,
false
))
{
status
.
edit
.
putBoolean
(
getVersionName
,
true
).
apply
()
update
.
edit
.
putBoolean
(
getVersionName
,
true
).
apply
()
reset
()
reset
()
}
}
handler
.
sendEmptyMessage
(
MSG_INITIAL_FINISH
)
handler
.
sendEmptyMessage
(
MSG_INITIAL_FINISH
)
...
@@ -459,7 +460,7 @@ class Shadowsocks
...
@@ -459,7 +460,7 @@ class Shadowsocks
switchButton
.
setChecked
(
false
)
switchButton
.
setChecked
(
false
)
Crouton
.
cancelAllCroutons
()
Crouton
.
cancelAllCroutons
()
setPreferenceEnabled
(
true
)
setPreferenceEnabled
(
true
)
if
(
s
etting
s
.
getBoolean
(
Key
.
isRunning
,
false
))
{
if
(
s
tatu
s
.
getBoolean
(
Key
.
isRunning
,
false
))
{
spawn
{
spawn
{
crash_recovery
()
crash_recovery
()
handler
.
sendEmptyMessage
(
MSG_CRASH_RECOVER
)
handler
.
sendEmptyMessage
(
MSG_CRASH_RECOVER
)
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksReceiver.scala
View file @
333ee156
...
@@ -50,7 +50,7 @@ class ShadowsocksReceiver extends BroadcastReceiver {
...
@@ -50,7 +50,7 @@ class ShadowsocksReceiver extends BroadcastReceiver {
def
onReceive
(
context
:
Context
,
intent
:
Intent
)
{
def
onReceive
(
context
:
Context
,
intent
:
Intent
)
{
val
settings
:
SharedPreferences
=
PreferenceManager
.
getDefaultSharedPreferences
(
context
)
val
settings
:
SharedPreferences
=
PreferenceManager
.
getDefaultSharedPreferences
(
context
)
val
update
=
context
.
getSharedPreferences
(
Key
.
update
,
Context
.
MODE_WORLD_READABL
E
)
val
status
=
context
.
getSharedPreferences
(
Key
.
status
,
Context
.
MODE_PRIVAT
E
)
if
(
intent
.
getAction
==
Action
.
UPDATE_STATE
)
{
if
(
intent
.
getAction
==
Action
.
UPDATE_STATE
)
{
val
state
=
intent
.
getIntExtra
(
Extra
.
STATE
,
State
.
INIT
)
val
state
=
intent
.
getIntExtra
(
Extra
.
STATE
,
State
.
INIT
)
...
@@ -59,7 +59,7 @@ class ShadowsocksReceiver extends BroadcastReceiver {
...
@@ -59,7 +59,7 @@ class ShadowsocksReceiver extends BroadcastReceiver {
case
State
.
CONNECTED
=>
true
case
State
.
CONNECTED
=>
true
case
_
=>
false
case
_
=>
false
}
}
s
etting
s
.
edit
.
putBoolean
(
Key
.
isRunning
,
running
).
commit
()
s
tatu
s
.
edit
.
putBoolean
(
Key
.
isRunning
,
running
).
commit
()
return
return
}
}
...
@@ -72,7 +72,7 @@ class ShadowsocksReceiver extends BroadcastReceiver {
...
@@ -72,7 +72,7 @@ class ShadowsocksReceiver extends BroadcastReceiver {
}
}
}
}
val
isAutoConnect
:
Boolean
=
settings
.
getBoolean
(
Key
.
isAutoConnect
,
false
)
val
isAutoConnect
:
Boolean
=
settings
.
getBoolean
(
Key
.
isAutoConnect
,
false
)
val
isInstalled
:
Boolean
=
update
.
getBoolean
(
versionName
,
false
)
val
isInstalled
:
Boolean
=
status
.
getBoolean
(
versionName
,
false
)
if
(
isAutoConnect
&&
isInstalled
)
{
if
(
isAutoConnect
&&
isInstalled
)
{
if
(
Utils
.
getRoot
)
{
if
(
Utils
.
getRoot
)
{
if
(
ShadowsocksService
.
isServiceStarted
(
context
))
return
if
(
ShadowsocksService
.
isServiceStarted
(
context
))
return
...
...
src/main/scala/com/github/shadowsocks/Utils.scala
View file @
333ee156
...
@@ -54,7 +54,7 @@ import android.app.ActivityManager
...
@@ -54,7 +54,7 @@ import android.app.ActivityManager
object
Key
{
object
Key
{
val
isRoot
=
"isRoot"
val
isRoot
=
"isRoot"
val
update
=
"update
"
val
status
=
"status
"
val
proxyedApps
=
"proxyedApps"
val
proxyedApps
=
"proxyedApps"
val
isRunning
=
"isRunning"
val
isRunning
=
"isRunning"
...
@@ -325,30 +325,9 @@ object Utils {
...
@@ -325,30 +325,9 @@ object Utils {
* @return The Property, or NULL if not found
* @return The Property, or NULL if not found
*/
*/
def
getSystemProperty
(
propName
:
String
)
:
String
=
{
def
getSystemProperty
(
propName
:
String
)
:
String
=
{
var
line
:
String
=
null
val
p
:
Process
=
Runtime
.
getRuntime
.
exec
(
"getprop "
+
propName
)
var
input
:
BufferedReader
=
null
val
lines
=
scala
.
io
.
Source
.
fromInputStream
(
p
.
getInputStream
).
getLines
()
try
{
if
(
lines
.
hasNext
)
lines
.
next
()
else
null
val
p
:
Process
=
Runtime
.
getRuntime
.
exec
(
"getprop "
+
propName
)
input
=
new
BufferedReader
(
new
InputStreamReader
(
p
.
getInputStream
),
1024
)
line
=
input
.
readLine
input
.
close
()
}
catch
{
case
ex
:
IOException
=>
{
Log
.
e
(
TAG
,
"Unable to read sysprop "
+
propName
,
ex
)
return
null
}
}
finally
{
if
(
input
!=
null
)
{
try
{
input
.
close
()
}
catch
{
case
ex
:
IOException
=>
{
Log
.
e
(
TAG
,
"Exception while closing InputStream"
,
ex
)
}
}
}
}
line
}
}
/**
/**
...
@@ -404,13 +383,13 @@ object Utils {
...
@@ -404,13 +383,13 @@ object Utils {
def
getAppIcon
(
c
:
Context
,
uid
:
Int
)
:
Drawable
=
{
def
getAppIcon
(
c
:
Context
,
uid
:
Int
)
:
Drawable
=
{
val
pm
:
PackageManager
=
c
.
getPackageManager
val
pm
:
PackageManager
=
c
.
getPackageManager
va
r
appI
con
:
Drawable
=
c
.
getResources
.
getDrawable
(
android
.
R
.
drawable
.
sym_def_app_icon
)
va
l
i
con
:
Drawable
=
c
.
getResources
.
getDrawable
(
android
.
R
.
drawable
.
sym_def_app_icon
)
val
packages
:
Array
[
String
]
=
pm
.
getPackagesForUid
(
uid
)
val
packages
:
Array
[
String
]
=
pm
.
getPackagesForUid
(
uid
)
if
(
packages
!=
null
)
{
if
(
packages
!=
null
)
{
if
(
packages
.
length
>=
1
)
{
if
(
packages
.
length
>=
1
)
{
try
{
try
{
val
appInfo
:
ApplicationInfo
=
pm
.
getApplicationInfo
(
packages
(
0
),
0
)
val
appInfo
:
ApplicationInfo
=
pm
.
getApplicationInfo
(
packages
(
0
),
0
)
appIcon
=
pm
.
getApplicationIcon
(
appInfo
)
return
pm
.
getApplicationIcon
(
appInfo
)
}
catch
{
}
catch
{
case
e
:
PackageManager.NameNotFoundException
=>
{
case
e
:
PackageManager.NameNotFoundException
=>
{
Log
.
e
(
c
.
getPackageName
,
"No package found matching with the uid "
+
uid
)
Log
.
e
(
c
.
getPackageName
,
"No package found matching with the uid "
+
uid
)
...
@@ -420,7 +399,7 @@ object Utils {
...
@@ -420,7 +399,7 @@ object Utils {
}
else
{
}
else
{
Log
.
e
(
c
.
getPackageName
,
"Package not found for uid "
+
uid
)
Log
.
e
(
c
.
getPackageName
,
"Package not found for uid "
+
uid
)
}
}
appI
con
i
con
}
}
def
getDataPath
(
ctx
:
Context
)
:
String
=
{
def
getDataPath
(
ctx
:
Context
)
:
String
=
{
...
...
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