修复部分设备下闪退问题
修复部分设备下闪退问题
This commit is contained in:
+6
-2
@@ -80,7 +80,11 @@ class ClashService : BaseService() {
|
||||
|
||||
|
||||
StaticNotificationModule.createNotificationChannel(this)
|
||||
StaticNotificationModule.notifyLoadingNotification(this)
|
||||
try {
|
||||
StaticNotificationModule.notifyLoadingNotification(this)
|
||||
} catch (e: SecurityException) {
|
||||
Log.e("Failed to post loading notification: ${e.message}", e)
|
||||
}
|
||||
|
||||
runtime.launch()
|
||||
}
|
||||
@@ -112,4 +116,4 @@ class ClashService : BaseService() {
|
||||
|
||||
runtime.requestGc()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-3
@@ -5,6 +5,7 @@ import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.os.Build
|
||||
import com.github.kr328.clash.common.constants.Permissions
|
||||
import com.github.kr328.clash.common.log.Log
|
||||
import kotlinx.coroutines.NonCancellable
|
||||
@@ -44,9 +45,17 @@ abstract class Module<E>(val service: Service) {
|
||||
}
|
||||
|
||||
if (requireSelf) {
|
||||
service.registerReceiver(receiver, filter, Permissions.RECEIVE_SELF_BROADCASTS, null)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
service.registerReceiver(receiver, filter, Permissions.RECEIVE_SELF_BROADCASTS, null, Context.RECEIVER_EXPORTED)
|
||||
} else {
|
||||
service.registerReceiver(receiver, filter, Permissions.RECEIVE_SELF_BROADCASTS, null)
|
||||
}
|
||||
} else {
|
||||
service.registerReceiver(receiver, filter)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
service.registerReceiver(receiver, filter, Context.RECEIVER_EXPORTED)
|
||||
} else {
|
||||
service.registerReceiver(receiver, filter)
|
||||
}
|
||||
}
|
||||
|
||||
receivers.add(receiver)
|
||||
@@ -75,4 +84,4 @@ abstract class Module<E>(val service: Service) {
|
||||
}
|
||||
|
||||
protected abstract suspend fun run()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user