summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Omer Ozer <omerozer@google.com> 2023-11-14 17:27:35 +0000
committer Omer Ozer <omerozer@google.com> 2024-01-09 20:10:53 +0000
commit6d4329cff60b0944691ecd1fe019d7235642234f (patch)
tree8bebd3ba00bdaf0b127456eb8c9c051e9bfd28c0
parenta5813cbe2b4f6cd7a470d8aecd5cb66ee013f921 (diff)
Add config flag for wallet role and
make nfc default component a system api so that it's accessible in the permissions module. Deprecate CardEmulation:Action_CHANGE_DEFAULT. API-Coverage-Bug: 316635253 Bug: 283989236 Bug: 315194263 Test: local Change-Id: I6661d6098eb122e54101e8e161f591516d4f2510
-rw-r--r--core/api/current.txt2
-rw-r--r--core/api/system-current.txt2
-rw-r--r--core/java/android/nfc/NfcAdapter.java4
-rw-r--r--core/java/android/nfc/cardemulation/CardEmulation.java33
-rw-r--r--core/java/android/permission/flags.aconfig7
-rw-r--r--core/java/android/provider/Settings.java4
-rw-r--r--core/res/res/values/config.xml2
-rw-r--r--core/res/res/values/public-staging.xml2
8 files changed, 53 insertions, 3 deletions
diff --git a/core/api/current.txt b/core/api/current.txt
index fdde707436bf..1aea1396d90a 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -28956,7 +28956,7 @@ package android.nfc.cardemulation {
method public boolean supportsAidPrefixRegistration();
method @NonNull @RequiresPermission(android.Manifest.permission.NFC) public boolean unsetOffHostForService(@NonNull android.content.ComponentName);
method public boolean unsetPreferredService(android.app.Activity);
- field public static final String ACTION_CHANGE_DEFAULT = "android.nfc.cardemulation.action.ACTION_CHANGE_DEFAULT";
+ field @Deprecated public static final String ACTION_CHANGE_DEFAULT = "android.nfc.cardemulation.action.ACTION_CHANGE_DEFAULT";
field public static final String CATEGORY_OTHER = "other";
field public static final String CATEGORY_PAYMENT = "payment";
field public static final String EXTRA_CATEGORY = "category";
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index 9077d02be8be..852e4b7dcc3e 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -475,6 +475,7 @@ package android {
field public static final int config_defaultNotes = 17039429; // 0x1040045
field @FlaggedApi("android.permission.flags.retail_demo_role_enabled") public static final int config_defaultRetailDemo;
field public static final int config_defaultSms = 17039396; // 0x1040024
+ field @FlaggedApi("android.permission.flags.wallet_role_enabled") public static final int config_defaultWallet;
field public static final int config_devicePolicyManagement = 17039421; // 0x104003d
field public static final int config_feedbackIntentExtraKey = 17039391; // 0x104001f
field public static final int config_feedbackIntentNameKey = 17039392; // 0x1040020
@@ -9967,6 +9968,7 @@ package android.nfc.cardemulation {
}
public final class CardEmulation {
+ method @FlaggedApi("android.permission.flags.wallet_role_enabled") @Nullable @RequiresPermission(android.Manifest.permission.NFC_PREFERRED_PAYMENT_INFO) public android.nfc.cardemulation.ApduServiceInfo getPreferredPaymentService();
method @FlaggedApi("android.nfc.enable_nfc_mainline") @NonNull public java.util.List<android.nfc.cardemulation.ApduServiceInfo> getServices(@NonNull String, int);
}
diff --git a/core/java/android/nfc/NfcAdapter.java b/core/java/android/nfc/NfcAdapter.java
index 5a40e424ea91..93889453bcf3 100644
--- a/core/java/android/nfc/NfcAdapter.java
+++ b/core/java/android/nfc/NfcAdapter.java
@@ -812,8 +812,8 @@ public final class NfcAdapter {
if (context == null) {
throw new IllegalArgumentException("context cannot be null");
}
- context = context.getApplicationContext();
- if (context == null) {
+ Context applicationContext = context.getApplicationContext();
+ if (applicationContext == null) {
throw new IllegalArgumentException(
"context not associated with any application (using a mock context?)");
}
diff --git a/core/java/android/nfc/cardemulation/CardEmulation.java b/core/java/android/nfc/cardemulation/CardEmulation.java
index ad86d70db967..81eab71fe080 100644
--- a/core/java/android/nfc/cardemulation/CardEmulation.java
+++ b/core/java/android/nfc/cardemulation/CardEmulation.java
@@ -69,7 +69,12 @@ public final class CardEmulation {
* specified in {@link #EXTRA_CATEGORY}. There is an optional
* extra field using {@link Intent#EXTRA_USER} to specify
* the {@link UserHandle} of the user that owns the app.
+ *
+ * @deprecated Please use {@link android.app.role.RoleManager#createRequestRoleIntent(String)}
+ * with {@link android.app.role.RoleManager#ROLE_WALLET} parameter
+ * and {@link Activity#startActivityForResult(Intent, int)} instead.
*/
+ @Deprecated
@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
public static final String ACTION_CHANGE_DEFAULT =
"android.nfc.cardemulation.action.ACTION_CHANGE_DEFAULT";
@@ -1084,4 +1089,32 @@ public final class CardEmulation {
sService = adapter.getCardEmulationService();
}
+ /**
+ * Returns the {@link Settings.Secure#NFC_PAYMENT_DEFAULT_COMPONENT} for the given user.
+ *
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(android.Manifest.permission.NFC_PREFERRED_PAYMENT_INFO)
+ @FlaggedApi(android.permission.flags.Flags.FLAG_WALLET_ROLE_ENABLED)
+ @Nullable
+ public ApduServiceInfo getPreferredPaymentService() {
+ try {
+ return sService.getPreferredPaymentService(mContext.getUser().getIdentifier());
+ } catch (RemoteException e) {
+ // Try one more time
+ recoverService();
+ if (sService == null) {
+ Log.e(TAG, "Failed to recover CardEmulationService.");
+ return null;
+ }
+ try {
+ return sService.getPreferredPaymentService(mContext.getUser().getIdentifier());
+ } catch (RemoteException ee) {
+ Log.e(TAG, "Failed to reach CardEmulationService.");
+ return null;
+ }
+ }
+ }
+
}
diff --git a/core/java/android/permission/flags.aconfig b/core/java/android/permission/flags.aconfig
index fae7cb394906..60143cc79d2d 100644
--- a/core/java/android/permission/flags.aconfig
+++ b/core/java/android/permission/flags.aconfig
@@ -71,3 +71,10 @@ flag {
description: "default retail demo role holder"
bug: "274132354"
}
+
+flag {
+ name: "wallet_role_enabled"
+ namespace: "wallet_integration"
+ description: "This flag is used to enabled the Wallet Role for all users on the device"
+ bug: "283989236"
+}
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 211bdef89247..6f917027fda1 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -10137,8 +10137,12 @@ public final class Settings {
/**
* The default NFC payment component
+ *
+ * @deprecated please use {@link android.app.role.RoleManager#getRoleHolders(String)}
+ * with {@link android.app.role.RoleManager#ROLE_WALLET} parameter.
* @hide
*/
+ @Deprecated
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public static final String NFC_PAYMENT_DEFAULT_COMPONENT = "nfc_payment_default_component";
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 806be9471ae5..5be29a6d68b8 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -2349,6 +2349,8 @@
<string name="config_defaultCallRedirection" translatable="false"></string>
<!-- The name of the package that will hold the call screening role by default. -->
<string name="config_defaultCallScreening" translatable="false"></string>
+ <!-- The name of the package that will hold the wallet role by default. -->
+ <string name="config_defaultWallet" translatable="false" />
<!-- The name of the package that will hold the system gallery role. -->
<string name="config_systemGallery" translatable="false">com.android.gallery3d</string>
<!-- The names of the packages that will hold the automotive projection role. -->
diff --git a/core/res/res/values/public-staging.xml b/core/res/res/values/public-staging.xml
index 17bb86a7c423..53b473e0ac1f 100644
--- a/core/res/res/values/public-staging.xml
+++ b/core/res/res/values/public-staging.xml
@@ -130,6 +130,8 @@
<staging-public-group type="string" first-id="0x01ba0000">
<!-- @hide @SystemApi @FlaggedApi("android.permission.flags.retail_demo_role_enabled") -->
<public name="config_defaultRetailDemo" />
+ <!-- @hide @SystemApi @FlaggedApi("android.permission.flags.wallet_role_enabled") -->
+ <public name="config_defaultWallet" />
</staging-public-group>
<staging-public-group type="dimen" first-id="0x01b90000">