-
-
Notifications
You must be signed in to change notification settings - Fork 28
Every stock-launcher path disables or restores its paired setup helper (#157, #158) #159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1a72456
fa521f4
41291de
60233e3
64cff76
d5ec864
fea28ed
c8a9118
7b83516
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -449,12 +449,95 @@ pub(crate) async fn disable_package_impl( | |
| return Ok(refusal); | ||
| } | ||
| state.require_pro(Feature::CuratedDebloat)?; | ||
| run( | ||
| // A stock launcher with a paired setup helper (Google TV's Setup Wraith): | ||
| // read the Home apps before disabling it, so the helper can follow (#157). | ||
| let pairs_helper = !super::loader::launchers() | ||
| .disable_with_for(package) | ||
| .is_empty(); | ||
| let inventory = if pairs_helper { | ||
| let adb = state.adb_snapshot().await; | ||
| match adb.shell(serial, super::launcher::HOME_HANDLER_QUERY).await { | ||
| Ok(out) if out.success() && !out.shell_reported_failure() => { | ||
| Some(super::launcher::parse_home_handler_packages(&out.stdout)) | ||
| .filter(|h| !h.is_empty()) | ||
| } | ||
| _ => None, | ||
| } | ||
| } else { | ||
| None | ||
| }; | ||
| let outcome = run( | ||
| state, | ||
| serial, | ||
| &format!("pm disable-user --user 0 {package}"), | ||
| ) | ||
| .await | ||
| .await; | ||
| if !pairs_helper { | ||
| return outcome; | ||
| } | ||
| // An errored or failure-marked disable may still have landed (the | ||
| // takeover path assumes the same), and stock off with its helper on is | ||
| // the unsafe state, so ask the device rather than trust the reply. | ||
| let landed = match &outcome { | ||
| Ok(r) if r.ok => true, | ||
| _ => { | ||
| let adb = state.adb_snapshot().await; | ||
| matches!( | ||
| adb.shell(serial, &format!("pm list packages -d {package}")).await, | ||
| Ok(out) if out.success() | ||
| && out.stdout.lines().any(|l| l.trim() == format!("package:{package}")) | ||
| ) | ||
| } | ||
| }; | ||
| let mut result = match outcome { | ||
| Ok(r) if r.ok => r, | ||
| Ok(r) if landed => ActionResult { | ||
| ok: true, | ||
| message: r.message, | ||
| }, | ||
| Err(_) if landed => ActionResult { | ||
| ok: true, | ||
| message: format!("{package} was disabled (the device's reply was lost)."), | ||
| }, | ||
| other => return other, | ||
| }; | ||
| if result.ok { | ||
| let adb = state.adb_snapshot().await; | ||
| let mut diagnostics = Vec::new(); | ||
| use super::launcher::PairedHelperOutcome as Outcome; | ||
| match super::launcher::settle_paired_helpers_after_stock_disable( | ||
| &*adb, | ||
| serial, | ||
| package, | ||
| inventory.as_deref(), | ||
| &mut diagnostics, | ||
| ) | ||
| .await | ||
| { | ||
| Outcome::Untouched => {} | ||
| Outcome::Disabled { target } => result.message.push_str(&format!( | ||
| " Google TV's setup helper (Setup Wraith) was turned off too, so {target} keeps the Home button." | ||
| )), | ||
| Outcome::RolledBack { reason } => { | ||
| result.ok = false; | ||
| result.message = format!( | ||
| "Couldn't turn off Google TV's setup helper after disabling {package}: {reason}." | ||
| ); | ||
| } | ||
| // Reported as not-ok so every caller shows it: a success toast | ||
| // would hide that the helper can still take the Home button. | ||
| Outcome::LeftOn => { | ||
| result.ok = false; | ||
| result.message = format!( | ||
|
Comment on lines
+527
to
+531
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When another launcher is installed but Android still resolves Home to Setup Wraith after Useful? React with 👍 / 👎.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in fea28ed.
Comment on lines
+529
to
+531
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When stock is disabled but no replacement currently holds Home, Useful? React with 👍 / 👎.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in c8a9118. |
||
| "{package} was disabled, but Google TV's setup helper (Setup Wraith) is still \ | ||
| on and can take the Home button. Set another launcher as Home, then use Turn \ | ||
| it off on the Launcher tab." | ||
|
Comment on lines
+530
to
+534
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When this branch reports that stock was actually disabled but Setup Wraith remains able to capture Home, the inspected mobile Optimize flow still discards Useful? React with 👍 / 👎. |
||
| ); | ||
| } | ||
| } | ||
| tracing::info!(serial, package, diagnostics = ?diagnostics, "stock disable: paired helper"); | ||
| } | ||
| Ok(result) | ||
| } | ||
|
|
||
| /// `Some(refusal)` when disabling `package` would leave the device without an | ||
|
|
@@ -490,10 +573,38 @@ pub async fn enable_package( | |
| serial: String, | ||
| package: String, | ||
| ) -> Result<ActionResult, String> { | ||
| if let Some(rejection) = reject_invalid_package(&package) { | ||
| enable_package_impl(&state, &serial, &package).await | ||
| } | ||
|
|
||
| pub(crate) async fn enable_package_impl( | ||
| state: &AppState, | ||
| serial: &str, | ||
| package: &str, | ||
| ) -> Result<ActionResult, String> { | ||
| if let Some(rejection) = reject_invalid_package(package) { | ||
| return Ok(rejection); | ||
| } | ||
| run(&state, &serial, &format!("pm enable {package}")).await | ||
| let mut result = run(state, serial, &format!("pm enable {package}")).await?; | ||
| // App List and Optimize Restore bring a disabled stock launcher back | ||
| // through here, so its paired setup helper (Setup Wraith) follows (#158). | ||
| if result.ok | ||
| && !super::loader::launchers() | ||
| .disable_with_for(package) | ||
| .is_empty() | ||
|
Comment on lines
+588
to
+593
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This restoration hook only covers Useful? React with 👍 / 👎.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 64cff76, with tests. |
||
| { | ||
| let adb = state.adb_snapshot().await; | ||
| let mut diagnostics = Vec::new(); | ||
| if let Some(warning) = | ||
| super::launcher::reenable_paired_helpers(&*adb, serial, package, &mut diagnostics).await | ||
| { | ||
| // Not-ok so Optimize and the App List show it rather than a plain | ||
| // "Enabled": stock is back, the helper is not. | ||
| result.ok = false; | ||
| result.message = format!("{package} was enabled. {warning}"); | ||
|
Comment on lines
+600
to
+603
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in c8a9118. |
||
| } | ||
| tracing::info!(serial, package, diagnostics = ?diagnostics, "stock enable: paired helper"); | ||
| } | ||
| Ok(result) | ||
| } | ||
|
|
||
| /// `trim_caches` — ask the package manager to clear app caches device-wide. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When applying a snapshot whose
disabled_packagescontains Google TV Home while Setup Wraith is enabled—such as a snapshot captured before this fix—apply_snapshotstill calls the directdisable_from_planloop atsnapshot.rs:348-370, bypassing this new settlement logic. If the current Home app already matches the snapshot,launcher_to_setisNone, so nothing later disables the helper; stock is turned off while Setup Wraith remains able to capture Home. Route snapshot stock-launcher disables through the paired-helper safety flow as well.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in c8a9118.