summaryrefslogtreecommitdiff
path: root/packages/Shell/src
diff options
context:
space:
mode:
author Ben Lin <linben@google.com> 2016-05-17 14:13:24 -0700
committer Ben Lin <linben@google.com> 2016-05-23 20:07:04 +0000
commitc6905cfb1133627dfd500491c60b6528a3e593e0 (patch)
tree3c7d22567e51e786d69f3547f1eeb3a4d9f94624 /packages/Shell/src
parent14abed66d7a70c3fc8e063246e3f79a0a53dfcd3 (diff)
Register change Uri and notify changes in bugreportServices.
Bug: 28767380 Change-Id: Ia4d1f5a2e44881d300f2869c628d4990406caf40 (cherry picked from commit 6c9ff513c6d7d3de7ab8920d88111c2b1dc1bb1f) (cherry picked from commit 93fafd67a6127a35ba9b7a0f7de3a0b54309d4c2)
Diffstat (limited to 'packages/Shell/src')
-rw-r--r--packages/Shell/src/com/android/shell/BugreportProgressService.java8
-rw-r--r--packages/Shell/src/com/android/shell/BugreportStorageProvider.java10
2 files changed, 18 insertions, 0 deletions
diff --git a/packages/Shell/src/com/android/shell/BugreportProgressService.java b/packages/Shell/src/com/android/shell/BugreportProgressService.java
index 474e3e64ad3d..6bc4df71fc5c 100644
--- a/packages/Shell/src/com/android/shell/BugreportProgressService.java
+++ b/packages/Shell/src/com/android/shell/BugreportProgressService.java
@@ -815,6 +815,14 @@ public class BugreportProgressService extends Service {
*/
private void onBugreportFinished(int id, Intent intent) {
final File bugreportFile = getFileExtra(intent, EXTRA_BUGREPORT);
+ // Since BugreportProvider and BugreportProgressService aren't tightly coupled,
+ // we need to make sure they are explicitly tied to a single unique notification URI
+ // so that the service can alert the provider of changes it has done (ie. new bug
+ // reports)
+ // See { @link Cursor#setNotificationUri } and {@link ContentResolver#notifyChanges }
+ final Uri notificationUri = BugreportStorageProvider.getNotificationUri();
+ mContext.getContentResolver().notifyChange(notificationUri, null, false);
+
if (bugreportFile == null) {
// Should never happen, dumpstate always set the file.
Log.wtf(TAG, "Missing " + EXTRA_BUGREPORT + " on intent " + intent);
diff --git a/packages/Shell/src/com/android/shell/BugreportStorageProvider.java b/packages/Shell/src/com/android/shell/BugreportStorageProvider.java
index 0f92fa6e8add..8b0759942df8 100644
--- a/packages/Shell/src/com/android/shell/BugreportStorageProvider.java
+++ b/packages/Shell/src/com/android/shell/BugreportStorageProvider.java
@@ -19,9 +19,11 @@ package com.android.shell;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.database.MatrixCursor.RowBuilder;
+import android.net.Uri;
import android.os.CancellationSignal;
import android.os.FileUtils;
import android.os.ParcelFileDescriptor;
+import android.provider.DocumentsContract;
import android.provider.DocumentsContract.Document;
import android.provider.DocumentsContract.Root;
import android.provider.DocumentsProvider;
@@ -32,6 +34,7 @@ import java.io.File;
import java.io.FileNotFoundException;
public class BugreportStorageProvider extends DocumentsProvider {
+ private static final String AUTHORITY = "com.android.shell.documents";
private static final String DOC_ID_ROOT = "bugreport";
private static final String[] DEFAULT_ROOT_PROJECTION = new String[] {
@@ -103,6 +106,7 @@ public class BugreportStorageProvider extends DocumentsProvider {
for (File file : files) {
addFileRow(result, file);
}
+ result.setNotificationUri(getContext().getContentResolver(), getNotificationUri());
}
}
return result;
@@ -130,6 +134,12 @@ public class BugreportStorageProvider extends DocumentsProvider {
}
}
+ // This is used by BugreportProgressService so that the notification uri shared by
+ // BugreportProgressService and BugreportStorageProvider are guaranteed the same and unique
+ protected static Uri getNotificationUri() {
+ return DocumentsContract.buildChildDocumentsUri(AUTHORITY, DOC_ID_ROOT);
+ }
+
private static String[] resolveRootProjection(String[] projection) {
return projection != null ? projection : DEFAULT_ROOT_PROJECTION;
}