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

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

Merge "api: Address API council feedback for createNfcResolverIntent" into main

parents 01b38aa8 5ae9a17b
Loading
Loading
Loading
Loading
+1 −9
Original line number Diff line number Diff line
@@ -367,7 +367,7 @@ package android {
    field public static final String SET_VOLUME_KEY_LONG_PRESS_LISTENER = "android.permission.SET_VOLUME_KEY_LONG_PRESS_LISTENER";
    field public static final String SET_WALLPAPER_COMPONENT = "android.permission.SET_WALLPAPER_COMPONENT";
    field public static final String SET_WALLPAPER_DIM_AMOUNT = "android.permission.SET_WALLPAPER_DIM_AMOUNT";
    field @FlaggedApi("android.service.chooser.support_nfc_resolver") public static final String SHOW_CUSTOMIZED_RESOLVER = "android.permission.SHOW_CUSTOMIZED_RESOLVER";
    field @FlaggedApi("android.nfc.enable_nfc_mainline") public static final String SHOW_CUSTOMIZED_RESOLVER = "android.permission.SHOW_CUSTOMIZED_RESOLVER";
    field public static final String SHOW_KEYGUARD_MESSAGE = "android.permission.SHOW_KEYGUARD_MESSAGE";
    field public static final String SHUTDOWN = "android.permission.SHUTDOWN";
    field public static final String SIGNAL_REBOOT_READINESS = "android.permission.SIGNAL_REBOOT_READINESS";
@@ -12328,14 +12328,6 @@ package android.service.carrier {
}
package android.service.chooser {
  @FlaggedApi("android.service.chooser.support_nfc_resolver") public class CustomChoosers {
    method @FlaggedApi("android.service.chooser.support_nfc_resolver") @NonNull public static android.content.Intent createNfcResolverIntent(@NonNull android.content.Intent, @Nullable CharSequence, @NonNull java.util.List<android.content.pm.ResolveInfo>);
  }
}
package android.service.cloudsearch {
  public abstract class CloudSearchService extends android.app.Service {
+0 −84
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.service.chooser;

import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.content.Intent;
import android.content.pm.ResolveInfo;

import java.util.ArrayList;
import java.util.List;

/**
 * Static helper methods that privileged clients can use to initiate Share sessions with extra
 * customization options that aren't usually available in the stock "Resolver/Chooser" flows.
 *
 * @hide
 */
@FlaggedApi(Flags.FLAG_SUPPORT_NFC_RESOLVER)
@SystemApi
public class CustomChoosers {
    /**
     * Intent action to start a Share session with additional customization options. Clients should
     * use the helper methods in this class to configure their customized share intents, and should
     * avoid using this action to construct their own intents directly.
     */
    private static final String ACTION_SHOW_CUSTOMIZED_RESOLVER =
            "android.service.chooser.action.SHOW_CUSTOMIZED_RESOLVER";

    /**
     * "Extras" key for an ArrayList of {@link ResolveInfo} records which are to be shown as the
     * targets in the customized share session.
     *
     * @hide
     */
    public static final String EXTRA_RESOLVE_INFOS = "android.service.chooser.extra.RESOLVE_INFOS";

    /**
     * Build an {@link Intent} to dispatch a "Chooser flow" that picks a target resolution for the
     * specified {@code target} intent, styling the Chooser UI according to the specified
     * customization parameters.
     *
     * @param target The ambiguous intent that should be resolved to a specific target selected
     * via the Chooser flow.
     * @param title An optional "headline" string to display at the top of the Chooser UI, or null
     * to use the system default.
     * @param resolutionList Explicit resolution info for targets that should be shown in the
     * dispatched Share UI.
     *
     * @hide
     */
    @FlaggedApi(Flags.FLAG_SUPPORT_NFC_RESOLVER)
    @SystemApi
    @NonNull
    public static Intent createNfcResolverIntent(
            @NonNull Intent target,
            @Nullable CharSequence title,
            @NonNull List<ResolveInfo> resolutionList) {
        Intent resolverIntent = new Intent(ACTION_SHOW_CUSTOMIZED_RESOLVER);
        resolverIntent.putExtra(Intent.EXTRA_INTENT, target);
        resolverIntent.putExtra(Intent.EXTRA_TITLE, title);
        resolverIntent.putParcelableArrayListExtra(
                EXTRA_RESOLVE_INFOS, new ArrayList<>(resolutionList));
        return resolverIntent;
    }

    private CustomChoosers() {}
}
+0 −7
Original line number Diff line number Diff line
@@ -14,13 +14,6 @@ flag {
    bug: "318942069"
}

flag {
  name: "support_nfc_resolver"
  namespace: "systemui"
  description: "This flag controls the new NFC 'resolver' activity"
  bug: "268089816"
}

flag {
  name: "chooser_payload_toggling"
  namespace: "intentresolver"
+6 −5
Original line number Diff line number Diff line
@@ -16,25 +16,25 @@

package com.android.internal.app;

import static android.service.chooser.CustomChoosers.EXTRA_RESOLVE_INFOS;
import static android.service.chooser.Flags.supportNfcResolver;
import static android.nfc.Flags.enableNfcMainline;

import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.nfc.NfcAdapter;
import android.os.Bundle;

import java.util.ArrayList;

/**
 * Caller-customizable variant of {@link ResolverActivity} to support the
 * {@link CustomChoosers#showNfcResolver()} API.
 * NFC resolver intent.
 */
public class NfcResolverActivity extends ResolverActivity {

    @Override
    @SuppressWarnings("MissingSuperCall")  // Called indirectly via `super_onCreate()`.
    protected void onCreate(Bundle savedInstanceState) {
        if (!supportNfcResolver()) {
        if (!enableNfcMainline()) {
            super_onCreate(savedInstanceState);
            finish();
            return;
@@ -43,7 +43,8 @@ public class NfcResolverActivity extends ResolverActivity {
        Intent intent = getIntent();
        Intent target = intent.getParcelableExtra(Intent.EXTRA_INTENT, Intent.class);
        ArrayList<ResolveInfo> rList =
            intent.getParcelableArrayListExtra(EXTRA_RESOLVE_INFOS, ResolveInfo.class);
                intent.getParcelableArrayListExtra(
                NfcAdapter.EXTRA_RESOLVE_INFOS, ResolveInfo.class);
        CharSequence title = intent.getExtras().getCharSequence(
                Intent.EXTRA_TITLE,
                getResources().getText(com.android.internal.R.string.chooseActivity));
+3 −3
Original line number Diff line number Diff line
@@ -7696,7 +7696,7 @@

    <!-- @SystemApi Allows the holder to launch an Intent Resolver flow with custom presentation
         and/or targets.
         @FlaggedApi("android.service.chooser.support_nfc_resolver")
         @FlaggedApi("android.nfc.enable_nfc_mainline")
         @hide -->
    <permission android:name="android.permission.SHOW_CUSTOMIZED_RESOLVER"
                android:protectionLevel="signature|privileged" />
@@ -8196,8 +8196,8 @@
                android:multiprocess="true"
                android:permission="android.permission.SHOW_CUSTOMIZED_RESOLVER"
                android:exported="true">
            <intent-filter>
                <action android:name="android.service.chooser.action.SHOW_CUSTOMIZED_RESOLVER" />
            <intent-filter android:priority="100" >
                <action android:name="android.nfc.action.SHOW_NFC_RESOLVER" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
Loading