Skip to content

Commit 1951ba0

Browse files
committed
fix(automation,webui): grace-period cleanup and accent color persistence
cleanup_dead_apps was immediately removing packages invisible to pm list (HMA filtering, multi-user, transient during updates). Now checks /data/data/<pkg> and requires 3 consecutive misses. WebUI accent picker didn't disable randomization on manual pick, so the choice was overwritten on next page load. Also made the target.txt save atomic (tmp+mv) to prevent daemon truncation race.
1 parent 5c08536 commit 1951ba0

6 files changed

Lines changed: 70 additions & 20 deletions

File tree

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## v5.27.0 (2026-03-18)
4+
5+
### Bug Fixes
6+
- **Accent color not persisting** — manually picking an accent color from the picker didn't disable randomization, so the next page load or tab switch would randomize over the user's choice. Picker now auto-disables randomization and syncs the toggle state
7+
- **Apps silently removed from target.txt**`cleanup_dead_apps` relied solely on `pm list packages -3` which can be filtered by HideMyAppList or miss apps in other user profiles. Now cross-checks `/data/data/<pkg>` existence and requires 3 consecutive misses before removing, preventing false removals during app updates or when HMA is active
8+
- **WebUI save race with daemon**`target.txt` was written non-atomically (`echo > file`), allowing the daemon to read a truncated file mid-write. Now uses temp-file-then-rename
9+
10+
---
11+
312
## v5.26.0 (2026-03-17)
413

514
### Bug Fixes

module.prop

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
id=TA_enhanced
22
name=Tricky Addon Enhanced
3-
version=v5.26.0
4-
versionCode=50028
3+
version=v5.27.0
4+
versionCode=50029
55
author=Enginex0
66
description=Enhanced TrickyStore addon with dual-source keybox, auto security patch, conflict detection & sleek WebUI
77
updateJson=https://raw.githubusercontent.com/Enginex0/tricky-addon-enhanced/main/update.json

rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ta-enhanced"
3-
version = "5.26.0"
3+
version = "5.27.0"
44
edition = "2021"
55

66
[dependencies]

rust/src/automation/watcher.rs

Lines changed: 53 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::collections::HashSet;
1+
use std::collections::{HashMap, HashSet};
22
use std::path::Path;
33
use std::process::Command;
44
use crate::platform::fs::{atomic_write, ensure_dir};
@@ -7,6 +7,8 @@ use super::DaemonStatus;
77

88
const AUTOMATION_DIR: &str = "/data/adb/tricky_store/.automation";
99
const KNOWN_PACKAGES: &str = "/data/adb/tricky_store/.automation/known_packages.txt";
10+
const CLEANUP_GRACE: &str = "/data/adb/tricky_store/.automation/cleanup_grace.txt";
11+
const GRACE_THRESHOLD: u32 = 3;
1012

1113
pub fn check_new_packages(exclude_list: &[String], manager: Option<&str>) -> anyhow::Result<u32> {
1214
ensure_dir(Path::new(AUTOMATION_DIR))?;
@@ -45,17 +47,31 @@ pub fn check_new_packages(exclude_list: &[String], manager: Option<&str>) -> any
4547
pub fn cleanup_dead_apps() -> anyhow::Result<u32> {
4648
let installed = list_third_party_packages()?;
4749
let target_list = target::read_target()?;
50+
let mut grace = load_grace_counts();
4851
let mut removed = 0u32;
4952

5053
for pkg in &target_list {
51-
if !installed.contains(pkg) && !is_system_package(pkg) {
52-
if target::remove_package(pkg)? {
53-
removed += 1;
54-
tracing::info!("removed uninstalled {pkg} from target");
55-
}
54+
if installed.contains(pkg) || app_data_exists(pkg) {
55+
grace.remove(pkg);
56+
continue;
57+
}
58+
59+
let count = grace.entry(pkg.clone()).or_insert(0);
60+
*count += 1;
61+
62+
if *count < GRACE_THRESHOLD {
63+
tracing::debug!("{pkg} not visible to pm ({count}/{GRACE_THRESHOLD})");
64+
continue;
5665
}
66+
67+
if target::remove_package(pkg)? {
68+
removed += 1;
69+
tracing::info!("removed uninstalled {pkg} from target");
70+
}
71+
grace.remove(pkg);
5772
}
5873

74+
save_grace_counts(&grace)?;
5975
Ok(removed)
6076
}
6177

@@ -129,12 +145,6 @@ fn list_third_party_packages() -> anyhow::Result<HashSet<String>> {
129145
.collect())
130146
}
131147

132-
fn is_system_package(pkg: &str) -> bool {
133-
pkg.starts_with("com.android.")
134-
|| pkg.starts_with("com.google.android.")
135-
|| pkg.starts_with("android")
136-
}
137-
138148
fn get_apk_path(package: &str) -> Option<String> {
139149
Command::new("pm")
140150
.args(["path", package])
@@ -150,6 +160,10 @@ fn get_apk_path(package: &str) -> Option<String> {
150160
})
151161
}
152162

163+
fn app_data_exists(pkg: &str) -> bool {
164+
Path::new(&format!("/data/data/{pkg}")).exists()
165+
}
166+
153167
fn load_known_packages() -> HashSet<String> {
154168
std::fs::read_to_string(KNOWN_PACKAGES)
155169
.unwrap_or_default()
@@ -169,3 +183,30 @@ fn save_known_packages(packages: &HashSet<String>) -> anyhow::Result<()> {
169183
}
170184
atomic_write(Path::new(KNOWN_PACKAGES), data.as_bytes())
171185
}
186+
187+
fn load_grace_counts() -> HashMap<String, u32> {
188+
std::fs::read_to_string(CLEANUP_GRACE)
189+
.unwrap_or_default()
190+
.lines()
191+
.filter_map(|l| {
192+
let (pkg, count) = l.rsplit_once(':')?;
193+
Some((pkg.to_string(), count.parse().ok()?))
194+
})
195+
.collect()
196+
}
197+
198+
fn save_grace_counts(counts: &HashMap<String, u32>) -> anyhow::Result<()> {
199+
if counts.is_empty() {
200+
let _ = std::fs::remove_file(CLEANUP_GRACE);
201+
return Ok(());
202+
}
203+
let mut pairs: Vec<_> = counts.iter().collect();
204+
pairs.sort_by_key(|(k, _)| k.as_str());
205+
let content: String = pairs.iter()
206+
.map(|(k, v)| format!("{k}:{v}"))
207+
.collect::<Vec<_>>()
208+
.join("\n");
209+
let mut data = content;
210+
data.push('\n');
211+
atomic_write(Path::new(CLEANUP_GRACE), data.as_bytes())
212+
}

update.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"version": "v5.26.0",
3-
"versionCode": 50028,
4-
"zipUrl": "https://github.com/Enginex0/tricky-addon-enhanced/releases/download/v5.26.0/TA_enhanced-v5.26.0.zip",
2+
"version": "v5.27.0",
3+
"versionCode": 50029,
4+
"zipUrl": "https://github.com/Enginex0/tricky-addon-enhanced/releases/download/v5.27.0/TA_enhanced-v5.27.0.zip",
55
"changelog": "https://raw.githubusercontent.com/Enginex0/tricky-addon-enhanced/main/CHANGELOG.md"
66
}

0 commit comments

Comments
 (0)