summaryrefslogtreecommitdiffstats
path: root/core/java/android/database/ContentObserver.java
diff options
context:
space:
mode:
authorSvetoslav <svetoslavganov@google.com>2014-08-21 14:22:53 -0700
committerSvetoslav <svetoslavganov@google.com>2014-08-26 18:19:13 -0700
commit86b1df234397802895771fe14cd8f2813fa43415 (patch)
tree62152dc66e9c90420240b17d851e0a202751a1b1 /core/java/android/database/ContentObserver.java
parent105f6ceb0f123d365e1ff5837f0442b3e377a056 (diff)
downloadframeworks_base-86b1df234397802895771fe14cd8f2813fa43415.zip
frameworks_base-86b1df234397802895771fe14cd8f2813fa43415.tar.gz
frameworks_base-86b1df234397802895771fe14cd8f2813fa43415.tar.bz2
Print services setting changes not handled for managed profiles.
We keep per user settings for enabled print services which are observed to update the print manager service state. We were listening to all user changes but the handling code was not updating the state of the user whose settings changed, rather the current user. Added hidden APIs in content observer to know which user changed and now the print manager serivce handles content changes for the correct user. bug:16977006 Change-Id: I71ec88c8f3f38cb405844c13ab83695c2029eb79
Diffstat (limited to 'core/java/android/database/ContentObserver.java')
-rw-r--r--core/java/android/database/ContentObserver.java48
1 files changed, 42 insertions, 6 deletions
diff --git a/core/java/android/database/ContentObserver.java b/core/java/android/database/ContentObserver.java
index e4fbc28..5f01e30 100644
--- a/core/java/android/database/ContentObserver.java
+++ b/core/java/android/database/ContentObserver.java
@@ -18,6 +18,7 @@ package android.database;
import android.net.Uri;
import android.os.Handler;
+import android.os.UserHandle;
/**
* Receives call backs for changes to content.
@@ -130,6 +131,21 @@ public abstract class ContentObserver {
}
/**
+ * Dispatches a change notification to the observer. Includes the changed
+ * content Uri when available and also the user whose content changed.
+ *
+ * @param selfChange True if this is a self-change notification.
+ * @param uri The Uri of the changed content, or null if unknown.
+ * @param userId The user whose content changed. Can be either a specific
+ * user or {@link UserHandle#USER_ALL}.
+ *
+ * @hide
+ */
+ public void onChange(boolean selfChange, Uri uri, int userId) {
+ onChange(selfChange, uri);
+ }
+
+ /**
* Dispatches a change notification to the observer.
* <p>
* If a {@link Handler} was supplied to the {@link ContentObserver} constructor,
@@ -159,25 +175,45 @@ public abstract class ContentObserver {
* @param uri The Uri of the changed content, or null if unknown.
*/
public final void dispatchChange(boolean selfChange, Uri uri) {
+ dispatchChange(selfChange, uri, UserHandle.getCallingUserId());
+ }
+
+ /**
+ * Dispatches a change notification to the observer. Includes the changed
+ * content Uri when available and also the user whose content changed.
+ * <p>
+ * If a {@link Handler} was supplied to the {@link ContentObserver} constructor,
+ * then a call to the {@link #onChange} method is posted to the handler's message queue.
+ * Otherwise, the {@link #onChange} method is invoked immediately on this thread.
+ * </p>
+ *
+ * @param selfChange True if this is a self-change notification.
+ * @param uri The Uri of the changed content, or null if unknown.
+ * @param userId The user whose content changed.
+ */
+ private void dispatchChange(boolean selfChange, Uri uri, int userId) {
if (mHandler == null) {
- onChange(selfChange, uri);
+ onChange(selfChange, uri, userId);
} else {
- mHandler.post(new NotificationRunnable(selfChange, uri));
+ mHandler.post(new NotificationRunnable(selfChange, uri, userId));
}
}
+
private final class NotificationRunnable implements Runnable {
private final boolean mSelfChange;
private final Uri mUri;
+ private final int mUserId;
- public NotificationRunnable(boolean selfChange, Uri uri) {
+ public NotificationRunnable(boolean selfChange, Uri uri, int userId) {
mSelfChange = selfChange;
mUri = uri;
+ mUserId = userId;
}
@Override
public void run() {
- ContentObserver.this.onChange(mSelfChange, mUri);
+ ContentObserver.this.onChange(mSelfChange, mUri, mUserId);
}
}
@@ -189,10 +225,10 @@ public abstract class ContentObserver {
}
@Override
- public void onChange(boolean selfChange, Uri uri) {
+ public void onChange(boolean selfChange, Uri uri, int userId) {
ContentObserver contentObserver = mContentObserver;
if (contentObserver != null) {
- contentObserver.dispatchChange(selfChange, uri);
+ contentObserver.dispatchChange(selfChange, uri, userId);
}
}