summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/api/system-current.txt9
-rw-r--r--core/java/android/service/chooser/CustomChoosers.java84
-rw-r--r--core/java/com/android/internal/app/NfcResolverActivity.java59
-rw-r--r--core/res/AndroidManifest.xml19
-rw-r--r--data/etc/privapp-permissions-platform.xml2
-rw-r--r--packages/Shell/AndroidManifest.xml3
6 files changed, 176 insertions, 0 deletions
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index 792310e44bfc..30d57bb190be 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -351,6 +351,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 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";
@@ -11783,6 +11784,14 @@ 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 {
diff --git a/core/java/android/service/chooser/CustomChoosers.java b/core/java/android/service/chooser/CustomChoosers.java
new file mode 100644
index 000000000000..5b89432b956d
--- /dev/null
+++ b/core/java/android/service/chooser/CustomChoosers.java
@@ -0,0 +1,84 @@
+/*
+ * 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/com/android/internal/app/NfcResolverActivity.java b/core/java/com/android/internal/app/NfcResolverActivity.java
new file mode 100644
index 000000000000..402192abaf0a
--- /dev/null
+++ b/core/java/com/android/internal/app/NfcResolverActivity.java
@@ -0,0 +1,59 @@
+/*
+ * 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 com.android.internal.app;
+
+import static android.service.chooser.CustomChoosers.EXTRA_RESOLVE_INFOS;
+import static android.service.chooser.Flags.supportNfcResolver;
+
+import android.content.Intent;
+import android.content.pm.ResolveInfo;
+import android.os.Bundle;
+
+import java.util.ArrayList;
+
+/**
+ * Caller-customizable variant of {@link ResolverActivity} to support the
+ * {@link CustomChoosers#showNfcResolver()} API.
+ */
+public class NfcResolverActivity extends ResolverActivity {
+
+ @Override
+ @SuppressWarnings("MissingSuperCall") // Called indirectly via `super_onCreate()`.
+ protected void onCreate(Bundle savedInstanceState) {
+ if (!supportNfcResolver()) {
+ super_onCreate(savedInstanceState);
+ finish();
+ return;
+ }
+
+ Intent intent = getIntent();
+ Intent target = intent.getParcelableExtra(Intent.EXTRA_INTENT, Intent.class);
+ ArrayList<ResolveInfo> rList =
+ intent.getParcelableArrayListExtra(EXTRA_RESOLVE_INFOS, ResolveInfo.class);
+ CharSequence title = intent.getExtras().getCharSequence(
+ Intent.EXTRA_TITLE,
+ getResources().getText(com.android.internal.R.string.chooseActivity));
+
+ super.onCreate(
+ savedInstanceState,
+ target,
+ title,
+ /* initialIntents=*/ null,
+ rList,
+ /* supportsAlwaysUseOption=*/ false);
+ }
+}
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index cf41a06a824e..38fde3dc2469 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -7469,6 +7469,13 @@
<permission android:name="android.permission.SIGNAL_REBOOT_READINESS"
android:protectionLevel="signature|privileged" />
+ <!-- @SystemApi Allows the holder to launch an Intent Resolver flow with custom presentation
+ and/or targets.
+ @FlaggedApi("android.service.chooser.support_nfc_resolver")
+ @hide -->
+ <permission android:name="android.permission.SHOW_CUSTOMIZED_RESOLVER"
+ android:protectionLevel="signature|privileged" />
+
<!-- @hide Allows an application to get a People Tile preview for a given shortcut. -->
<permission android:name="android.permission.GET_PEOPLE_TILE_PREVIEW"
android:protectionLevel="signature|recents" />
@@ -7891,6 +7898,18 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
+ <activity android:name="com.android.internal.app.NfcResolverActivity"
+ android:theme="@style/Theme.Dialog.Alert"
+ android:finishOnCloseSystemDialogs="true"
+ android:excludeFromRecents="true"
+ 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" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </activity>
<activity android:name="com.android.internal.app.IntentForwarderActivity"
android:finishOnCloseSystemDialogs="true"
android:theme="@style/Theme.DeviceDefault.Resolver"
diff --git a/data/etc/privapp-permissions-platform.xml b/data/etc/privapp-permissions-platform.xml
index 1f08955e5f58..3cf28c919f07 100644
--- a/data/etc/privapp-permissions-platform.xml
+++ b/data/etc/privapp-permissions-platform.xml
@@ -383,6 +383,8 @@ applications that come with the platform
<!-- Permission required for ShortcutManagerUsageTest CTS test. -->
<permission name="android.permission.ACCESS_SHORTCUTS"/>
<permission name="android.permission.REBOOT"/>
+ <!-- Permission required for NfcResolverActivity CTS tests. -->
+ <permission name="android.permission.SHOW_CUSTOMIZED_RESOLVER"/>
<!-- Permission required for access VIBRATOR_STATE. -->
<permission name="android.permission.ACCESS_VIBRATOR_STATE"/>
<!-- Permission required for UsageStatsTest CTS test. -->
diff --git a/packages/Shell/AndroidManifest.xml b/packages/Shell/AndroidManifest.xml
index 650319fd58f9..b6a0c7bafa44 100644
--- a/packages/Shell/AndroidManifest.xml
+++ b/packages/Shell/AndroidManifest.xml
@@ -442,6 +442,9 @@
<uses-permission android:name="android.permission.MANAGE_NOTIFICATIONS" />
<uses-permission android:name="android.permission.ACCESS_LOCUS_ID_USAGE_STATS" />
+ <!-- Permission required for CTS test - CtsNfcResolverDerviceTest -->
+ <uses-permission android:name="android.permission.SHOW_CUSTOMIZED_RESOLVER" />
+
<!-- Permission needed for CTS test - MusicRecognitionManagerTest -->
<uses-permission android:name="android.permission.MANAGE_MUSIC_RECOGNITION" />