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

Commit 384971f7 authored by Bobby Georgescu's avatar Bobby Georgescu
Browse files

Instrument importer for usage statistics

Bug: 8744068
Change-Id: I416463ba15713d363ac0ce68109532b770fb02b3
parent a042bfaa
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ public class ImportTask implements Runnable {
    public interface Listener {
        void onImportProgress(int visitedCount, int totalCount, String pathIfSuccessful);

        void onImportFinish(Collection<MtpObjectInfo> objectsNotImported);
        void onImportFinish(Collection<MtpObjectInfo> objectsNotImported, int visitedCount);
    }

    static private final String WAKELOCK_LABEL = "MTP Import Task";
@@ -84,7 +84,7 @@ public class ImportTask implements Runnable {
                }
            }
            if (mListener != null) {
                mListener.onImportFinish(objectsNotImported);
                mListener.onImportFinish(objectsNotImported, visited);
            }
        } finally {
            mListener = null;
+2 −1
Original line number Diff line number Diff line
@@ -440,7 +440,8 @@ public class IngestActivity extends Activity implements
    }

    @Override
    public void onImportFinish(Collection<MtpObjectInfo> objectsNotImported) {
    public void onImportFinish(Collection<MtpObjectInfo> objectsNotImported,
            int numVisited) {
        // Not guaranteed to be called on the UI thread
        mHandler.sendEmptyMessage(ItemListHandler.MSG_PROGRESS_HIDE);
        // TODO: maybe show an extra dialog listing the ones that failed
+12 −3
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import com.android.gallery3d.R;
import com.android.gallery3d.app.NotificationIds;
import com.android.gallery3d.data.MtpClient;
import com.android.gallery3d.util.BucketNames;
import com.android.gallery3d.util.UsageStatistics;

import java.util.ArrayList;
import java.util.Collection;
@@ -63,6 +64,7 @@ public class IngestService extends Service implements ImportTask.Listener,
    private MtpDeviceIndex mIndex;
    private IngestActivity mClientActivity;
    private boolean mRedeliverImportFinish = false;
    private int mRedeliverImportFinishCount = 0;
    private Collection<MtpObjectInfo> mRedeliverObjectsNotImported;
    private boolean mRedeliverNotifyIndexChanged = false;
    private boolean mRedeliverIndexFinish = false;
@@ -151,7 +153,8 @@ public class IngestService extends Service implements ImportTask.Listener,
        mNotificationManager.cancel(NotificationIds.INGEST_NOTIFICATION_IMPORTING);
        mNotificationManager.cancel(NotificationIds.INGEST_NOTIFICATION_SCANNING);
        if (mRedeliverImportFinish) {
            mClientActivity.onImportFinish(mRedeliverObjectsNotImported);
            mClientActivity.onImportFinish(mRedeliverObjectsNotImported,
                    mRedeliverImportFinishCount);
            mRedeliverImportFinish = false;
            mRedeliverObjectsNotImported = null;
        }
@@ -188,6 +191,8 @@ public class IngestService extends Service implements ImportTask.Listener,
    public void deviceAdded(MtpDevice device) {
        if (mDevice == null) {
            setDevice(device);
            UsageStatistics.onEvent(UsageStatistics.COMPONENT_IMPORTER,
                    "DeviceConnected", null);
        }
    }

@@ -217,19 +222,23 @@ public class IngestService extends Service implements ImportTask.Listener,
    }

    @Override
    public void onImportFinish(Collection<MtpObjectInfo> objectsNotImported) {
    public void onImportFinish(Collection<MtpObjectInfo> objectsNotImported,
            int visitedCount) {
        stopForeground(true);
        mNeedRelaunchNotification = true;
        if (mClientActivity != null) {
            mClientActivity.onImportFinish(objectsNotImported);
            mClientActivity.onImportFinish(objectsNotImported, visitedCount);
        } else {
            mRedeliverImportFinish = true;
            mRedeliverObjectsNotImported = objectsNotImported;
            mRedeliverImportFinishCount = visitedCount;
            mNotificationBuilder.setProgress(0, 0, false)
                .setContentText(getResources().getText(R.string.import_complete));
            mNotificationManager.notify(NotificationIds.INGEST_NOTIFICATION_IMPORTING,
                    mNotificationBuilder.build());
        }
        UsageStatistics.onEvent(UsageStatistics.COMPONENT_IMPORTER,
                "ImportFinished", null, visitedCount);
    }

    @Override
+1 −1
Original line number Diff line number Diff line
@@ -19,11 +19,11 @@ package com.android.gallery3d.util;
import android.content.Context;

public class UsageStatistics {
    public static final boolean ENABLED = false;

    public static final String COMPONENT_GALLERY = "Gallery";
    public static final String COMPONENT_CAMERA = "Camera";
    public static final String COMPONENT_EDITOR = "Editor";
    public static final String COMPONENT_IMPORTER = "Importer";

    public static final String TRANSITION_BACK_BUTTON = "BackButton";
    public static final String TRANSITION_UP_BUTTON = "UpButton";