/**@class android.nfc.cardemulation.CardEmulation @extends java.lang.Object This class can be used to query the state of NFC card emulation services. For a general introduction into NFC card emulation, please read the <a href="{@docRoot}guide/topics/connectivity/nfc/hce.html"> NFC card emulation developer guide</a>.</p> <p class="note">Use of this class requires the {@link PackageManager#FEATURE_NFC_HOST_CARD_EMULATION} to be present on the device. */ var CardEmulation = { /** Activity action: ask the user to change the default card emulation service for a certain category. This will show a dialog that asks the user whether he wants to replace the current default service with the service identified with the ComponentName specified in {@link #EXTRA_SERVICE_COMPONENT}, for the category specified in {@link #EXTRA_CATEGORY} */ ACTION_CHANGE_DEFAULT : "android.nfc.cardemulation.action.ACTION_CHANGE_DEFAULT", /** The category extra for {@link #ACTION_CHANGE_DEFAULT}. @see #ACTION_CHANGE_DEFAULT */ EXTRA_CATEGORY : "category", /** The service {@link ComponentName} object passed in as an extra for {@link #ACTION_CHANGE_DEFAULT}. @see #ACTION_CHANGE_DEFAULT */ EXTRA_SERVICE_COMPONENT : "component", /** Category used for NFC payment services. */ CATEGORY_PAYMENT : "payment", /** Category that can be used for all other card emulation services. */ CATEGORY_OTHER : "other", /** Return value for {@link #getSelectionModeForCategory}(String). <p>In this mode, the user has set a default service for this category. <p>When using ISO-DEP card emulation with {@link android.nfc.cardemulation.HostApduService} or {@link android.nfc.cardemulation.OffHostApduService}, if a remote NFC device selects any of the Application IDs (AIDs) that the default service has registered in this category, that service will automatically be bound to to handle the transaction. */ SELECTION_MODE_PREFER_DEFAULT : "0", /** Return value for {@link #getSelectionModeForCategory}(String). <p>In this mode, when using ISO-DEP card emulation with {@link android.nfc.cardemulation.HostApduService} or {@link android.nfc.cardemulation.OffHostApduService}, whenever an Application ID (AID) of this category is selected, the user is asked which service he wants to use to handle the transaction, even if there is only one matching service. */ SELECTION_MODE_ALWAYS_ASK : "1", /** Return value for {@link #getSelectionModeForCategory}(String). <p>In this mode, when using ISO-DEP card emulation with {@link android.nfc.cardemulation.HostApduService} or {@link android.nfc.cardemulation.OffHostApduService}, the user will only be asked to select a service if the Application ID (AID) selected by the reader has been registered by multiple services. If there is only one service that has registered for the AID, that service will be invoked directly. */ SELECTION_MODE_ASK_IF_CONFLICT : "2", /**Helper to get an instance of this class. @param {Object {NfcAdapter}} adapter A reference to an NfcAdapter object. @return {Object {android.nfc.cardemulation.CardEmulation}} */ getInstance : function( ) {}, /**Allows an application to query whether a service is currently the default service to handle a card emulation category. <p>Note that if {@link #getSelectionModeForCategory}(String) returns {@link #SELECTION_MODE_ALWAYS_ASK} or {@link #SELECTION_MODE_ASK_IF_CONFLICT}, this method will always return false. That is because in these selection modes a default can't be set at the category level. For categories where the selection mode is {@link #SELECTION_MODE_ALWAYS_ASK} or {@link #SELECTION_MODE_ASK_IF_CONFLICT}, use {@link #isDefaultServiceForAid(ComponentName, String)} to determine whether a service is the default for a specific AID. @param {Object {ComponentName}} service The ComponentName of the service @param {String} category The category @return {Boolean} whether service is currently the default service for the category. <p class="note">Requires the {@link android.Manifest.permission#NFC} permission. */ isDefaultServiceForCategory : function( ) {}, /**Allows an application to query whether a service is currently the default handler for a specified ISO7816-4 Application ID. @param {Object {ComponentName}} service The ComponentName of the service @param {String} aid The ISO7816-4 Application ID @return {Boolean} whether the service is the default handler for the specified AID <p class="note">Requires the {@link android.Manifest.permission#NFC} permission. */ isDefaultServiceForAid : function( ) {}, /**Returns whether the user has allowed AIDs registered in the specified category to be handled by a service that is preferred by the foreground application, instead of by a pre-configured default. Foreground applications can set such preferences using the {@link #setPreferredService(Activity, ComponentName)} method. @param {String} category The category, e.g. {@link #CATEGORY_PAYMENT} @return {Boolean} whether AIDs in the category can be handled by a service specified by the foreground app. */ categoryAllowsForegroundPreference : function( ) {}, /**Returns the service selection mode for the passed in category. Valid return values are: <p>{@link #SELECTION_MODE_PREFER_DEFAULT} the user has requested a default service for this category, which will be preferred. <p>{@link #SELECTION_MODE_ALWAYS_ASK} the user has requested to be asked every time what service he would like to use in this category. <p>{@link #SELECTION_MODE_ASK_IF_CONFLICT} the user will only be asked to pick a service if there is a conflict. @param {String} category The category, for example {@link #CATEGORY_PAYMENT} @return {Number} the selection mode for the passed in category */ getSelectionModeForCategory : function( ) {}, /**Registers a list of AIDs for a specific category for the specified service. <p>If a list of AIDs for that category was previously registered for this service (either statically through the manifest, or dynamically by using this API), that list of AIDs will be replaced with this one. <p>Note that you can only register AIDs for a service that is running under the same UID as the caller of this API. Typically this means you need to call this from the same package as the service itself, though UIDs can also be shared between packages using shared UIDs. @param {Object {ComponentName}} service The component name of the service @param {String} category The category of AIDs to be registered @param {Object {java.util.List}} aids A list containing the AIDs to be registered @return {Boolean} whether the registration was successful. */ registerAidsForService : function( ) {}, /**Unsets the off-host Secure Element for the given service. <p>Note that this will only remove Secure Element that was dynamically set using the {@link #setOffHostForService(ComponentName, String)} and resets it to a value that was statically assigned using manifest. <p>Note that you can only unset off-host SE for a service that is running under the same UID as the caller of this API. Typically this means you need to call this from the same package as the service itself, though UIDs can also be shared between packages using shared UIDs. @param {Object {ComponentName}} service The component name of the service @return {Boolean} whether the registration was successful. */ unsetOffHostForService : function( ) {}, /**Sets the off-host Secure Element for the given service. <p>If off-host SE was initially set (either statically 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. 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 this means you need to call this from the same package as the service itself, though UIDs can also be shared between packages using shared UIDs. <p>Registeration will be successful only if the Secure Element exists on the device. @param {Object {ComponentName}} service The component name of the service @param {String} 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 {Boolean} whether the registration was successful. */ setOffHostForService : function( ) {}, /**Retrieves the currently registered AIDs for the specified category for a service. <p>Note that this will only return AIDs that were dynamically registered using {@link #registerAidsForService(ComponentName, String, List)} method. It will *not* return AIDs that were statically registered in the manifest. @param {Object {ComponentName}} service The component name of the service @param {String} category The category for which the AIDs were registered, e.g. {@link #CATEGORY_PAYMENT} @return {Object {java.util.List}} The list of AIDs registered for this category, or null if it couldn't be found. */ getAidsForService : function( ) {}, /**Removes a previously registered list of AIDs for the specified category for the service provided. <p>Note that this will only remove AIDs that were dynamically registered using the {@link #registerAidsForService(ComponentName, String, List)} method. It will *not* remove AIDs that were statically registered in the manifest. If dynamically registered AIDs are removed using this method, and a statically registered AID group for the same category exists in the manifest, the static AID group will become active again. @param {Object {ComponentName}} service The component name of the service @param {String} category The category of the AIDs to be removed, e.g. {@link #CATEGORY_PAYMENT} @return {Boolean} whether the group was successfully removed. */ removeAidsForService : function( ) {}, /**Allows a foreground application to specify which card emulation service should be preferred while a specific Activity is in the foreground. <p>The specified Activity must currently be in resumed state. A good paradigm is to call this method in your {@link Activity#onResume}, and to call {@link #unsetPreferredService}(Activity) in your {@link Activity#onPause}. <p>This method call will fail in two specific scenarios: <ul> <li> If the service registers one or more AIDs in the {@link #CATEGORY_PAYMENT} category, but the user has indicated that foreground apps are not allowed to override the default payment service. <li> If the service registers one or more AIDs in the {@link #CATEGORY_OTHER} category that are also handled by the default payment service, and the user has indicated that foreground apps are not allowed to override the default payment service. </ul> <p> Use {@link #categoryAllowsForegroundPreference}(String) to determine whether foreground apps can override the default payment service. <p>Note that this preference is not persisted by the OS, and hence must be called every time the Activity is resumed. @param {Object {Activity}} activity The activity which prefers this service to be invoked @param {Object {ComponentName}} service The service to be preferred while this activity is in the foreground @return {Boolean} whether the registration was successful */ setPreferredService : function( ) {}, /**Unsets the preferred service for the specified Activity. <p>Note that the specified Activity must still be in resumed state at the time of this call. A good place to call this method is in your {@link Activity#onPause} implementation. @param {Object {Activity}} activity The activity which the service was registered for @return {Boolean} true when successful */ unsetPreferredService : function( ) {}, /**Some devices may allow an application to register all AIDs that starts with a certain prefix, e.g. "A000000004*" to register all MasterCard AIDs. Use this method to determine whether this device supports registering AID prefixes. @return {Boolean} whether AID prefix registering is supported on this device. */ supportsAidPrefixRegistration : function( ) {}, /** @hide */ setDefaultServiceForCategory : function( ) {}, /** @hide */ setDefaultForNextTap : function( ) {}, /** @hide */ getServices : function( ) {}, /**A valid AID according to ISO/IEC 7816-4: <ul> <li>Has >= 5 bytes and <=16 bytes (>=10 hex chars and <= 32 hex chars) <li>Consist of only hex characters <li>Additionally, we allow an asterisk at the end, to indicate a prefix <li>Additinally we allow an (#) at symbol at the end, to indicate a subset </ul> @hide */ isValidAid : function( ) {}, };