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

Commit d3d8a322 authored by Fabrice Di Meglio's avatar Fabrice Di Meglio
Browse files

Add private flag PRIVATE_FLAG_HAS_DOMAIN_URLS to ApplicationInfo

This is for supporting Settings UX and Domain URLs

- the new PRIVATE_FLAG_HAS_DOMAIN_URLS flag will be set by
generateApplicationInfo() when the Activity is said to have some
IntentFilter with a VIEW action and a http / https data URI

- code cleaning for args passing
- also add a new constant for the MetricsLogger

Change-Id: I5c9762fc2c4a9b46c0e255b9a23bffd70fae40c7
parent 9e57a254
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -420,6 +420,14 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     */
    public static final int PRIVATE_FLAG_PRIVILEGED = 1<<3;

    /**
     * Value for {@link #flags}: {@code true} if the application has any IntentFiler with some
     * data URI using HTTP or HTTPS with an associated VIEW action.
     *
     * {@hide}
     */
    public static final int PRIVATE_FLAG_HAS_DOMAIN_URLS = 1<<4;

    /**
     * Private/hidden flags. See {@code PRIVATE_FLAG_...} constants.
     * {@hide}
+1 −1
Original line number Diff line number Diff line
@@ -437,7 +437,7 @@ interface IPackageManager {
    void verifyPendingInstall(int id, int verificationCode);
    void extendVerificationTimeout(int id, int verificationCodeAtTimeout, long millisecondsToDelay);

    void verifyIntentFilter(int id, int verificationCode, in List<String> outFailedDomains);
    void verifyIntentFilter(int id, int verificationCode, in List<String> failedDomains);
    int getIntentVerificationStatus(String packageName, int userId);
    boolean updateIntentVerificationStatus(String packageName, int status, int userId);
    List<IntentFilterVerificationInfo> getIntentFilterVerifications(String packageName);
+30 −0
Original line number Diff line number Diff line
@@ -2752,6 +2752,12 @@ public class PackageParser {

        modifySharedLibrariesForBackwardCompatibility(owner);

        if (hasDomainURLs(owner)) {
            owner.applicationInfo.privateFlags |= ApplicationInfo.PRIVATE_FLAG_HAS_DOMAIN_URLS;
        } else {
            owner.applicationInfo.privateFlags &= ~ApplicationInfo.PRIVATE_FLAG_HAS_DOMAIN_URLS;
        }

        return true;
    }

@@ -2767,6 +2773,30 @@ public class PackageParser {
                "org.apache.http.legacy");
    }

    /**
     * Check if one of the IntentFilter as an action VIEW and a HTTP/HTTPS data URI
     */
    private static boolean hasDomainURLs(Package pkg) {
        if (pkg == null || pkg.activities == null) return false;
        final ArrayList<Activity> activities = pkg.activities;
        final int countActivities = activities.size();
        for (int n=0; n<countActivities; n++) {
            Activity activity = activities.get(n);
            ArrayList<ActivityIntentInfo> filters = activity.intents;
            if (filters == null) continue;
            final int countFilters = filters.size();
            for (int m=0; m<countFilters; m++) {
                ActivityIntentInfo aii = filters.get(m);
                if (!aii.hasAction(Intent.ACTION_VIEW)) continue;
                if (aii.hasDataScheme(IntentFilter.SCHEME_HTTP) ||
                        aii.hasDataScheme(IntentFilter.SCHEME_HTTPS)) {
                    return true;
                }
            }
        }
        return false;
    }

    /**
     * Parse the {@code application} XML tree at the current parse location in a
     * <em>split APK</em> manifest.
+2 −0
Original line number Diff line number Diff line
@@ -40,6 +40,8 @@ public class MetricsLogger implements MetricsConstants {

    public static final int MANAGE_PERMISSIONS = 142;

    public static final int MANAGE_DOMAIN_URLS = 143;

    public static void visible(Context context, int category) throws IllegalArgumentException {
        if (Build.IS_DEBUGGABLE && category == VIEW_UNKNOWN) {
            throw new IllegalArgumentException("Must define metric category");
+2 −2
Original line number Diff line number Diff line
@@ -8921,7 +8921,7 @@ public class PackageManagerService extends IPackageManager.Stub {
    }
    @Override
    public void verifyIntentFilter(int id, int verificationCode, List<String> outFailedDomains)
    public void verifyIntentFilter(int id, int verificationCode, List<String> failedDomains)
            throws RemoteException {
        mContext.enforceCallingOrSelfPermission(
                Manifest.permission.INTENT_FILTER_VERIFICATION_AGENT,
@@ -8929,7 +8929,7 @@ public class PackageManagerService extends IPackageManager.Stub {
        final Message msg = mHandler.obtainMessage(INTENT_FILTER_VERIFIED);
        final IntentFilterVerificationResponse response = new IntentFilterVerificationResponse(
                Binder.getCallingUid(), verificationCode, outFailedDomains);
                Binder.getCallingUid(), verificationCode, failedDomains);
        msg.arg1 = id;
        msg.obj = response;
        mHandler.sendMessage(msg);