Merge "Offer a NOTIFY_NO_DELAY flag for notifications." into rvc-dev am: de7f060772
Change-Id: I0adbe79ac4bec6061f49f5ff63698dca72963231
This commit is contained in:
@@ -686,6 +686,19 @@ public abstract class ContentResolver implements ContentInterface {
|
|||||||
*/
|
*/
|
||||||
public static final int NOTIFY_DELETE = 1 << 4;
|
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.
|
* No exception, throttled by app standby normally.
|
||||||
* @hide
|
* @hide
|
||||||
|
|||||||
@@ -569,9 +569,10 @@ public final class ContentService extends IContentService.Stub {
|
|||||||
// Immediately dispatch notifications to foreground apps that
|
// Immediately dispatch notifications to foreground apps that
|
||||||
// are important to the user; all other background observers are
|
// are important to the user; all other background observers are
|
||||||
// delayed to avoid stampeding
|
// delayed to avoid stampeding
|
||||||
|
final boolean noDelay = (key.flags & ContentResolver.NOTIFY_NO_DELAY) != 0;
|
||||||
final int procState = LocalServices.getService(ActivityManagerInternal.class)
|
final int procState = LocalServices.getService(ActivityManagerInternal.class)
|
||||||
.getUidProcessState(key.uid);
|
.getUidProcessState(key.uid);
|
||||||
if (procState <= ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND) {
|
if (procState <= ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND || noDelay) {
|
||||||
task.run();
|
task.run();
|
||||||
} else {
|
} else {
|
||||||
BackgroundThread.getHandler().postDelayed(task, BACKGROUND_OBSERVER_DELAY);
|
BackgroundThread.getHandler().postDelayed(task, BACKGROUND_OBSERVER_DELAY);
|
||||||
|
|||||||
Reference in New Issue
Block a user