Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0b94a0eb authored by Alison Cichowlas's avatar Alison Cichowlas Committed by Android (Google) Code Review
Browse files

Merge " Add a flag for calling old ChooserTargetService API & remove flags for Shortcuts."

parents 48acf101 cef37d00
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -1855,6 +1855,7 @@ public class ChooserActivity extends ResolverActivity implements

    @VisibleForTesting
    protected void queryTargetServices(ChooserListAdapter adapter) {

        mQueriedTargetServicesTimeMs = System.currentTimeMillis();

        Context selectedProfileContext = createContextAsUser(
@@ -1871,15 +1872,14 @@ public class ChooserActivity extends ResolverActivity implements
                continue;
            }
            final ActivityInfo ai = dri.getResolveInfo().activityInfo;
            if (ChooserFlags.USE_SHORTCUT_MANAGER_FOR_DIRECT_TARGETS
                    && sm.hasShareTargets(ai.packageName)) {
            if (sm.hasShareTargets(ai.packageName)) {
                // Share targets will be queried from ShortcutManager
                continue;
            }
            final Bundle md = ai.metaData;
            final String serviceName = md != null ? convertServiceName(ai.packageName,
                    md.getString(ChooserTargetService.META_DATA_NAME)) : null;
            if (serviceName != null) {
            if (serviceName != null && ChooserFlags.USE_SERVICE_TARGETS_FOR_DIRECT_TARGETS) {
                final ComponentName serviceComponent = new ComponentName(
                        ai.packageName, serviceName);

@@ -2883,8 +2883,7 @@ public class ChooserActivity extends ResolverActivity implements
            return;
        }

        if (ChooserFlags.USE_SHORTCUT_MANAGER_FOR_DIRECT_TARGETS
                || ChooserFlags.USE_PREDICTION_MANAGER_FOR_DIRECT_TARGETS) {
        if (ChooserFlags.USE_PREDICTION_MANAGER_FOR_DIRECT_TARGETS) {
            if (DEBUG) {
                Log.d(TAG, "querying direct share targets from ShortcutManager");
            }
+13 −6
Original line number Diff line number Diff line
@@ -17,22 +17,29 @@
package com.android.internal.app;

import android.app.prediction.AppPredictionManager;
import android.provider.DeviceConfig;

import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;

/**
 * Common flags for {@link ChooserListAdapter} and {@link ChooserActivity}.
 */
public class ChooserFlags {

    /**
     * If set to true, use ShortcutManager to retrieve the matching direct share targets, instead of
     * binding to every ChooserTargetService implementation.
     * Whether to use the deprecated {@link android.service.chooser.ChooserTargetService} API for
     * direct share targets. If true, both CTS and Shortcuts will be used to find Direct Share
     * targets. If false, only Shortcuts will be used.
     */
    // TODO(b/121287573): Replace with a system flag (setprop?)
    public static final boolean USE_SHORTCUT_MANAGER_FOR_DIRECT_TARGETS = true;
    public static final boolean USE_SERVICE_TARGETS_FOR_DIRECT_TARGETS =
            DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI,
                SystemUiDeviceConfigFlags.SHARE_USE_SERVICE_TARGETS, true);

    /**
     * If {@link ChooserFlags#USE_SHORTCUT_MANAGER_FOR_DIRECT_TARGETS} and this is set to true,
     * {@link AppPredictionManager} will be queried for direct share targets.
     * Whether to use {@link AppPredictionManager} to query for direct share targets (as opposed to
     * talking directly to {@link android.content.pm.ShortcutManager}.
     */
    // TODO(b/123089490): Replace with system flag
    static final boolean USE_PREDICTION_MANAGER_FOR_DIRECT_TARGETS = true;
}
+1 −2
Original line number Diff line number Diff line
@@ -38,7 +38,6 @@ import android.text.SpannableStringBuilder;
import android.util.Log;

import com.android.internal.app.ChooserActivity;
import com.android.internal.app.ChooserFlags;
import com.android.internal.app.ResolverActivity;
import com.android.internal.app.ResolverListAdapter.ActivityInfoPresentationGetter;
import com.android.internal.app.SimpleIconFactory;
@@ -147,7 +146,7 @@ public final class SelectableTargetInfo implements ChooserTargetInfo {
        final Icon icon = target.getIcon();
        if (icon != null) {
            directShareIcon = icon.loadDrawable(mContext);
        } else if (ChooserFlags.USE_SHORTCUT_MANAGER_FOR_DIRECT_TARGETS && shortcutInfo != null) {
        } else if (shortcutInfo != null) {
            LauncherApps launcherApps = (LauncherApps) mContext.getSystemService(
                    Context.LAUNCHER_APPS_SERVICE);
            directShareIcon = launcherApps.getShortcutIconDrawable(shortcutInfo, 0);
+8 −0
Original line number Diff line number Diff line
@@ -429,6 +429,14 @@ public final class SystemUiDeviceConfigFlags {
     */
    public static final String BACK_GESTURE_ML_MODEL_THRESHOLD = "back_gesture_ml_model_threshold";

    /**
     * (boolean) Sharesheet - Whether to use the deprecated
     * {@link android.service.chooser.ChooserTargetService} API for
     *  direct share targets. If true, both CTS and Shortcuts will be used to find Direct
     *  Share targets. If false, only Shortcuts will be used.
     */
    public static final String SHARE_USE_SERVICE_TARGETS = "share_use_service_targets";


    private SystemUiDeviceConfigFlags() {
    }