diff options
| author | 2023-07-07 04:10:33 +0000 | |
|---|---|---|
| committer | 2023-07-07 04:10:33 +0000 | |
| commit | 37440a296b0f2b55243fe6949bb171f5b66b9503 (patch) | |
| tree | 585d0c63dd814dc4e1ef8c8549bb10631e21d158 /java/src | |
| parent | 8215c15cff272d17219164bd92cab1bebce9044d (diff) | |
| parent | 3a0ac7d534fb3dda80de82a889511344850b2c3f (diff) | |
Merge "Add a null check for a rare error case." into udc-qpr-dev
Diffstat (limited to 'java/src')
| -rw-r--r-- | java/src/com/android/intentresolver/ChooserActivity.java | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/java/src/com/android/intentresolver/ChooserActivity.java b/java/src/com/android/intentresolver/ChooserActivity.java index 3409ca0a..7ebcf9f9 100644 --- a/java/src/com/android/intentresolver/ChooserActivity.java +++ b/java/src/com/android/intentresolver/ChooserActivity.java @@ -882,7 +882,7 @@ public class ChooserActivity extends ResolverActivity implements final long selectionCost = System.currentTimeMillis() - mChooserShownTime; - if (targetInfo.isMultiDisplayResolveInfo()) { + if ((targetInfo != null) && targetInfo.isMultiDisplayResolveInfo()) { MultiDisplayResolveInfo mti = (MultiDisplayResolveInfo) targetInfo; if (!mti.hasSelected()) { // Add userHandle based badge to the stackedAppDialogBox. @@ -897,7 +897,17 @@ public class ChooserActivity extends ResolverActivity implements super.startSelected(which, always, filtered); - if (currentListAdapter.getCount() > 0) { + // TODO: both of the conditions around this switch logic *should* be redundant, and + // can be removed if certain invariants can be guaranteed. In particular, it seems + // like targetInfo (from `ChooserListAdapter.targetInfoForPosition()`) is *probably* + // expected to be null only at out-of-bounds indexes where `getPositionTargetType()` + // returns TARGET_BAD; then the switch falls through to a default no-op, and we don't + // need to null-check targetInfo. We only need the null check if it's possible that + // the ChooserListAdapter contains null elements "in the middle" of its list data, + // such that they're classified as belonging to one of the real target types. That + // should probably never happen. But why would this method ever be invoked with a + // null target at all? Even an out-of-bounds index should never be "selected"... + if ((currentListAdapter.getCount() > 0) && (targetInfo != null)) { switch (currentListAdapter.getPositionTargetType(which)) { case ChooserListAdapter.TARGET_SERVICE: getChooserActivityLogger().logShareTargetSelected( |