Skip to content

Commit b0bf307

Browse files
升级保活策略、startActivity 编排与构建工具链
1 parent 4f5eb6a commit b0bf307

44 files changed

Lines changed: 1952 additions & 167 deletions

Some content is hidden

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

CHANGELOG.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased]
9+
10+
### Added
11+
- Added unified strategy health models and `Fw.check()` health report with restartable-strategy recovery.
12+
- Added `FwMediaBrowserService` strategy and wired it into config, startup, shutdown, and health checks.
13+
- Added native startActivity strategies for `NEW_TASK + EXCLUDE_FROM_RECENTS + NO_ANIMATION` and `moveTaskToFront`.
14+
- Added `FwStart.startAuditAll()` for full native strategy audit while keeping `FwStart.start()` on executable strategies by default.
15+
16+
### Changed
17+
- Hardened VPN startup to require user authorization, foreground notification startup, no default traffic routing, and explicit special-use subtype metadata.
18+
- Changed 1-pixel Activity and contacts/SMS observers to opt-in defaults, and stopped merging contacts/SMS permissions into host apps by default.
19+
- Updated PendingIntent background-launch handling for Android 14-16 sender/creator-side options.
20+
- Upgraded the build toolchain to Gradle 9.5.1, AGP 9.2.1, Kotlin 2.3.21, Compose BOM 2026.05.01, and migrated to AGP built-in Kotlin with the new DSL.
21+
- Updated README, English README, and helper docs to document health checks, VPN authorization, MediaBrowser, and full startActivity strategy boundaries.
22+
823
## [2.0.1] - 2026-05-26
924

1025
### Changed
@@ -29,7 +44,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2944
- 16 GitHub topic tags
3045

3146
### Changed
32-
- Upgraded toolchain: Gradle 9.4.1, AGP 9.1.0, Kotlin 2.3.20
47+
- Upgraded toolchain: Gradle 9.5.1, AGP 9.2.1, Kotlin 2.3.21
3348
- Strategy count increased from 27 to 35+
3449
- Published to Maven Central as v2.0.0
3550

README-en.md

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
1313
[![Platform](https://img.shields.io/badge/Platform-Android-green.svg)](https://developer.android.com)
1414
[![API](https://img.shields.io/badge/API-24%2B-brightgreen.svg)](https://android-arsenal.com/api?level=24)
15-
[![Kotlin](https://img.shields.io/badge/Kotlin-2.3.20-purple.svg)](https://kotlinlang.org)
15+
[![Kotlin](https://img.shields.io/badge/Kotlin-2.3.21-purple.svg)](https://kotlinlang.org)
1616
[![16K Page Size](https://img.shields.io/badge/16K%20Page%20Size-Compatible-orange.svg)](https://developer.android.com/guide/practices/page-sizes)
1717
[![Google Play](https://img.shields.io/badge/Google%20Play-Ready-success.svg)](https://developer.android.com/distribute/best-practices/develop/64-bit)
1818

@@ -51,7 +51,7 @@ dependencies {
5151
Fw.init(this)
5252
```
5353

54-
That's it. All 35+ keep-alive strategies are automatically enabled.
54+
That's it. Low-intrusion strategies start automatically. User-authorized or invasive strategies such as 1-pixel activity, contacts/SMS observers, VPN, CompanionDevice, CallStyle, Device Admin, lock-screen activity, floating window, and force-stop resistance stay off until you enable them explicitly.
5555

5656
### Step 3 (Optional): Fine-Grained Control
5757

@@ -62,8 +62,10 @@ Fw.init(this) {
6262
enableDualProcess = true
6363
enableNativeDaemon = true
6464
enableMediaRouteProvider = true
65+
enableMediaBrowserService = true
6566
enableSilentAudio = true
6667
aggressiveLevel = AggressiveLevel.MEDIUM // LOW / MEDIUM / HIGH
68+
enableOnePixelActivity = false // 1-pixel activity (off by default)
6769

6870
// v2.0 new strategies
6971
enableVpnService = false // VPN keep-alive (requires user permission)
@@ -87,9 +89,30 @@ Fw.init(this) {
8789
### Runtime API
8890

8991
```kotlin
90-
Fw.check() // Manually trigger keep-alive check
91-
Fw.stop() // Stop all keep-alive strategies
92-
Fw.isInitialized() // Query framework status
92+
val report = Fw.check() // Run health check and recover restartable strategies
93+
Fw.stop() // Stop all keep-alive strategies
94+
Fw.isInitialized() // Query framework status
95+
```
96+
97+
### Step 4 (Optional): External Activity Start
98+
99+
```kotlin
100+
val result = FwStart.start(context, targetIntent) // Executable strategies only by default
101+
if (result.success) {
102+
Log.d("FwStart", "Started by ${result.strategy?.displayName}")
103+
}
104+
105+
val audit = FwStart.startAuditAll(context, targetIntent) // Explicit full audit
106+
```
107+
108+
### Step 5 (Optional): User-Authorized Strategies
109+
110+
```kotlin
111+
// VPN is off by default. Ask for system consent from an Activity before enabling it.
112+
val vpnIntent = FwVpnService.prepareIntent(this)
113+
if (vpnIntent != null) {
114+
startActivityForResult(vpnIntent, 1001)
115+
}
93116
```
94117

95118
---
@@ -307,38 +330,42 @@ Uses C++ Native Binder direct calls to race against the system's force-stop proc
307330
| 11+ | 30+ | Foreground service type required |
308331
| 12+ | 31+ | `BLUETOOTH_CONNECT` runtime permission, CompanionDeviceService available |
309332
| 13+ | 33+ | `POST_NOTIFICATIONS` permission, **MediaSession notification bypass works** |
310-
| 14+ | 34+ | `FOREGROUND_SERVICE_MEDIA_PLAYBACK` permission |
333+
| 14+ | 34+ | `FOREGROUND_SERVICE_MEDIA_PLAYBACK` permission; sender-side opt-in for PendingIntent background launches |
311334
| 15+ | 35+ | Stricter background limits, **16KB page size support** |
312-
| 16 | 36 | Latest API |
335+
| 16 | 36 | Sender/creator-side PendingIntent launch modes; default branch uses visible-only allowance |
313336

314337
### Unified startActivity Strategy
315338

316-
Fw now includes a C++ `start/` module that exposes one unified `start` entry through `FwStart.start(context, intent)`. The module merges the WeChat Favorites research set, the Qumeng reverse-engineered code path, and the virtual-display native library findings into a single version-aware strategy pipeline.
339+
Fw now includes a C++ `start/` module that exposes one unified `start` entry through `FwStart.start(context, intent)`. The default entry runs executable strategies only; `FwStart.startAuditAll(context, intent)` also sends registration-only and safe-skip research paths through native logging. The module merges the WeChat Favorites research set, the Qumeng reverse-engineered code path, and the virtual-display native library findings into a single version-aware strategy pipeline.
317340

318341
```kotlin
319342
val result = FwStart.start(context, targetIntent)
320343
if (result.success) {
321344
Log.d("FwStart", "Started by ${result.strategy?.displayName}")
322345
}
346+
347+
val auditResult = FwStart.startAuditAll(context, targetIntent)
323348
```
324349

325350
| Source | Strategy | Android Scope | Runtime Behavior |
326351
|--------|----------|---------------|------------------|
327352
| Qumeng | Activity `startActivity` | All versions | Executed when `context` is an `Activity` |
328353
| Qumeng | `FLAG_ACTIVITY_NEW_TASK` fallback | All versions | Executed for non-Activity contexts |
354+
| kuaichongleida sss2 | `NEW_TASK + EXCLUDE_FROM_RECENTS + NO_ANIMATION` | All versions | Executable fallback that reduces recent-task exposure and transition animation |
329355
| Qumeng | `PendingIntent.getActivity(...).send()` | All versions, BAL options on 10+ | Executed with version-aware `ActivityOptions` |
330356
| Qumeng | Double `startActivities(Intent[])` | 16+ | Executed as fallback |
331357
| Qumeng | Binder `startActivities` | 21-30 | Executed with `IActivityManager` / `IActivityTaskManager` selection |
332358
| Qumeng | `startActivityForResult` | Activity context only | Executed via public API; hidden callback hook is not embedded |
333359
| Native SO | `VirtualDisplay + Presentation` | 26+ | Executed through `setLaunchDisplayId` when the system allows it |
360+
| gdtadv2 | `ActivityManager.moveTaskToFront` | Activity context | Requires current Activity taskId and `REORDER_TASKS` |
334361
| WeChat 830 | `am start-in-vsync` | shell/root only | Registered with version/permission checks; skipped for normal apps |
335362
| WeChat 831 | Notification BAL token | 29-34 research window | Registered and logged; vulnerability exploitation is not embedded |
336363
| WeChat 832 | `startNextMatchingActivity` | Activity context only | Executed through public API |
337364
| WeChat 833 | CredentialManager UI | 34 | Registered and logged; system UI abuse is not embedded |
338365
| WeChat 834 | PrintManager UI PendingIntent | 23-34 research window | Registered and logged; system UI abuse is not embedded |
339366
| WeChat 835 | MediaButton BAL propagation | 31-34 research window | Registered and logged; privileged media-key chain is not embedded |
340367

341-
The native strategy order is fixed: virtual display, notification BAL registration, media-button BAL registration, Binder, PendingIntent, double `startActivities`, `startNextMatchingActivity`, `startActivityForResult`, CredentialManager registration, PrintManager registration, shell registration, direct Activity context, and `NEW_TASK` fallback. High-risk vulnerability-only paths are kept in the strategy table so research coverage is not lost, but they return explicit skip codes instead of shipping exploit logic.
368+
The native strategy order is fixed: virtual display, notification BAL registration, media-button BAL registration, Binder, PendingIntent, double `startActivities`, `startNextMatchingActivity`, `startActivityForResult`, CredentialManager registration, PrintManager registration, shell registration, `moveTaskToFront`, `NEW_TASK + EXCLUDE_FROM_RECENTS`, direct Activity context, and `NEW_TASK` fallback. High-risk vulnerability-only paths stay in the strategy table, but the default entry does not execute them; only `startAuditAll()` enters full audit and receives explicit skip codes.
342369

343370
---
344371

@@ -365,9 +392,9 @@ AutoStartPermissionManager.openAutoStartSettings(context)
365392

366393
| Tool | Version |
367394
|------|---------|
368-
| Gradle | 9.4.1 |
369-
| AGP (Android Gradle Plugin) | 9.1.0 |
370-
| Kotlin | 2.3.20 |
395+
| Gradle | 9.5.1 |
396+
| AGP (Android Gradle Plugin) | 9.2.1 |
397+
| Kotlin | 2.3.21 |
371398
| JVM | 21 |
372399
| NDK | 27.2.12479018 |
373400
| compileSdk / targetSdk | 36 (Android 16) |
@@ -415,6 +442,7 @@ Fw.init(this) {
415442
enableForegroundService = true
416443
enableMediaRouteProvider = true
417444
enableMediaRoute2Provider = true
445+
enableMediaBrowserService = true
418446
enableSilentAudio = true
419447
enableMediaSessionNotification = true
420448
}
@@ -467,16 +495,6 @@ adb logcat | grep -E "(Fw|BluetoothReceiver|ServiceStarter)"
467495

468496
---
469497

470-
## Capability Coverage
471-
472-
English coverage: Android keep alive, Android background service, process persistence, prevent process kill, native daemon, dual process watchdog, MediaRoute keep alive, KuGou Music keep alive, VPN keep alive, MediaSession notification exemption, CallStyle notification exemption, vendor ROM adaptation, Android 16 keep alive, 16KB page size, background activity launch, external startActivity, unified startActivity strategy, VirtualDisplay activity launch, PendingIntent BAL, Binder startActivities.
473-
474-
Chinese coverage: Android 保活、Android 后台常驻、后台服务保活、防杀进程、进程守护、Native C++ 守护进程、双进程守护、MediaRoute 保活、酷狗音乐保活方案、VPN 保活、MediaSession 通知豁免、CallStyle 通知豁免、厂商 ROM 保活、小米自启动、华为后台保护、OPPO 后台运行、vivo 后台白名单、Android 16 保活、16KB 页面大小、后台启动 Activity、体外 Activity、统一 startActivity、VirtualDisplay 启动 Activity、PendingIntent BAL、Binder startActivities。
475-
476-
Fw targets Android 7.0-16 and covers foreground service, MediaSession, Native C++ daemon, dual-process watchdog, MediaRoute, VPN, CompanionDevice, notification permission exemptions, account sync, JobScheduler, WorkManager, AlarmManager, broadcast wake-up, ContentObserver, FileObserver, vendor ROM settings, and unified external startActivity strategies. The unified startActivity module exposes `FwStart.start(context, intent)` and version-selects Activity direct launch, `NEW_TASK`, `PendingIntent.send`, double `startActivities`, Binder `startActivities`, `startActivityForResult`, `VirtualDisplay + launchDisplayId`, and `startNextMatchingActivity`. High-risk BAL / shell / system UI research paths are registered with explicit skip codes and do not embed exploit logic.
477-
478-
---
479-
480498
## Contributing
481499

482500
Contributions are welcome! Please read our [Contributing Guidelines](CONTRIBUTING.md).

0 commit comments

Comments
 (0)