diff --git a/mobile/src/main/scala/com/github/shadowsocks/BaseService.scala b/mobile/src/main/scala/com/github/shadowsocks/BaseService.scala index 30e4b977..3c9835e1 100644 --- a/mobile/src/main/scala/com/github/shadowsocks/BaseService.scala +++ b/mobile/src/main/scala/com/github/shadowsocks/BaseService.scala @@ -21,16 +21,14 @@ package com.github.shadowsocks import java.io.{File, IOException} +import java.net.{Inet6Address, InetAddress} import java.util import java.util.concurrent.TimeUnit import java.util.{Timer, TimerTask} -import java.net.InetAddress -import java.net.Inet6Address import android.app.Service import android.content.{BroadcastReceiver, Context, Intent, IntentFilter} -import android.os.{Handler, IBinder, RemoteCallbackList} -import android.support.v4.os.BuildCompat +import android.os.{Build, Handler, IBinder, RemoteCallbackList} import android.text.TextUtils import android.util.Log import android.widget.Toast @@ -166,7 +164,7 @@ trait BaseService extends Service { def startRunner(profile: Profile) { this.profile = profile - if (BuildCompat.isAtLeastO) startForegroundService(new Intent(this, getClass)) + if (Build.VERSION.SDK_INT >= 26) startForegroundService(new Intent(this, getClass)) else startService(new Intent(this, getClass)) TrafficMonitor.reset() trafficMonitorThread = new TrafficMonitorThread(getApplicationContext) diff --git a/mobile/src/main/scala/com/github/shadowsocks/ShadowsocksApplication.scala b/mobile/src/main/scala/com/github/shadowsocks/ShadowsocksApplication.scala index 72f8b006..9ad88c31 100644 --- a/mobile/src/main/scala/com/github/shadowsocks/ShadowsocksApplication.scala +++ b/mobile/src/main/scala/com/github/shadowsocks/ShadowsocksApplication.scala @@ -29,7 +29,6 @@ import android.content._ import android.content.res.Configuration import android.os.{Build, LocaleList} import android.preference.PreferenceManager -import android.support.v4.os.BuildCompat import android.support.v7.app.AppCompatDelegate import android.util.Log import com.evernote.android.job.JobManager @@ -43,8 +42,8 @@ import com.google.firebase.remoteconfig.FirebaseRemoteConfig import com.j256.ormlite.logger.LocalLog import eu.chainfire.libsuperuser.Shell -import scala.collection.mutable.ArrayBuffer import scala.collection.JavaConversions._ +import scala.collection.mutable.ArrayBuffer object ShadowsocksApplication { var app: ShadowsocksApplication = _ @@ -157,7 +156,7 @@ class ShadowsocksApplication extends Application { TcpFastOpen.enabled(settings.getBoolean(Key.tfo, TcpFastOpen.sendEnabled)) - if (BuildCompat.isAtLeastO) getSystemService(classOf[NotificationManager]).createNotificationChannels(List( + if (Build.VERSION.SDK_INT >= 26) getSystemService(classOf[NotificationManager]).createNotificationChannels(List( new NotificationChannel("service-vpn", getText(R.string.service_vpn), NotificationManager.IMPORTANCE_MIN), new NotificationChannel("service-nat", getText(R.string.service_nat), NotificationManager.IMPORTANCE_LOW) )) diff --git a/mobile/src/main/scala/com/github/shadowsocks/ShadowsocksRunnerService.scala b/mobile/src/main/scala/com/github/shadowsocks/ShadowsocksRunnerService.scala index 75f7d832..6c089d02 100644 --- a/mobile/src/main/scala/com/github/shadowsocks/ShadowsocksRunnerService.scala +++ b/mobile/src/main/scala/com/github/shadowsocks/ShadowsocksRunnerService.scala @@ -23,7 +23,7 @@ package com.github.shadowsocks import android.app.Service import android.content.Intent import android.net.VpnService -import android.os.{Handler, IBinder} +import android.os.{Build, Handler, IBinder} import android.support.v4.app.NotificationCompat import android.support.v4.os.BuildCompat import com.github.shadowsocks.ShadowsocksApplication.app @@ -49,7 +49,7 @@ class ShadowsocksRunnerService extends Service with ServiceBoundContext { override def onCreate() { super.onCreate() - if (BuildCompat.isAtLeastO) { + if (Build.VERSION.SDK_INT >= 26) { val builder = new NotificationCompat.Builder(this) builder.setPriority(NotificationCompat.PRIORITY_MIN) startForeground(1, builder.build) diff --git a/mobile/src/main/scala/com/github/shadowsocks/utils/Utils.scala b/mobile/src/main/scala/com/github/shadowsocks/utils/Utils.scala index 29c54340..5bda5098 100644 --- a/mobile/src/main/scala/com/github/shadowsocks/utils/Utils.scala +++ b/mobile/src/main/scala/com/github/shadowsocks/utils/Utils.scala @@ -28,7 +28,6 @@ import android.content.pm.PackageManager import android.content.{Context, Intent} import android.graphics._ import android.os.Build -import android.support.v4.os.BuildCompat import android.util.{Base64, DisplayMetrics, Log} import android.view.View.MeasureSpec import android.view.{Gravity, View, Window} @@ -139,7 +138,7 @@ object Utils { def startSsService(context: Context) { val intent = new Intent(context, classOf[ShadowsocksRunnerService]) - if (BuildCompat.isAtLeastO) context.startForegroundService(intent) + if (Build.VERSION.SDK_INT >= 26) context.startForegroundService(intent) else context.startService(intent) }