Storing the app who sets a CrossProfileIntentFilter.

When we add a CrossProfileIntentFilter, we store the package and userId of the calling app
inside the CrossProfileIntentFilter.
When an app calls clearCrossProfileIntentFilters, we only remove the filters that the calling app
has set itself.

BUG: 16537557

Change-Id: I6e7bc859383ea66553d9f4230365df8ba27525f3
This commit is contained in:
Nicolas Prevot
2014-07-24 15:58:39 +01:00
parent 91a801d42f
commit 3f7777fa4f
7 changed files with 103 additions and 49 deletions

View File

@@ -1583,7 +1583,8 @@ final class ApplicationPackageManager extends PackageManager {
public void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId, int targetUserId,
int flags) {
try {
mPM.addCrossProfileIntentFilter(filter, sourceUserId, targetUserId, flags);
mPM.addCrossProfileIntentFilter(filter, mContext.getOpPackageName(),
mContext.getUserId(), sourceUserId, targetUserId, flags);
} catch (RemoteException e) {
// Should never happen!
}
@@ -1607,7 +1608,8 @@ final class ApplicationPackageManager extends PackageManager {
@Override
public void clearCrossProfileIntentFilters(int sourceUserId) {
try {
mPM.clearCrossProfileIntentFilters(sourceUserId);
mPM.clearCrossProfileIntentFilters(sourceUserId, mContext.getOpPackageName(),
mContext.getUserId());
} catch (RemoteException e) {
// Should never happen!
}

View File

@@ -2391,8 +2391,9 @@ public class DevicePolicyManager {
}
/**
* Called by a profile owner to remove the cross-profile intent filters from the managed profile
* and from the parent.
* Called by a profile owner to remove the cross-profile intent filters that go from the
* managed profile to the parent, or from the parent to the managed profile.
* Only removes those that have been set by the profile owner.
* @param admin Which {@link DeviceAdminReceiver} this request is associated with.
*/
public void clearCrossProfileIntentFilters(ComponentName admin) {

View File

@@ -244,13 +244,13 @@ interface IPackageManager {
void clearPackagePersistentPreferredActivities(String packageName, int userId);
void addCrossProfileIntentFilter(in IntentFilter intentFilter, int sourceUserId, int targetUserId,
int flags);
void addCrossProfileIntentFilter(in IntentFilter intentFilter, String ownerPackage,
int ownerUserId, int sourceUserId, int targetUserId, int flags);
void addCrossProfileIntentsForPackage(in String packageName, int sourceUserId,
int targetUserId);
void clearCrossProfileIntentFilters(int sourceUserId);
void clearCrossProfileIntentFilters(int sourceUserId, String ownerPackage, int ownerUserId);
/**
* Report the set of 'Home' activity candidates, plus (if any) which of them

View File

@@ -204,13 +204,6 @@ public abstract class PackageManager {
*/
public static final int NO_CROSS_PROFILE = 0x00020000;
/**
* Flag for {@link addCrossProfileIntentFilter}: if the cross-profile intent has been set by the
* profile owner.
* @hide
*/
public static final int SET_BY_PROFILE_OWNER= 0x00000001;
/**
* Flag for {@link addCrossProfileIntentFilter}: if this flag is set:
* when resolving an intent that matches the {@link CrossProfileIntentFilter}, the current
@@ -3744,9 +3737,10 @@ public abstract class PackageManager {
* Adds a {@link CrossProfileIntentFilter}. After calling this method all intents sent from the
* user with id sourceUserId can also be be resolved by activities in the user with id
* targetUserId if they match the specified intent filter.
* @param filter the {@link IntentFilter} the intent has to match
* @param removable if set to false, {@link clearCrossProfileIntentFilters} will not remove this
* {@link CrossProfileIntentFilter}
* @param filter The {@link IntentFilter} the intent has to match
* @param sourceUserId The source user id.
* @param targetUserId The target user id.
* @param flags The only possible value is {@link SKIP_CURRENT_PROFILE}
* @hide
*/
public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId,
@@ -3754,8 +3748,8 @@ public abstract class PackageManager {
/**
* Clearing {@link CrossProfileIntentFilter}s which have the specified user as their
* source, and have been set by the profile owner
* @param sourceUserId
* source, and have been set by the app calling this method.
* @param sourceUserId The source user id.
* @hide
*/
public abstract void clearCrossProfileIntentFilters(int sourceUserId);