Loading src/com/android/documentsui/Metrics.java +26 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.content.Intent; import android.content.pm.ResolveInfo; import android.net.Uri; import android.provider.DocumentsContract; import android.provider.DocumentsProvider; import android.util.Log; import com.android.documentsui.base.DocumentInfo; Loading Loading @@ -64,6 +65,9 @@ public final class Metrics { private static final String COUNT_STARTUP_MS = "docsui_startup_ms"; private static final String COUNT_DRAWER_OPENED = "docsui_drawer_opened"; private static final String COUNT_USER_ACTION = "docsui_menu_action"; private static final String COUNT_CREATE_AT_LOCATION = "docsui_create_at_location"; private static final String COUNT_OPEN_AT_LOCATION = "docsui_open_at_location"; private static final String COUNT_GET_CONTENT_AT_LOCATION = "docsui_get_content_at_location"; // Indices for bucketing roots in the roots histogram. "Other" is the catch-all index for any // root that is not explicitly recognized by the Metrics code (see {@link Loading Loading @@ -343,6 +347,28 @@ public final class Metrics { } } /** * Logs when DocumentsUI are launched with {@link DocumentsContract#EXTRA_INITIAL_URI}. * * @param context * @param state used to resolve action * @param rootUri the resolved rootUri, or {@code null} if the provider doesn't * support {@link DocumentsProvider#findDocumentPath(String, String)} */ public static void logLaunchAtLocation(Context context, State state, @Nullable Uri rootUri) { switch (state.action) { case State.ACTION_CREATE: logHistogram(context, COUNT_CREATE_AT_LOCATION, sanitizeRoot(rootUri)); break; case State.ACTION_GET_CONTENT: logHistogram(context, COUNT_GET_CONTENT_AT_LOCATION, sanitizeRoot(rootUri)); break; case State.ACTION_OPEN: logHistogram(context, COUNT_OPEN_AT_LOCATION, sanitizeRoot(rootUri)); break; } } /** * Logs a root visited event. Call this when the user visits on a root in the RootsFragment. * Loading src/com/android/documentsui/picker/ActionHandler.java +5 −0 Original line number Diff line number Diff line Loading @@ -140,10 +140,15 @@ class ActionHandler<T extends Activity & Addons> extends AbstractActionHandler<T } mState.stack.reset(stack); mActivity.refreshCurrentRootAndDirectory(AnimationView.ANIM_NONE); Metrics.logLaunchAtLocation(mActivity, mState, stack.getRoot().getUri()); } else { Log.w(TAG, "Failed to launch into the given uri. Load last accessed stack."); loadLastAccessedStack(); Metrics.logLaunchAtLocation(mActivity, mState, null); } } private void loadLastAccessedStack() { Loading Loading
src/com/android/documentsui/Metrics.java +26 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.content.Intent; import android.content.pm.ResolveInfo; import android.net.Uri; import android.provider.DocumentsContract; import android.provider.DocumentsProvider; import android.util.Log; import com.android.documentsui.base.DocumentInfo; Loading Loading @@ -64,6 +65,9 @@ public final class Metrics { private static final String COUNT_STARTUP_MS = "docsui_startup_ms"; private static final String COUNT_DRAWER_OPENED = "docsui_drawer_opened"; private static final String COUNT_USER_ACTION = "docsui_menu_action"; private static final String COUNT_CREATE_AT_LOCATION = "docsui_create_at_location"; private static final String COUNT_OPEN_AT_LOCATION = "docsui_open_at_location"; private static final String COUNT_GET_CONTENT_AT_LOCATION = "docsui_get_content_at_location"; // Indices for bucketing roots in the roots histogram. "Other" is the catch-all index for any // root that is not explicitly recognized by the Metrics code (see {@link Loading Loading @@ -343,6 +347,28 @@ public final class Metrics { } } /** * Logs when DocumentsUI are launched with {@link DocumentsContract#EXTRA_INITIAL_URI}. * * @param context * @param state used to resolve action * @param rootUri the resolved rootUri, or {@code null} if the provider doesn't * support {@link DocumentsProvider#findDocumentPath(String, String)} */ public static void logLaunchAtLocation(Context context, State state, @Nullable Uri rootUri) { switch (state.action) { case State.ACTION_CREATE: logHistogram(context, COUNT_CREATE_AT_LOCATION, sanitizeRoot(rootUri)); break; case State.ACTION_GET_CONTENT: logHistogram(context, COUNT_GET_CONTENT_AT_LOCATION, sanitizeRoot(rootUri)); break; case State.ACTION_OPEN: logHistogram(context, COUNT_OPEN_AT_LOCATION, sanitizeRoot(rootUri)); break; } } /** * Logs a root visited event. Call this when the user visits on a root in the RootsFragment. * Loading
src/com/android/documentsui/picker/ActionHandler.java +5 −0 Original line number Diff line number Diff line Loading @@ -140,10 +140,15 @@ class ActionHandler<T extends Activity & Addons> extends AbstractActionHandler<T } mState.stack.reset(stack); mActivity.refreshCurrentRootAndDirectory(AnimationView.ANIM_NONE); Metrics.logLaunchAtLocation(mActivity, mState, stack.getRoot().getUri()); } else { Log.w(TAG, "Failed to launch into the given uri. Load last accessed stack."); loadLastAccessedStack(); Metrics.logLaunchAtLocation(mActivity, mState, null); } } private void loadLastAccessedStack() { Loading