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

Commit f46aade7 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Make mapIntentToUri understand meta-data hookup"

parents 822c23e2 f200887b
Loading
Loading
Loading
Loading
+23 −6
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.content.ContentProviderClient;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Binder;
@@ -295,12 +296,10 @@ public class SliceManager {
    }

    /**
     * Turns a slice intent into a slice uri. Expects an explicit intent. If there is no
     * {@link android.content.ContentProvider} associated with the given intent this will throw
     * {@link IllegalArgumentException}.
     * Turns a slice intent into a slice uri. Expects an explicit intent.
     *
     * @param intent The intent associated with a slice.
     * @return The Slice Uri provided by the app or null if none is given.
     * @return The Slice Uri provided by the app or null if none exists.
     * @see Slice
     * @see SliceProvider#onMapIntentToUri(Intent)
     * @see Intent
@@ -320,7 +319,16 @@ public class SliceManager {
        List<ResolveInfo> providers =
                mContext.getPackageManager().queryIntentContentProviders(intent, 0);
        if (providers == null || providers.isEmpty()) {
            throw new IllegalArgumentException("Unable to resolve intent " + intent);
            // There are no providers, see if this activity has a direct link.
            ResolveInfo resolve = mContext.getPackageManager().resolveActivity(intent,
                    PackageManager.GET_META_DATA);
            if (resolve != null && resolve.activityInfo != null
                    && resolve.activityInfo.metaData != null
                    && resolve.activityInfo.metaData.containsKey(SLICE_METADATA_KEY)) {
                return Uri.parse(
                        resolve.activityInfo.metaData.getString(SLICE_METADATA_KEY));
            }
            return null;
        }
        String authority = providers.get(0).providerInfo.authority;
        Uri uri = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT)
@@ -371,7 +379,16 @@ public class SliceManager {
        List<ResolveInfo> providers =
                mContext.getPackageManager().queryIntentContentProviders(intent, 0);
        if (providers == null || providers.isEmpty()) {
            throw new IllegalArgumentException("Unable to resolve intent " + intent);
            // There are no providers, see if this activity has a direct link.
            ResolveInfo resolve = mContext.getPackageManager().resolveActivity(intent,
                    PackageManager.GET_META_DATA);
            if (resolve != null && resolve.activityInfo != null
                    && resolve.activityInfo.metaData != null
                    && resolve.activityInfo.metaData.containsKey(SLICE_METADATA_KEY)) {
                return bindSlice(Uri.parse(resolve.activityInfo.metaData
                        .getString(SLICE_METADATA_KEY)), supportedSpecs);
            }
            return null;
        }
        String authority = providers.get(0).providerInfo.authority;
        Uri uri = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT)