summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Tony Huang <tonyychuang@google.com> 2019-05-10 11:59:33 +0800
committer Tony Huang <tonyychuang@google.com> 2019-05-10 14:13:40 +0800
commit26c3793213b84ebe9b02685597f351acca3c095d (patch)
tree6d89489ccf59b7fa60946298445b0a1d5f5d6664
parent71513f91c3f44943629788d0d7df0324efff263c (diff)
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
-rw-r--r--src/com/android/documentsui/RefreshTask.java8
-rw-r--r--src/com/android/documentsui/base/DocumentInfo.java3
2 files changed, 8 insertions, 3 deletions
diff --git a/src/com/android/documentsui/RefreshTask.java b/src/com/android/documentsui/RefreshTask.java
index 3c238aebd..bcdfac83c 100644
--- a/src/com/android/documentsui/RefreshTask.java
+++ b/src/com/android/documentsui/RefreshTask.java
@@ -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;
diff --git a/src/com/android/documentsui/base/DocumentInfo.java b/src/com/android/documentsui/base/DocumentInfo.java
index 0ad363b73..89f6039bc 100644
--- a/src/com/android/documentsui/base/DocumentInfo.java
+++ b/src/com/android/documentsui/base/DocumentInfo.java
@@ -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();
}