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

Commit 9f7e39fc authored by Fabrice Di Meglio's avatar Fabrice Di Meglio
Browse files

Use Default Browser App for IntentResolution when needed

- add MATCH_ALL as a new flag for telling that all results need to
be returned (even if there is some sort of filtering done).
- take into account the default Browser App for Intent resolution
- also, dont do any domain verification priming for non system app

See bug #20144393

Change-Id: Iddd1f2029e3bbf3b99ebc5f416dc7f17e5bad10c
parent ff623a5a
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -9402,6 +9402,7 @@ package android.content.pm {
    field public static final int GET_SIGNATURES = 64; // 0x40
    field public static final int GET_SIGNATURES = 64; // 0x40
    field public static final int GET_UNINSTALLED_PACKAGES = 8192; // 0x2000
    field public static final int GET_UNINSTALLED_PACKAGES = 8192; // 0x2000
    field public static final int GET_URI_PERMISSION_PATTERNS = 2048; // 0x800
    field public static final int GET_URI_PERMISSION_PATTERNS = 2048; // 0x800
    field public static final int MATCH_ALL = 131072; // 0x20000
    field public static final int MATCH_DEFAULT_ONLY = 65536; // 0x10000
    field public static final int MATCH_DEFAULT_ONLY = 65536; // 0x10000
    field public static final long MAXIMUM_VERIFICATION_TIMEOUT = 3600000L; // 0x36ee80L
    field public static final long MAXIMUM_VERIFICATION_TIMEOUT = 3600000L; // 0x36ee80L
    field public static final int PERMISSION_DENIED = -1; // 0xffffffff
    field public static final int PERMISSION_DENIED = -1; // 0xffffffff
@@ -30433,7 +30434,6 @@ package android.telecom {
  public static abstract class InCallService.VideoCall {
  public static abstract class InCallService.VideoCall {
    ctor public InCallService.VideoCall();
    ctor public InCallService.VideoCall();
    method public abstract void registerCallback(android.telecom.InCallService.VideoCall.Callback);
    method public abstract void registerCallback(android.telecom.InCallService.VideoCall.Callback);
    method public abstract void unregisterCallback();
    method public abstract void requestCallDataUsage();
    method public abstract void requestCallDataUsage();
    method public abstract void requestCameraCapabilities();
    method public abstract void requestCameraCapabilities();
    method public abstract void sendSessionModifyRequest(android.telecom.VideoProfile);
    method public abstract void sendSessionModifyRequest(android.telecom.VideoProfile);
@@ -30444,6 +30444,7 @@ package android.telecom {
    method public abstract void setPauseImage(java.lang.String);
    method public abstract void setPauseImage(java.lang.String);
    method public abstract void setPreviewSurface(android.view.Surface);
    method public abstract void setPreviewSurface(android.view.Surface);
    method public abstract void setZoom(float);
    method public abstract void setZoom(float);
    method public abstract void unregisterCallback();
  }
  }
  public static abstract class InCallService.VideoCall.Callback {
  public static abstract class InCallService.VideoCall.Callback {
+2 −1
Original line number Original line Diff line number Diff line
@@ -9697,6 +9697,7 @@ package android.content.pm {
    field public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103; // 0xffffff99
    field public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103; // 0xffffff99
    field public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102; // 0xffffff9a
    field public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102; // 0xffffff9a
    field public static final int INSTALL_SUCCEEDED = 1; // 0x1
    field public static final int INSTALL_SUCCEEDED = 1; // 0x1
    field public static final int MATCH_ALL = 131072; // 0x20000
    field public static final int MATCH_DEFAULT_ONLY = 65536; // 0x10000
    field public static final int MATCH_DEFAULT_ONLY = 65536; // 0x10000
    field public static final long MAXIMUM_VERIFICATION_TIMEOUT = 3600000L; // 0x36ee80L
    field public static final long MAXIMUM_VERIFICATION_TIMEOUT = 3600000L; // 0x36ee80L
    field public static final int PERMISSION_DENIED = -1; // 0xffffffff
    field public static final int PERMISSION_DENIED = -1; // 0xffffffff
@@ -32550,7 +32551,6 @@ package android.telecom {
  public static abstract class InCallService.VideoCall {
  public static abstract class InCallService.VideoCall {
    ctor public InCallService.VideoCall();
    ctor public InCallService.VideoCall();
    method public abstract void registerCallback(android.telecom.InCallService.VideoCall.Callback);
    method public abstract void registerCallback(android.telecom.InCallService.VideoCall.Callback);
    method public abstract void unregisterCallback();
    method public abstract void requestCallDataUsage();
    method public abstract void requestCallDataUsage();
    method public abstract void requestCameraCapabilities();
    method public abstract void requestCameraCapabilities();
    method public abstract void sendSessionModifyRequest(android.telecom.VideoProfile);
    method public abstract void sendSessionModifyRequest(android.telecom.VideoProfile);
@@ -32561,6 +32561,7 @@ package android.telecom {
    method public abstract void setPauseImage(java.lang.String);
    method public abstract void setPauseImage(java.lang.String);
    method public abstract void setPreviewSurface(android.view.Surface);
    method public abstract void setPreviewSurface(android.view.Surface);
    method public abstract void setZoom(float);
    method public abstract void setZoom(float);
    method public abstract void unregisterCallback();
  }
  }
  public static abstract class InCallService.VideoCall.Callback {
  public static abstract class InCallService.VideoCall.Callback {
+12 −1
Original line number Original line Diff line number Diff line
@@ -211,6 +211,13 @@ public abstract class PackageManager {
     */
     */
    public static final int MATCH_DEFAULT_ONLY  = 0x00010000;
    public static final int MATCH_DEFAULT_ONLY  = 0x00010000;


    /**
     * Querying flag: if set and if the platform is doing any filtering of the results, then
     * the filtering will not happen. This is a synonym for saying that all results should
     * be returned.
     */
    public static final int MATCH_ALL = 0x00020000;

    /**
    /**
     * Flag for {@link addCrossProfileIntentFilter}: if this flag is set:
     * Flag for {@link addCrossProfileIntentFilter}: if this flag is set:
     * when resolving an intent that matches the {@link CrossProfileIntentFilter}, the current
     * when resolving an intent that matches the {@link CrossProfileIntentFilter}, the current
@@ -2637,6 +2644,8 @@ public abstract class PackageManager {
     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
     *
     *
     * You can also set {@link #MATCH_ALL} for preventing the filtering of the results.
     *
     * @return A List<ResolveInfo> containing one entry for each matching
     * @return A List<ResolveInfo> containing one entry for each matching
     *         Activity. These are ordered from best to worst match -- that
     *         Activity. These are ordered from best to worst match -- that
     *         is, the first item in the list is what is returned by
     *         is, the first item in the list is what is returned by
@@ -2658,6 +2667,8 @@ public abstract class PackageManager {
     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
     *
     *
     * You can also set {@link #MATCH_ALL} for preventing the filtering of the results.
     *
     * @return A List<ResolveInfo> containing one entry for each matching
     * @return A List<ResolveInfo> containing one entry for each matching
     *         Activity. These are ordered from best to worst match -- that
     *         Activity. These are ordered from best to worst match -- that
     *         is, the first item in the list is what is returned by
     *         is, the first item in the list is what is returned by
+49 −11
Original line number Original line Diff line number Diff line
@@ -49,6 +49,7 @@ import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATIO
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK;
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK;
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER;
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER;
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED;
import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED;
import static android.content.pm.PackageManager.MATCH_ALL;
import static android.content.pm.PackageManager.MOVE_FAILED_DOESNT_EXIST;
import static android.content.pm.PackageManager.MOVE_FAILED_DOESNT_EXIST;
import static android.content.pm.PackageManager.MOVE_FAILED_INTERNAL_ERROR;
import static android.content.pm.PackageManager.MOVE_FAILED_INTERNAL_ERROR;
import static android.content.pm.PackageManager.MOVE_FAILED_OPERATION_PENDING;
import static android.content.pm.PackageManager.MOVE_FAILED_OPERATION_PENDING;
@@ -2274,6 +2275,13 @@ public class PackageManagerService extends IPackageManager.Stub {
                }
                }
                continue;
                continue;
            }
            }
            if (!pkg.isSystemApp()) {
                if (logging) {
                    Slog.d(TAG, "No priming domain verifications for a non system package : " +
                            packageName);
                }
                continue;
            }
            for (PackageParser.Activity a : pkg.activities) {
            for (PackageParser.Activity a : pkg.activities) {
                for (ActivityIntentInfo filter : a.intents) {
                for (ActivityIntentInfo filter : a.intents) {
                    if (hasValidDomains(filter, false)) {
                    if (hasValidDomains(filter, false)) {
@@ -2281,7 +2289,7 @@ public class PackageManagerService extends IPackageManager.Stub {
                    }
                    }
                }
                }
            }
            }
            if (allHosts.size() > 0) {
            if (allHosts.size() == 0) {
                allHosts.add("*");
                allHosts.add("*");
            }
            }
            IntentFilterVerificationInfo ivi =
            IntentFilterVerificationInfo ivi =
@@ -3939,7 +3947,7 @@ public class PackageManagerService extends IPackageManager.Stub {
                }
                }
                result = filterIfNotPrimaryUser(result, userId);
                result = filterIfNotPrimaryUser(result, userId);
                if (result.size() > 1 && hasWebURI(intent)) {
                if (result.size() > 1 && hasWebURI(intent)) {
                    return filterCandidatesWithDomainPreferedActivitiesLPr(result);
                    return filterCandidatesWithDomainPreferedActivitiesLPr(flags, result);
                }
                }
                return result;
                return result;
            }
            }
@@ -3984,7 +3992,7 @@ public class PackageManagerService extends IPackageManager.Stub {
    }
    }
    private List<ResolveInfo> filterCandidatesWithDomainPreferedActivitiesLPr(
    private List<ResolveInfo> filterCandidatesWithDomainPreferedActivitiesLPr(
            List<ResolveInfo> candidates) {
            int flags, List<ResolveInfo> candidates) {
        if (DEBUG_PREFERRED) {
        if (DEBUG_PREFERRED) {
            Slog.v("TAG", "Filtering results with prefered activities. Candidates count: " +
            Slog.v("TAG", "Filtering results with prefered activities. Candidates count: " +
                    candidates.size());
                    candidates.size());
@@ -4004,6 +4012,11 @@ public class PackageManagerService extends IPackageManager.Stub {
                String packageName = info.activityInfo.packageName;
                String packageName = info.activityInfo.packageName;
                PackageSetting ps = mSettings.mPackages.get(packageName);
                PackageSetting ps = mSettings.mPackages.get(packageName);
                if (ps != null) {
                if (ps != null) {
                    // Add to the special match all list (Browser use case)
                    if (info.handleAllWebDataURI) {
                        matchAllList.add(info);
                        continue;
                    }
                    // Try to get the status from User settings first
                    // Try to get the status from User settings first
                    int status = getDomainVerificationStatusLPr(ps, userId);
                    int status = getDomainVerificationStatusLPr(ps, userId);
                    if (status == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS) {
                    if (status == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS) {
@@ -4013,10 +4026,6 @@ public class PackageManagerService extends IPackageManager.Stub {
                    } else if (status == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED) {
                    } else if (status == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED) {
                        undefinedList.add(info);
                        undefinedList.add(info);
                    }
                    }
                    // Add to the special match all list (Browser use case)
                    if (info.handleAllWebDataURI) {
                        matchAllList.add(info);
                    }
                }
                }
            }
            }
            // If there is nothing selected, add all candidates and remove the ones that the User
            // If there is nothing selected, add all candidates and remove the ones that the User
@@ -4031,8 +4040,31 @@ public class PackageManagerService extends IPackageManager.Stub {
            result.removeAll(matchAllList);
            result.removeAll(matchAllList);
            if (result.size() == 0) {
            if (result.size() == 0) {
                result.addAll(undefinedList);
                result.addAll(undefinedList);
                if ((flags & MATCH_ALL) != 0) {
                    result.addAll(matchAllList);
                } else {
                    // Try to add the Default Browser if we can
                    final String defaultBrowserPackageName = getDefaultBrowserPackageName(
                            UserHandle.myUserId());
                    if (!TextUtils.isEmpty(defaultBrowserPackageName)) {
                        boolean defaultBrowserFound = false;
                        final int browserCount = matchAllList.size();
                        for (int n=0; n<browserCount; n++) {
                            ResolveInfo browser = matchAllList.get(n);
                            if (browser.activityInfo.packageName.equals(defaultBrowserPackageName)) {
                                result.add(browser);
                                defaultBrowserFound = true;
                                break;
                            }
                        }
                        if (!defaultBrowserFound) {
                            result.addAll(matchAllList);
                            result.addAll(matchAllList);
                        }
                        }
                    } else {
                        result.addAll(matchAllList);
                    }
                }
            }
        }
        }
        if (DEBUG_PREFERRED) {
        if (DEBUG_PREFERRED) {
            Slog.v("TAG", "Filtered results with prefered activities. New candidates count: " +
            Slog.v("TAG", "Filtered results with prefered activities. New candidates count: " +
@@ -11331,10 +11363,16 @@ public class PackageManagerService extends IPackageManager.Stub {
                                verifierUid, userId, verificationId, filter, packageName);
                                verifierUid, userId, verificationId, filter, packageName);
                        count++;
                        count++;
                    } else if (!needsFilterVerification) {
                    } else if (!needsFilterVerification) {
                        Slog.d(TAG, "No verification needed for IntentFilter:"
                        Slog.d(TAG, "No verification needed for IntentFilter:" + filter.toString());
                                + filter.toString());
                        if (hasValidDomains(filter)) {
                        if (hasValidDomains(filter)) {
                            allHosts.addAll(filter.getHostsList());
                            ArrayList<String> hosts = filter.getHostsList();
                            if (hosts.size() > 0) {
                                allHosts.addAll(hosts);
                            } else {
                                if (allHosts.isEmpty()) {
                                    allHosts.add("*");
                                }
                            }
                        }
                        }
                    } else {
                    } else {
                        Slog.d(TAG, "Verification already done for IntentFilter:"
                        Slog.d(TAG, "Verification already done for IntentFilter:"