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

Commit 81870e9f authored by Ivan Chiang's avatar Ivan Chiang
Browse files

Add Documents root and related metrics

Bug: 138173113
Bug: 146413601
Test: atest DocumentsUIGoogleTests
Change-Id: I5f16fdc0adb43ac6242c0f7f7d17d3ba221381e7
parent a42476f2
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ public class MetricConsts {
    public static final int ROOT_VIDEOS = 9;
    public static final int ROOT_MTP = 10;
    public static final int ROOT_THIRD_PARTY_APP = 11;
    public static final int ROOT_DOCUMENTS = 12;

    @IntDef(flag = true, value = {
            ROOT_UNKNOWN,
@@ -53,7 +54,8 @@ public class MetricConsts {
            ROOT_RECENTS,
            ROOT_VIDEOS,
            ROOT_MTP,
            ROOT_THIRD_PARTY_APP
            ROOT_THIRD_PARTY_APP,
            ROOT_DOCUMENTS
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface Root {
+2 −0
Original line number Diff line number Diff line
@@ -375,6 +375,8 @@ public final class Metrics {
                        return MetricConsts.ROOT_IMAGES;
                    case Providers.ROOT_ID_VIDEOS:
                        return MetricConsts.ROOT_VIDEOS;
                    case Providers.ROOT_ID_DOCUMENTS:
                        return MetricConsts.ROOT_DOCUMENTS;
                    default:
                        return MetricConsts.ROOT_OTHER_DOCS_PROVIDER;
                }
+1 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ public final class Providers {
    public static final String ROOT_ID_IMAGES = "images_root";
    public static final String ROOT_ID_VIDEOS = "videos_root";
    public static final String ROOT_ID_AUDIO = "audio_root";
    public static final String ROOT_ID_DOCUMENTS = "documents_root";

    public static final String AUTHORITY_MTP = "com.android.mtp.documents";
    public static final String AUTHORITY_BUGREPORT = "com.android.shell.documents";
+18 −7
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ public class RootInfo implements Durable, Parcelable, Comparable<RootInfo> {
            TYPE_IMAGES,
            TYPE_VIDEO,
            TYPE_AUDIO,
            TYPE_DOCUMENTS,
            TYPE_DOWNLOADS,
            TYPE_LOCAL,
            TYPE_MTP,
@@ -78,12 +79,13 @@ public class RootInfo implements Durable, Parcelable, Comparable<RootInfo> {
    public static final int TYPE_IMAGES = 2;
    public static final int TYPE_VIDEO = 3;
    public static final int TYPE_AUDIO = 4;
    public static final int TYPE_DOWNLOADS = 5;
    public static final int TYPE_LOCAL = 6;
    public static final int TYPE_MTP = 7;
    public static final int TYPE_SD = 8;
    public static final int TYPE_USB = 9;
    public static final int TYPE_OTHER = 10;
    public static final int TYPE_DOCUMENTS = 5;
    public static final int TYPE_DOWNLOADS = 6;
    public static final int TYPE_LOCAL = 7;
    public static final int TYPE_MTP = 8;
    public static final int TYPE_SD = 9;
    public static final int TYPE_USB = 10;
    public static final int TYPE_OTHER = 11;

    public String authority;
    public String rootId;
@@ -235,6 +237,9 @@ public class RootInfo implements Durable, Parcelable, Comparable<RootInfo> {
        } else if (isAudio()) {
            derivedType = TYPE_AUDIO;
            derivedIcon = LOAD_FROM_CONTENT_RESOLVER;
        } else if (isDocuments()) {
            derivedType = TYPE_DOCUMENTS;
            derivedIcon = LOAD_FROM_CONTENT_RESOLVER;
        } else if (isRecents()) {
            derivedType = TYPE_RECENTS;
        } else if (isBugReport()) {
@@ -292,6 +297,11 @@ public class RootInfo implements Durable, Parcelable, Comparable<RootInfo> {
                && Providers.ROOT_ID_AUDIO.equals(rootId);
    }

    public boolean isDocuments() {
        return Providers.AUTHORITY_MEDIA.equals(authority)
                && Providers.ROOT_ID_DOCUMENTS.equals(rootId);
    }

    public boolean isMtp() {
        return Providers.AUTHORITY_MTP.equals(authority);
    }
@@ -303,7 +313,8 @@ public class RootInfo implements Durable, Parcelable, Comparable<RootInfo> {
        return derivedType == TYPE_IMAGES
                || derivedType == TYPE_VIDEO
                || derivedType == TYPE_AUDIO
                || derivedType == TYPE_RECENTS;
                || derivedType == TYPE_RECENTS
                || derivedType == TYPE_DOCUMENTS;
    }

    /*
+7 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ public class TestProvidersAccess implements ProvidersAccess {
    public static final RootInfo IMAGE;
    public static final RootInfo AUDIO;
    public static final RootInfo VIDEO;
    public static final RootInfo DOCUMENT;
    public static final RootInfo EXTERNALSTORAGE;
    public static final RootInfo NO_TREE_ROOT;

@@ -116,6 +117,12 @@ public class TestProvidersAccess implements ProvidersAccess {
        VIDEO.title = "Videos";
        VIDEO.derivedType = RootInfo.TYPE_VIDEO;

        DOCUMENT = new RootInfo();
        DOCUMENT.authority = Providers.AUTHORITY_MEDIA;
        DOCUMENT.rootId = Providers.ROOT_ID_DOCUMENTS;
        DOCUMENT.title = "Documents";
        DOCUMENT.derivedType = RootInfo.TYPE_DOCUMENTS;

        EXTERNALSTORAGE = new RootInfo();
        EXTERNALSTORAGE.authority = Providers.AUTHORITY_STORAGE;
        EXTERNALSTORAGE.rootId = Providers.ROOT_ID_DEVICE;
Loading