summaryrefslogtreecommitdiffstats
path: root/services/devicepolicy
diff options
context:
space:
mode:
authorNicolas Prevot <nprevot@google.com>2014-03-24 13:44:38 +0000
committerNicolas Prevot <nprevot@google.com>2014-04-30 19:24:52 +0100
commit10fa67c77e11699391e27975fc2d276a0b8c7cbb (patch)
tree8a3349d2424f13e5c89ea710da84aaec81a42d70 /services/devicepolicy
parentdfacf855fd91eb2d40891721ad4b92ed65d0b46d (diff)
downloadframeworks_base-10fa67c77e11699391e27975fc2d276a0b8c7cbb.zip
frameworks_base-10fa67c77e11699391e27975fc2d276a0b8c7cbb.tar.gz
frameworks_base-10fa67c77e11699391e27975fc2d276a0b8c7cbb.tar.bz2
Introduce forwarding intents across profiles.
The package manager service maintains, for some user ids, a list of forwarding intent filters. A forwarding intent filter is an intent filter with a destination (a user id). If an intent matches the forwarding intent filter, then activities in the destination can also respond to the intent. When the package manager service is asked for components that resolve an intent: If the intent matches the forwarding intent filter, and at least one activity in the destination user can respond to the intent: The package manager service also returns the IntentForwarderActivity. This activity will forward the intent to the destination. Change-Id: Id8957de3e4a4fdbc1e0dea073eadb45e04ef985a
Diffstat (limited to 'services/devicepolicy')
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index f1ee280..8e1f82a 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -3099,6 +3099,51 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
}
}
+ public void forwardMatchingIntents(ComponentName who, IntentFilter filter, int flags) {
+ int callingUserId = UserHandle.getCallingUserId();
+ synchronized (this) {
+ if (who == null) {
+ throw new NullPointerException("ComponentName is null");
+ }
+ getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
+
+ IPackageManager pm = AppGlobals.getPackageManager();
+ long id = Binder.clearCallingIdentity();
+ try {
+ if ((flags & DevicePolicyManager.FLAG_TO_PRIMARY_USER) != 0) {
+ pm.addForwardingIntentFilter(filter, callingUserId, UserHandle.USER_OWNER);
+ }
+ if ((flags & DevicePolicyManager.FLAG_TO_MANAGED_PROFILE) != 0) {
+ pm.addForwardingIntentFilter(filter, UserHandle.USER_OWNER, callingUserId);
+ }
+ } catch (RemoteException re) {
+ // Shouldn't happen
+ } finally {
+ restoreCallingIdentity(id);
+ }
+ }
+ }
+
+ public void clearForwardingIntentFilters(ComponentName who) {
+ int callingUserId = UserHandle.getCallingUserId();
+ synchronized (this) {
+ if (who == null) {
+ throw new NullPointerException("ComponentName is null");
+ }
+ getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
+ IPackageManager pm = AppGlobals.getPackageManager();
+ long id = Binder.clearCallingIdentity();
+ try {
+ pm.clearForwardingIntentFilters(callingUserId);
+ pm.clearForwardingIntentFilters(UserHandle.USER_OWNER);
+ } catch (RemoteException re) {
+ // Shouldn't happen
+ } finally {
+ restoreCallingIdentity(id);
+ }
+ }
+ }
+
@Override
public Bundle getApplicationRestrictions(ComponentName who, String packageName) {
final UserHandle userHandle = new UserHandle(UserHandle.getCallingUserId());