diff options
author | Christopher Tate <ctate@google.com> | 2012-09-17 16:23:44 -0700 |
---|---|---|
committer | Christopher Tate <ctate@google.com> | 2012-09-17 16:35:36 -0700 |
commit | 16aa9736175f5bbe924a6e5587a2ca47c2dd702b (patch) | |
tree | 40a40cd4aee50183ced46dbc34106c29c09c4787 /core/tests/coretests | |
parent | 9f5f80e7a64d9388e3e73763b5c73dcddaa729fc (diff) | |
download | frameworks_base-16aa9736175f5bbe924a6e5587a2ca47c2dd702b.zip frameworks_base-16aa9736175f5bbe924a6e5587a2ca47c2dd702b.tar.gz frameworks_base-16aa9736175f5bbe924a6e5587a2ca47c2dd702b.tar.bz2 |
Per-user content observer APIs
Callers with INTERACT_ACROSS_USERS_FULL permission can now observe content
for a given user's view (and can notify content uri changes targeted to a
specific user). An observer watching for UserHandle.USER_ALL will see all
notifications for the given uri across all users; similarly, a notifier
who specifies USER_ALL will broadcast the change to all observers across
all users.
The API handles both USER_ALL or USER_CURRENT, and explicitly forbids
any other "pseudouser" designations.
This CL also revs the Settings provider to notify with USER_ALL for
changes to global settings, and with only the affected user's handle
for all other changes.
Bug 7122169
Change-Id: I94248b11aa91d1beb0a36432e82fe5725bb1264f
Diffstat (limited to 'core/tests/coretests')
-rw-r--r-- | core/tests/coretests/src/android/content/ObserverNodeTest.java | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/core/tests/coretests/src/android/content/ObserverNodeTest.java b/core/tests/coretests/src/android/content/ObserverNodeTest.java index 95b8465..1acff9c 100644 --- a/core/tests/coretests/src/android/content/ObserverNodeTest.java +++ b/core/tests/coretests/src/android/content/ObserverNodeTest.java @@ -23,6 +23,7 @@ import android.content.ContentService.ObserverNode; import android.database.ContentObserver; import android.net.Uri; import android.os.Handler; +import android.os.UserHandle; import android.test.AndroidTestCase; public class ObserverNodeTest extends AndroidTestCase { @@ -33,6 +34,8 @@ public class ObserverNodeTest extends AndroidTestCase { } public void testUri() { + final int myUserHandle = UserHandle.myUserId(); + ObserverNode root = new ObserverNode(""); Uri[] uris = new Uri[] { Uri.parse("content://c/a/"), @@ -48,21 +51,25 @@ public class ObserverNodeTest extends AndroidTestCase { int[] nums = new int[] {4, 7, 1, 4, 2, 2, 3, 3}; // special case - root.addObserverLocked(uris[0], new TestObserver().getContentObserver(), false, root, 0, 0); + root.addObserverLocked(uris[0], new TestObserver().getContentObserver(), false, root, + 0, 0, myUserHandle); for(int i = 1; i < uris.length; i++) { - root.addObserverLocked(uris[i], new TestObserver().getContentObserver(), true, root, 0, 0); + root.addObserverLocked(uris[i], new TestObserver().getContentObserver(), true, root, + 0, 0, myUserHandle); } ArrayList<ObserverCall> calls = new ArrayList<ObserverCall>(); for (int i = nums.length - 1; i >=0; --i) { - root.collectObserversLocked(uris[i], 0, null, false, calls); + root.collectObserversLocked(uris[i], 0, null, false, myUserHandle, calls); assertEquals(nums[i], calls.size()); calls.clear(); } } public void testUriNotNotify() { + final int myUserHandle = UserHandle.myUserId(); + ObserverNode root = new ObserverNode(""); Uri[] uris = new Uri[] { Uri.parse("content://c/"), @@ -77,13 +84,14 @@ public class ObserverNodeTest extends AndroidTestCase { int[] nums = new int[] {7, 1, 3, 3, 1, 1, 1, 1}; for(int i = 0; i < uris.length; i++) { - root.addObserverLocked(uris[i], new TestObserver().getContentObserver(), false, root, 0, 0); + root.addObserverLocked(uris[i], new TestObserver().getContentObserver(), false, root, + 0, 0, myUserHandle); } ArrayList<ObserverCall> calls = new ArrayList<ObserverCall>(); for (int i = uris.length - 1; i >=0; --i) { - root.collectObserversLocked(uris[i], 0, null, false, calls); + root.collectObserversLocked(uris[i], 0, null, false, myUserHandle, calls); assertEquals(nums[i], calls.size()); calls.clear(); } |