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

Commit b3add4da authored by Adam Powell's avatar Adam Powell Committed by Android (Google) Code Review
Browse files

Merge "Fix regression in viewing app info from ChooserActivity targets" into mnc-dev

parents ce49be7e 98b7f894
Loading
Loading
Loading
Loading
+42 −0
Original line number Diff line number Diff line
@@ -50,11 +50,13 @@ import android.util.Slog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
import android.widget.ListView;
import com.android.internal.R;
import com.android.internal.logging.MetricsLogger;

import java.util.ArrayList;
import java.util.List;
@@ -185,6 +187,8 @@ public class ChooserActivity extends ResolverActivity {
        setSafeForwardingMode(true);
        super.onCreate(savedInstanceState, target, title, defaultTitleRes, initialIntents,
                null, false);

        MetricsLogger.action(this, MetricsLogger.ACTION_ACTIVITY_CHOOSER_SHOWN);
    }

    @Override
@@ -291,6 +295,36 @@ public class ChooserActivity extends ResolverActivity {
        return super.onTargetSelected(target, alwaysCheck);
    }

    @Override
    void startSelected(int which, boolean always, boolean filtered) {
        super.startSelected(which, always, filtered);

        if (mChooserListAdapter != null) {
            // Log the index of which type of target the user picked.
            // Lower values mean the ranking was better.
            int cat = 0;
            int value = which;
            switch (mChooserListAdapter.getPositionTargetType(which)) {
                case ChooserListAdapter.TARGET_CALLER:
                    cat = MetricsLogger.ACTION_ACTIVITY_CHOOSER_PICKED_APP_TARGET;
                    break;
                case ChooserListAdapter.TARGET_SERVICE:
                    cat = MetricsLogger.ACTION_ACTIVITY_CHOOSER_PICKED_SERVICE_TARGET;
                    value -= mChooserListAdapter.getCallerTargetCount();
                    break;
                case ChooserListAdapter.TARGET_STANDARD:
                    cat = MetricsLogger.ACTION_ACTIVITY_CHOOSER_PICKED_STANDARD_TARGET;
                    value -= mChooserListAdapter.getCallerTargetCount()
                            + mChooserListAdapter.getServiceTargetCount();
                    break;
            }

            if (cat != 0) {
                MetricsLogger.action(this, cat, value);
            }
        }
    }

    void queryTargetServices(ChooserListAdapter adapter) {
        final PackageManager pm = getPackageManager();
        int targetsToQuery = 0;
@@ -851,6 +885,14 @@ public class ChooserActivity extends ResolverActivity {
                            startSelected(itemIndex, false, true);
                        }
                    });
                    v.setOnLongClickListener(new OnLongClickListener() {
                        @Override
                        public boolean onLongClick(View v) {
                            showAppDetails(
                                    mChooserListAdapter.resolveInfoForPosition(itemIndex, true));
                            return true;
                        }
                    });
                } else {
                    v.setVisibility(View.GONE);
                }
+4 −0
Original line number Diff line number Diff line
@@ -33,6 +33,10 @@ public class MetricsLogger implements MetricsConstants {
    public static final int ACTION_VOLUME_KEY = 211;
    public static final int ACTION_VOLUME_ICON = 212;
    public static final int ACTION_RINGER_MODE = 213;
    public static final int ACTION_ACTIVITY_CHOOSER_SHOWN = 214;
    public static final int ACTION_ACTIVITY_CHOOSER_PICKED_APP_TARGET = 215;
    public static final int ACTION_ACTIVITY_CHOOSER_PICKED_SERVICE_TARGET = 216;
    public static final int ACTION_ACTIVITY_CHOOSER_PICKED_STANDARD_TARGET = 217;
    // Temporary constants go here, to await migration to MetricsConstants.

    public static void visible(Context context, int category) throws IllegalArgumentException {