Loading core/java/android/app/ApplicationPackageManager.java +2 −3 Original line number Diff line number Diff line Loading @@ -1662,7 +1662,7 @@ final class ApplicationPackageManager extends PackageManager { int flags) { try { mPM.addCrossProfileIntentFilter(filter, mContext.getOpPackageName(), mContext.getUserId(), sourceUserId, targetUserId, flags); sourceUserId, targetUserId, flags); } catch (RemoteException e) { // Should never happen! } Loading @@ -1674,8 +1674,7 @@ final class ApplicationPackageManager extends PackageManager { @Override public void clearCrossProfileIntentFilters(int sourceUserId) { try { mPM.clearCrossProfileIntentFilters(sourceUserId, mContext.getOpPackageName(), mContext.getUserId()); mPM.clearCrossProfileIntentFilters(sourceUserId, mContext.getOpPackageName()); } catch (RemoteException e) { // Should never happen! } Loading core/java/android/content/pm/IPackageManager.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -261,9 +261,9 @@ interface IPackageManager { void clearPackagePersistentPreferredActivities(String packageName, int userId); void addCrossProfileIntentFilter(in IntentFilter intentFilter, String ownerPackage, int ownerUserId, int sourceUserId, int targetUserId, int flags); int sourceUserId, int targetUserId, int flags); void clearCrossProfileIntentFilters(int sourceUserId, String ownerPackage, int ownerUserId); void clearCrossProfileIntentFilters(int sourceUserId, String ownerPackage); /** * Report the set of 'Home' activity candidates, plus (if any) which of them Loading services/core/java/com/android/server/pm/CrossProfileIntentFilter.java +2 −12 Original line number Diff line number Diff line Loading @@ -33,7 +33,6 @@ 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"; Loading @@ -41,15 +40,13 @@ class CrossProfileIntentFilter extends IntentFilter { // 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, String ownerPackage, int ownerUserId, int targetUserId, int flags) { CrossProfileIntentFilter(IntentFilter filter, String ownerPackage, int targetUserId, int flags) { super(filter); mTargetUserId = targetUserId; mOwnerUserId = ownerUserId; mOwnerPackage = ownerPackage; mFlags = flags; } Loading @@ -62,17 +59,12 @@ class CrossProfileIntentFilter extends IntentFilter { return mFlags; } public int getOwnerUserId() { return mOwnerUserId; } 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); Loading Loading @@ -129,7 +121,6 @@ class CrossProfileIntentFilter extends IntentFilter { 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); Loading @@ -144,7 +135,6 @@ class CrossProfileIntentFilter extends IntentFilter { boolean equalsIgnoreFilter(CrossProfileIntentFilter other) { return mTargetUserId == other.mTargetUserId && mOwnerUserId == other.mOwnerUserId && mOwnerPackage.equals(other.mOwnerPackage) && mFlags == other.mFlags; } Loading services/core/java/com/android/server/pm/PackageManagerService.java +7 −15 Original line number Diff line number Diff line Loading @@ -11792,11 +11792,11 @@ public class PackageManagerService extends IPackageManager.Stub { @Override public void addCrossProfileIntentFilter(IntentFilter intentFilter, String ownerPackage, int ownerUserId, int sourceUserId, int targetUserId, int flags) { int sourceUserId, int targetUserId, int flags) { mContext.enforceCallingOrSelfPermission( android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, null); int callingUid = Binder.getCallingUid(); enforceOwnerRights(ownerPackage, ownerUserId, callingUid); enforceOwnerRights(ownerPackage, callingUid); enforceShellRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES, callingUid, sourceUserId); if (intentFilter.countActions() == 0) { Slog.w(TAG, "Cannot set a crossProfile intent filter with no filter actions"); Loading @@ -11804,7 +11804,7 @@ public class PackageManagerService extends IPackageManager.Stub { } synchronized (mPackages) { CrossProfileIntentFilter newFilter = new CrossProfileIntentFilter(intentFilter, ownerPackage, UserHandle.getUserId(callingUid), targetUserId, flags); ownerPackage, targetUserId, flags); CrossProfileIntentResolver resolver = mSettings.editCrossProfileIntentResolverLPw(sourceUserId); ArrayList<CrossProfileIntentFilter> existing = resolver.findFilters(intentFilter); Loading @@ -11823,22 +11823,19 @@ public class PackageManagerService extends IPackageManager.Stub { } @Override public void clearCrossProfileIntentFilters(int sourceUserId, String ownerPackage, int ownerUserId) { public void clearCrossProfileIntentFilters(int sourceUserId, String ownerPackage) { mContext.enforceCallingOrSelfPermission( android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, null); int callingUid = Binder.getCallingUid(); enforceOwnerRights(ownerPackage, ownerUserId, callingUid); enforceOwnerRights(ownerPackage, callingUid); enforceShellRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES, callingUid, sourceUserId); int callingUserId = UserHandle.getUserId(callingUid); synchronized (mPackages) { CrossProfileIntentResolver resolver = mSettings.editCrossProfileIntentResolverLPw(sourceUserId); ArraySet<CrossProfileIntentFilter> set = new ArraySet<CrossProfileIntentFilter>(resolver.filterSet()); for (CrossProfileIntentFilter filter : set) { if (filter.getOwnerPackage().equals(ownerPackage) && filter.getOwnerUserId() == callingUserId) { if (filter.getOwnerPackage().equals(ownerPackage)) { resolver.removeFilter(filter); } } Loading @@ -11847,17 +11844,12 @@ public class PackageManagerService extends IPackageManager.Stub { } // Enforcing that callingUid is owning pkg on userId private void enforceOwnerRights(String pkg, int userId, int callingUid) { private void enforceOwnerRights(String pkg, int callingUid) { // The system owns everything. if (UserHandle.getAppId(callingUid) == Process.SYSTEM_UID) { return; } int callingUserId = UserHandle.getUserId(callingUid); if (callingUserId != userId) { throw new SecurityException("calling uid " + callingUid + " pretends to own " + pkg + " on user " + userId + " but belongs to user " + callingUserId); } PackageInfo pi = getPackageInfo(pkg, 0, callingUserId); if (pi == null) { throw new IllegalArgumentException("Unknown package " + pkg + " on user " services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +7 −7 Original line number Diff line number Diff line Loading @@ -4504,12 +4504,12 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { long id = Binder.clearCallingIdentity(); try { if ((flags & DevicePolicyManager.FLAG_PARENT_CAN_ACCESS_MANAGED) != 0) { pm.addCrossProfileIntentFilter(filter, who.getPackageName(), mContext.getUserId(), callingUserId, UserHandle.USER_OWNER, 0); pm.addCrossProfileIntentFilter(filter, who.getPackageName(), callingUserId, UserHandle.USER_OWNER, 0); } if ((flags & DevicePolicyManager.FLAG_MANAGED_CAN_ACCESS_PARENT) != 0) { pm.addCrossProfileIntentFilter(filter, who.getPackageName(), mContext.getUserId(), UserHandle.USER_OWNER, callingUserId, 0); UserHandle.USER_OWNER, callingUserId, 0); } } catch (RemoteException re) { // Shouldn't happen Loading @@ -4527,12 +4527,12 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { IPackageManager pm = AppGlobals.getPackageManager(); long id = Binder.clearCallingIdentity(); try { pm.clearCrossProfileIntentFilters(callingUserId, who.getPackageName(), callingUserId); // Removing those that go from the managed profile to the primary user. pm.clearCrossProfileIntentFilters(callingUserId, who.getPackageName()); // And those that go from the primary user to the managed profile. // If we want to support multiple managed profiles, we will have to only remove // those that have callingUserId as their target. pm.clearCrossProfileIntentFilters(UserHandle.USER_OWNER, who.getPackageName(), callingUserId); pm.clearCrossProfileIntentFilters(UserHandle.USER_OWNER, who.getPackageName()); } catch (RemoteException re) { // Shouldn't happen } finally { Loading Loading
core/java/android/app/ApplicationPackageManager.java +2 −3 Original line number Diff line number Diff line Loading @@ -1662,7 +1662,7 @@ final class ApplicationPackageManager extends PackageManager { int flags) { try { mPM.addCrossProfileIntentFilter(filter, mContext.getOpPackageName(), mContext.getUserId(), sourceUserId, targetUserId, flags); sourceUserId, targetUserId, flags); } catch (RemoteException e) { // Should never happen! } Loading @@ -1674,8 +1674,7 @@ final class ApplicationPackageManager extends PackageManager { @Override public void clearCrossProfileIntentFilters(int sourceUserId) { try { mPM.clearCrossProfileIntentFilters(sourceUserId, mContext.getOpPackageName(), mContext.getUserId()); mPM.clearCrossProfileIntentFilters(sourceUserId, mContext.getOpPackageName()); } catch (RemoteException e) { // Should never happen! } Loading
core/java/android/content/pm/IPackageManager.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -261,9 +261,9 @@ interface IPackageManager { void clearPackagePersistentPreferredActivities(String packageName, int userId); void addCrossProfileIntentFilter(in IntentFilter intentFilter, String ownerPackage, int ownerUserId, int sourceUserId, int targetUserId, int flags); int sourceUserId, int targetUserId, int flags); void clearCrossProfileIntentFilters(int sourceUserId, String ownerPackage, int ownerUserId); void clearCrossProfileIntentFilters(int sourceUserId, String ownerPackage); /** * Report the set of 'Home' activity candidates, plus (if any) which of them Loading
services/core/java/com/android/server/pm/CrossProfileIntentFilter.java +2 −12 Original line number Diff line number Diff line Loading @@ -33,7 +33,6 @@ 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"; Loading @@ -41,15 +40,13 @@ class CrossProfileIntentFilter extends IntentFilter { // 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, String ownerPackage, int ownerUserId, int targetUserId, int flags) { CrossProfileIntentFilter(IntentFilter filter, String ownerPackage, int targetUserId, int flags) { super(filter); mTargetUserId = targetUserId; mOwnerUserId = ownerUserId; mOwnerPackage = ownerPackage; mFlags = flags; } Loading @@ -62,17 +59,12 @@ class CrossProfileIntentFilter extends IntentFilter { return mFlags; } public int getOwnerUserId() { return mOwnerUserId; } 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); Loading Loading @@ -129,7 +121,6 @@ class CrossProfileIntentFilter extends IntentFilter { 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); Loading @@ -144,7 +135,6 @@ class CrossProfileIntentFilter extends IntentFilter { boolean equalsIgnoreFilter(CrossProfileIntentFilter other) { return mTargetUserId == other.mTargetUserId && mOwnerUserId == other.mOwnerUserId && mOwnerPackage.equals(other.mOwnerPackage) && mFlags == other.mFlags; } Loading
services/core/java/com/android/server/pm/PackageManagerService.java +7 −15 Original line number Diff line number Diff line Loading @@ -11792,11 +11792,11 @@ public class PackageManagerService extends IPackageManager.Stub { @Override public void addCrossProfileIntentFilter(IntentFilter intentFilter, String ownerPackage, int ownerUserId, int sourceUserId, int targetUserId, int flags) { int sourceUserId, int targetUserId, int flags) { mContext.enforceCallingOrSelfPermission( android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, null); int callingUid = Binder.getCallingUid(); enforceOwnerRights(ownerPackage, ownerUserId, callingUid); enforceOwnerRights(ownerPackage, callingUid); enforceShellRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES, callingUid, sourceUserId); if (intentFilter.countActions() == 0) { Slog.w(TAG, "Cannot set a crossProfile intent filter with no filter actions"); Loading @@ -11804,7 +11804,7 @@ public class PackageManagerService extends IPackageManager.Stub { } synchronized (mPackages) { CrossProfileIntentFilter newFilter = new CrossProfileIntentFilter(intentFilter, ownerPackage, UserHandle.getUserId(callingUid), targetUserId, flags); ownerPackage, targetUserId, flags); CrossProfileIntentResolver resolver = mSettings.editCrossProfileIntentResolverLPw(sourceUserId); ArrayList<CrossProfileIntentFilter> existing = resolver.findFilters(intentFilter); Loading @@ -11823,22 +11823,19 @@ public class PackageManagerService extends IPackageManager.Stub { } @Override public void clearCrossProfileIntentFilters(int sourceUserId, String ownerPackage, int ownerUserId) { public void clearCrossProfileIntentFilters(int sourceUserId, String ownerPackage) { mContext.enforceCallingOrSelfPermission( android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, null); int callingUid = Binder.getCallingUid(); enforceOwnerRights(ownerPackage, ownerUserId, callingUid); enforceOwnerRights(ownerPackage, callingUid); enforceShellRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES, callingUid, sourceUserId); int callingUserId = UserHandle.getUserId(callingUid); synchronized (mPackages) { CrossProfileIntentResolver resolver = mSettings.editCrossProfileIntentResolverLPw(sourceUserId); ArraySet<CrossProfileIntentFilter> set = new ArraySet<CrossProfileIntentFilter>(resolver.filterSet()); for (CrossProfileIntentFilter filter : set) { if (filter.getOwnerPackage().equals(ownerPackage) && filter.getOwnerUserId() == callingUserId) { if (filter.getOwnerPackage().equals(ownerPackage)) { resolver.removeFilter(filter); } } Loading @@ -11847,17 +11844,12 @@ public class PackageManagerService extends IPackageManager.Stub { } // Enforcing that callingUid is owning pkg on userId private void enforceOwnerRights(String pkg, int userId, int callingUid) { private void enforceOwnerRights(String pkg, int callingUid) { // The system owns everything. if (UserHandle.getAppId(callingUid) == Process.SYSTEM_UID) { return; } int callingUserId = UserHandle.getUserId(callingUid); if (callingUserId != userId) { throw new SecurityException("calling uid " + callingUid + " pretends to own " + pkg + " on user " + userId + " but belongs to user " + callingUserId); } PackageInfo pi = getPackageInfo(pkg, 0, callingUserId); if (pi == null) { throw new IllegalArgumentException("Unknown package " + pkg + " on user "
services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +7 −7 Original line number Diff line number Diff line Loading @@ -4504,12 +4504,12 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { long id = Binder.clearCallingIdentity(); try { if ((flags & DevicePolicyManager.FLAG_PARENT_CAN_ACCESS_MANAGED) != 0) { pm.addCrossProfileIntentFilter(filter, who.getPackageName(), mContext.getUserId(), callingUserId, UserHandle.USER_OWNER, 0); pm.addCrossProfileIntentFilter(filter, who.getPackageName(), callingUserId, UserHandle.USER_OWNER, 0); } if ((flags & DevicePolicyManager.FLAG_MANAGED_CAN_ACCESS_PARENT) != 0) { pm.addCrossProfileIntentFilter(filter, who.getPackageName(), mContext.getUserId(), UserHandle.USER_OWNER, callingUserId, 0); UserHandle.USER_OWNER, callingUserId, 0); } } catch (RemoteException re) { // Shouldn't happen Loading @@ -4527,12 +4527,12 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { IPackageManager pm = AppGlobals.getPackageManager(); long id = Binder.clearCallingIdentity(); try { pm.clearCrossProfileIntentFilters(callingUserId, who.getPackageName(), callingUserId); // Removing those that go from the managed profile to the primary user. pm.clearCrossProfileIntentFilters(callingUserId, who.getPackageName()); // And those that go from the primary user to the managed profile. // If we want to support multiple managed profiles, we will have to only remove // those that have callingUserId as their target. pm.clearCrossProfileIntentFilters(UserHandle.USER_OWNER, who.getPackageName(), callingUserId); pm.clearCrossProfileIntentFilters(UserHandle.USER_OWNER, who.getPackageName()); } catch (RemoteException re) { // Shouldn't happen } finally { Loading