From 41bb0f4081f43e84cf4120b79ad4957311b4896b Mon Sep 17 00:00:00 2001 From: Mark Renouf Date: Wed, 29 May 2024 22:00:09 -0400 Subject: Add logcat to all finish() call sites For future troubleshooting aid and ongoing investigation of b/334179669 (sharesheet dismisses unexpectedly during GTS-I). The theory is that Sharesheet is incorrectly invoking finish at some point after switching tabs within the test, but there is no way to identify the code path taken to calling finish(). Bug: 334179669 Flag: EXEMPT bugfix Test: compile Change-Id: I6b81b87506ce1ecff795772f9d1283ce533552a3 --- .../com/android/intentresolver/ChooserActionFactory.java | 2 ++ java/src/com/android/intentresolver/ChooserActivity.java | 14 ++++++++++++++ 2 files changed, 16 insertions(+) (limited to 'java/src/com') diff --git a/java/src/com/android/intentresolver/ChooserActionFactory.java b/java/src/com/android/intentresolver/ChooserActionFactory.java index d6153b36..dae1ab52 100644 --- a/java/src/com/android/intentresolver/ChooserActionFactory.java +++ b/java/src/com/android/intentresolver/ChooserActionFactory.java @@ -257,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); }; } @@ -395,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 66810187..7353ff37 100644 --- a/java/src/com/android/intentresolver/ChooserActivity.java +++ b/java/src/com/android/intentresolver/ChooserActivity.java @@ -393,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(); } } @@ -725,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; } @@ -860,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; @@ -928,6 +933,7 @@ public class ChooserActivity extends Hilt_ChooserActivity implements .setStrings(getMetricsCategory()) .write(); safelyStartActivity(activeProfileTarget); + Log.d(TAG, "auto launching! " + activeProfileTarget); finish(); return true; } @@ -1194,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(); } } @@ -1761,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(); } } @@ -2183,6 +2191,8 @@ public class ChooserActivity extends Hilt_ChooserActivity implements targetInfo, mProfiles.getPersonalHandle() ); + Log.d(TAG, "safelyStartActivityAsPersonalProfileUser(" + + targetInfo + "): finishing!"); finish(); } @@ -2218,6 +2228,7 @@ public class ChooserActivity extends Hilt_ChooserActivity implements if (status != null) { setResult(status); } + Log.d(TAG, "finishWithStatus: result=" + status); finish(); } @@ -2360,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(); @@ -2375,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); } -- cgit v1.2.3-59-g8ed1b