From 7e145c5e1c4be62c47bee591d6e96eb361c9dfdc Mon Sep 17 00:00:00 2001 From: Joshua Trask Date: Thu, 23 Mar 2023 15:02:23 +0000 Subject: Skip refinement for suspended targets. It's just rude to send users into the refinement flow when we expect the launch to fail (with a message dialog indicating that the entire target app was never supposed to work; i.e., we make it clear to users that this failure had nothing to do with their refinement choices). OTOH if we skip refinement, we have some handling to bounce back into a usable Sharesheet session after that dialog appears, so we'd like to take advantage of that. A subsequent CL will "plug all the holes" in our handling of various refinement exit conditions. There's currently an analogous post-refinement "bounce back" for suspended targets, but we won't be able to recover a Sharesheet session at that time, so (TODO) we'll turn that into a hard failure (as with any other refinement problems). Bug: 273864843 Test: manually tested `adb shell cmd package suspend ` confirm we no longer invoke refinement (and instead trigger the system dialog immediately) when the suspended target is chosen. Change-Id: Iff1cf67f67015c754437726b8f52431deca797e0 --- java/src/com/android/intentresolver/ChooserRefinementManager.java | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'java/src/com') diff --git a/java/src/com/android/intentresolver/ChooserRefinementManager.java b/java/src/com/android/intentresolver/ChooserRefinementManager.java index 3ddc1c7c..23cf6ba0 100644 --- a/java/src/com/android/intentresolver/ChooserRefinementManager.java +++ b/java/src/com/android/intentresolver/ChooserRefinementManager.java @@ -77,6 +77,13 @@ public final class ChooserRefinementManager { if (selectedTarget.getAllSourceIntents().isEmpty()) { return false; } + if (selectedTarget.isSuspended()) { + // We expect all launches to fail for this target, so don't make the user go through the + // refinement flow first. Besides, the default (non-refinement) handling displays a + // warning in this case and recovers the session; we won't be equipped to recover if + // problems only come up after refinement. + return false; + } destroy(); // Terminate any prior sessions. mRefinementResultReceiver = new RefinementResultReceiver( -- cgit v1.2.3-59-g8ed1b