Skip to content

Commit 5708f72

Browse files
committed
Add rule override
Optimize more details
1 parent de9c5ba commit 5708f72

File tree

137 files changed

+7275
-1977
lines changed

Some content is hidden

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

137 files changed

+7275
-1977
lines changed

.github/workflows/build.yaml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
push:
55
tags:
66
- 'v*'
7+
env:
8+
IS_STABLE: ${{ !contains(github.ref, '-') }}
79

810
jobs:
911
build:
@@ -74,7 +76,7 @@ jobs:
7476
run: flutter pub get
7577

7678
- name: Setup
77-
run: dart setup.dart ${{ matrix.platform }} ${{ matrix.arch && format('--arch {0}', matrix.arch) }}
79+
run: dart setup.dart ${{ matrix.platform }} ${{ matrix.arch && format('--arch {0}', matrix.arch) }} ${{ env.IS_STABLE && format('--env stable}') }},
7880

7981
- name: Upload
8082
uses: actions/upload-artifact@v4
@@ -84,18 +86,16 @@ jobs:
8486
overwrite: true
8587

8688
changelog:
89+
if: ${{ env.IS_STABLE == 'true'}}
8790
runs-on: ubuntu-latest
8891
needs: [ build ]
8992
steps:
9093
- name: Checkout
91-
if: ${{ !contains(github.ref, '+') }}
9294
uses: actions/checkout@v4
9395
with:
9496
fetch-depth: 0
9597
ref: refs/heads/main
96-
9798
- name: Generate
98-
if: ${{ !contains(github.ref, '+') }}
9999
run: |
100100
tags=($(git tag --merged $(git rev-parse HEAD) --sort=-creatordate))
101101
preTag=$(grep -oP '^## \K.*' CHANGELOG.md | head -n 1)
@@ -127,7 +127,6 @@ jobs:
127127
cat NEW_CHANGELOG.md > CHANGELOG.md
128128
129129
- name: Commit
130-
if: ${{ !contains(github.ref, '+') }}
131130
run: |
132131
git add CHANGELOG.md
133132
if ! git diff --cached --quiet; then
@@ -206,29 +205,29 @@ jobs:
206205
run: |
207206
python -m pip install --upgrade pip
208207
pip install requests
209-
python release.py
208+
python release_telegram.py
210209
211210
- name: Patch release.md
212211
run: |
213212
version=$(echo "${{ github.ref_name }}" | sed 's/^v//')
214213
sed "s|VERSION|$version|g" ./.github/release_template.md >> release.md
215214
216215
- name: Release
217-
if: ${{ !contains(github.ref, '+') }}
216+
if: ${{ env.IS_STABLE == 'true'}}
218217
uses: softprops/action-gh-release@v2
219218
with:
220219
files: ./dist/*
221220
body_path: './release.md'
222221

223222
- name: Create Fdroid Source Dir
224-
if: ${{ !contains(github.ref, '+') }}
223+
if: ${{ env.IS_STABLE == 'true'}}
225224
run: |
226225
mkdir -p ./tmp
227226
cp ./dist/*android-arm64-v8a* ./tmp/ || true
228227
echo "Files copied successfully"
229228
230229
- name: Push to fdroid repo
231-
if: ${{ !contains(github.ref, '+') }}
230+
if: ${{ env.IS_STABLE == 'true'}}
232231
uses: cpina/github-action-push-to-another-repository@v1.7.2
233232
env:
234233
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
@@ -238,7 +237,7 @@ jobs:
238237
destination-repository-name: FlClash-fdroid-repo
239238
user-name: 'github-actions[bot]'
240239
user-email: 'github-actions[bot]@users.noreply.github.com'
241-
target-branch: action-pr
240+
target-branch: main
242241
commit-message: Update from ${{ github.ref_name }}
243242
target-directory: /tmp/
244243

analysis_options.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1 @@
11
include: package:flutter_lints/flutter.yaml
2-
3-
linter:
4-
rules:
5-
6-
analyzer:
7-
plugins:
8-
- custom_lint

android/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def isRelease = defStoreFile.exists() && defStorePassword != null && defKeyAlias
3333

3434
android {
3535
namespace "com.follow.clash"
36-
compileSdkVersion 34
36+
compileSdkVersion 35
3737
ndkVersion "27.1.12297006"
3838

3939
compileOptions {
@@ -63,7 +63,7 @@ android {
6363
defaultConfig {
6464
applicationId "com.follow.clash"
6565
minSdkVersion 21
66-
targetSdkVersion 34
66+
targetSdkVersion 35
6767
versionCode flutterVersionCode.toInteger()
6868
versionName flutterVersionName
6969
}

android/app/src/main/AndroidManifest.xml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@
1010

1111
<uses-permission android:name="android.permission.INTERNET" />
1212
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
13-
<uses-permission
14-
android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE"
15-
tools:ignore="SystemPermissionTypo" />
1613
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
1714
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
1815
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
1916
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
20-
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
17+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
18+
2119
<uses-permission
2220
android:name="android.permission.QUERY_ALL_PACKAGES"
2321
tools:ignore="QueryAllPackagesPermission" />
@@ -64,7 +62,9 @@
6462
</intent-filter>
6563
</activity>
6664

67-
<meta-data android:name="io.flutter.embedding.android.EnableImpeller" android:value="false" />
65+
<meta-data
66+
android:name="io.flutter.embedding.android.EnableImpeller"
67+
android:value="false" />
6868

6969
<activity
7070
android:name=".TempActivity"
@@ -87,7 +87,6 @@
8787
<service
8888
android:name=".services.FlClashTileService"
8989
android:exported="true"
90-
android:foregroundServiceType="specialUse"
9190
android:icon="@drawable/ic_stat_name"
9291
android:label="FlClash"
9392
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
@@ -125,7 +124,7 @@
125124
<service
126125
android:name=".services.FlClashVpnService"
127126
android:exported="false"
128-
android:foregroundServiceType="specialUse"
127+
android:foregroundServiceType="dataSync"
129128
android:permission="android.permission.BIND_VPN_SERVICE">
130129
<intent-filter>
131130
<action android:name="android.net.VpnService" />
@@ -138,7 +137,7 @@
138137
<service
139138
android:name=".services.FlClashService"
140139
android:exported="false"
141-
android:foregroundServiceType="specialUse">
140+
android:foregroundServiceType="dataSync">
142141
<property
143142
android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
144143
android:value="service" />

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.follow.clash;
22

33
import android.app.Application
4-
import android.content.Context;
4+
import android.content.Context
55

66
class FlClashApplication : Application() {
77
companion object {

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package com.follow.clash
22

3-
import android.content.Context
43
import androidx.lifecycle.MutableLiveData
54
import com.follow.clash.plugins.AppPlugin
6-
import com.follow.clash.plugins.ServicePlugin
75
import com.follow.clash.plugins.TilePlugin
86
import com.follow.clash.plugins.VpnPlugin
97
import io.flutter.FlutterInjector

android/app/src/main/kotlin/com/follow/clash/plugins/AppPlugin.kt

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -291,16 +291,18 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
291291
private fun getPackages(): List<Package> {
292292
val packageManager = FlClashApplication.getAppContext().packageManager
293293
if (packages.isNotEmpty()) return packages
294-
packageManager?.getInstalledPackages(PackageManager.GET_META_DATA)?.filter {
295-
it.packageName != FlClashApplication.getAppContext().packageName
296-
|| it.requestedPermissions?.contains(Manifest.permission.INTERNET) == true
297-
|| it.packageName == "android"
298-
299-
}?.map {
294+
packageManager?.getInstalledPackages(PackageManager.GET_META_DATA or PackageManager.GET_PERMISSIONS)
295+
?.filter {
296+
it.packageName != FlClashApplication.getAppContext().packageName && (
297+
it.requestedPermissions?.contains(Manifest.permission.INTERNET) == true
298+
|| it.packageName == "android"
299+
)
300+
301+
}?.map {
300302
Package(
301303
packageName = it.packageName,
302-
label = it.applicationInfo.loadLabel(packageManager).toString(),
303-
isSystem = (it.applicationInfo.flags and ApplicationInfo.FLAG_SYSTEM) == 1,
304+
label = it.applicationInfo?.loadLabel(packageManager).toString(),
305+
isSystem = (it.applicationInfo?.flags?.and(ApplicationInfo.FLAG_SYSTEM)) == 1,
304306
lastUpdateTime = it.lastUpdateTime
305307
)
306308
}?.let { packages.addAll(it) }
@@ -353,7 +355,7 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
353355
}
354356

355357
suspend fun getText(text: String): String? {
356-
return withContext(Dispatchers.Default){
358+
return withContext(Dispatchers.Default) {
357359
channel.awaitResult<String>("getText", text)
358360
}
359361
}
@@ -391,31 +393,33 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
391393
}.forEach {
392394
if (it.name.matches(chinaAppRegex)) return true
393395
}
394-
ZipFile(File(packageInfo.applicationInfo.publicSourceDir)).use {
395-
for (packageEntry in it.entries()) {
396-
if (packageEntry.name.startsWith("firebase-")) return false
397-
}
398-
for (packageEntry in it.entries()) {
399-
if (!(packageEntry.name.startsWith("classes") && packageEntry.name.endsWith(
400-
".dex"
401-
))
402-
) {
403-
continue
404-
}
405-
if (packageEntry.size > 15000000) {
406-
return true
407-
}
408-
val input = it.getInputStream(packageEntry).buffered()
409-
val dexFile = try {
410-
DexBackedDexFile.fromInputStream(null, input)
411-
} catch (e: Exception) {
412-
return false
396+
packageInfo.applicationInfo?.publicSourceDir?.let {
397+
ZipFile(File(it)).use {
398+
for (packageEntry in it.entries()) {
399+
if (packageEntry.name.startsWith("firebase-")) return false
413400
}
414-
for (clazz in dexFile.classes) {
415-
val clazzName =
416-
clazz.type.substring(1, clazz.type.length - 1).replace("/", ".")
417-
.replace("$", ".")
418-
if (clazzName.matches(chinaAppRegex)) return true
401+
for (packageEntry in it.entries()) {
402+
if (!(packageEntry.name.startsWith("classes") && packageEntry.name.endsWith(
403+
".dex"
404+
))
405+
) {
406+
continue
407+
}
408+
if (packageEntry.size > 15000000) {
409+
return true
410+
}
411+
val input = it.getInputStream(packageEntry).buffered()
412+
val dexFile = try {
413+
DexBackedDexFile.fromInputStream(null, input)
414+
} catch (e: Exception) {
415+
return false
416+
}
417+
for (clazz in dexFile.classes) {
418+
val clazzName =
419+
clazz.type.substring(1, clazz.type.length - 1).replace("/", ".")
420+
.replace("$", ".")
421+
if (clazzName.matches(chinaAppRegex)) return true
422+
}
419423
}
420424
}
421425
}

android/app/src/main/kotlin/com/follow/clash/plugins/ServicePlugin.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.follow.clash.plugins
22

3-
import com.follow.clash.FlClashApplication
43
import com.follow.clash.GlobalState
54
import com.follow.clash.models.VpnOptions
65
import com.google.gson.Gson

android/app/src/main/kotlin/com/follow/clash/plugins/VpnPlugin.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import android.net.NetworkCapabilities
1010
import android.net.NetworkRequest
1111
import android.os.Build
1212
import android.os.IBinder
13-
import android.util.Log
1413
import androidx.core.content.getSystemService
1514
import com.follow.clash.FlClashApplication
1615
import com.follow.clash.GlobalState

android/app/src/main/kotlin/com/follow/clash/services/FlClashService.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import android.app.NotificationManager
77
import android.app.PendingIntent
88
import android.app.Service
99
import android.content.Intent
10-
import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE
10+
import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC
1111
import android.os.Binder
1212
import android.os.Build
1313
import android.os.IBinder
@@ -87,6 +87,7 @@ class FlClashService : Service(), BaseServiceInterface {
8787
}
8888
}
8989
}
90+
9091
private suspend fun getNotificationBuilder(): NotificationCompat.Builder {
9192
return notificationBuilderDeferred.await()
9293
}
@@ -100,7 +101,8 @@ class FlClashService : Service(), BaseServiceInterface {
100101
}
101102
}
102103

103-
@SuppressLint("ForegroundServiceType", "WrongConstant")
104+
105+
@SuppressLint("ForegroundServiceType")
104106
override suspend fun startForeground(title: String, content: String) {
105107
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
106108
val manager = getSystemService(NotificationManager::class.java)
@@ -116,7 +118,11 @@ class FlClashService : Service(), BaseServiceInterface {
116118
.setContentTitle(title)
117119
.setContentText(content).build()
118120
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
119-
startForeground(notificationId, notification, FOREGROUND_SERVICE_TYPE_SPECIAL_USE)
121+
try {
122+
startForeground(notificationId, notification, FOREGROUND_SERVICE_TYPE_DATA_SYNC)
123+
} catch (_: Exception) {
124+
startForeground(notificationId, notification)
125+
}
120126
} else {
121127
startForeground(notificationId, notification)
122128
}

0 commit comments

Comments
 (0)