Skip to content

Commit 6fb895e

Browse files
committed
Fix some issues
Optimize Windows service mode Update core
1 parent 2ab70f1 commit 6fb895e

File tree

29 files changed

+300
-180
lines changed

29 files changed

+300
-180
lines changed

.github/workflows/build.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ jobs:
2727
- platform: macos
2828
os: macos-latest
2929
arch: arm64
30-
- platform: windows
31-
os: windows-11-arm
32-
arch: arm64
30+
# - platform: windows
31+
# os: windows-11-arm
32+
# arch: arm64
3333
- platform: linux
3434
os: ubuntu-24.04-arm
3535
arch: arm64

.gitignore

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,19 @@ app.*.map.json
4545
/android/app/debug
4646
/android/app/profile
4747
/android/app/release
48+
/android/**/.cxx
49+
/android/**/build
50+
/android/common/**/.**/
51+
/android/common/local.*
52+
/android/core/**/includes/
53+
/android/core/**/cmake-build-*/
54+
/android/core/**/jniLibs/
4855

4956

50-
51-
#libclash
57+
#FlClash
5258
/libclash/
53-
54-
#jniLibs
5559
/android/app/src/main/jniLibs/
60+
/services/helper/target
61+
/macos/**/Package.resolved
62+
devtools_options.yaml
63+

android/app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666

6767
<activity
6868
android:name=".TempActivity"
69-
android:excludeFromRecents="true"
7069
android:exported="true"
7170
android:theme="@style/TransparentTheme">
7271
<intent-filter>

android/app/src/main/kotlin/com/follow/clash/Service.kt

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.follow.clash
33
import com.follow.clash.common.ServiceDelegate
44
import com.follow.clash.common.formatString
55
import com.follow.clash.common.intent
6+
import com.follow.clash.service.IAckInterface
67
import com.follow.clash.service.ICallbackInterface
78
import com.follow.clash.service.IEventInterface
89
import com.follow.clash.service.IRemoteInterface
@@ -44,8 +45,11 @@ object Service {
4445
return delegate.useService {
4546
it.invokeAction(
4647
data, object : ICallbackInterface.Stub() {
47-
override fun onResult(result: ByteArray?, isSuccess: Boolean) {
48+
override fun onResult(
49+
result: ByteArray?, isSuccess: Boolean, ack: IAckInterface?
50+
) {
4851
res.add(result ?: byteArrayOf())
52+
ack?.onAck()
4953
if (isSuccess) {
5054
cb(res.formatString())
5155
}
@@ -61,24 +65,24 @@ object Service {
6165
return delegate.useService {
6266
it.setEventListener(
6367
when (cb != null) {
64-
true -> object : IEventInterface.Stub() {
65-
override fun onEvent(
66-
id: String, data: ByteArray?, isSuccess: Boolean
67-
) {
68-
if (results[id] == null) {
69-
results[id] = mutableListOf()
70-
}
71-
results[id]?.add(data ?: byteArrayOf())
72-
if (isSuccess) {
73-
cb(results[id]?.formatString())
74-
results.remove(id)
75-
}
68+
true -> object : IEventInterface.Stub() {
69+
override fun onEvent(
70+
id: String, data: ByteArray?, isSuccess: Boolean, ack: IAckInterface?
71+
) {
72+
if (results[id] == null) {
73+
results[id] = mutableListOf()
74+
}
75+
results[id]?.add(data ?: byteArrayOf())
76+
ack?.onAck()
77+
if (isSuccess) {
78+
cb(results[id]?.formatString())
79+
results.remove(id)
7680
}
7781
}
78-
79-
false -> null
8082
}
81-
)
83+
84+
false -> null
85+
})
8286
}
8387
}
8488

android/app/src/main/kotlin/com/follow/clash/TempActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ class TempActivity : Activity(),
3030
}
3131
}
3232
}
33-
finish()
33+
finishAndRemoveTask()
3434
}
3535
}

android/app/src/main/kotlin/com/follow/clash/TileService.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ class TileService : TileService() {
4545
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
4646
startActivityAndCollapse(pendingIntent)
4747
} else {
48-
@Suppress("DEPRECATION")
49-
startActivityAndCollapse(intent)
48+
@Suppress("DEPRECATION") startActivityAndCollapse(intent)
5049
}
5150
}
5251

android/common/src/main/java/com/follow/clash/common/Ext.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ val Long.formatBytes: String
220220
fun String.chunkedForAidl(charset: Charset = Charsets.UTF_8): List<ByteArray> {
221221
val allBytes = toByteArray(charset)
222222
val total = allBytes.size
223-
224223
val maxBytes = when {
225224
total <= 100 * 1024 -> total
226225
total <= 1024 * 1024 -> 64 * 1024

android/common/src/main/java/com/follow/clash/common/Service.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import kotlinx.coroutines.flow.StateFlow
1111
import kotlinx.coroutines.flow.filterNotNull
1212
import kotlinx.coroutines.flow.first
1313
import kotlinx.coroutines.launch
14+
import kotlinx.coroutines.withContext
1415
import kotlinx.coroutines.withTimeout
1516
import java.util.concurrent.atomic.AtomicBoolean
1617

@@ -59,7 +60,9 @@ class ServiceDelegate<T>(
5960
withTimeout(timeoutMillis) {
6061
val state = serviceState.filterNotNull().first()
6162
state.first?.let {
62-
block(it)
63+
withContext(Dispatchers.Default) {
64+
block(it)
65+
}
6366
} ?: throw Exception(state.second)
6467
}
6568
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// IAckInterface.aidl
2+
package com.follow.clash.service;
3+
4+
import com.follow.clash.service.IAckInterface;
5+
6+
interface IAckInterface {
7+
oneway void onAck();
8+
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// ICallbackInterface.aidl
22
package com.follow.clash.service;
33

4+
import com.follow.clash.service.IAckInterface;
5+
46
interface ICallbackInterface {
5-
oneway void onResult(in byte[] data,in boolean isSuccess);
7+
oneway void onResult(in byte[] data,in boolean isSuccess, in IAckInterface ack);
68
}

0 commit comments

Comments
 (0)