summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jeff Sharkey <jsharkey@google.com> 2020-04-09 03:14:42 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2020-04-09 03:14:42 +0000
commitde7f06077250dca332d0ff16b4ea491f9232aaa4 (patch)
tree893fc12f9fa3b6e36e4a40026e53329894c229a0
parent466397c4e98a171328dcee96824cd58e131d4fb9 (diff)
parent9d475e958df9ea0f558458de6629733d5b1fd3e1 (diff)
Merge "Offer a NOTIFY_NO_DELAY flag for notifications." into rvc-dev
-rw-r--r--core/java/android/content/ContentResolver.java13
-rw-r--r--services/core/java/com/android/server/content/ContentService.java3
2 files changed, 15 insertions, 1 deletions
diff --git a/core/java/android/content/ContentResolver.java b/core/java/android/content/ContentResolver.java
index e446f4fa5eb4..0a4627da223a 100644
--- a/core/java/android/content/ContentResolver.java
+++ b/core/java/android/content/ContentResolver.java
@@ -687,6 +687,19 @@ public abstract class ContentResolver implements ContentInterface {
public static final int NOTIFY_DELETE = 1 << 4;
/**
+ * Flag for {@link #notifyChange(Uri, ContentObserver, int)}: typically set
+ * by a {@link ContentProvider} to indicate that this notification should
+ * not be subject to any delays when dispatching to apps running in the
+ * background.
+ * <p>
+ * Using this flag may negatively impact system health and performance, and
+ * should be used sparingly.
+ *
+ * @hide
+ */
+ public static final int NOTIFY_NO_DELAY = 1 << 15;
+
+ /**
* No exception, throttled by app standby normally.
* @hide
*/
diff --git a/services/core/java/com/android/server/content/ContentService.java b/services/core/java/com/android/server/content/ContentService.java
index 962f337a8b3f..9a910bf5e859 100644
--- a/services/core/java/com/android/server/content/ContentService.java
+++ b/services/core/java/com/android/server/content/ContentService.java
@@ -569,9 +569,10 @@ public final class ContentService extends IContentService.Stub {
// Immediately dispatch notifications to foreground apps that
// are important to the user; all other background observers are
// delayed to avoid stampeding
+ final boolean noDelay = (key.flags & ContentResolver.NOTIFY_NO_DELAY) != 0;
final int procState = LocalServices.getService(ActivityManagerInternal.class)
.getUidProcessState(key.uid);
- if (procState <= ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND) {
+ if (procState <= ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND || noDelay) {
task.run();
} else {
BackgroundThread.getHandler().postDelayed(task, BACKGROUND_OBSERVER_DELAY);