summaryrefslogtreecommitdiff
path: root/java/src/com
diff options
context:
space:
mode:
author Joshua Trask <joshtrask@google.com> 2024-11-22 18:19:08 +0000
committer Joshua Trask <joshtrask@google.com> 2024-11-22 18:19:08 +0000
commit8046148e83998422fc4555757e6e03f4659027c3 (patch)
tree2ff766637079f33c8344634d3d68451055b0a495 /java/src/com
parentae552c0849242379a39a248bab11092211831473 (diff)
Skip "last-chosen" query for Chooser
`getLastChosen()` is invoked in the course of the generic/"base-class" `ResolverListAdapter::rebuildList()`, and the result is cached as `mLastChosen`. By inspection, `mLastChosen` is *only* ever read by `ResolverListAdapter` methods that are gated on `mFilterLastUsed` (except when it's used internally to derive `mLastChosenPosition`, but that field is *also* only used in conjunction with `mFilterLastUsed`). `mFilterLastUsed` is final and false in all instances of the `ChooserListAdapter` subclass (i.e., any `ChooserActivity` configuration): go/chooser-mfilterlastused-false. In some cases (for unknown reason, b/335196436), the call to `getLastChosen()` crashes in Chooser; this CL should safely workaround that problem. Even if it wasn't failing, we could expect some performance boost by omitting the unnecessary system call. Note that Chooser configurations will still call `setLastChosen()` (via the base `ResolverActivity::onTargetSelected()`) to *write* this setting in the system, so it'll still be reflected in subsequent *ResolverActivity* sessions -- it's just never *read* in Chooser. Writing from Chooser probably has only "marginal" user value, but there's no need to change that legacy behavior at this time. Test: existing `IntentForwarder` & CTS tests. Bug: 335196436 Flag: EXEMPT bugfix Change-Id: Ieaf4bc713d51494a6a3ada89810f232b8875108f
Diffstat (limited to 'java/src/com')
-rw-r--r--java/src/com/android/intentresolver/ResolverListAdapter.java20
1 files changed, 12 insertions, 8 deletions
diff --git a/java/src/com/android/intentresolver/ResolverListAdapter.java b/java/src/com/android/intentresolver/ResolverListAdapter.java
index fc5514b6..f29553eb 100644
--- a/java/src/com/android/intentresolver/ResolverListAdapter.java
+++ b/java/src/com/android/intentresolver/ResolverListAdapter.java
@@ -404,14 +404,18 @@ public class ResolverListAdapter extends BaseAdapter {
);
} else {
mOtherProfile = null;
- try {
- mLastChosen = mResolverListController.getLastChosen();
- // TODO: does this also somehow need to update mLastChosenPosition? If so, maybe
- // the current method should also take responsibility for re-initializing
- // mLastChosenPosition, where it's currently done at the start of rebuildList()?
- // (Why is this related to the presence of mOtherProfile in fhe first place?)
- } catch (RemoteException re) {
- Log.d(TAG, "Error calling getLastChosenActivity\n" + re);
+ // If `mFilterLastUsed` is (`final`) false, we'll never read `mLastChosen`, so don't
+ // bother making the system query.
+ if (mFilterLastUsed) {
+ try {
+ mLastChosen = mResolverListController.getLastChosen();
+ // TODO: does this also somehow need to update mLastChosenPosition? If so, maybe
+ // the current method should also take responsibility for re-initializing
+ // mLastChosenPosition, where it's currently done at the start of rebuildList()?
+ // (Why is this related to the presence of mOtherProfile in fhe first place?)
+ } catch (RemoteException re) {
+ Log.d(TAG, "Error calling getLastChosenActivity\n" + re);
+ }
}
}
}