Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 33e0aff4 authored by Ayush Sharma's avatar Ayush Sharma
Browse files

Reset call/sms cross profile intent filters

* When work profile telephony is enabled, reset the call/sms intent
  filters to be handled by work profile.
* Also added an api to remove the cross profile intent filters in
  package manager

Bug: 258820628
Test: NA
Change-Id: If935e69bb7eaf644876ad68bf47535f1cf6d8f9d
parent ad2f77db
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -3285,6 +3285,20 @@ public class ApplicationPackageManager extends PackageManager {
        }
    }

    /**
     * @hide
     */
    @Override
    public boolean removeCrossProfileIntentFilter(IntentFilter filter, int sourceUserId,
            int targetUserId, int flags) {
        try {
            return mPM.removeCrossProfileIntentFilter(filter, mContext.getOpPackageName(),
                    sourceUserId, targetUserId, flags);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * @hide
     */
+3 −0
Original line number Diff line number Diff line
@@ -281,6 +281,9 @@ interface IPackageManager {
    void addCrossProfileIntentFilter(in IntentFilter intentFilter, String ownerPackage,
            int sourceUserId, int targetUserId, int flags);

    boolean removeCrossProfileIntentFilter(in IntentFilter intentFilter, String ownerPackage,
                int sourceUserId, int targetUserId, int flags);

    void clearCrossProfileIntentFilters(int sourceUserId, String ownerPackage);

    String[] setDistractingPackageRestrictionsAsUser(in String[] packageNames, int restrictionFlags,
+17 −0
Original line number Diff line number Diff line
@@ -9612,6 +9612,23 @@ public abstract class PackageManager {
    public abstract void addCrossProfileIntentFilter(@NonNull IntentFilter filter,
            @UserIdInt int sourceUserId, @UserIdInt int targetUserId, int flags);

    /**
     * Removes all {@code CrossProfileIntentFilter}s which matches the specified intent filer,
     * source, target and flag.
     *
     * @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 possible values are {@link #SKIP_CURRENT_PROFILE} and
     *                     {@link #ONLY_IF_NO_MATCH_FOUND}.
     * @hide
     */
    public boolean removeCrossProfileIntentFilter(@NonNull IntentFilter filter,
            @UserIdInt int sourceUserId, @UserIdInt int targetUserId, int flags) {
        throw new UnsupportedOperationException(
                "removeCrossProfileIntentFilter not implemented in subclass");
    }

    /**
     * Clearing {@code CrossProfileIntentFilter}s which have the specified user
     * as their source, and have been set by the app calling this method.
+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ import java.lang.annotation.RetentionPolicy;
 * Representation of an immutable default cross-profile intent filter.
 */
@Immutable
final class DefaultCrossProfileIntentFilter {
public final class DefaultCrossProfileIntentFilter {

    @IntDef({
            Direction.TO_PARENT,
+9 −0
Original line number Diff line number Diff line
@@ -320,6 +320,15 @@ public class DefaultCrossProfileIntentFiltersUtils {
                MOBILE_NETWORK_SETTINGS);
    }

    /**
     * Returns default telephony related intent filters for managed profile.
     */
    public static List<DefaultCrossProfileIntentFilter> getDefaultManagedProfileTelephonyFilters() {
        return Arrays.asList(
                DIAL_DATA,
                SMS_MMS);
    }

    /**
     * Clone profile's DefaultCrossProfileIntentFilter
     */
Loading