From 237b8372b7013569beed659ee70ba24a21bfdc02 Mon Sep 17 00:00:00 2001 From: Joshua Trask Date: Tue, 9 Nov 2021 12:00:17 -0500 Subject: [PATCH] DeviceConfig flag to guard delegate chooser flow. This replaces the ad-hoc hard-coded flag that previously guarded the delegation flow, and updates the config to point to the new delegate component. Note this is still the Phase 2 ("Delegation Trials") architecture from go/sharesheet-unbundling-phases which delegates to the new component only for the final step of dispatching the user's selected target. When the new component takes responsibility for displaying the Sharesheet UI (Phase 3) we'll use the same DeviceConfig flag to guard the new logic to delegate out from earlier on in the system activity lifecycle. I was able to test this manually (once I eventually figured out how to get the new unbundled APK installed), by going through Sharesheet and confirming that the delegate activity (at the new path) is only invoked after overriding the flag by: adb shell device_config put systemui use_delegate_chooser true An upcoming CL will add the server-side config that we can use to control this experiment. Bug: 202166034 Test: manual (as described above) Change-Id: Ie3eb5bca6b768383156293cddbf6932df2cd3a64 --- .../internal/app/chooser/DisplayResolveInfo.java | 12 +++++++----- .../config/sysui/SystemUiDeviceConfigFlags.java | 5 +++++ core/res/res/values/config.xml | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/core/java/com/android/internal/app/chooser/DisplayResolveInfo.java b/core/java/com/android/internal/app/chooser/DisplayResolveInfo.java index b00148af312f0..4f2e7dbebb048 100644 --- a/core/java/com/android/internal/app/chooser/DisplayResolveInfo.java +++ b/core/java/com/android/internal/app/chooser/DisplayResolveInfo.java @@ -30,9 +30,11 @@ import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; import android.os.UserHandle; +import android.provider.DeviceConfig; import com.android.internal.app.ResolverActivity; import com.android.internal.app.ResolverListAdapter.ResolveInfoPresentationGetter; +import com.android.internal.config.sysui.SystemUiDeviceConfigFlags; import java.util.ArrayList; import java.util.Arrays; @@ -43,10 +45,10 @@ import java.util.List; * resolve it to an activity. */ public class DisplayResolveInfo implements TargetInfo, Parcelable { - // Temporary flag for new chooser delegate behavior. There are occassional token - // permission errors from bouncing through the delegate. Watch out before reenabling: - // b/157272342 is one example but this issue has been reported many times - private static final boolean ENABLE_CHOOSER_DELEGATE = false; + private final boolean mEnableChooserDelegate = + DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI, + SystemUiDeviceConfigFlags.USE_DELEGATE_CHOOSER, + false); private final ResolveInfo mResolveInfo; private CharSequence mDisplayLabel; @@ -178,7 +180,7 @@ public class DisplayResolveInfo implements TargetInfo, Parcelable { @Override public boolean startAsCaller(ResolverActivity activity, Bundle options, int userId) { - if (ENABLE_CHOOSER_DELEGATE) { + if (mEnableChooserDelegate) { return activity.startAsCallerImpl(mResolvedIntent, options, false, userId); } else { activity.startActivityAsCaller(mResolvedIntent, options, null, false, userId); diff --git a/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java b/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java index 1b3fd7bbad652..d1019c5f16139 100644 --- a/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java +++ b/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java @@ -501,6 +501,11 @@ public final class SystemUiDeviceConfigFlags { public static final String IS_NEARBY_SHARE_FIRST_TARGET_IN_RANKED_APP = "is_nearby_share_first_target_in_ranked_app"; + /** + * (boolean) Whether to enable the new unbundled "delegate chooser" implementation. + */ + public static final String USE_DELEGATE_CHOOSER = "use_delegate_chooser"; + private SystemUiDeviceConfigFlags() { } } diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index fceb951a79235..7f68bfd622cc8 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -2723,7 +2723,7 @@ com.android.systemui/com.android.systemui.chooser.ChooserActivity + >com.android.intentresolver/.ChooserActivity