diff options
| author | 2024-05-30 18:48:21 +0000 | |
|---|---|---|
| committer | 2024-05-30 18:48:21 +0000 | |
| commit | b4f32dac1da25d614f3ef284ab499a4577177372 (patch) | |
| tree | 855e7c04c3c0cb28a96568ea344e2a9d9a6d5a37 /java/src | |
| parent | 057e8a500d3211cb47d000b0520f8c8f4dfc5e00 (diff) | |
| parent | 41bb0f4081f43e84cf4120b79ad4957311b4896b (diff) | |
Merge changes I6b81b875,Ie13464cb into main
* changes:
Add logcat to all finish() call sites
Suppress ShareResult for launch of Editor component
Diffstat (limited to 'java/src')
| -rw-r--r-- | java/src/com/android/intentresolver/ChooserActionFactory.java | 6 | ||||
| -rw-r--r-- | java/src/com/android/intentresolver/ChooserActivity.java | 20 |
2 files changed, 24 insertions, 2 deletions
diff --git a/java/src/com/android/intentresolver/ChooserActionFactory.java b/java/src/com/android/intentresolver/ChooserActionFactory.java index 79998fbc..dae1ab52 100644 --- a/java/src/com/android/intentresolver/ChooserActionFactory.java +++ b/java/src/com/android/intentresolver/ChooserActionFactory.java @@ -88,7 +88,9 @@ public final class ChooserActionFactory implements ChooserContentPreviewUi.Actio // Boolean extra used to inform the editor that it may want to customize the editing experience // for the sharesheet editing flow. - private static final String EDIT_SOURCE = "edit_source"; + // Note: EDIT_SOURCE is also used as a signal to avoid sending a 'Component Selected' + // ShareResult for this intent when sent via ChooserActivity#safelyStartActivityAsUser + static final String EDIT_SOURCE = "edit_source"; private static final String EDIT_SOURCE_SHARESHEET = "sharesheet"; private static final String CHIP_LABEL_METADATA_KEY = "android.service.chooser.chip_label"; @@ -255,6 +257,7 @@ public final class ChooserActionFactory implements ChooserContentPreviewUi.Actio clipboardManager.setPrimaryClipAsPackage(clipData, referrerPackageName); log.logActionSelected(EventLog.SELECTION_TYPE_COPY); + Log.d(TAG, "finish due to copy clicked"); finishCallback.accept(Activity.RESULT_OK); }; } @@ -393,6 +396,7 @@ public final class ChooserActionFactory implements ChooserContentPreviewUi.Actio if (shareResultSender != null) { shareResultSender.onActionSelected(ShareAction.APPLICATION_DEFINED); } + Log.d(TAG, "finish due to custom action clicked"); finishCallback.accept(Activity.RESULT_OK); } ); diff --git a/java/src/com/android/intentresolver/ChooserActivity.java b/java/src/com/android/intentresolver/ChooserActivity.java index 9643b9f0..7353ff37 100644 --- a/java/src/com/android/intentresolver/ChooserActivity.java +++ b/java/src/com/android/intentresolver/ChooserActivity.java @@ -22,6 +22,7 @@ import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTE import static androidx.lifecycle.LifecycleKt.getCoroutineScope; +import static com.android.intentresolver.ChooserActionFactory.EDIT_SOURCE; import static com.android.intentresolver.ext.CreationExtrasExtKt.addDefaultArgs; import static com.android.intentresolver.profiles.MultiProfilePagerAdapter.PROFILE_PERSONAL; import static com.android.intentresolver.profiles.MultiProfilePagerAdapter.PROFILE_WORK; @@ -392,6 +393,7 @@ public class ChooserActivity extends Hilt_ChooserActivity implements // so we will now finish ourself since being no longer visible, // the user probably can't get back to us. if (!isChangingConfigurations()) { + Log.d(TAG, "finishing in onStop"); finish(); } } @@ -724,6 +726,9 @@ public class ChooserActivity extends Hilt_ChooserActivity implements } private void onAppTargetsLoaded(ResolverListAdapter listAdapter) { + Log.d(TAG, "onAppTargetsLoaded(" + + "listAdapter.userHandle=" + listAdapter.getUserHandle() + ")"); + if (mChooserMultiProfilePagerAdapter == null) { return; } @@ -859,6 +864,7 @@ public class ChooserActivity extends Hilt_ChooserActivity implements final TargetInfo target = mChooserMultiProfilePagerAdapter.getActiveListAdapter() .targetInfoForPosition(0, false); if (shouldAutoLaunchSingleChoice(target)) { + Log.d(TAG, "auto launching " + target + " and finishing."); safelyStartActivity(target); finish(); return true; @@ -927,6 +933,7 @@ public class ChooserActivity extends Hilt_ChooserActivity implements .setStrings(getMetricsCategory()) .write(); safelyStartActivity(activeProfileTarget); + Log.d(TAG, "auto launching! " + activeProfileTarget); finish(); return true; } @@ -1079,7 +1086,10 @@ public class ChooserActivity extends Hilt_ChooserActivity implements } try { if (cti.startAsCaller(this, options, user.getIdentifier())) { - maybeSendShareResult(cti); + // Prevent sending a second chooser result when starting the edit action intent. + if (!cti.getTargetIntent().hasExtra(EDIT_SOURCE)) { + maybeSendShareResult(cti); + } maybeLogCrossProfileTargetLaunch(cti, user); } } catch (RuntimeException e) { @@ -1190,6 +1200,7 @@ public class ChooserActivity extends Hilt_ChooserActivity implements (ChooserListAdapter) listAdapter, mProfileAvailability.getWaitingToEnableProfile())) { // We no longer have any items... just finish the activity. + Log.d(TAG, "onHandlePackagesChanged(): returned false, finishing"); finish(); } } @@ -1757,6 +1768,7 @@ public class ChooserActivity extends Hilt_ChooserActivity implements mChooserMultiProfilePagerAdapter.getActiveListAdapter().hasFilteredItem() ? MetricsEvent.ACTION_HIDE_APP_DISAMBIG_APP_FEATURED : MetricsEvent.ACTION_HIDE_APP_DISAMBIG_NONE_FEATURED); + Log.d(TAG, "onTargetSelected() returned true, finishing! " + target); finish(); } } @@ -2179,6 +2191,8 @@ public class ChooserActivity extends Hilt_ChooserActivity implements targetInfo, mProfiles.getPersonalHandle() ); + Log.d(TAG, "safelyStartActivityAsPersonalProfileUser(" + + targetInfo + "): finishing!"); finish(); } @@ -2214,6 +2228,7 @@ public class ChooserActivity extends Hilt_ChooserActivity implements if (status != null) { setResult(status); } + Log.d(TAG, "finishWithStatus: result=" + status); finish(); } @@ -2356,6 +2371,8 @@ public class ChooserActivity extends Hilt_ChooserActivity implements } protected void onListRebuilt(ResolverListAdapter listAdapter, boolean rebuildComplete) { + Log.d(TAG, "onListRebuilt(listAdapter.userHandle=" + listAdapter.getUserHandle() + ", " + + "rebuildComplete=" + rebuildComplete + ")"); setupScrollListener(); maybeSetupGlobalLayoutListener(); @@ -2371,6 +2388,7 @@ public class ChooserActivity extends Hilt_ChooserActivity implements //TODO: move this block inside ChooserListAdapter (should be called when // ResolverListAdapter#mPostListReadyRunnable is executed. if (chooserListAdapter.getDisplayResolveInfoCount() == 0) { + Log.d(TAG, "getDisplayResolveInfoCount() == 0"); if (rebuildComplete && mChooserServiceFeatureFlags.chooserPayloadToggling()) { onAppTargetsLoaded(listAdapter); } |