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

Commit 9082f5b6 authored by Kang Li's avatar Kang Li
Browse files

Log metrics for Smart-Sharing in ChooserActivity.

Bug: 33051310, 30982298
Test: manually shared several images in Camera.

Change-Id: I6b147ec89729815931e2b626b7533e1e5b95c819
parent 1fd9c8d3
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -96,6 +96,9 @@ public class ChooserActivity extends ResolverActivity {

    private Intent mReferrerFillInIntent;

    private long mChooserShownTime;
    private boolean mIsSuccessfullySelected;

    private ChooserListAdapter mChooserListAdapter;
    private ChooserRowAdapter mChooserRowAdapter;

@@ -155,6 +158,8 @@ public class ChooserActivity extends ResolverActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        final long intentReceivedTime = System.currentTimeMillis();
        mIsSuccessfullySelected = false;
        Intent intent = getIntent();
        Parcelable targetParcelable = intent.getParcelableExtra(Intent.EXTRA_INTENT);
        if (!(targetParcelable instanceof Intent)) {
@@ -257,6 +262,13 @@ public class ChooserActivity extends ResolverActivity {
                null, false);

        MetricsLogger.action(this, MetricsEvent.ACTION_ACTIVITY_CHOOSER_SHOWN);

        mChooserShownTime = System.currentTimeMillis();
        final long systemCost = mChooserShownTime - intentReceivedTime;
        MetricsLogger.histogram(null, "system_cost_for_smart_sharing", (int) systemCost);
        if (DEBUG) {
            Log.d(TAG, "System Time Cost is " + systemCost);
        }
    }

    static SharedPreferences getPinnedSharedPrefs(Context context) {
@@ -410,6 +422,7 @@ public class ChooserActivity extends ResolverActivity {

    @Override
    public void startSelected(int which, boolean always, boolean filtered) {
        final long selectionCost = System.currentTimeMillis() - mChooserShownTime;
        super.startSelected(which, always, filtered);

        if (mChooserListAdapter != null) {
@@ -435,6 +448,17 @@ public class ChooserActivity extends ResolverActivity {
            if (cat != 0) {
                MetricsLogger.action(this, cat, value);
            }

            if (mIsSuccessfullySelected) {
                if (DEBUG) {
                    Log.d(TAG, "User Selection Time Cost is " + selectionCost);
                    Log.d(TAG, "position of selected app/service/caller is " +
                            Integer.toString(value));
                }
                MetricsLogger.histogram(null, "user_selection_cost_for_smart_sharing",
                        (int) selectionCost);
                MetricsLogger.histogram(null, "app_position_for_smart_sharing", value);
            }
        }
    }

@@ -570,6 +594,7 @@ public class ChooserActivity extends ResolverActivity {
                Log.d(TAG, "Can not log Chooser Counts of null ResovleInfo");
            }
        }
        mIsSuccessfullySelected = true;
    }

    void onRefinementResult(TargetInfo selectedTarget, Intent matchingIntent) {