Compare commits

..
35 Commits
Author SHA1 Message Date
Max Lv 0a400ef5f9 Trim the KCP parameters 2016-08-09 12:27:32 +08:00
Max Lv cda3650c43 Revert "Fix SecurityException on Asus Fonepads"
This reverts commit f7d422da2b.
2016-08-09 12:10:57 +08:00
Max Lv b1c19f8f03 Bump version 2016-08-09 11:53:13 +08:00
Mygod f7d422da2b Fix SecurityException on Asus Fonepads
This is a bug of their ROMs but the documentation says:

> Must be required by a VpnService, to ensure that only the system can bind to it.
>
> Protection level: signature
>
> Constant Value: "android.permission.BIND_VPN_SERVICE"

And we have `android:exported="false"` set, so I think it's safe to remove this permission restriction.
2016-08-09 10:45:02 +08:00
Mygod 10725c39cb Check QsTile is null 2016-08-09 10:33:03 +08:00
Mygod 4b5c94022b Update sbt-android 2016-08-09 10:16:01 +08:00
Mygod 6afc3f80be Revert "Update dependency (#799)"
This reverts commit a02d19bba0.
2016-08-09 10:12:56 +08:00
Syrone Wong a02d19bba0 Update dependency (#799)
* Run android-update before native building

* Update sbt-android to 1.6.11
2016-08-09 09:36:48 +08:00
Mygod 984e75ae99 Fix incorrect handling of default values on database upgrade 2016-08-09 04:34:51 +08:00
Mygod 3cc1a1602e Fix go install: no install location for directory again 2016-08-08 19:27:24 +08:00
Mygod 72305c5f60 Fix a bug in SummaryEditTextPreference 2016-08-08 18:47:26 +08:00
Mygod 4303c1cd0c Remove signing in Travis builds (#798) 2016-08-08 13:20:10 +08:00
Mygod 5dad89b71e Update prerequisites in README.md 2016-08-08 12:25:11 +08:00
Mygod 109d4728f4 Remove redundant platform-tools install for Travis 2016-08-08 12:12:37 +08:00
Mygod 53b9c1f4af Switch to Android platform on Travis 2016-08-08 11:58:44 +08:00
Mygod 23fc7e9134 Fix go install: no install location for directory error 2016-08-08 03:20:33 +08:00
Mygod e73fc9f881 Refine travis CI 2016-08-08 02:48:06 +08:00
Mygod 941393cab4 Update dependencies 2016-08-08 02:40:12 +08:00
Mygod a6e87cf666 Merge branch 'master' of github.com:shadowsocks/shadowsocks-android 2016-08-08 00:15:38 +08:00
Max Lv 4817539ca2 Fix UDP forward 2016-08-07 10:43:25 +08:00
Max Lv 03c857536d Fix the build scripts 2016-08-07 08:16:55 +08:00
Eva Kane 14038cd152 Fix remove problem (#793) 2016-08-06 23:10:04 +08:00
Syrone Wong 935314a1c5 Fix kcptun license in about page (#792)
Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
2016-08-06 22:37:41 +08:00
Max Lv 7263bf11a4 Update license 2016-08-06 19:36:10 +08:00
Max Lv e766ae2244 Fix the build sequence 2016-08-06 19:15:25 +08:00
Max Lv f3ed157145 Fix travis path 2016-08-06 19:00:45 +08:00
Max Lv eb0d5ceccc Fix travis 2016-08-06 18:57:09 +08:00
Max Lv 2ffbf4c56f Fix a typo 2016-08-06 18:55:48 +08:00
Max Lv 9ee3bab7e0 Update build scripts 2016-08-06 18:47:07 +08:00
Max Lv 70a7317a1e Update kcptun 2016-08-06 18:41:56 +08:00
Max Lv 43caaa684f Add submodules for kcptun 2016-08-06 18:22:27 +08:00
Max Lv 586c5e2ae4 Bump version 2016-08-06 17:25:10 +08:00
Max Lv 416d93062f Update kcptun 2016-08-06 13:01:40 +08:00
Max Lv 66ceed8607 Restart kcptun when switching network 2016-08-06 10:55:33 +08:00
Mygod 81295e4a51 Remove unnecessary padding for connection test text 2016-07-31 09:57:52 -06:00
31 changed files with 258 additions and 178 deletions
+1 -2
View File
@@ -14,6 +14,7 @@ gen_*
*.class
*.o
local.sbt
.deps
#Intellij IDEA
*.iml
@@ -27,7 +28,5 @@ out/
src/main/obj
src/main/libs
src/main/assets/armeabi-v7a/*
!src/main/assets/armeabi-v7a/kcptun
src/main/assets/x86/*
!src/main/assets/x86/kcptun
jni/Application.mk
+6
View File
@@ -24,3 +24,9 @@
path = src/main/jni/pdnsd
url = https://github.com/shadowsocks/pdnsd.git
branch = shadowsocks-android
[submodule "kcptun/kcptun"]
path = kcptun/kcptun
url = https://github.com/shadowsocks/kcptun
[submodule "kcptun/go"]
path = kcptun/go
url = https://github.com/shadowsocks/go
+34 -22
View File
@@ -1,19 +1,16 @@
language: scala
language: android
jdk:
- oraclejdk8
sudo: false
addons:
apt:
packages:
- gcc-multilib
- g++-multilib
- libstdc++6:i386
- libgcc1:i386
- zlib1g:i386
- libncurses5:i386
env:
global:
- NDK_VERSION=r12b
- NDK_CCACHE=ccache
- GOROOT_BOOTSTRAP=$GOROOT
- ANDROID_NDK_HOME=$HOME/.android/android-ndk-${NDK_VERSION}
- SBTPATH=$HOME/.sbt
- PATH=${ANDROID_NDK_HOME}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools:${PATH}
scala:
- 2.11.8
@@ -24,17 +21,32 @@ before_cache:
cache:
directories:
- $HOME/.ivy2/cache
- $HOME/.sbt/boot
- $HOME/.ivy2
- $HOME/.sbt
android:
components:
- tools
- build-tools-24.0.1
- extra-google-m2repository
install:
- ./travis-ci/setup.sh
- export NDK_CCACHE=ccache
- export ARCH=`uname -m`
- export ANDROID_NDK_HOME=$HOME/.android/android-ndk-r12b
- export ANDROID_HOME=$HOME/.android/android-sdk-linux
- export PATH=${ANDROID_NDK_HOME}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools:${PATH}
- cp local.properties.travis local.properties
- >
if [ ! -d "$ANDROID_NDK_HOME" ]; then
mkdir -p $ANDROID_NDK_HOME;
pushd $HOME/.android;
export ARCH=`uname -m`;
wget -q http://dl.google.com/android/repository/android-ndk-${NDK_VERSION}-linux-${ARCH}.zip;
unzip -q android-ndk-${NDK_VERSION}-linux-${ARCH}.zip;
popd;
fi
- >
if [ ! -f "$SBTPATH/sbt" ]; then
pushd $SBTPATH;
wget -q https://raw.githubusercontent.com/paulp/sbt-extras/master/sbt;
chmod a+x sbt;
popd;
fi
script:
- sbt native-build android:package-release
- $SBTPATH/sbt native-build android:package-debug
+8 -25
View File
@@ -12,13 +12,17 @@ A [shadowsocks](http://shadowsocks.org) client for Android, written in Scala.
* JDK 1.8
* SBT 0.13.0+
* Android SDK r25+
* Go 1.4+
* Android SDK
- Build Tools 24+ (as required by [`sbt-android`](https://github.com/scala-android/sbt-android))
- Google Repository (see `build.sbt` for version)
* Android NDK r12b+
### BUILD
* Set environment variable `ANDROID_HOME` to `/path/to/android-sdk`
* Set environment variable `ANDROID_NDK_HOME` to `/path/to/android-ndk`
* Set environment variable `GOROOT_BOOTSTRAP` to `/path/to/go`
* Create your key following the instructions at https://developer.android.com/studio/publish/app-signing.html
* Put your key in ~/.keystore
* Create `local.properties` from `local.properties.example` with your own key information
@@ -26,33 +30,11 @@ A [shadowsocks](http://shadowsocks.org) client for Android, written in Scala.
```bash
git submodule update --init
# Build the App
sbt native-build clean android:package-release
```
#### BUILD on Mac OS X (with HomeBrew)
* Install Android SDK and NDK by run `brew install android-ndk android-sdk`
* Add `export ANDROID_HOME=/usr/local/Cellar/android-sdk/$version` to your .bashrc , then reopen the shell to load it.
* Add `export ANDROID_NDK_HOME=/usr/local/Cellar/android-ndk/$version` to your .bashrc , then reopen the shell to load it.
* echo "y" | android update sdk --filter tools,platform-tools,build-tools-23.0.2,android-23,extra-google-m2repository --no-ui -a
* echo "y" | android update sdk --filter extra-android-m2repository --no-ui --no-https -a
* Create your key following the instructions at http://developer.android.com/guide/publishing/app-signing.html#cert
* Put your key in ~/.keystore
* Create `local.properties` from `local.properties.example` with your own key information .
* Invoke the building like this
```bash
git submodule update --init
# Build native binaries
./build.sh
# Build the apk
sbt clean android:package-release
```
## OPEN SOURCE LICENSES
* shadowsocks-libev: [GPLv3](https://github.com/shadowsocks/shadowsocks-libev/blob/master/LICENSE)
@@ -62,10 +44,11 @@ A [shadowsocks](http://shadowsocks.org) client for Android, written in Scala.
* pdnsd: [GPLv3](https://github.com/shadowsocks/shadowsocks-android/blob/master/src/main/jni/pdnsd/COPYING)
* libev: [GPLv2](https://github.com/shadowsocks/shadowsocks-android/blob/master/src/main/jni/libev/LICENSE)
* libevent: [BSD](https://github.com/shadowsocks/libevent/blob/master/LICENSE)
* kcptun: [MIT](https://github.com/xtaci/kcptun)
### LICENSE
Copyright (C) 2016 by Max Lv <<max.c.lv@gmail.com>> <br/>
Copyright (C) 2016 by Max Lv <<max.c.lv@gmail.com>>
Copyright (C) 2016 by Mygod Studio <<mygodstudio@gmail.com>>
This program is free software: you can redistribute it and/or modify
+9 -13
View File
@@ -37,16 +37,16 @@ libraryDependencies ++= Seq(
"com.github.kevinsawicki" % "http-request" % "6.0",
"eu.chainfire" % "libsuperuser" % "1.0.0.201607041850",
"net.glxn.qrgen" % "android" % "2.0",
"com.google.android.gms" % "play-services-ads" % "9.2.1",
"com.google.android.gms" % "play-services-analytics" % "9.2.1",
"com.android.support" % "design" % "24.1.0",
"com.android.support" % "gridlayout-v7" % "24.1.0",
"com.android.support" % "cardview-v7" % "24.1.0",
"com.google.android.gms" % "play-services-ads" % "9.4.0",
"com.google.android.gms" % "play-services-analytics" % "9.4.0",
"com.android.support" % "design" % "24.1.1",
"com.android.support" % "gridlayout-v7" % "24.1.1",
"com.android.support" % "cardview-v7" % "24.1.1",
"com.github.jorgecastilloprz" % "fabprogresscircle" % "1.01",
"com.j256.ormlite" % "ormlite-android" % "4.48",
"com.j256.ormlite" % "ormlite-android" % "5.0",
"com.twofortyfouram" % "android-plugin-api-for-locale" % "1.0.2",
"com.github.clans" % "fab" % "1.6.4",
"me.dm7.barcodescanner" % "zxing" % "1.8.4"
"me.dm7.barcodescanner" % "zxing" % "1.9"
)
proguardVersion in Android := "5.2.1"
@@ -55,12 +55,8 @@ proguardCache in Android := Seq()
proguardOptions in Android ++= Seq(
"-keep class com.github.shadowsocks.System { *; }",
"-dontwarn com.google.android.gms.**",
"-keep class com.google.android.gms.**",
"-dontnote com.google.android.gms.internal.**",
"-dontnote com.j256.ormlite.**",
"-dontnote me.dm7.barcodescannerview.**",
"-dontnote org.xbill.**",
"-dontwarn com.google.android.gms.internal.**",
"-dontwarn com.j256.ormlite.**",
"-dontwarn org.xbill.**")
lazy val nativeBuild = TaskKey[Unit]("native-build", "Build native executables")
+14 -8
View File
@@ -4,19 +4,25 @@ function try () {
"$@" || exit -1
}
try pushd src/main
# Build
#try $ANDROID_NDK_HOME/ndk-build clean
# Build native binaries
pushd src/main
try $ANDROID_NDK_HOME/ndk-build -j8
# copy executables
rm -rf assets/armeabi-v7a
rm -rf assets/x86
mkdir -p assets/armeabi-v7a
mkdir -p assets/x86
#copy executables
for app in pdnsd redsocks ss-local ss-tunnel tun2socks
do
rm -f assets/armeabi-v7a/$app
rm -f assets/x86/$app
echo $app
try mv libs/armeabi-v7a/$app assets/armeabi-v7a/
try mv libs/x86/$app assets/x86/
done
popd
try popd
# Build kcptun
pushd kcptun
try ./make.bash
popd
-3
View File
@@ -1,3 +0,0 @@
#!/bin/bash
cd ${1}
travis-artifacts upload --path ${2} --target-path nightly
Submodule
+1
Submodule kcptun/go added at f3e7e7b69f
Submodule
+1
Submodule kcptun/kcptun added at eced3949b2
+67
View File
@@ -0,0 +1,67 @@
#!/bin/bash
function try () {
"$@" || exit -1
}
[ -z "$ANDROID_NDK_HOME" ] && ANDROID_NDK_HOME=~/android-ndk-r12b
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
DEPS=$DIR/.deps
ANDROID_ARM_TOOLCHAIN=$DEPS/android-toolchain-16-arm
ANDROID_X86_TOOLCHAIN=$DEPS/android-toolchain-16-x86
ANDROID_ARM_CC=$ANDROID_ARM_TOOLCHAIN/bin/arm-linux-androideabi-gcc
ANDROID_ARM_STRIP=$ANDROID_ARM_TOOLCHAIN/bin/arm-linux-androideabi-strip
ANDROID_X86_CC=$ANDROID_X86_TOOLCHAIN/bin/i686-linux-android-gcc
ANDROID_X86_STRIP=$ANDROID_X86_TOOLCHAIN/bin/i686-linux-android-strip
if [ ! -d "$DEPS" ]; then
mkdir -p $DEPS
fi
if [ ! -d "$ANDROID_ARM_TOOLCHAIN" ]; then
echo "Make standalone toolchain for ARM arch"
$ANDROID_NDK_HOME/build/tools/make_standalone_toolchain.py --arch arm \
--api 16 --install-dir $ANDROID_ARM_TOOLCHAIN
fi
if [ ! -d "$ANDROID_X86_TOOLCHAIN" ]; then
echo "Make standalone toolchain for X86 arch"
$ANDROID_NDK_HOME/build/tools/make_standalone_toolchain.py --arch x86 \
--api 16 --install-dir $ANDROID_X86_TOOLCHAIN
fi
if [ ! -d "$DIR/go/bin" ]; then
echo "Build the custom go"
pushd $DIR/go/src
try ./make.bash
popd
fi
export GOROOT=$DIR/go
export GOPATH=$HOME
export GOBIN=$GOPATH/bin
mkdir $GOBIN
export PATH=$GOROOT/bin:$PATH
pushd kcptun/client
echo "Get dependences for kcptun"
go get
echo "Cross compile kcptun for arm"
try env CGO_ENABLED=1 CC=$ANDROID_ARM_CC GOOS=android GOARCH=arm GOARM=7 go build
try $ANDROID_ARM_STRIP client
try mv client $DIR/../src/main/assets/armeabi-v7a/kcptun
echo "Cross compile kcptun for x86"
try env CGO_ENABLED=1 CC=$ANDROID_X86_CC GOOS=android GOARCH=386 go build
try $ANDROID_X86_STRIP client
try mv client $DIR/../src/main/assets/x86/kcptun
popd
echo "Successfully build kcptun"
-3
View File
@@ -1,3 +0,0 @@
key.alias: travis
key.store: travis.keystore
key.store.password: travis
+1 -1
View File
@@ -1,4 +1,4 @@
addSbtPlugin("org.scala-android" % "sbt-android" % "1.6.10")
addSbtPlugin("org.scala-android" % "sbt-android" % "1.6.12")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.1.10")
+2 -2
View File
@@ -1,7 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" package="com.github.shadowsocks"
android:versionCode="142"
android:versionName="3.0.0">
android:versionCode="145"
android:versionName="3.0.3">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Binary file not shown.
+1
View File
@@ -296,6 +296,7 @@ along with this program. If not, see <a href="http://www.gnu.org/licenses/">http
<li>pdnsd: <a href="https://github.com/shadowsocks/shadowsocks-android/blob/master/src/main/jni/pdnsd/COPYING">GPLv3</a></li>
<li>libev: <a href="https://github.com/shadowsocks/libevent/blob/shadowsocks-android/LICENSE">GPLv2</a></li>
<li>libevent: <a href="https://github.com/shadowsocks/shadowsocks-android/blob/master/src/main/jni/libevent/LICENSE">BSD</a></li>
<li>kcptun: <a href="https://github.com/xtaci/kcptun/commits/master/LICENSE.md">MIT</a></li>
</ul>
</body>
Binary file not shown.
@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="wrap_content">
<TextView android:text="@string/stat" android:textSize="16sp"
android:textColor="?android:attr/textColorPrimary" android:ellipsize="marquee"
android:layout_width="wrap_content" android:layout_height="wrap_content"/>
<TextView android:id="@+id/connection_test" android:gravity="end"
android:textSize="14sp" android:textColor="?android:attr/textColorSecondary"
android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1"/>
</LinearLayout>
+22 -4
View File
@@ -10,13 +10,31 @@
<LinearLayout android:id="@+id/stat" android:elevation="4dp" android:visibility="gone"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight" android:gravity="center_vertical"
android:paddingStart="16dip" android:paddingEnd="88dip" android:focusable="true"
android:paddingLeft="16dip" android:paddingRight="88dip"
android:paddingStart="16dip" android:paddingEnd="16dip" android:focusable="true"
android:paddingLeft="16dip" android:paddingRight="16dip"
android:paddingTop="16dip" android:paddingBottom="16dip"
android:background="@drawable/background_stat" android:orientation="vertical">
<include layout="@layout/layout_main_stat_title"/>
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView android:text="@string/stat"
android:textSize="16sp"
android:textColor="?android:attr/textColorPrimary"
android:ellipsize="marquee"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/connection_test"
android:gravity="end"
android:textSize="14sp"
android:textColor="?android:attr/textColorSecondary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
<android.support.v7.widget.GridLayout android:layout_width="match_parent"
android:layout_height="wrap_content" app:columnCount="4">
android:layout_height="wrap_content"
android:paddingEnd="72dip"
android:paddingRight="72dip"
app:columnCount="4">
<TextView app:layout_column="0" style="@style/TextAppearance.AppCompat.Body2"
android:ellipsize="marquee" android:text="@string/sent"
android:layout_width="wrap_content" android:layout_height="wrap_content"
@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical"
android:layout_width="match_parent" android:layout_height="wrap_content">
<TextView android:text="@string/stat" android:textSize="16sp"
android:textColor="?android:attr/textColorPrimary" android:ellipsize="marquee"
android:layout_width="match_parent" android:layout_height="wrap_content"/>
<TextView android:id="@+id/connection_test"
android:textSize="14sp" android:textColor="?android:attr/textColorSecondary"
android:layout_width="match_parent" android:layout_height="wrap_content"/>
</LinearLayout>
@@ -43,10 +43,12 @@ import java.util.{Timer, TimerTask}
import android.app.Service
import android.content.{BroadcastReceiver, Context, Intent, IntentFilter}
import android.net.ConnectivityManager
import android.os.{Handler, RemoteCallbackList}
import android.text.TextUtils
import android.util.Log
import android.widget.Toast
import com.github.kevinsawicki.http.HttpRequest
import com.github.shadowsocks.aidl.{IShadowsocksService, IShadowsocksServiceCallback}
import com.github.shadowsocks.utils._
@@ -71,6 +73,16 @@ trait BaseService extends Service {
}
var closeReceiverRegistered: Boolean = _
var kcptunProcess: GuardedProcess = _
private val networkReceiver: BroadcastReceiver = (context: Context, intent: Intent) => {
val cm = context.getSystemService(Context.CONNECTIVITY_SERVICE).asInstanceOf[ConnectivityManager]
val activeNetwork = cm.getActiveNetworkInfo()
val isConnected = activeNetwork != null && activeNetwork.isConnected()
if (isConnected && profile.kcp && kcptunProcess != null) kcptunProcess.restart()
}
var networkReceiverRegistered: Boolean = _
val binder = new IShadowsocksService.Stub {
override def getState: Int = {
state
@@ -162,6 +174,14 @@ trait BaseService extends Service {
closeReceiverRegistered = true
}
if (profile.kcp && !networkReceiverRegistered) {
// register network change receiver
val filter = new IntentFilter()
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION)
registerReceiver(networkReceiver, filter)
networkReceiverRegistered = true
}
app.track(getClass.getSimpleName, "start")
changeState(State.CONNECTING)
@@ -177,6 +197,10 @@ trait BaseService extends Service {
unregisterReceiver(closeReceiver)
closeReceiverRegistered = false
}
if (networkReceiverRegistered) {
unregisterReceiver(networkReceiver)
networkReceiverRegistered = false
}
// Make sure update total traffic when stopping the runner
updateTrafficTotal(TrafficMonitor.txTotal, TrafficMonitor.rxTotal)
@@ -56,6 +56,7 @@ class GuardedProcess(cmd: Seq[String]) extends Process {
@volatile private var guardThread: Thread = _
@volatile private var isDestroyed: Boolean = _
@volatile private var process: Process = _
@volatile private var isRestart = false
def start(onRestartCallback: () => Unit = null): GuardedProcess = {
val semaphore = new Semaphore(1)
@@ -76,9 +77,13 @@ class GuardedProcess(cmd: Seq[String]) extends Process {
semaphore.release
process.waitFor
if (currentTimeMillis - startTime < 1000) {
Log.w(TAG, "process exit too fast, stop guard: " + cmd)
isDestroyed = true
if (isRestart) {
isRestart = false
} else {
if (currentTimeMillis - startTime < 1000) {
Log.w(TAG, "process exit too fast, stop guard: " + cmd)
isDestroyed = true
}
}
}
} catch {
@@ -108,6 +113,11 @@ class GuardedProcess(cmd: Seq[String]) extends Process {
}
}
def restart() {
isRestart = true
process.destroy()
}
def exitValue: Int = throw new UnsupportedOperationException
def getErrorStream: InputStream = throw new UnsupportedOperationException
def getInputStream: InputStream = throw new UnsupportedOperationException
@@ -481,7 +481,7 @@ class Shadowsocks extends AppCompatActivity with ServiceBoundContext {
private def updatePreferenceScreen(profile: Profile) {
if (profile.host == "198.199.101.152") if (adView == null) {
adView = new AdView(this)
adView.setAdUnitId("ca-app-pub-9097031975646651/7760346322")
adView.setAdUnitId("ca-app-pub-4984938374218635/1433320509")
adView.setAdSize(AdSize.SMART_BANNER)
preferences.getView.asInstanceOf[ViewGroup].addView(adView, 1)
adView.loadAd(new AdRequest.Builder().build())
@@ -65,7 +65,6 @@ class ShadowsocksNatService extends BaseService {
private var notification: ShadowsocksNotification = _
val myUid = android.os.Process.myUid()
var kcptunProcess: Process = _
var sslocalProcess: Process = _
var sstunnelProcess: Process = _
var redsocksProcess: Process = _
@@ -117,12 +116,13 @@ class ShadowsocksNatService extends BaseService {
}
def startKcptunDaemon() {
if (profile.kcpcli == null) profile.kcpcli = ""
val cmd = new ArrayBuffer[String]
cmd += (getApplicationInfo.dataDir + "/kcptun"
, "-r", profile.host + ":" + profile.kcpPort
, "-l", "127.0.0.1:" + (profile.localPort + 90)
, profile.kcpcli)
, profile.kcpcli.trim)
if (BuildConfig.DEBUG) Log.d(TAG, cmd.mkString(" "))
@@ -36,10 +36,8 @@ object ShadowsocksSettings {
}
def updateSummaryEditTextPreference(pref: Preference, value: String) {
if (value != null) {
pref.setSummary(value)
pref.asInstanceOf[SummaryEditTextPreference].setText(value)
}
pref.setSummary(value)
pref.asInstanceOf[SummaryEditTextPreference].setText(value)
}
def updateSwitchPreference(pref: Preference, value: Boolean) {
@@ -25,24 +25,26 @@ final class ShadowsocksTileService extends TileService with ServiceBoundContext
def trafficUpdated(txRate: Long, rxRate: Long, txTotal: Long, rxTotal: Long) = ()
def stateChanged(state: Int, msg: String) {
val tile = getQsTile
state match {
case State.STOPPED =>
tile.setIcon(iconIdle)
tile.setLabel(getString(R.string.app_name))
tile.setState(Tile.STATE_INACTIVE)
case State.CONNECTED =>
tile.setIcon(iconConnected)
tile.setLabel(app.currentProfile match {
case Some(profile) => profile.name
case None => getString(R.string.app_name)
})
tile.setState(Tile.STATE_ACTIVE)
case _ =>
tile.setIcon(iconBusy)
tile.setLabel(getString(R.string.app_name))
tile.setState(Tile.STATE_UNAVAILABLE)
if (tile != null) {
state match {
case State.STOPPED =>
tile.setIcon(iconIdle)
tile.setLabel(getString(R.string.app_name))
tile.setState(Tile.STATE_INACTIVE)
case State.CONNECTED =>
tile.setIcon(iconConnected)
tile.setLabel(app.currentProfile match {
case Some(profile) => profile.name
case None => getString(R.string.app_name)
})
tile.setState(Tile.STATE_ACTIVE)
case _ =>
tile.setIcon(iconBusy)
tile.setLabel(getString(R.string.app_name))
tile.setState(Tile.STATE_UNAVAILABLE)
}
tile.updateTile
}
tile.updateTile
}
}
@@ -63,7 +63,6 @@ class ShadowsocksVpnService extends VpnService with BaseService {
var vpnThread: ShadowsocksVpnThread = _
private var notification: ShadowsocksNotification = _
var kcptunProcess: Process = _
var sslocalProcess: Process = _
var sstunnelProcess: Process = _
var pdnsdProcess: Process = _
@@ -183,34 +182,36 @@ class ShadowsocksVpnService extends VpnService with BaseService {
/** Called when the activity is first created. */
def handleConnection: Boolean = {
val fd = startVpn()
if (!sendFd(fd)) return false
if (profile.kcp) {
startKcptunDaemon()
}
startShadowsocksDaemon()
if (profile.udpdns && profile.kcp) {
startShadowsocksUDPDaemon()
}
if (!profile.udpdns) {
startDnsDaemon()
startDnsTunnel()
}
startShadowsocksDaemon()
if (profile.udpdns) {
startShadowsocksUDPDaemon()
}
val fd = startVpn()
val ret = sendFd(fd)
if (ret && profile.kcp) {
startKcptunDaemon()
}
ret
true
}
def startKcptunDaemon() {
if (profile.kcpcli == null) profile.kcpcli = ""
val cmd = new ArrayBuffer[String]
cmd += (getApplicationInfo.dataDir + "/kcptun"
, "-r", profile.host + ":" + profile.kcpPort
, "-l", "127.0.0.1:" + (profile.localPort + 90)
, "--path", getApplicationInfo.dataDir + "/protect_path"
, profile.kcpcli)
, profile.kcpcli.trim)
if (BuildConfig.DEBUG)
Log.d(TAG, cmd.mkString(" "))
@@ -275,6 +276,8 @@ class ShadowsocksVpnService extends VpnService with BaseService {
if (profile.auth) cmd += "-A"
if (profile.udpdns && !profile.kcp) cmd += "-u"
if (profile.route != Route.ALL) {
cmd += "--acl"
cmd += (getApplicationInfo.dataDir + "/acl.list")
@@ -64,7 +64,7 @@ object DBHelper {
}
class DBHelper(val context: Context)
extends OrmLiteSqliteOpenHelper(context, DBHelper.PROFILE, null, 18) {
extends OrmLiteSqliteOpenHelper(context, DBHelper.PROFILE, null, 19) {
import DBHelper._
lazy val profileDao: Dao[Profile, Int] = getDao(classOf[Profile])
@@ -83,10 +83,11 @@ class DBHelper(val context: Context)
}
if (oldVersion < 8) {
profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN udpdns SMALLINT;")
profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN route VARCHAR;")
}
if (oldVersion < 9) {
profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN route VARCHAR;")
profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN route VARCHAR DEFAULT 'all';")
} else if (oldVersion < 19) {
profileDao.executeRawNoArgs("UPDATE `profile` SET route = 'all' WHERE route IS NULL;")
}
if (oldVersion < 10) {
profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN auth SMALLINT;")
@@ -128,11 +129,13 @@ class DBHelper(val context: Context)
if (oldVersion < 17) {
profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN kcp SMALLINT;")
profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN kcpcli VARCHAR;")
profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN kcpcli VARCHAR DEFAULT '';")
}
if (oldVersion < 18) {
profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN kcpPort INTEGER;")
profileDao.executeRawNoArgs("ALTER TABLE `profile` ADD COLUMN kcpPort INTEGER DEFAULT 8399;")
} else if (oldVersion < 19) {
profileDao.executeRawNoArgs("UPDATE `profile` SET kcpPort = 8399 WHERE kcpPort = 0;")
}
}
}
@@ -41,6 +41,7 @@ package com.github.shadowsocks.preferences
import android.content.Context
import android.preference.EditTextPreference
import android.text.TextUtils
import android.util.AttributeSet
class SummaryEditTextPreference(context: Context, attrs: AttributeSet, defStyle: Int)
@@ -57,7 +58,7 @@ class SummaryEditTextPreference(context: Context, attrs: AttributeSet, defStyle:
}
override def setSummary(summary: CharSequence) {
if (summary.toString.isEmpty) {
if (TextUtils.isEmpty(summary)) {
super.setSummary(mDefaultSummary)
} else {
super.setSummary(summary)
-25
View File
@@ -1,25 +0,0 @@
#!/bin/bash
export ARCH=`uname -m`
export ANDROID_NDK_HOME=$HOME/.android/android-ndk-r12b
export ANDROID_HOME=$HOME/.android/android-sdk-linux
export PATH=${ANDROID_NDK_HOME}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools:${PATH}
if [ ! -d "$ANDROID_HOME" ]; then
mkdir -p $ANDROID_HOME
pushd $HOME/.android
wget -q http://dl.google.com/android/android-sdk_r24.4.1-linux.tgz
tar xf android-sdk_r24.4.1-linux.tgz
popd
fi
if [ ! -d "$ANDROID_NDK_HOME" ]; then
mkdir -p $ANDROID_NDK_HOME
pushd $HOME/.android
wget -q http://dl.google.com/android/repository/android-ndk-r12b-linux-${ARCH}.zip
unzip -q android-ndk-r12b-linux-${ARCH}.zip
popd
fi
( sleep 5 && while [ 1 ]; do sleep 1; echo y; done ) | android update sdk --filter tools,platform-tools,build-tools-24.0.0,android-23,android-24,extra-google-m2repository --no-ui -a
( sleep 5 && while [ 1 ]; do sleep 1; echo y; done ) | android update sdk --filter extra-android-m2repository --no-ui -a
BIN
View File
Binary file not shown.