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

Commit 26c37932 authored by Tony Huang's avatar Tony Huang
Browse files

Fix crash bug on RefreshTask

Due to Recent root stack change, it have DocumentsInfo but derivedUri
is null. Add NPE check on RefreshTask.

This issue cannot repro on debug rom because only debug rom
will log debugString(), this founction will call deriveFields() and it
will help on generate derivedUri. To avoid such situation, change
debugString implemention.

Fix: 132324406
Test: atest  DocumentsUIGoogleTests
Change-Id: Ic8d185e6f5438fcfc4f52d0b75de305304271bfe
parent 71513f91
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.documentsui;

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

import androidx.annotation.Nullable;
import android.content.ContentProviderClient;
import android.content.ContentResolver;
import android.content.Context;
@@ -27,6 +26,8 @@ import android.os.CancellationSignal;
import android.os.FileUtils;
import android.util.Log;

import androidx.annotation.Nullable;

import com.android.documentsui.base.ApplicationScope;
import com.android.documentsui.base.BooleanConsumer;
import com.android.documentsui.base.CheckedTask;
@@ -74,6 +75,11 @@ public class RefreshTask extends TimeoutTask<Void, Boolean> {
            return false;
        }

        if (mDoc.derivedUri == null) {
            Log.w(TAG, "Ignoring attempt to refresh due to null derived uri in DocumentInfo.");
            return false;
        }

        if (!mDoc.derivedUri.equals(mState.stack.peek().derivedUri)) {
            Log.w(TAG, "Ignoring attempt to refresh on a non-top-level uri.");
            return false;
+1 −2
Original line number Diff line number Diff line
@@ -406,8 +406,7 @@ public class DocumentInfo implements Durable, Parcelable {
        }

        if (doc.derivedUri == null) {
            doc.deriveFields();
            assert(doc.derivedUri != null);
            return "<DocumentInfo null derivedUri>";
        }
        return doc.derivedUri.toString();
    }