Merge "Cleaning code related to the forwarding intent filters."

This commit is contained in:
Nicolas Prevot
2014-05-06 13:57:56 +00:00
committed by Android (Google) Code Review
8 changed files with 76 additions and 18 deletions

View File

@@ -5009,12 +5009,12 @@ package android.app.admin {
}
public class DevicePolicyManager {
method public void addForwardingIntentFilter(android.content.ComponentName, android.content.IntentFilter, int);
method public void addPersistentPreferredActivity(android.content.ComponentName, android.content.IntentFilter, android.content.ComponentName);
method public void addUserRestriction(android.content.ComponentName, java.lang.String);
method public void clearForwardingIntentFilters(android.content.ComponentName);
method public void clearPackagePersistentPreferredActivities(android.content.ComponentName, java.lang.String);
method public void clearUserRestriction(android.content.ComponentName, java.lang.String);
method public void forwardMatchingIntents(android.content.ComponentName, android.content.IntentFilter, int);
method public java.util.List<android.content.ComponentName> getActiveAdmins();
method public android.os.Bundle getApplicationRestrictions(android.content.ComponentName, java.lang.String);
method public boolean getCameraDisabled(android.content.ComponentName);

View File

@@ -1440,6 +1440,31 @@ final class ApplicationPackageManager extends PackageManager {
return null;
}
/**
* @hide
*/
@Override
public void addForwardingIntentFilter(IntentFilter filter, boolean removable, int userIdOrig,
int userIdDest) {
try {
mPM.addForwardingIntentFilter(filter, removable, userIdOrig, userIdDest);
} catch (RemoteException e) {
// Should never happen!
}
}
/**
* @hide
*/
@Override
public void clearForwardingIntentFilters(int userIdOrig) {
try {
mPM.clearForwardingIntentFilters(userIdOrig);
} catch (RemoteException e) {
// Should never happen!
}
}
private final ContextImpl mContext;
private final IPackageManager mPM;

View File

@@ -173,12 +173,12 @@ public class DevicePolicyManager {
public static final String ACTION_SET_NEW_PASSWORD
= "android.app.action.SET_NEW_PASSWORD";
/**
* Flag for {@link #forwardMatchingIntents}: the intents will forwarded to the primary user.
* Flag for {@link #addForwardingIntentFilter}: the intents will forwarded to the primary user.
*/
public static int FLAG_TO_PRIMARY_USER = 0x0001;
/**
* Flag for {@link #forwardMatchingIntents}: the intents will be forwarded to the managed
* Flag for {@link #addForwardingIntentFilter}: the intents will be forwarded to the managed
* profile.
*/
public static int FLAG_TO_MANAGED_PROFILE = 0x0002;
@@ -1949,10 +1949,10 @@ public class DevicePolicyManager {
* @param admin Which {@link DeviceAdminReceiver} this request is associated with.
* @param filter if an intent matches this IntentFilter, then it can be forwarded.
*/
public void forwardMatchingIntents(ComponentName admin, IntentFilter filter, int flags) {
public void addForwardingIntentFilter(ComponentName admin, IntentFilter filter, int flags) {
if (mService != null) {
try {
mService.forwardMatchingIntents(admin, filter, flags);
mService.addForwardingIntentFilter(admin, filter, flags);
} catch (RemoteException e) {
Log.w(TAG, "Failed talking with device policy service", e);
}
@@ -1960,7 +1960,7 @@ public class DevicePolicyManager {
}
/**
* Called by a profile owner to remove all the forwarding intent filters from the current user
* Called by a profile owner to remove the forwarding intent filters from the current user
* and from the owner.
* @param admin Which {@link DeviceAdminReceiver} this request is associated with.
*/

View File

@@ -120,6 +120,6 @@ interface IDevicePolicyManager {
Bundle getApplicationRestrictions(in ComponentName who, in String packageName);
void setUserRestriction(in ComponentName who, in String key, boolean enable);
void forwardMatchingIntents(in ComponentName admin, in IntentFilter filter, int flags);
void addForwardingIntentFilter(in ComponentName admin, in IntentFilter filter, int flags);
void clearForwardingIntentFilters(in ComponentName admin);
}

View File

@@ -3507,4 +3507,26 @@ public abstract class PackageManager {
return Environment.getDataDirectory().toString() + "/user/" + userId
+ "/" + packageName;
}
/**
* Adds a forwarding intent filter. After calling this method all intents sent from the user
* with id userIdOrig can also be be resolved by activities in the user with id userIdDest if
* they match the specified intent filter.
* @param filter the {@link IntentFilter} the intent has to match to be forwarded
* @param removable if set to false, {@link clearForwardingIntents} will not remove this intent
* filter
* @param userIdOrig user from which the intent can be forwarded
* @param userIdDest user to which the intent can be forwarded
* @hide
*/
public abstract void addForwardingIntentFilter(IntentFilter filter, boolean removable,
int userIdOrig, int userIdDest);
/**
* Clearing all removable {@link ForwardingIntentFilter}s that are set with the given user as
* the origin.
* @param userIdOrig user from which the intent can be forwarded
* @hide
*/
public abstract void clearForwardingIntentFilters(int userIdOrig);
}

View File

@@ -11115,11 +11115,8 @@ public class PackageManagerService extends IPackageManager.Stub {
@Override
public void addForwardingIntentFilter(IntentFilter filter, boolean removable, int userIdOrig,
int userIdDest) {
int callingUid = Binder.getCallingUid();
if (callingUid != Process.SYSTEM_UID) {
throw new SecurityException(
"addForwardingIntentFilter can only be run by the system");
}
mContext.enforceCallingOrSelfPermission(
android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, null);
if (filter.countActions() == 0) {
Slog.w(TAG, "Cannot set a forwarding intent filter with no filter actions");
return;
@@ -11133,11 +11130,8 @@ public class PackageManagerService extends IPackageManager.Stub {
@Override
public void clearForwardingIntentFilters(int userIdOrig) {
int callingUid = Binder.getCallingUid();
if (callingUid != Process.SYSTEM_UID) {
throw new SecurityException(
"clearForwardingIntentFilter can only be run by the system");
}
mContext.enforceCallingOrSelfPermission(
android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, null);
synchronized (mPackages) {
ForwardingIntentResolver fir = mSettings.editForwardingIntentResolverLPw(userIdOrig);
HashSet<ForwardingIntentFilter> set =

View File

@@ -3082,7 +3082,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
}
}
public void forwardMatchingIntents(ComponentName who, IntentFilter filter, int flags) {
public void addForwardingIntentFilter(ComponentName who, IntentFilter filter, int flags) {
int callingUserId = UserHandle.getCallingUserId();
synchronized (this) {
if (who == null) {

View File

@@ -701,4 +701,21 @@ public class MockPackageManager extends PackageManager {
VerificationParams verificationParams, ContainerEncryptionParams encryptionParams) {
throw new UnsupportedOperationException();
}
/**
* @hide
*/
@Override
public void addForwardingIntentFilter(IntentFilter filter, boolean removable, int userIdOrig,
int userIdDest) {
throw new UnsupportedOperationException();
}
/**
* @hide
*/
@Override
public void clearForwardingIntentFilters(int userIdOrig) {
throw new UnsupportedOperationException();
}
}