Clears previously added cross-profile-intents

Clears the old cross-profile intent filters added by the Settings app.
This makes sure we do not have duplicates and also that there are no
outdated intents being forwarded (intents that do not exist any more).

Bug: 16647771
Change-Id: Ief4f7341e3f984b9435a9757bf469e53227ce2bf
This commit is contained in:
Alexandra Gherghina
2014-07-29 14:55:56 +01:00
parent a6145a656a
commit 5667a6890a

View File

@@ -47,12 +47,15 @@ public class ManagedProfileSetup extends BroadcastReceiver {
return; return;
} }
final PackageManager pm = context.getPackageManager();
// Clear any previous intent forwarding we set up
pm.clearCrossProfileIntentFilters(UserHandle.myUserId());
// Set up intent forwarding for implicit intents // Set up intent forwarding for implicit intents
Intent intent = new Intent(); Intent intent = new Intent();
intent.addCategory(Intent.CATEGORY_DEFAULT); intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setPackage(context.getPackageName()); intent.setPackage(context.getPackageName());
final PackageManager pm = context.getPackageManager();
// Resolves activities for the managed profile (which we're running as) // Resolves activities for the managed profile (which we're running as)
List<ResolveInfo> resolvedIntents = pm.queryIntentActivities(intent, List<ResolveInfo> resolvedIntents = pm.queryIntentActivities(intent,
GET_ACTIVITIES | GET_META_DATA | GET_RESOLVED_FILTER); GET_ACTIVITIES | GET_META_DATA | GET_RESOLVED_FILTER);