Merge "Update Multi-OffHost related API definition"

This commit is contained in:
Treehugger Robot
2019-04-18 18:08:11 +00:00
committed by Gerrit Code Review
5 changed files with 36 additions and 11 deletions

View File

@@ -29116,7 +29116,6 @@ package android.nfc {
method @Deprecated public void enableForegroundNdefPush(android.app.Activity, android.nfc.NdefMessage);
method public void enableReaderMode(android.app.Activity, android.nfc.NfcAdapter.ReaderCallback, int, android.os.Bundle);
method public static android.nfc.NfcAdapter getDefaultAdapter(android.content.Context);
method @NonNull public java.util.List<java.lang.String> getSupportedOffHostSecureElements();
method public boolean ignore(android.nfc.Tag, int, android.nfc.NfcAdapter.OnTagRemovedListener, android.os.Handler);
method @Deprecated public boolean invokeBeam(android.app.Activity);
method public boolean isEnabled();
@@ -29209,10 +29208,10 @@ package android.nfc.cardemulation {
method public boolean isDefaultServiceForCategory(android.content.ComponentName, String);
method public boolean registerAidsForService(android.content.ComponentName, String, java.util.List<java.lang.String>);
method public boolean removeAidsForService(android.content.ComponentName, String);
method public boolean setOffHostForService(@NonNull android.content.ComponentName, @NonNull String);
method @RequiresPermission(android.Manifest.permission.NFC) @NonNull public boolean setOffHostForService(@NonNull android.content.ComponentName, @NonNull String);
method public boolean setPreferredService(android.app.Activity, android.content.ComponentName);
method public boolean supportsAidPrefixRegistration();
method public boolean unsetOffHostForService(@NonNull android.content.ComponentName);
method @RequiresPermission(android.Manifest.permission.NFC) @NonNull 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 public static final String CATEGORY_OTHER = "other";

View File

@@ -526,6 +526,7 @@ public final class NfcAdapter {
* @return List<String> containing secure elements on the device which supports
* off host card emulation. eSE for Embedded secure element,
* SIM for UICC and so on.
* @hide
*/
public @NonNull List<String> getSupportedOffHostSecureElements() {
List<String> offHostSE = new ArrayList<String>();

View File

@@ -432,7 +432,15 @@ public final class ApduServiceInfo implements Parcelable {
mDynamicAidGroups.put(aidGroup.getCategory(), aidGroup);
}
@UnsupportedAppUsage
/**
* Sets the off host Secure Element.
* @param offHost Secure Element to set. Only accept strings with prefix SIM or prefix eSE.
* Ref: GSMA TS.26 - NFC Handset Requirements
* TS26_NFC_REQ_069: For UICC, Secure Element Name SHALL be SIM[smartcard slot]
* (e.g. SIM/SIM1, SIM2… SIMn).
* TS26_NFC_REQ_070: For embedded SE, Secure Element Name SHALL be eSE[number]
* (e.g. eSE/eSE1, eSE2, etc.).
*/
public void setOffHostSecureElement(String offHost) {
mOffHostName = offHost;
}
@@ -441,7 +449,6 @@ public final class ApduServiceInfo implements Parcelable {
* Resets the off host Secure Element to statically defined
* by the service in the manifest file.
*/
@UnsupportedAppUsage
public void unsetOffHostSecureElement() {
mOffHostName = mStaticOffHostName;
}
@@ -581,10 +588,9 @@ public final class ApduServiceInfo implements Parcelable {
pw.println(" On Host Service");
} else {
pw.println(" Off-host Service");
pw.println(" " + "Current off-host SE" + mOffHostName
+ " static off-host: " + mOffHostName);
pw.println(" " + "Current off-host SE:" + mOffHostName
+ " static off-host SE:" + mStaticOffHostName);
}
pw.println(" Static off-host Secure Element:");
pw.println(" Static AID groups:");
for (AidGroup group : mStaticAidGroups.values()) {
pw.println(" Category: " + group.category);

View File

@@ -17,6 +17,7 @@
package android.nfc.cardemulation;
import android.annotation.NonNull;
import android.annotation.RequiresPermission;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.app.Activity;
@@ -360,6 +361,8 @@ public final class CardEmulation {
* @param service The component name of the service
* @return whether the registration was successful.
*/
@RequiresPermission(android.Manifest.permission.NFC)
@NonNull
public boolean unsetOffHostForService(@NonNull ComponentName service) {
NfcAdapter adapter = NfcAdapter.getDefaultAdapter(mContext);
if (adapter == null) {
@@ -391,7 +394,9 @@ public final class CardEmulation {
* through the manifest, or dynamically by using this API),
* it will be replaced with this one. All AIDs registered by
* this service will be re-routed to this Secure Element if
* successful.
* successful. AIDs that was statically assigned using manifest
* will re-route to off-host SE that stated in manifest after NFC
* toggle.
*
* <p>Note that you can only set off-host SE for a service that
* is running under the same UID as the caller of this API. Typically
@@ -403,9 +408,19 @@ public final class CardEmulation {
* exists on the device.
*
* @param service The component name of the service
* @param offHostSecureElement Secure Element to register the AID to
* @param offHostSecureElement Secure Element to register the AID to. Only accept strings with
* prefix SIM or prefix eSE.
* Ref: GSMA TS.26 - NFC Handset Requirements
* TS26_NFC_REQ_069: For UICC, Secure Element Name SHALL be
* SIM[smartcard slot]
* (e.g. SIM/SIM1, SIM2… SIMn).
* TS26_NFC_REQ_070: For embedded SE, Secure Element Name SHALL be
* eSE[number]
* (e.g. eSE/eSE1, eSE2, etc.).
* @return whether the registration was successful.
*/
@RequiresPermission(android.Manifest.permission.NFC)
@NonNull
public boolean setOffHostForService(@NonNull ComponentName service,
@NonNull String offHostSecureElement) {
boolean validSecureElement = false;
@@ -421,6 +436,10 @@ public final class CardEmulation {
return false;
}
if (!offHostSecureElement.startsWith("eSE") && !offHostSecureElement.startsWith("SIM")) {
return false;
}
if (offHostSecureElement.equals("eSE")) {
offHostSecureElement = "eSE1";
} else if (offHostSecureElement.equals("SIM")) {

View File

@@ -3691,7 +3691,7 @@
the settings for this service. -->
<attr name="settingsActivity"/>
<!-- Secure Element which the AIDs should be routed to -->
<attr name="secureElementName"/>
<attr name="secureElementName" format="string"/>
</declare-styleable>
<!-- Specify one or more <code>aid-group</code> elements inside a