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
2eb0b193
Commit
2eb0b193
authored
May 16, 2013
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tricks to start VPN service in background
parent
18e62360
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
9 deletions
+52
-9
src/main/AndroidManifest.xml
src/main/AndroidManifest.xml
+12
-6
src/main/scala/com/github/shadowsocks/ShadowVpnActivity.scala
...main/scala/com/github/shadowsocks/ShadowVpnActivity.scala
+33
-0
src/main/scala/com/github/shadowsocks/ShadowVpnService.scala
src/main/scala/com/github/shadowsocks/ShadowVpnService.scala
+7
-3
No files found.
src/main/AndroidManifest.xml
View file @
2eb0b193
...
@@ -16,13 +16,13 @@
...
@@ -16,13 +16,13 @@
android:targetSdkVersion=
"16"
/>
android:targetSdkVersion=
"16"
/>
<application
<application
android:name=
"
com.github.shadowsocks
.ShadowsocksApplication"
android:name=
".ShadowsocksApplication"
android:hardwareAccelerated=
"true"
android:hardwareAccelerated=
"true"
android:icon=
"@drawable/ic_launcher"
android:icon=
"@drawable/ic_launcher"
android:label=
"@string/app_name"
>
android:label=
"@string/app_name"
>
<activity
<activity
android:name=
"
com.github.shadowsocks
.Shadowsocks"
android:name=
".Shadowsocks"
android:label=
"@string/app_name"
android:label=
"@string/app_name"
android:theme=
"@style/Theme.GAEProxy"
android:theme=
"@style/Theme.GAEProxy"
android:launchMode=
"singleTask"
>
android:launchMode=
"singleTask"
>
...
@@ -33,7 +33,13 @@
...
@@ -33,7 +33,13 @@
</activity>
</activity>
<activity
<activity
android:name=
"com.github.shadowsocks.AppManager"
android:name=
".ShadowVpnActivity"
android:theme=
"@android:style/Theme.Translucent.NoTitleBar"
android:launchMode=
"singleTask"
>
</activity>
<activity
android:name=
".AppManager"
android:theme=
"@style/Theme.GAEProxy"
android:theme=
"@style/Theme.GAEProxy"
android:label=
"@string/app_name"
>
android:label=
"@string/app_name"
>
<intent-filter>
<intent-filter>
...
@@ -43,11 +49,11 @@
...
@@ -43,11 +49,11 @@
</activity>
</activity>
<service
<service
android:name=
"
com.github.shadowsocks
.ShadowsocksService"
android:name=
".ShadowsocksService"
android:enabled=
"true"
/>
android:enabled=
"true"
/>
<service
<service
android:name=
"
com.github.shadowsocks
.ShadowVpnService"
android:name=
".ShadowVpnService"
android:label=
"@string/app_name"
android:label=
"@string/app_name"
android:permission=
"android.permission.BIND_VPN_SERVICE"
android:permission=
"android.permission.BIND_VPN_SERVICE"
android:exported=
"false"
>
android:exported=
"false"
>
...
@@ -56,7 +62,7 @@
...
@@ -56,7 +62,7 @@
</intent-filter>
</intent-filter>
</service>
</service>
<receiver
android:name=
"
com.github.shadowsocks
.ShadowsocksReceiver"
>
<receiver
android:name=
".ShadowsocksReceiver"
>
<intent-filter>
<intent-filter>
<action
android:name=
"android.intent.action.BOOT_COMPLETED"
/>
<action
android:name=
"android.intent.action.BOOT_COMPLETED"
/>
</intent-filter>
</intent-filter>
...
...
src/main/scala/com/github/shadowsocks/ShadowVpnActivity.scala
0 → 100644
View file @
2eb0b193
package
com.github.shadowsocks
import
android.app.Activity
import
android.os.Bundle
import
android.net.VpnService
import
android.content.Intent
import
android.util.Log
class
ShadowVpnActivity
extends
Activity
{
override
def
onCreate
(
savedInstanceState
:
Bundle
)
{
super
.
onCreate
(
savedInstanceState
)
val
intent
=
VpnService
.
prepare
(
this
)
if
(
intent
!=
null
)
{
startActivityForResult
(
intent
,
Shadowsocks
.
REQUEST_CONNECT
)
}
else
{
onActivityResult
(
Shadowsocks
.
REQUEST_CONNECT
,
Activity
.
RESULT_OK
,
null
)
}
}
override
def
onActivityResult
(
requestCode
:
Int
,
resultCode
:
Int
,
data
:
Intent
)
{
resultCode
match
{
case
Activity
.
RESULT_OK
=>
{
val
it
:
Intent
=
new
Intent
(
this
,
classOf
[
ShadowVpnService
])
startService
(
it
)
}
case
_
=>
{
Log
.
e
(
Shadowsocks
.
TAG
,
"Failed to start VpnService"
)
}
}
finish
()
}
}
src/main/scala/com/github/shadowsocks/ShadowVpnService.scala
View file @
2eb0b193
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
*/
*/
package
com.github.shadowsocks
package
com.github.shadowsocks
import
android.app.
{
NotificationManager
,
Notification
,
PendingIntent
,
Service
}
import
android.app.
_
import
android.content._
import
android.content._
import
android.content.pm.PackageInfo
import
android.content.pm.PackageInfo
import
android.content.pm.PackageManager
import
android.content.pm.PackageManager
...
@@ -166,10 +166,15 @@ class ShadowVpnService extends VpnService {
...
@@ -166,10 +166,15 @@ class ShadowVpnService extends VpnService {
}
}
def
handleCommand
(
intent
:
Intent
)
{
def
handleCommand
(
intent
:
Intent
)
{
if
(
intent
==
null
)
{
if
(
VpnService
.
prepare
(
this
)
!=
null
)
{
val
i
=
new
Intent
(
this
,
classOf
[
ShadowVpnActivity
])
i
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
)
startActivity
(
i
)
stopSelf
()
stopSelf
()
return
return
}
}
appHost
=
settings
.
getString
(
"proxy"
,
"127.0.0.1"
)
appHost
=
settings
.
getString
(
"proxy"
,
"127.0.0.1"
)
sitekey
=
settings
.
getString
(
"sitekey"
,
"default"
)
sitekey
=
settings
.
getString
(
"sitekey"
,
"default"
)
encMethod
=
settings
.
getString
(
"encMethod"
,
"table"
)
encMethod
=
settings
.
getString
(
"encMethod"
,
"table"
)
...
@@ -362,7 +367,6 @@ class ShadowVpnService extends VpnService {
...
@@ -362,7 +367,6 @@ class ShadowVpnService extends VpnService {
super
.
onCreate
()
super
.
onCreate
()
EasyTracker
.
getTracker
.
sendEvent
(
"service"
,
"start"
,
getVersionName
,
0L
)
EasyTracker
.
getTracker
.
sendEvent
(
"service"
,
"start"
,
getVersionName
,
0L
)
settings
=
PreferenceManager
.
getDefaultSharedPreferences
(
this
)
settings
=
PreferenceManager
.
getDefaultSharedPreferences
(
this
)
notificationManager
=
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)
notificationManager
=
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)
.
asInstanceOf
[
NotificationManager
]
.
asInstanceOf
[
NotificationManager
]
...
...
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