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

Commit ec70cdb4 authored by Tony Huang's avatar Tony Huang Committed by Android (Google) Code Review
Browse files

Merge "Fix crash bug while opening zip on recent root"

parents 953a6548 590e2b0f
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -16,9 +16,10 @@

package com.android.documentsui.base;

import static com.android.documentsui.base.SharedMinimal.DEBUG;
import static androidx.core.util.Preconditions.checkArgument;

import static com.android.documentsui.base.SharedMinimal.DEBUG;

import android.content.ContentResolver;
import android.database.Cursor;
import android.os.Parcel;
@@ -150,6 +151,11 @@ public class DocumentStack implements Durable, Parcelable {
        if (DEBUG) Log.d(TAG, "Root changed to: " + root);
        reset();
        mRoot = root;

        // Add this for keep stack size is 1 on recent root.
        if (root.isRecents()) {
            push(new DocumentInfo());
        }
    }

    /** This will return true even when the initial location is set.
@@ -170,7 +176,7 @@ public class DocumentStack implements Durable, Parcelable {
    }

    public boolean isRecents() {
        return mRoot != null && mRoot.isRecents();
        return mRoot != null && mRoot.isRecents() && size() == 1;
    }

    /**
+9 −0
Original line number Diff line number Diff line
@@ -188,4 +188,13 @@ public class DocumentStackTest {
            return true;
        });
    }

    @Test
    public void testIsRecent() {
        final RootInfo rootRecent = new RootInfo();
        mStack.changeRoot(rootRecent);

        assertEquals(1, mStack.size());
        assertEquals(true, mStack.isRecents());
    }
}