Compare commits

..

1 Commits

Author SHA1 Message Date
chen08209
a1edaba5c9 Add android separates the core process
Support core status check and force restart

Update flutter and pub dependencies
2025-08-27 19:13:43 +08:00
5 changed files with 35 additions and 24 deletions

View File

@@ -1,5 +1,7 @@
package com.follow.clash
import android.os.Bundle
import androidx.lifecycle.lifecycleScope
import com.follow.clash.plugins.AppPlugin
import com.follow.clash.plugins.ServicePlugin
import com.follow.clash.plugins.TilePlugin
@@ -13,10 +15,14 @@ import kotlinx.coroutines.launch
class MainActivity : FlutterActivity(),
CoroutineScope by CoroutineScope(SupervisorJob() + Dispatchers.Default) {
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
launch {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
lifecycleScope.launch {
State.destroyServiceEngine()
}
}
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
flutterEngine.plugins.add(AppPlugin())
flutterEngine.plugins.add(ServicePlugin())

View File

@@ -285,9 +285,12 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
arrayOf(Manifest.permission.POST_NOTIFICATIONS),
NOTIFICATION_PERMISSION_REQUEST_CODE
)
return
}
return
} else {
invokeRequestNotificationCallback()
}
}
fun invokeRequestNotificationCallback() {

View File

@@ -6,9 +6,12 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.retryWhen
import kotlinx.coroutines.launch
import kotlinx.coroutines.withTimeoutOrNull
@@ -51,12 +54,17 @@ class ServiceDelegate<T>(
}
}
suspend inline fun <R> useService(crossinline block: (T) -> R): Result<R> {
suspend inline fun <R> useService(
crossinline block: (T) -> R
): Result<R> {
return withTimeoutOrNull(10_000) {
service.first { it != null }
}?.let { service ->
service.filterNotNull().retryWhen { _, _ ->
delay(200)
true
}.first()
}?.let { s ->
try {
Result.success(block(service))
Result.success(block(s))
} catch (e: Exception) {
Result.failure(e)
}

View File

@@ -14,16 +14,15 @@ extension ArchiveExt on Archive {
final data = entity.readAsBytesSync();
final archiveFile = ArchiveFile(relativePath, data.length, data);
addFile(archiveFile);
} else if (entity is Directory) {
addDirectoryToArchive(entity.path, parentPath);
}
// else if (entity is Directory) {
// addDirectoryToArchive(entity.path, parentPath);
// }
}
}
void addTextFile<T>(String name, T raw) {
final data = json.encode(raw);
addFile(
ArchiveFile.string(name, data),
);
addFile(ArchiveFile.string(name, data));
}
}

View File

@@ -77,13 +77,14 @@ class AppPath {
return join(directory, '$id.yaml');
}
Future<String> getProvidersRootPath() async {
final directory = await profilesPath;
return join(directory, 'providers');
}
Future<String> getProvidersDirPath(String id) async {
final directory = await profilesPath;
return join(
directory,
'providers',
id,
);
return join(directory, 'providers', id);
}
Future<String> getProvidersFilePath(
@@ -92,13 +93,7 @@ class AppPath {
String url,
) async {
final directory = await profilesPath;
return join(
directory,
'providers',
id,
type,
url.toMd5(),
);
return join(directory, 'providers', id, type, url.toMd5());
}
Future<String> get tempPath async {