Skip to content

Commit e684beb

Browse files
committed
Add android separates the core process
Support core status check and force restart Optimize proxies page and access page Update flutter and pub dependencies
1 parent e956373 commit e684beb

File tree

246 files changed

+38597
-43998
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

246 files changed

+38597
-43998
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Support the following actions
5454

5555
com.follow.clash.action.STOP
5656

57-
com.follow.clash.action.CHANGE
57+
com.follow.clash.action.TOGGLE
5858
```
5959

6060
## Download

README_zh_CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ on Mobile:
5454

5555
com.follow.clash.action.STOP
5656

57-
com.follow.clash.action.CHANGE
57+
com.follow.clash.action.TOGGLE
5858
```
5959

6060
## Download

analysis_options.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ include: package:flutter_lints/flutter.yaml
22
analyzer:
33
exclude:
44
- lib/l10n/intl/**
5+
errors:
6+
invalid_annotation_target: ignore
57

68
linter:
79
rules:

android/app/build.gradle.kts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
12
import java.util.Properties
23

34
plugins {
@@ -24,22 +25,19 @@ val isRelease = mStoreFile.exists()
2425

2526
android {
2627
namespace = "com.follow.clash"
27-
compileSdk = 35
28-
ndkVersion = "28.0.13004108"
28+
compileSdk = libs.versions.compileSdk.get().toInt()
29+
ndkVersion = libs.versions.ndkVersion.get()
30+
2931

3032
compileOptions {
3133
sourceCompatibility = JavaVersion.VERSION_17
3234
targetCompatibility = JavaVersion.VERSION_17
3335
}
3436

35-
kotlinOptions {
36-
jvmTarget = JavaVersion.VERSION_17.toString()
37-
}
38-
3937
defaultConfig {
4038
applicationId = "com.follow.clash"
4139
minSdk = flutter.minSdkVersion
42-
targetSdk = flutter.targetSdkVersion
40+
targetSdk = libs.versions.targetSdk.get().toInt()
4341
versionCode = flutter.versionCode
4442
versionName = flutter.versionName
4543
}
@@ -63,8 +61,7 @@ android {
6361

6462
release {
6563
isMinifyEnabled = true
66-
isDebuggable = false
67-
64+
isShrinkResources = true
6865
signingConfig = if (isRelease) {
6966
signingConfigs.getByName("release")
7067
} else {
@@ -79,15 +76,22 @@ android {
7976
}
8077
}
8178

79+
kotlin {
80+
compilerOptions {
81+
jvmTarget.set(JvmTarget.JVM_17)
82+
}
83+
}
84+
8285
flutter {
8386
source = "../.."
8487
}
8588

8689
dependencies {
87-
implementation(project(":core"))
88-
implementation("androidx.core:core-splashscreen:1.0.1")
89-
implementation("com.google.code.gson:gson:2.10.1")
90-
implementation("com.android.tools.smali:smali-dexlib2:3.0.9") {
90+
implementation(project(":service"))
91+
implementation(project(":common"))
92+
implementation(libs.core.splashscreen)
93+
implementation(libs.gson)
94+
implementation(libs.smali.dexlib2) {
9195
exclude(group = "com.google.guava", module = "guava")
9296
}
9397
}

android/app/proguard-rules.pro

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11

2-
-keep class com.follow.clash.models.**{ *; }
2+
-keep class com.follow.clash.models.**{ *; }
3+
4+
-keep class com.follow.clash.service.models.**{ *; }

android/app/src/debug/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
android:label="FlClash Debug"
1010
tools:replace="android:label">
1111
<service
12-
android:name=".services.FlClashTileService"
12+
android:name=".TileService"
1313
android:label="FlClash Debug"
1414
tools:replace="android:label"
1515
tools:targetApi="24" />

android/app/src/main/AndroidManifest.xml

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
12
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
23
xmlns:tools="http://schemas.android.com/tools">
34

5+
<permission
6+
android:name="${applicationId}.permission.RECEIVE_BROADCASTS"
7+
android:protectionLevel="signature" />
8+
49
<uses-feature
510
android:name="android.hardware.touchscreen"
611
android:required="false" />
@@ -13,19 +18,19 @@
1318

1419
<uses-permission android:name="android.permission.INTERNET" />
1520
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
16-
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
1721
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
1822
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
1923
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
20-
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
21-
2224
<uses-permission
2325
android:name="android.permission.QUERY_ALL_PACKAGES"
2426
tools:ignore="QueryAllPackagesPermission" />
27+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
28+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
2529

2630
<application
27-
android:name=".FlClashApplication"
31+
android:name=".Application"
2832
android:banner="@mipmap/ic_banner"
33+
android:extractNativeLibs="true"
2934
android:hardwareAccelerated="true"
3035
android:icon="@mipmap/ic_launcher"
3136
android:label="FlClash">
@@ -47,6 +52,7 @@
4752

4853
<intent-filter>
4954
<action android:name="android.intent.action.MAIN" />
55+
5056
<category android:name="android.intent.category.LAUNCHER" />
5157
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
5258
</intent-filter>
@@ -73,6 +79,7 @@
7379

7480
<activity
7581
android:name=".TempActivity"
82+
android:excludeFromRecents="true"
7683
android:exported="true"
7784
android:theme="@style/TransparentTheme">
7885
<intent-filter>
@@ -85,17 +92,16 @@
8592
</intent-filter>
8693
<intent-filter>
8794
<category android:name="android.intent.category.DEFAULT" />
88-
<action android:name="${applicationId}.action.CHANGE" />
95+
<action android:name="${applicationId}.action.TOGGLE" />
8996
</intent-filter>
9097
</activity>
9198

9299
<service
93-
android:name=".services.FlClashTileService"
100+
android:name=".TileService"
94101
android:exported="true"
95102
android:icon="@drawable/ic"
96103
android:label="FlClash"
97-
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
98-
tools:targetApi="n">
104+
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
99105
<intent-filter>
100106
<action android:name="android.service.quicksettings.action.QS_TILE" />
101107
</intent-filter>
@@ -104,6 +110,19 @@
104110
android:value="true" />
105111
</service>
106112

113+
<receiver
114+
android:name=".BroadcastReceiver"
115+
android:enabled="true"
116+
android:exported="true"
117+
android:permission="${applicationId}.permission.RECEIVE_BROADCASTS">
118+
<intent-filter>
119+
<action android:name="${applicationId}.intent.action.START" />
120+
<action android:name="${applicationId}.intent.action.STOP" />
121+
<action android:name="${applicationId}.intent.action.TOGGLE" />
122+
</intent-filter>
123+
</receiver>
124+
125+
107126
<provider
108127
android:name=".FilesProvider"
109128
android:authorities="${applicationId}.files"
@@ -126,28 +145,6 @@
126145
android:resource="@xml/file_paths" />
127146
</provider>
128147

129-
<service
130-
android:name=".services.FlClashVpnService"
131-
android:exported="false"
132-
android:foregroundServiceType="dataSync"
133-
android:permission="android.permission.BIND_VPN_SERVICE">
134-
<intent-filter>
135-
<action android:name="android.net.VpnService" />
136-
</intent-filter>
137-
<property
138-
android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
139-
android:value="vpn" />
140-
</service>
141-
142-
<service
143-
android:name=".services.FlClashService"
144-
android:exported="false"
145-
android:foregroundServiceType="dataSync">
146-
<property
147-
android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
148-
android:value="service" />
149-
</service>
150-
151148
<meta-data
152149
android:name="flutterEmbedding"
153150
android:value="2" />
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.follow.clash
2+
3+
import android.app.Application
4+
import android.content.Context
5+
import com.follow.clash.common.GlobalState
6+
7+
class Application : Application() {
8+
9+
override fun attachBaseContext(base: Context?) {
10+
super.attachBaseContext(base)
11+
GlobalState.init(this)
12+
}
13+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.follow.clash
2+
3+
import android.content.BroadcastReceiver
4+
import android.content.Context
5+
import android.content.Intent
6+
import com.follow.clash.common.BroadcastAction
7+
import com.follow.clash.common.action
8+
import kotlinx.coroutines.CoroutineScope
9+
import kotlinx.coroutines.Dispatchers
10+
import kotlinx.coroutines.SupervisorJob
11+
import kotlinx.coroutines.launch
12+
13+
class BroadcastReceiver : BroadcastReceiver(),
14+
CoroutineScope by CoroutineScope(SupervisorJob() + Dispatchers.Default) {
15+
override fun onReceive(context: Context?, intent: Intent?) {
16+
when (intent?.action) {
17+
BroadcastAction.START.action -> {
18+
launch {
19+
State.handleStartServiceAction()
20+
}
21+
}
22+
23+
BroadcastAction.STOP.action -> {
24+
State.handleStopServiceAction()
25+
}
26+
27+
BroadcastAction.TOGGLE.action -> {
28+
launch {
29+
State.handleToggleAction()
30+
}
31+
}
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)