diff options
| author | 2022-10-24 13:56:21 +0000 | |
|---|---|---|
| committer | 2022-10-27 20:57:40 +0000 | |
| commit | 9bcaf18b0fda7adb1a93c5d170e390bf3b7ce0e3 (patch) | |
| tree | 15bf26f81f84f2dba6c9409dddc244ef8acce996 /java/src | |
| parent | 8d51b6f18d47cc6d019529a6b7f1938936d14b4a (diff) | |
Remove experiment code to promote nearby as 1st target
- Verified that we don't expect to do this experiment in U, nothing else
was using this code so we can simplify.
- Fix NPE that was hidden in the code (see bug).
- Slight change to the excluded components behavior where the entire
array given for EXTRA_EXCLUDE_COMPONENTS must be of type
ComponentName[] otherwise it'll be ignored after logging an error.
Relevant prior CLs:
- ag/15527538 added this functionality (zzhen)
- ag/17871086 added direct share pinning and modified some of these
methods (songhu)
Bug: 254895117
Test: atest AbstractResolverComparatorTest
Test: atest CtsSharesheetDeviceTest (with flag enabled)
Test: Manual verification that nearby component still hidden.
Change-Id: I0306eb2547a2f60823d7c9d77d86e743d432fefc
Diffstat (limited to 'java/src')
4 files changed, 22 insertions, 101 deletions
diff --git a/java/src/com/android/intentresolver/AbstractResolverComparator.java b/java/src/com/android/intentresolver/AbstractResolverComparator.java index 6f802876..07dcd664 100644 --- a/java/src/com/android/intentresolver/AbstractResolverComparator.java +++ b/java/src/com/android/intentresolver/AbstractResolverComparator.java @@ -161,11 +161,6 @@ public abstract class AbstractResolverComparator implements Comparator<ResolvedC final ResolveInfo lhs = lhsp.getResolveInfoAt(0); final ResolveInfo rhs = rhsp.getResolveInfoAt(0); - final boolean lFixedAtTop = lhsp.isFixedAtTop(); - final boolean rFixedAtTop = rhsp.isFixedAtTop(); - if (lFixedAtTop && !rFixedAtTop) return -1; - if (!lFixedAtTop && rFixedAtTop) return 1; - // We want to put the one targeted to another user at the end of the dialog. if (lhs.targetUserId != UserHandle.USER_CURRENT) { return rhs.targetUserId != UserHandle.USER_CURRENT ? 0 : 1; diff --git a/java/src/com/android/intentresolver/ChooserActivity.java b/java/src/com/android/intentresolver/ChooserActivity.java index 6455e4d1..6735ab4e 100644 --- a/java/src/com/android/intentresolver/ChooserActivity.java +++ b/java/src/com/android/intentresolver/ChooserActivity.java @@ -242,12 +242,6 @@ public class ChooserActivity extends ResolverActivity implements SystemUiDeviceConfigFlags.HASH_SALT_MAX_DAYS, DEFAULT_SALT_EXPIRATION_DAYS); - private static final boolean DEFAULT_IS_NEARBY_SHARE_FIRST_TARGET_IN_RANKED_APP = false; - private boolean mIsNearbyShareFirstTargetInRankedApp = - DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI, - SystemUiDeviceConfigFlags.IS_NEARBY_SHARE_FIRST_TARGET_IN_RANKED_APP, - DEFAULT_IS_NEARBY_SHARE_FIRST_TARGET_IN_RANKED_APP); - private static final int DEFAULT_LIST_VIEW_UPDATE_DELAY_MS = 0; private static final int URI_PERMISSION_INTENT_FLAGS = Intent.FLAG_GRANT_READ_URI_PERMISSION @@ -265,7 +259,7 @@ public class ChooserActivity extends ResolverActivity implements private IntentSender mRefinementIntentSender; private RefinementResultReceiver mRefinementResultReceiver; private ChooserTarget[] mCallerChooserTargets; - private ComponentName[] mFilteredComponentNames; + private ArrayList<ComponentName> mFilteredComponentNames; private Intent mReferrerFillInIntent; @@ -619,32 +613,22 @@ public class ChooserActivity extends ResolverActivity implements mPinnedSharedPrefs = getPinnedSharedPrefs(this); - pa = intent.getParcelableArrayExtra(Intent.EXTRA_EXCLUDE_COMPONENTS); - - - // Exclude out Nearby from main list if chip is present, to avoid duplication - ComponentName nearbySharingComponent = getNearbySharingComponent(); - boolean shouldFilterNearby = !shouldNearbyShareBeFirstInRankedRow() - && nearbySharingComponent != null; - - if (pa != null) { - ComponentName[] names = new ComponentName[pa.length + (shouldFilterNearby ? 1 : 0)]; - for (int i = 0; i < pa.length; i++) { - if (!(pa[i] instanceof ComponentName)) { - Log.w(TAG, "Filtered component #" + i + " not a ComponentName: " + pa[i]); - names = null; - break; - } - names[i] = (ComponentName) pa[i]; - } - if (shouldFilterNearby) { - names[names.length - 1] = nearbySharingComponent; + mFilteredComponentNames = new ArrayList<>(); + try { + ComponentName[] exclodedComponents = intent.getParcelableArrayExtra( + Intent.EXTRA_EXCLUDE_COMPONENTS, + ComponentName.class); + if (exclodedComponents != null) { + Collections.addAll(mFilteredComponentNames, exclodedComponents); } + } catch (ClassCastException e) { + Log.e(TAG, "Excluded components must be of type ComponentName[]", e); + } - mFilteredComponentNames = names; - } else if (shouldFilterNearby) { - mFilteredComponentNames = new ComponentName[1]; - mFilteredComponentNames[0] = nearbySharingComponent; + // Exclude Nearby from main list if chip is present, to avoid duplication + ComponentName nearby = getNearbySharingComponent(); + if (nearby != null) { + mFilteredComponentNames.add(nearby); } pa = intent.getParcelableArrayExtra(Intent.EXTRA_CHOOSER_TARGETS); @@ -1325,9 +1309,7 @@ public class ChooserActivity extends ResolverActivity implements final ViewGroup actionRow = (ViewGroup) contentPreviewLayout.findViewById(com.android.internal.R.id.chooser_action_row); addActionButton(actionRow, createCopyButton()); - if (shouldNearbyShareBeIncludedAsActionButton()) { - addActionButton(actionRow, createNearbyButton(targetIntent)); - } + addActionButton(actionRow, createNearbyButton(targetIntent)); CharSequence sharingText = targetIntent.getCharSequenceExtra(Intent.EXTRA_TEXT); if (sharingText == null) { @@ -1378,9 +1360,7 @@ public class ChooserActivity extends ResolverActivity implements final ViewGroup actionRow = (ViewGroup) contentPreviewLayout.findViewById(com.android.internal.R.id.chooser_action_row); //TODO: addActionButton(actionRow, createCopyButton()); - if (shouldNearbyShareBeIncludedAsActionButton()) { - addActionButton(actionRow, createNearbyButton(targetIntent)); - } + addActionButton(actionRow, createNearbyButton(targetIntent)); addActionButton(actionRow, createEditButton(targetIntent)); mPreviewCoord = new ContentPreviewCoordinator(contentPreviewLayout, false); @@ -1500,9 +1480,7 @@ public class ChooserActivity extends ResolverActivity implements final ViewGroup actionRow = (ViewGroup) contentPreviewLayout.findViewById(com.android.internal.R.id.chooser_action_row); //TODO(b/120417119): addActionButton(actionRow, createCopyButton()); - if (shouldNearbyShareBeIncludedAsActionButton()) { - addActionButton(actionRow, createNearbyButton(targetIntent)); - } + addActionButton(actionRow, createNearbyButton(targetIntent)); String action = targetIntent.getAction(); if (Intent.ACTION_SEND.equals(action)) { @@ -2324,27 +2302,13 @@ public class ChooserActivity extends ResolverActivity implements @Override boolean isComponentFiltered(ComponentName name) { - if (mFilteredComponentNames == null) { - return false; - } - for (ComponentName filteredComponentName : mFilteredComponentNames) { - if (name.equals(filteredComponentName)) { - return true; - } - } - return false; + return mFilteredComponentNames != null && mFilteredComponentNames.contains(name); } @Override public boolean isComponentPinned(ComponentName name) { return mPinnedSharedPrefs.getBoolean(name.flattenToString(), false); } - - @Override - public boolean isFixedAtTop(ComponentName name) { - return name != null && name.equals(getNearbySharingComponent()) - && shouldNearbyShareBeFirstInRankedRow(); - } } @VisibleForTesting @@ -2899,8 +2863,8 @@ public class ChooserActivity extends ResolverActivity implements .targetInfoForPosition(mListPosition, /* filtered */ true); // This should always be the case for ItemViewHolder, check for validity - if (ti.isDisplayResolveInfo() && shouldShowTargetDetails(ti)) { - showTargetDetails((DisplayResolveInfo) ti); + if (ti.isDisplayResolveInfo()) { + showTargetDetails(ti); } return true; }); @@ -2908,15 +2872,6 @@ public class ChooserActivity extends ResolverActivity implements } } - private boolean shouldShowTargetDetails(TargetInfo ti) { - ComponentName nearbyShare = getNearbySharingComponent(); - // Suppress target details for nearby share to hide pin/unpin action - boolean isNearbyShare = nearbyShare != null && nearbyShare.equals( - ti.getResolvedComponentName()) && shouldNearbyShareBeFirstInRankedRow(); - return ti.isSelectableTargetInfo() - || (ti.isDisplayResolveInfo() && !isNearbyShare); - } - /** * Add a footer to the list, to support scrolling behavior below the navbar. */ @@ -3279,9 +3234,7 @@ public class ChooserActivity extends ResolverActivity implements v.setOnLongClickListener(v1 -> { TargetInfo ti = mChooserListAdapter.targetInfoForPosition( holder.getItemIndex(column), true); - if (shouldShowTargetDetails(ti)) { - showTargetDetails(ti); - } + showTargetDetails(ti); return true; }); @@ -4039,14 +3992,6 @@ public class ChooserActivity extends ResolverActivity implements getChooserActivityLogger().logSharesheetProfileChanged(); } - private boolean shouldNearbyShareBeFirstInRankedRow() { - return ActivityManager.isLowRamDeviceStatic() && mIsNearbyShareFirstTargetInRankedApp; - } - - private boolean shouldNearbyShareBeIncludedAsActionButton() { - return !shouldNearbyShareBeFirstInRankedRow(); - } - private static <K, V> Map<K, V> emptyIfNull(@Nullable Map<K, V> map) { return map == null ? Collections.emptyMap() : map; } diff --git a/java/src/com/android/intentresolver/ResolverActivity.java b/java/src/com/android/intentresolver/ResolverActivity.java index 1d57b9f2..19251490 100644 --- a/java/src/com/android/intentresolver/ResolverActivity.java +++ b/java/src/com/android/intentresolver/ResolverActivity.java @@ -2140,7 +2140,6 @@ public class ResolverActivity extends FragmentActivity implements private final List<Intent> mIntents = new ArrayList<>(); private final List<ResolveInfo> mResolveInfos = new ArrayList<>(); private boolean mPinned; - private boolean mFixedAtTop; public ResolvedComponentInfo(ComponentName name, Intent intent, ResolveInfo info) { this.name = name; @@ -2189,14 +2188,6 @@ public class ResolverActivity extends FragmentActivity implements public void setPinned(boolean pinned) { mPinned = pinned; } - - public boolean isFixedAtTop() { - return mFixedAtTop; - } - - public void setFixedAtTop(boolean isFixedAtTop) { - mFixedAtTop = isFixedAtTop; - } } class ItemClickListener implements AdapterView.OnItemClickListener, diff --git a/java/src/com/android/intentresolver/ResolverListController.java b/java/src/com/android/intentresolver/ResolverListController.java index ff616ce0..6169c032 100644 --- a/java/src/com/android/intentresolver/ResolverListController.java +++ b/java/src/com/android/intentresolver/ResolverListController.java @@ -32,7 +32,6 @@ import android.os.UserHandle; import android.util.Log; import com.android.intentresolver.chooser.DisplayResolveInfo; - import com.android.internal.annotations.VisibleForTesting; import java.util.ArrayList; @@ -187,7 +186,6 @@ public class ResolverListController { final ResolverActivity.ResolvedComponentInfo rci = new ResolverActivity.ResolvedComponentInfo(name, intent, newInfo); rci.setPinned(isComponentPinned(name)); - rci.setFixedAtTop(isFixedAtTop(name)); into.add(rci); } } @@ -202,14 +200,6 @@ public class ResolverListController { return false; } - /** - * Whether this component is fixed at top in the ranked apps list. Always false for Resolver; - * overridden in Chooser. - */ - public boolean isFixedAtTop(ComponentName name) { - return false; - } - // Filter out any activities that the launched uid does not have permission for. // To preserve the inputList, optionally will return the original list if any modification has // been made. |