Loading core/java/android/app/ApplicationPackageManager.java +4 −2 Original line number Diff line number Diff line Loading @@ -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! } Loading @@ -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! } Loading core/java/android/app/admin/DevicePolicyManager.java +3 −2 Original line number Diff line number Diff line Loading @@ -2402,8 +2402,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) { Loading core/java/android/content/pm/IPackageManager.aidl +3 −3 Original line number Diff line number Diff line Loading @@ -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 Loading core/java/android/content/pm/PackageManager.java +6 −12 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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, Loading @@ -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); Loading services/core/java/com/android/server/pm/CrossProfileIntentFilter.java +43 −19 Original line number Diff line number Diff line Loading @@ -33,17 +33,24 @@ import android.os.UserHandle; class CrossProfileIntentFilter extends IntentFilter { private static final String ATTR_TARGET_USER_ID = "targetUserId"; private static final String ATTR_FLAGS = "flags"; private static final String ATTR_OWNER_USER_ID = "ownerUserId"; private static final String ATTR_OWNER_PACKAGE = "ownerPackage"; private static final String ATTR_FILTER = "filter"; private static final String TAG = "CrossProfileIntentFilter"; // If the intent matches the IntentFilter, then it can be forwarded to this userId. final int mTargetUserId; final int mOwnerUserId; // userId of the app which has set this CrossProfileIntentFilter. final String mOwnerPackage; // packageName of the app. final int mFlags; CrossProfileIntentFilter(IntentFilter filter, int targetUserId, int flags) { CrossProfileIntentFilter(IntentFilter filter, String ownerPackage, int ownerUserId, int targetUserId, int flags) { super(filter); mTargetUserId = targetUserId; mOwnerUserId = ownerUserId; mOwnerPackage = ownerPackage; mFlags = flags; } Loading @@ -55,25 +62,20 @@ class CrossProfileIntentFilter extends IntentFilter { return mFlags; } CrossProfileIntentFilter(XmlPullParser parser) throws XmlPullParserException, IOException { String targetUserIdString = parser.getAttributeValue(null, ATTR_TARGET_USER_ID); if (targetUserIdString == null) { String msg = "Missing element under " + TAG +": " + ATTR_TARGET_USER_ID + " at " + parser.getPositionDescription(); PackageManagerService.reportSettingsProblem(Log.WARN, msg); mTargetUserId = UserHandle.USER_NULL; } else { mTargetUserId = Integer.parseInt(targetUserIdString); public int getOwnerUserId() { return mOwnerUserId; } String flagsString = parser.getAttributeValue(null, ATTR_FLAGS); if (flagsString == null) { String msg = "Missing element under " + TAG +": " + ATTR_FLAGS + " at " + parser.getPositionDescription(); PackageManagerService.reportSettingsProblem(Log.WARN, msg); mFlags = 0; } else { mFlags = Integer.parseInt(flagsString); public String getOwnerPackage() { return mOwnerPackage; } CrossProfileIntentFilter(XmlPullParser parser) throws XmlPullParserException, IOException { mTargetUserId = getIntFromXml(parser, ATTR_TARGET_USER_ID, UserHandle.USER_NULL); mOwnerUserId = getIntFromXml(parser, ATTR_OWNER_USER_ID, UserHandle.USER_NULL); mOwnerPackage = getStringFromXml(parser, ATTR_OWNER_PACKAGE, ""); mFlags = getIntFromXml(parser, ATTR_FLAGS, 0); int outerDepth = parser.getDepth(); String tagName = parser.getName(); int type; Loading Loading @@ -103,9 +105,31 @@ class CrossProfileIntentFilter extends IntentFilter { } } String getStringFromXml(XmlPullParser parser, String attribute, String defaultValue) { String value = parser.getAttributeValue(null, attribute); if (value == null) { String msg = "Missing element under " + TAG +": " + attribute + " at " + parser.getPositionDescription(); PackageManagerService.reportSettingsProblem(Log.WARN, msg); return defaultValue; } else { return value; } } int getIntFromXml(XmlPullParser parser, String attribute, int defaultValue) { String stringValue = getStringFromXml(parser, attribute, null); if (stringValue != null) { return Integer.parseInt(stringValue); } return defaultValue; } public void writeToXml(XmlSerializer serializer) throws IOException { serializer.attribute(null, ATTR_TARGET_USER_ID, Integer.toString(mTargetUserId)); serializer.attribute(null, ATTR_FLAGS, Integer.toString(mFlags)); serializer.attribute(null, ATTR_OWNER_USER_ID, Integer.toString(mOwnerUserId)); serializer.attribute(null, ATTR_OWNER_PACKAGE, mOwnerPackage); serializer.startTag(null, ATTR_FILTER); super.writeToXml(serializer); serializer.endTag(null, ATTR_FILTER); Loading Loading
core/java/android/app/ApplicationPackageManager.java +4 −2 Original line number Diff line number Diff line Loading @@ -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! } Loading @@ -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! } Loading
core/java/android/app/admin/DevicePolicyManager.java +3 −2 Original line number Diff line number Diff line Loading @@ -2402,8 +2402,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) { Loading
core/java/android/content/pm/IPackageManager.aidl +3 −3 Original line number Diff line number Diff line Loading @@ -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 Loading
core/java/android/content/pm/PackageManager.java +6 −12 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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, Loading @@ -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); Loading
services/core/java/com/android/server/pm/CrossProfileIntentFilter.java +43 −19 Original line number Diff line number Diff line Loading @@ -33,17 +33,24 @@ import android.os.UserHandle; class CrossProfileIntentFilter extends IntentFilter { private static final String ATTR_TARGET_USER_ID = "targetUserId"; private static final String ATTR_FLAGS = "flags"; private static final String ATTR_OWNER_USER_ID = "ownerUserId"; private static final String ATTR_OWNER_PACKAGE = "ownerPackage"; private static final String ATTR_FILTER = "filter"; private static final String TAG = "CrossProfileIntentFilter"; // If the intent matches the IntentFilter, then it can be forwarded to this userId. final int mTargetUserId; final int mOwnerUserId; // userId of the app which has set this CrossProfileIntentFilter. final String mOwnerPackage; // packageName of the app. final int mFlags; CrossProfileIntentFilter(IntentFilter filter, int targetUserId, int flags) { CrossProfileIntentFilter(IntentFilter filter, String ownerPackage, int ownerUserId, int targetUserId, int flags) { super(filter); mTargetUserId = targetUserId; mOwnerUserId = ownerUserId; mOwnerPackage = ownerPackage; mFlags = flags; } Loading @@ -55,25 +62,20 @@ class CrossProfileIntentFilter extends IntentFilter { return mFlags; } CrossProfileIntentFilter(XmlPullParser parser) throws XmlPullParserException, IOException { String targetUserIdString = parser.getAttributeValue(null, ATTR_TARGET_USER_ID); if (targetUserIdString == null) { String msg = "Missing element under " + TAG +": " + ATTR_TARGET_USER_ID + " at " + parser.getPositionDescription(); PackageManagerService.reportSettingsProblem(Log.WARN, msg); mTargetUserId = UserHandle.USER_NULL; } else { mTargetUserId = Integer.parseInt(targetUserIdString); public int getOwnerUserId() { return mOwnerUserId; } String flagsString = parser.getAttributeValue(null, ATTR_FLAGS); if (flagsString == null) { String msg = "Missing element under " + TAG +": " + ATTR_FLAGS + " at " + parser.getPositionDescription(); PackageManagerService.reportSettingsProblem(Log.WARN, msg); mFlags = 0; } else { mFlags = Integer.parseInt(flagsString); public String getOwnerPackage() { return mOwnerPackage; } CrossProfileIntentFilter(XmlPullParser parser) throws XmlPullParserException, IOException { mTargetUserId = getIntFromXml(parser, ATTR_TARGET_USER_ID, UserHandle.USER_NULL); mOwnerUserId = getIntFromXml(parser, ATTR_OWNER_USER_ID, UserHandle.USER_NULL); mOwnerPackage = getStringFromXml(parser, ATTR_OWNER_PACKAGE, ""); mFlags = getIntFromXml(parser, ATTR_FLAGS, 0); int outerDepth = parser.getDepth(); String tagName = parser.getName(); int type; Loading Loading @@ -103,9 +105,31 @@ class CrossProfileIntentFilter extends IntentFilter { } } String getStringFromXml(XmlPullParser parser, String attribute, String defaultValue) { String value = parser.getAttributeValue(null, attribute); if (value == null) { String msg = "Missing element under " + TAG +": " + attribute + " at " + parser.getPositionDescription(); PackageManagerService.reportSettingsProblem(Log.WARN, msg); return defaultValue; } else { return value; } } int getIntFromXml(XmlPullParser parser, String attribute, int defaultValue) { String stringValue = getStringFromXml(parser, attribute, null); if (stringValue != null) { return Integer.parseInt(stringValue); } return defaultValue; } public void writeToXml(XmlSerializer serializer) throws IOException { serializer.attribute(null, ATTR_TARGET_USER_ID, Integer.toString(mTargetUserId)); serializer.attribute(null, ATTR_FLAGS, Integer.toString(mFlags)); serializer.attribute(null, ATTR_OWNER_USER_ID, Integer.toString(mOwnerUserId)); serializer.attribute(null, ATTR_OWNER_PACKAGE, mOwnerPackage); serializer.startTag(null, ATTR_FILTER); super.writeToXml(serializer); serializer.endTag(null, ATTR_FILTER); Loading