Skip to content

Commit 75a35d3

Browse files
committed
Make linter happy
1 parent 78dd252 commit 75a35d3

23 files changed

+53
-34
lines changed

app/src/main/java/io/nekohasekai/sfa/Application.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class Application : Application() {
3131

3232
Seq.setContext(this)
3333

34+
@Suppress("OPT_IN_USAGE")
3435
GlobalScope.launch(Dispatchers.IO) {
3536
UpdateProfileWork.reconfigureUpdater()
3637
}

app/src/main/java/io/nekohasekai/sfa/bg/AppChangeReceiver.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ class AppChangeReceiver : BroadcastReceiver() {
1515

1616
override fun onReceive(context: Context, intent: Intent) {
1717
Log.d(TAG, "onReceive: ${intent.action}")
18-
checkUpdate(context, intent)
18+
checkUpdate(intent)
1919
}
2020

21-
private fun checkUpdate(context: Context, intent: Intent) {
21+
private fun checkUpdate(intent: Intent) {
2222
if (!Settings.perAppProxyEnabled) {
2323
Log.d(TAG, "per app proxy disabled")
2424
return

app/src/main/java/io/nekohasekai/sfa/bg/BootReceiver.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ import android.content.BroadcastReceiver
44
import android.content.Context
55
import android.content.Intent
66
import io.nekohasekai.sfa.database.Settings
7+
import kotlinx.coroutines.DelicateCoroutinesApi
78
import kotlinx.coroutines.Dispatchers
89
import kotlinx.coroutines.GlobalScope
910
import kotlinx.coroutines.launch
1011
import kotlinx.coroutines.withContext
1112

1213
class BootReceiver : BroadcastReceiver() {
1314

15+
@OptIn(DelicateCoroutinesApi::class)
1416
override fun onReceive(context: Context, intent: Intent) {
1517
when (intent.action) {
1618
Intent.ACTION_BOOT_COMPLETED, Intent.ACTION_MY_PACKAGE_REPLACED -> {

app/src/main/java/io/nekohasekai/sfa/bg/BoxService.kt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import io.nekohasekai.sfa.constant.Status
2727
import io.nekohasekai.sfa.database.ProfileManager
2828
import io.nekohasekai.sfa.database.Settings
2929
import io.nekohasekai.sfa.ktx.hasPermission
30+
import kotlinx.coroutines.DelicateCoroutinesApi
3031
import kotlinx.coroutines.Dispatchers
3132
import kotlinx.coroutines.GlobalScope
3233
import kotlinx.coroutines.delay
@@ -243,6 +244,7 @@ class BoxService(
243244
}
244245
}
245246

247+
@OptIn(DelicateCoroutinesApi::class)
246248
private fun stopService() {
247249
if (status.value != Status.Started) return
248250
status.value = Status.Stopping
@@ -298,7 +300,9 @@ class BoxService(
298300
}
299301
}
300302

301-
fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
303+
@OptIn(DelicateCoroutinesApi::class)
304+
@Suppress("SameReturnValue")
305+
internal fun onStartCommand(): Int {
302306
if (status.value != Status.Stopped) return Service.START_NOT_STICKY
303307
status.value = Status.Starting
304308

@@ -327,19 +331,19 @@ class BoxService(
327331
return Service.START_NOT_STICKY
328332
}
329333

330-
fun onBind(intent: Intent): IBinder {
334+
internal fun onBind(): IBinder {
331335
return binder
332336
}
333337

334-
fun onDestroy() {
338+
internal fun onDestroy() {
335339
binder.close()
336340
}
337341

338-
fun onRevoke() {
342+
internal fun onRevoke() {
339343
stopService()
340344
}
341345

342-
fun writeLog(message: String) {
346+
internal fun writeLog(message: String) {
343347
binder.broadcast {
344348
it.onServiceWriteLog(message)
345349
}

app/src/main/java/io/nekohasekai/sfa/bg/DefaultNetworkListener.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ import android.os.Handler
3030
import android.os.Looper
3131
import io.nekohasekai.sfa.Application
3232
import kotlinx.coroutines.CompletableDeferred
33+
import kotlinx.coroutines.DelicateCoroutinesApi
3334
import kotlinx.coroutines.Dispatchers
3435
import kotlinx.coroutines.GlobalScope
36+
import kotlinx.coroutines.ObsoleteCoroutinesApi
3537
import kotlinx.coroutines.channels.actor
3638
import kotlinx.coroutines.runBlocking
3739

@@ -49,6 +51,7 @@ object DefaultNetworkListener {
4951
class Lost(val network: Network) : NetworkMessage()
5052
}
5153

54+
@OptIn(DelicateCoroutinesApi::class, ObsoleteCoroutinesApi::class)
5255
private val networkActor = GlobalScope.actor<NetworkMessage>(Dispatchers.Unconfined) {
5356
val listeners = mutableMapOf<Any, (Network?) -> Unit>()
5457
var network: Network? = null

app/src/main/java/io/nekohasekai/sfa/bg/PlatformInterfaceWrapper.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ interface PlatformInterfaceWrapper : PlatformInterface {
103103
}
104104

105105
override fun readWIFIState(): WIFIState? {
106+
@Suppress("DEPRECATION")
106107
val wifiInfo = Application.wifiManager.connectionInfo ?: return null
107108
var ssid = wifiInfo.ssid
108109
if (ssid.startsWith("\"") && ssid.endsWith("\"")) {

app/src/main/java/io/nekohasekai/sfa/bg/ProxyService.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ class ProxyService : Service(), PlatformInterfaceWrapper {
88
private val service = BoxService(this, this)
99

1010
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int) =
11-
service.onStartCommand(intent, flags, startId)
11+
service.onStartCommand()
1212

13-
override fun onBind(intent: Intent) = service.onBind(intent)
13+
override fun onBind(intent: Intent) = service.onBind()
1414
override fun onDestroy() = service.onDestroy()
1515

1616
override fun writeLog(message: String) = service.writeLog(message)

app/src/main/java/io/nekohasekai/sfa/bg/ServiceBinder.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import androidx.lifecycle.MutableLiveData
55
import io.nekohasekai.sfa.aidl.IService
66
import io.nekohasekai.sfa.aidl.IServiceCallback
77
import io.nekohasekai.sfa.constant.Status
8+
import kotlinx.coroutines.DelicateCoroutinesApi
89
import kotlinx.coroutines.Dispatchers
910
import kotlinx.coroutines.GlobalScope
1011
import kotlinx.coroutines.launch
@@ -23,6 +24,7 @@ class ServiceBinder(private val status: MutableLiveData<Status>) : IService.Stub
2324
}
2425
}
2526

27+
@OptIn(DelicateCoroutinesApi::class)
2628
fun broadcast(work: (IServiceCallback) -> Unit) {
2729
GlobalScope.launch(Dispatchers.Main) {
2830
broadcastLock.withLock {

app/src/main/java/io/nekohasekai/sfa/bg/ServiceNotification.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import io.nekohasekai.sfa.constant.Status
2222
import io.nekohasekai.sfa.database.Settings
2323
import io.nekohasekai.sfa.ui.MainActivity
2424
import io.nekohasekai.sfa.utils.CommandClient
25+
import kotlinx.coroutines.DelicateCoroutinesApi
2526
import kotlinx.coroutines.Dispatchers
2627
import kotlinx.coroutines.GlobalScope
2728
import kotlinx.coroutines.withContext
@@ -43,6 +44,7 @@ class ServiceNotification(
4344
}
4445
}
4546

47+
@OptIn(DelicateCoroutinesApi::class)
4648
private val commandClient =
4749
CommandClient(GlobalScope, CommandClient.ConnectionType.Status, this)
4850
private var receiverRegistered = false

app/src/main/java/io/nekohasekai/sfa/bg/VPNService.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ class VPNService : VpnService(), PlatformInterfaceWrapper {
2222
private val service = BoxService(this, this)
2323

2424
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int) =
25-
service.onStartCommand(intent, flags, startId)
25+
service.onStartCommand()
2626

2727
override fun onBind(intent: Intent): IBinder {
2828
val binder = super.onBind(intent)
2929
if (binder != null) {
3030
return binder
3131
}
32-
return service.onBind(intent)
32+
return service.onBind()
3333
}
3434

3535
override fun onDestroy() {

0 commit comments

Comments
 (0)