Skip to content

Commit 92bf322

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 92bf322

File tree

256 files changed

+39426
-44322
lines changed

Some content is hidden

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

256 files changed

+39426
-44322
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: 24 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,20 @@ 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+
31+
2932

3033
compileOptions {
3134
sourceCompatibility = JavaVersion.VERSION_17
3235
targetCompatibility = JavaVersion.VERSION_17
3336
}
3437

35-
kotlinOptions {
36-
jvmTarget = JavaVersion.VERSION_17.toString()
37-
}
38-
3938
defaultConfig {
4039
applicationId = "com.follow.clash"
4140
minSdk = flutter.minSdkVersion
42-
targetSdk = flutter.targetSdkVersion
41+
targetSdk = libs.versions.targetSdk.get().toInt()
4342
versionCode = flutter.versionCode
4443
versionName = flutter.versionName
4544
}
@@ -55,6 +54,12 @@ android {
5554
}
5655
}
5756

57+
packaging {
58+
jniLibs {
59+
useLegacyPackaging = true
60+
}
61+
}
62+
5863
buildTypes {
5964
debug {
6065
isMinifyEnabled = false
@@ -63,8 +68,7 @@ android {
6368

6469
release {
6570
isMinifyEnabled = true
66-
isDebuggable = false
67-
71+
isShrinkResources = true
6872
signingConfig = if (isRelease) {
6973
signingConfigs.getByName("release")
7074
} else {
@@ -79,15 +83,22 @@ android {
7983
}
8084
}
8185

86+
kotlin {
87+
compilerOptions {
88+
jvmTarget.set(JvmTarget.JVM_17)
89+
}
90+
}
91+
8292
flutter {
8393
source = "../.."
8494
}
8595

8696
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") {
97+
implementation(project(":service"))
98+
implementation(project(":common"))
99+
implementation(libs.core.splashscreen)
100+
implementation(libs.gson)
101+
implementation(libs.smali.dexlib2) {
91102
exclude(group = "com.google.guava", module = "guava")
92103
}
93104
}

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: 18 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
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

@@ -13,40 +14,36 @@
1314

1415
<uses-permission android:name="android.permission.INTERNET" />
1516
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
16-
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
1717
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
1818
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
1919
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
20-
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
21-
2220
<uses-permission
2321
android:name="android.permission.QUERY_ALL_PACKAGES"
2422
tools:ignore="QueryAllPackagesPermission" />
23+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
24+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
2525

2626
<application
27-
android:name=".FlClashApplication"
27+
android:name=".Application"
2828
android:banner="@mipmap/ic_banner"
2929
android:hardwareAccelerated="true"
3030
android:icon="@mipmap/ic_launcher"
3131
android:label="FlClash">
3232
<activity
33-
android:name="com.follow.clash.MainActivity"
33+
android:name=".MainActivity"
3434
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
3535
android:exported="true"
3636
android:hardwareAccelerated="true"
3737
android:launchMode="singleTop"
3838
android:theme="@style/LaunchTheme"
3939
android:windowSoftInputMode="adjustResize">
40-
<!-- Specifies an Android theme to apply to this Activity as soon as
41-
the Android process has started. This theme is visible to the user
42-
while the Flutter UI initializes. After that, this theme continues
43-
to determine the Window background behind the Flutter UI. -->
4440
<meta-data
4541
android:name="io.flutter.embedding.android.NormalTheme"
4642
android:resource="@style/NormalTheme" />
4743

4844
<intent-filter>
4945
<action android:name="android.intent.action.MAIN" />
46+
5047
<category android:name="android.intent.category.LAUNCHER" />
5148
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
5249
</intent-filter>
@@ -67,12 +64,9 @@
6764
</intent-filter>
6865
</activity>
6966

70-
<meta-data
71-
android:name="io.flutter.embedding.android.EnableImpeller"
72-
android:value="false" />
73-
7467
<activity
7568
android:name=".TempActivity"
69+
android:excludeFromRecents="true"
7670
android:exported="true"
7771
android:theme="@style/TransparentTheme">
7872
<intent-filter>
@@ -85,17 +79,16 @@
8579
</intent-filter>
8680
<intent-filter>
8781
<category android:name="android.intent.category.DEFAULT" />
88-
<action android:name="${applicationId}.action.CHANGE" />
82+
<action android:name="${applicationId}.action.TOGGLE" />
8983
</intent-filter>
9084
</activity>
9185

9286
<service
93-
android:name=".services.FlClashTileService"
87+
android:name=".TileService"
9488
android:exported="true"
9589
android:icon="@drawable/ic"
9690
android:label="FlClash"
97-
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
98-
tools:targetApi="n">
91+
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
9992
<intent-filter>
10093
<action android:name="android.service.quicksettings.action.QS_TILE" />
10194
</intent-filter>
@@ -104,49 +97,17 @@
10497
android:value="true" />
10598
</service>
10699

107-
<provider
108-
android:name=".FilesProvider"
109-
android:authorities="${applicationId}.files"
100+
<receiver
101+
android:name=".BroadcastReceiver"
102+
android:enabled="true"
110103
android:exported="true"
111-
android:grantUriPermissions="true"
112-
android:permission="android.permission.MANAGE_DOCUMENTS"
113-
android:process=":background">
114-
<intent-filter>
115-
<action android:name="android.content.action.DOCUMENTS_PROVIDER" />
116-
</intent-filter>
117-
</provider>
118-
119-
<provider
120-
android:name="androidx.core.content.FileProvider"
121-
android:authorities="${applicationId}.fileProvider"
122-
android:exported="false"
123-
android:grantUriPermissions="true">
124-
<meta-data
125-
android:name="android.support.FILE_PROVIDER_PATHS"
126-
android:resource="@xml/file_paths" />
127-
</provider>
128-
129-
<service
130-
android:name=".services.FlClashVpnService"
131-
android:exported="false"
132-
android:foregroundServiceType="dataSync"
133-
android:permission="android.permission.BIND_VPN_SERVICE">
104+
android:permission="${applicationId}.permission.RECEIVE_BROADCASTS">
134105
<intent-filter>
135-
<action android:name="android.net.VpnService" />
106+
<action android:name="${applicationId}.intent.action.START" />
107+
<action android:name="${applicationId}.intent.action.STOP" />
108+
<action android:name="${applicationId}.intent.action.TOGGLE" />
136109
</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>
110+
</receiver>
150111

151112
<meta-data
152113
android:name="flutterEmbedding"
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)