api: Address API council feedback for createNfcResolverIntent
Move the underlying intent and extra as an API in `NfcManager`
Bug: 315228007
Test: atest CtsNfcResolverDeviceTest
Change-Id: If2fb5a8f2856e65ec4e961d2facba812035897c9
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index 9e09931..d11e7cd 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -365,7 +365,7 @@
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";
@@ -12291,14 +12291,6 @@
}
-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 {
diff --git a/core/java/android/service/chooser/CustomChoosers.java b/core/java/android/service/chooser/CustomChoosers.java
deleted file mode 100644
index 5b89432..0000000
--- a/core/java/android/service/chooser/CustomChoosers.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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() {}
-}
diff --git a/core/java/android/service/chooser/flags.aconfig b/core/java/android/service/chooser/flags.aconfig
index add575b..00236df 100644
--- a/core/java/android/service/chooser/flags.aconfig
+++ b/core/java/android/service/chooser/flags.aconfig
@@ -15,13 +15,6 @@
}
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"
description: "This flag controls content toggling in Chooser"
diff --git a/core/java/com/android/internal/app/NfcResolverActivity.java b/core/java/com/android/internal/app/NfcResolverActivity.java
index 402192a..78427fe 100644
--- a/core/java/com/android/internal/app/NfcResolverActivity.java
+++ b/core/java/com/android/internal/app/NfcResolverActivity.java
@@ -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 @@
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));
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 04367e7..539881f 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -7651,7 +7651,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" />
@@ -8159,8 +8159,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>
diff --git a/nfc/api/system-current.txt b/nfc/api/system-current.txt
index dd2e174..a72e539 100644
--- a/nfc/api/system-current.txt
+++ b/nfc/api/system-current.txt
@@ -26,6 +26,8 @@
method @FlaggedApi("android.nfc.nfc_vendor_cmd") @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void unregisterNfcVendorNciCallback(@NonNull android.nfc.NfcAdapter.NfcVendorNciCallback);
method @FlaggedApi("android.nfc.enable_nfc_charging") public void unregisterWlcStateListener(@NonNull android.nfc.NfcAdapter.WlcStateListener);
field @FlaggedApi("android.nfc.enable_nfc_mainline") public static final String ACTION_REQUIRE_UNLOCK_FOR_NFC = "android.nfc.action.REQUIRE_UNLOCK_FOR_NFC";
+ field @FlaggedApi("android.nfc.enable_nfc_mainline") @RequiresPermission(android.Manifest.permission.SHOW_CUSTOMIZED_RESOLVER) public static final String ACTION_SHOW_NFC_RESOLVER = "android.nfc.action.SHOW_NFC_RESOLVER";
+ field @FlaggedApi("android.nfc.enable_nfc_mainline") public static final String EXTRA_RESOLVE_INFOS = "android.nfc.extra.RESOLVE_INFOS";
field @FlaggedApi("android.nfc.nfc_vendor_cmd") public static final int MESSAGE_TYPE_COMMAND = 1; // 0x1
field @FlaggedApi("android.nfc.nfc_vendor_cmd") public static final int SEND_VENDOR_NCI_STATUS_FAILED = 3; // 0x3
field @FlaggedApi("android.nfc.nfc_vendor_cmd") public static final int SEND_VENDOR_NCI_STATUS_MESSAGE_CORRUPTED = 2; // 0x2
diff --git a/nfc/java/android/nfc/NfcAdapter.java b/nfc/java/android/nfc/NfcAdapter.java
index 252f46f..c5b7582 100644
--- a/nfc/java/android/nfc/NfcAdapter.java
+++ b/nfc/java/android/nfc/NfcAdapter.java
@@ -16,6 +16,7 @@
package android.nfc;
+import android.Manifest;
import android.annotation.CallbackExecutor;
import android.annotation.FlaggedApi;
import android.annotation.IntDef;
@@ -35,6 +36,7 @@
import android.content.Context;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.nfc.tech.MifareClassic;
import android.nfc.tech.Ndef;
@@ -485,6 +487,25 @@
"android.nfc.action.REQUIRE_UNLOCK_FOR_NFC";
/**
+ * Intent action to start a NFC resolver activity in a customized share session with list of
+ * {@link ResolveInfo}.
+ * @hide
+ */
+ @SystemApi
+ @FlaggedApi(Flags.FLAG_ENABLE_NFC_MAINLINE)
+ @RequiresPermission(Manifest.permission.SHOW_CUSTOMIZED_RESOLVER)
+ public static final String ACTION_SHOW_NFC_RESOLVER = "android.nfc.action.SHOW_NFC_RESOLVER";
+
+ /**
+ * "Extras" key for an ArrayList of {@link ResolveInfo} records which are to be shown as the
+ * targets in the customized share session.
+ * @hide
+ */
+ @SystemApi
+ @FlaggedApi(Flags.FLAG_ENABLE_NFC_MAINLINE)
+ public static final String EXTRA_RESOLVE_INFOS = "android.nfc.extra.RESOLVE_INFOS";
+
+ /**
* The requested app is correctly added to the Tag intent app preference.
*
* @see #setTagIntentAppPreferenceForUser(int userId, String pkg, boolean allow)