diff options
| author | 2024-01-26 13:26:01 -0800 | |
|---|---|---|
| committer | 2024-01-26 13:45:14 -0800 | |
| commit | 7b468b86871b26e164c9bf8163fe7ca810ddbe08 (patch) | |
| tree | a8edd2e6a045e864afc661f86e908dbf92dc1c8c /java/src | |
| parent | 8b814a1856c02b339e7bba57b82e03bcc0989f88 (diff) | |
ChooserAdapter: fix NPE for non-work profiles
For some non-work profiles (Communal, and maybe Private), the
getListAdapterForUserHandle is returning null. The method is indeed
nullable. But we run getCount on it without doing a null-check,
causing crashes for such profiles.
This previously couldn't have happened, since shouldShowTabs() returns
false in these cases, and the evaluation was skipped; however,
ag/I8273cf365a1e00b1acff4030086f1a044ad7531f moved that check to later,
so we are hitting this problem.
Bug: 322523699
Bug: 320369524
Bug: 320615143
Bug: 322497953
Test: atest IntentResolver-tests-unit
Change-Id: I82303d6a6a1be1066f5c3e05c53f6a70d486bf5a
Diffstat (limited to 'java/src')
| -rw-r--r-- | java/src/com/android/intentresolver/ChooserActivity.java | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/java/src/com/android/intentresolver/ChooserActivity.java b/java/src/com/android/intentresolver/ChooserActivity.java index 82e46a57..e30c198a 100644 --- a/java/src/com/android/intentresolver/ChooserActivity.java +++ b/java/src/com/android/intentresolver/ChooserActivity.java @@ -1651,8 +1651,9 @@ public class ChooserActivity extends Hilt_ChooserActivity implements if (!shouldShowContentPreview()) { return false; } - boolean isEmpty = mMultiProfilePagerAdapter.getListAdapterForUserHandle( - UserHandle.of(UserHandle.myUserId())).getCount() == 0; + ResolverListAdapter adapter = mMultiProfilePagerAdapter.getListAdapterForUserHandle( + UserHandle.of(UserHandle.myUserId())); + boolean isEmpty = adapter == null || adapter.getCount() == 0; return (mFeatureFlags.scrollablePreview() || shouldShowTabs()) && (!isEmpty || shouldShowContentPreviewWhenEmpty()); } |