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

Commit 68e1a098 authored by Android Build Merger (Role)'s avatar Android Build Merger (Role) Committed by Android (Google) Code Review
Browse files

Merge "Merge "Create auxiliary info for local instant apps" into oc-dev am:...

Merge "Merge "Create auxiliary info for local instant apps" into oc-dev am: 4804e415 am: 143ad7ff"
parents 28f320c5 e12063c1
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -47,7 +47,7 @@ public final class InstantAppResolveInfo implements Parcelable {
    private final int mVersionCode;
    private final int mVersionCode;


    public InstantAppResolveInfo(@NonNull InstantAppDigest digest, @Nullable String packageName,
    public InstantAppResolveInfo(@NonNull InstantAppDigest digest, @Nullable String packageName,
            @Nullable List<InstantAppIntentFilter> filters, int versionConde) {
            @Nullable List<InstantAppIntentFilter> filters, int versionCode) {
        // validate arguments
        // validate arguments
        if ((packageName == null && (filters != null && filters.size() != 0))
        if ((packageName == null && (filters != null && filters.size() != 0))
                || (packageName != null && (filters == null || filters.size() == 0))) {
                || (packageName != null && (filters == null || filters.size() == 0))) {
@@ -61,7 +61,7 @@ public final class InstantAppResolveInfo implements Parcelable {
            mFilters = null;
            mFilters = null;
        }
        }
        mPackageName = packageName;
        mPackageName = packageName;
        mVersionCode = versionConde;
        mVersionCode = versionCode;
    }
    }


    public InstantAppResolveInfo(@NonNull String hostName, @Nullable String packageName,
    public InstantAppResolveInfo(@NonNull String hostName, @Nullable String packageName,
+26 −13
Original line number Original line Diff line number Diff line
@@ -6500,11 +6500,12 @@ public class PackageManagerService extends IPackageManager.Stub
            String resolvedType, int flags, int userId) {
            String resolvedType, int flags, int userId) {
        // first, check to see if we've got an instant app already installed
        // first, check to see if we've got an instant app already installed
        final boolean alreadyResolvedLocally = (flags & PackageManager.MATCH_INSTANT) != 0;
        final boolean alreadyResolvedLocally = (flags & PackageManager.MATCH_INSTANT) != 0;
        boolean localInstantAppAvailable = false;
        ResolveInfo localInstantApp = null;
        boolean blockResolution = false;
        boolean blockResolution = false;
        if (!alreadyResolvedLocally) {
        if (!alreadyResolvedLocally) {
            final List<ResolveInfo> instantApps = mActivities.queryIntent(intent, resolvedType,
            final List<ResolveInfo> instantApps = mActivities.queryIntent(intent, resolvedType,
                    flags
                    flags
                        | PackageManager.GET_RESOLVED_FILTER
                        | PackageManager.MATCH_INSTANT
                        | PackageManager.MATCH_INSTANT
                        | PackageManager.MATCH_VISIBLE_TO_INSTANT_APP_ONLY,
                        | PackageManager.MATCH_VISIBLE_TO_INSTANT_APP_ONLY,
                    userId);
                    userId);
@@ -6531,7 +6532,7 @@ public class PackageManagerService extends IPackageManager.Stub
                        if (DEBUG_EPHEMERAL) {
                        if (DEBUG_EPHEMERAL) {
                            Slog.v(TAG, "Found installed instant app; pkg: " + packageName);
                            Slog.v(TAG, "Found installed instant app; pkg: " + packageName);
                        }
                        }
                        localInstantAppAvailable = true;
                        localInstantApp = info;
                        break;
                        break;
                    }
                    }
                }
                }
@@ -6539,7 +6540,9 @@ public class PackageManagerService extends IPackageManager.Stub
        }
        }
        // no app installed, let's see if one's available
        // no app installed, let's see if one's available
        AuxiliaryResolveInfo auxiliaryResponse = null;
        AuxiliaryResolveInfo auxiliaryResponse = null;
        if (!localInstantAppAvailable && !blockResolution) {
        if (!blockResolution) {
            if (localInstantApp == null) {
                // we don't have an instant app locally, resolve externally
                Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "resolveEphemeral");
                Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "resolveEphemeral");
                final InstantAppRequest requestObject = new InstantAppRequest(
                final InstantAppRequest requestObject = new InstantAppRequest(
                        null /*responseObj*/, intent /*origIntent*/, resolvedType,
                        null /*responseObj*/, intent /*origIntent*/, resolvedType,
@@ -6548,8 +6551,18 @@ public class PackageManagerService extends IPackageManager.Stub
                        InstantAppResolver.doInstantAppResolutionPhaseOne(
                        InstantAppResolver.doInstantAppResolutionPhaseOne(
                                mContext, mInstantAppResolverConnection, requestObject);
                                mContext, mInstantAppResolverConnection, requestObject);
                Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
                Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
            } else {
                // we have an instant application locally, but, we can't admit that since
                // callers shouldn't be able to determine prior browsing. create a dummy
                // auxiliary response so the downstream code behaves as if there's an
                // instant application available externally. when it comes time to start
                // the instant application, we'll do the right thing.
                final ApplicationInfo ai = localInstantApp.activityInfo.applicationInfo;
                auxiliaryResponse = new AuxiliaryResolveInfo(
                        ai.packageName, null /*splitName*/, ai.versionCode, null /*failureIntent*/);
            }
        }
        }
        if (localInstantAppAvailable || auxiliaryResponse != null) {
        if (auxiliaryResponse != null) {
            if (DEBUG_EPHEMERAL) {
            if (DEBUG_EPHEMERAL) {
                Slog.v(TAG, "Adding ephemeral installer to the ResolveInfo list");
                Slog.v(TAG, "Adding ephemeral installer to the ResolveInfo list");
            }
            }
@@ -6569,7 +6582,7 @@ public class PackageManagerService extends IPackageManager.Stub
                ephemeralInstaller.filter = new IntentFilter(intent.getAction());
                ephemeralInstaller.filter = new IntentFilter(intent.getAction());
                ephemeralInstaller.filter.addDataPath(
                ephemeralInstaller.filter.addDataPath(
                        intent.getData().getPath(), PatternMatcher.PATTERN_LITERAL);
                        intent.getData().getPath(), PatternMatcher.PATTERN_LITERAL);
                ephemeralInstaller.instantAppAvailable = true;
                ephemeralInstaller.isInstantAppAvailable = true;
                result.add(ephemeralInstaller);
                result.add(ephemeralInstaller);
            }
            }
        }
        }