From 5ac72a29593ab9a20337a2225df52bdf4754be02 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Wed, 29 Aug 2012 18:32:08 -0700 Subject: Improve multi-user broadcasts. You can now use ALL and CURRENT when sending broadcasts, to specify where the broadcast goes. Sticky broadcasts are now correctly separated per user, and registered receivers are filtered based on the requested target user. New Context APIs for more kinds of sending broadcasts as users. Updating a bunch of system code that sends broadcasts to explicitly specify which user the broadcast goes to. Made a single version of the code for interpreting the requested target user ID that all entries to activity manager (start activity, send broadcast, start service) use. Change-Id: Ie29f02dd5242ef8c8fa56c54593a315cd2574e1c --- .../coretests/src/android/app/activity/BroadcastTest.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'core/tests') diff --git a/core/tests/coretests/src/android/app/activity/BroadcastTest.java b/core/tests/coretests/src/android/app/activity/BroadcastTest.java index d527c0d..7f551b0 100644 --- a/core/tests/coretests/src/android/app/activity/BroadcastTest.java +++ b/core/tests/coretests/src/android/app/activity/BroadcastTest.java @@ -26,6 +26,7 @@ import android.os.Binder; import android.os.Bundle; import android.os.IBinder; import android.os.Parcel; +import android.os.UserHandle; import android.test.FlakyTest; import android.test.suitebuilder.annotation.Suppress; import android.util.Log; @@ -306,7 +307,7 @@ public class BroadcastTest extends ActivityTestsBase { ActivityManagerNative.getDefault().unbroadcastIntent(null, intent, Binder.getOrigCallingUser()); - ActivityManagerNative.broadcastStickyIntent(intent, null); + ActivityManagerNative.broadcastStickyIntent(intent, null, UserHandle.myUserId()); addIntermediate("finished-broadcast"); IntentFilter filter = new IntentFilter(LaunchpadActivity.BROADCAST_STICKY1); @@ -318,7 +319,7 @@ public class BroadcastTest extends ActivityTestsBase { public void testClearSticky() throws Exception { Intent intent = new Intent(LaunchpadActivity.BROADCAST_STICKY1, null); intent.putExtra("test", LaunchpadActivity.DATA_1); - ActivityManagerNative.broadcastStickyIntent(intent, null); + ActivityManagerNative.broadcastStickyIntent(intent, null, UserHandle.myUserId()); ActivityManagerNative.getDefault().unbroadcastIntent( null, new Intent(LaunchpadActivity.BROADCAST_STICKY1, null), @@ -333,10 +334,10 @@ public class BroadcastTest extends ActivityTestsBase { public void testReplaceSticky() throws Exception { Intent intent = new Intent(LaunchpadActivity.BROADCAST_STICKY1, null); intent.putExtra("test", LaunchpadActivity.DATA_1); - ActivityManagerNative.broadcastStickyIntent(intent, null); + ActivityManagerNative.broadcastStickyIntent(intent, null, UserHandle.myUserId()); intent.putExtra("test", LaunchpadActivity.DATA_2); - ActivityManagerNative.broadcastStickyIntent(intent, null); + ActivityManagerNative.broadcastStickyIntent(intent, null, UserHandle.myUserId()); addIntermediate("finished-broadcast"); IntentFilter filter = new IntentFilter(LaunchpadActivity.BROADCAST_STICKY1); @@ -350,7 +351,7 @@ public class BroadcastTest extends ActivityTestsBase { public void testReceiveSticky() throws Exception { Intent intent = new Intent(LaunchpadActivity.BROADCAST_STICKY1, null); intent.putExtra("test", LaunchpadActivity.DATA_1); - ActivityManagerNative.broadcastStickyIntent(intent, null); + ActivityManagerNative.broadcastStickyIntent(intent, null, UserHandle.myUserId()); runLaunchpad(LaunchpadActivity.BROADCAST_STICKY1); } @@ -360,10 +361,10 @@ public class BroadcastTest extends ActivityTestsBase { public void testReceive2Sticky() throws Exception { Intent intent = new Intent(LaunchpadActivity.BROADCAST_STICKY1, null); intent.putExtra("test", LaunchpadActivity.DATA_1); - ActivityManagerNative.broadcastStickyIntent(intent, null); + ActivityManagerNative.broadcastStickyIntent(intent, null, UserHandle.myUserId()); intent = new Intent(LaunchpadActivity.BROADCAST_STICKY2, null); intent.putExtra("test", LaunchpadActivity.DATA_2); - ActivityManagerNative.broadcastStickyIntent(intent, null); + ActivityManagerNative.broadcastStickyIntent(intent, null, UserHandle.myUserId()); runLaunchpad(LaunchpadActivity.BROADCAST_STICKY2); } -- cgit v1.1