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
diff --git a/src/com/android/settings/ManagedProfileSetup.java b/src/com/android/settings/ManagedProfileSetup.java
index 8677219..1b3c838 100644
--- a/src/com/android/settings/ManagedProfileSetup.java
+++ b/src/com/android/settings/ManagedProfileSetup.java
@@ -47,12 +47,15 @@
             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
         Intent intent = new Intent();
         intent.addCategory(Intent.CATEGORY_DEFAULT);
         intent.setPackage(context.getPackageName());
 
-        final PackageManager pm  = context.getPackageManager();
         // Resolves activities for the managed profile (which we're running as)
         List<ResolveInfo> resolvedIntents = pm.queryIntentActivities(intent,
                 GET_ACTIVITIES | GET_META_DATA | GET_RESOLVED_FILTER);