TECHNICAL FIELD
[0001] The present invention relates to the field of communications technologies, and in
particular, to an information processing method and an NFC terminal.
BACKGROUND
[0002] With development of a mobile communications technology and a near field communication
(English: Near Field Communication, NFC for short) technology, more mobile terminals
support a payment service that has a relatively high requirement on a security level.
This mobile terminal is referred to as an NFC terminal. Generally, the NFC terminal
includes a near field communication controller (English: Near Field Communication
Controller, NFCC for short), an NFC antenna, and at least one secure element (English:
Secure Element, SE for short).
[0003] With development of the mobile payment industry, one NFC terminal can include multiple
SEs, and multiple contactless applications can be installed in each SE. For convenience
of distinguishing multiple contactless applications, generally each contactless application
has one application identifier (English: Application Identification, AID for short).
When the NFC terminal enters a radio frequency field of an NFC card reader, an NFC
antenna generates an induced current, and an NFCC connected to the NFC antenna receives
a contactless application selection command sent by the NFC card reader. To forward
the command to a correct SE, a device host (English: Device Host, DH for short) of
the NFC terminal needs to configure routing information for the NFCC, that is, configure
a correspondence between the AID and the SE, and other routing information into the
NFCC. In this way, the NFCC can forward the command to the correct SE, and then select
a correct contactless application.
[0004] In the prior art, a method for the DH to configure the routing information into the
NFCC is: A method of statically reporting an AID of a contactless application is provided
by using a companion application of the contactless application and a configuration
file that is written into the NFC terminal. Specifically, the contactless application
is installed into the SE, and the companion application of the contactless application
is also installed into the NFC terminal, where the companion application includes
a configuration file, and the configuration file identifies the AID of the contactless
application. When an application manager is refreshed, the companion application is
discovered, and the AID in the configuration file in the companion application is
obtained, and is configured into the NFCC. However, this method is not flexible enough.
For a contactless application that does not have a companion application, even if
the contactless application is installed into the SE, the terminal cannot obtain an
AID.
[0005] Therefore, a disadvantage of the prior art is: An NFC terminal cannot obtain an AID
of a contactless application in an SE in real time.
SUMMARY
[0006] Embodiments of the present invention provide an information processing method and
an NFC terminal, so as to resolve a technical problem in the prior art that an NFC
terminal cannot obtain an AID of a contactless application in an SE in real time,
and provide a technical solution for the NFC terminal to obtain the AID of the contactless
application in the SE in real time, so that the NFC terminal obtains the AID of the
contactless application in the SE in real time, and a DH of the NFC terminal configures
an NFCC routing table more properly and effectively.
[0007] A first aspect of the embodiments of the present invention provides an information
processing method, where the method includes:
monitoring a state of a TCP connection that is established by at least one secure
element SE in a near field communication NFC terminal to a server by using a Transmission
Control Protocol TCP port of the NFC terminal;
when monitoring that the state of the TCP connection is disconnected, determining
a first SE from the at least one SE, where the first SE is an SE corresponding to
a TCP port whose TCP connection is disconnected; and
obtaining an application identifier AID of a contactless application in the first
SE.
[0008] With reference to the first aspect, in a first possible implementation manner of
the first aspect, the obtaining an application identifier AID of a contactless application
in the first SE specifically includes:
sending a first command to the first SE, where the first command is used to query
a quantity of update times of all contactless applications in the first SE, and receiving
a response message, sent by the first SE, of the first command;
parsing the response message of the first command, to obtain a first global update
counter GUC value, where the first GUC value is the quantity of update times of all
the contactless applications in the first SE; and
when the first GUC value is different from a second GUC value, obtaining a first AID,
where the first AID is an AID in the response message of the first command, and the
second GUC value is a quantity, stored in a non-volatile memory of the NFC terminal,
of update times of all the contactless applications in the first SE.
[0009] With reference to the first possible implementation manner of the first aspect, in
a second possible implementation manner of the first aspect, after the obtaining a
first AID, the method further includes:
comparing the first AID with all AIDs stored in the non-volatile memory; and
if the first AID is different from all the AIDs stored in the non-volatile memory,
obtaining an identifier SE ID of the first SE, and saving, in the non-volatile memory,
a data record that includes at least the first AID and the SE ID.
[0010] With reference to the second possible implementation manner of the first aspect,
in a third possible implementation manner of the first aspect, after the comparing
the first AID with all AIDs stored in the non-volatile memory, the method further
includes:
if the first AID is the same as one AID stored in the non-volatile memory, sending
a second command to the first SE, where the second command is used to query a lifecycle
state of the first AID, and receiving a response message, sent by the first SE, of
the second command;
parsing the response message of the second command, to obtain the lifecycle state
of the first AID; and
updating the lifecycle state that is of the first AID and that is stored in the non-volatile
memory.
[0011] With reference to the first aspect, in a fourth possible implementation manner of
the first aspect, the obtaining an application identifier AID of a contactless application
in the first SE specifically includes:
sending a third command to the first SE, where the third command is used to obtain
AIDs of all contactless applications in the first SE, and receiving a response message,
sent by the first SE, of the third command; and
parsing the response message of the third command, to obtain a third AID, where the
third AID is an AID in the response message of the third command.
[0012] With reference to the fourth possible implementation manner of the first aspect,
in a fifth possible implementation manner of the first aspect, after the obtaining
a third AID, the method further includes:
comparing the third AID with all AIDs stored in a non-volatile memory of the NFC terminal;
and
if the third AID is different from all the AIDs stored in the non-volatile memory,
obtaining an identifier SE ID of the first SE, and saving, in the non-volatile memory,
a data record that includes at least the third AID and the SE ID.
[0013] With reference to the fifth possible implementation manner of the first aspect, in
a sixth possible implementation manner of the first aspect, after the comparing the
third AID with all AIDs stored in a non-volatile memory of the NFC terminal, the method
further includes:
if the third AID is the same as one AID stored in the non-volatile memory, comparing
a first update counter UC value with a second UC value, where the first UC value is
a quantity of update times of a contactless application that has the third AID, and
the second UC value is a quantity, stored in the non-volatile memory, of update times
of the contactless application that has the third AID;
if the first UC value is different from the second UC value, sending a fourth command
to the first SE, where the fourth command is used to query a lifecycle state of the
third AID, and receiving a response message, sent by the first SE, of the fourth command;
parsing the response message of the fourth command, to obtain the lifecycle state
of the third AID; and
updating the lifecycle state and the UC values that are of the third AID and that
are stored in the non-volatile memory.
[0014] A second aspect of the present invention provides an information processing method,
where the method includes:
receiving application change notification information sent by a server; and
obtaining an application identifier AID of a contactless application in a first secure
element SE, where the first SE is an SE that is in a near field communication NFC
terminal and that communicates with the server.
[0015] With reference to the second aspect, in a first possible implementation manner of
the second aspect, the obtaining an AID of a contactless application in a first SE
specifically includes:
parsing the application change notification information, to obtain an AID in the application
change notification information.
[0016] With reference to the second aspect, in a second possible implementation manner of
the second aspect, the obtaining an AID of a contactless application in a first SE
specifically includes:
sending a first command to the first SE, where the first command is used to query
a quantity of update times of all contactless applications in the first SE, and receiving
a response message, sent by the first SE, of the first command;
parsing the response message of the first command, to obtain a first global update
counter GUC value, where the first GUC value is the quantity of update times of all
the contactless applications in the first SE; and
when the first GUC value is different from a second GUC value, obtaining a first AID,
where the first AID is an AID in the response message of the first command, and the
second GUC value is a quantity, stored in a non-volatile memory of the NFC terminal,
of update times of all the contactless applications in the first SE.
[0017] With reference to the second aspect, in a third possible implementation manner of
the second aspect, the obtaining an AID of a contactless application in a first SE
specifically includes:
sending a third command to the first SE, where the third command is used to obtain
AIDs of all contactless applications in the first SE, and receiving a response message,
sent by the first SE, of the third command; and
parsing the response message of the third command, to obtain a third AID, where the
third AID is an AID in the response message of the third command.
[0018] With reference to the first possible implementation manner of the second aspect,
in a fourth possible implementation manner of the second aspect, after the obtaining
an AID in the application change notification information, the method further includes:
comparing the first AID with all AIDs stored in the non-volatile memory; and
if the first AID is different from all the AIDs stored in the non-volatile memory,
obtaining an identifier SE ID of the first SE, and saving, in the non-volatile memory,
a data record that includes at least the first AID and the SE ID.
[0019] With reference to the fourth possible implementation manner of the second aspect,
in a fifth possible implementation manner of the second aspect, after the comparing
the first AID with all AIDs stored in the non-volatile memory, the method further
includes:
if the first AID is the same as one AID stored in the non-volatile memory, sending
a second command to the first SE, where the second command is used to query a lifecycle
state of the first AID, and receiving a response message, sent by the first SE, of
the second command;
parsing the response message of the second command, to obtain the lifecycle state
of the first AID; and
updating the lifecycle state that is of the first AID and that is stored in the non-volatile
memory.
[0020] With reference to the second possible implementation manner of the second aspect,
in a sixth possible implementation manner of the second aspect, after the obtaining
a first AID, the method further includes:
comparing the first AID with all AIDs stored in the non-volatile memory; and
if the first AID is different from all the AIDs stored in the non-volatile memory,
obtaining an identifier SE ID of the first SE, and saving, in the non-volatile memory,
a data record that includes at least the first AID and the SE ID.
[0021] With reference to the sixth possible implementation manner of the second aspect,
in a seventh possible implementation manner of the second aspect, after the comparing
the first AID with all AIDs stored in the non-volatile memory, the method further
includes:
if the first AID is the same as one AID stored in the non-volatile memory, sending
a second command to the first SE, where the second command is used to query a lifecycle
state of the first AID, and receiving a response message, sent by the first SE, of
the second command;
parsing the response message of the second command, to obtain the lifecycle state
of the first AID; and
updating the lifecycle state that is of the first AID and that is stored in the non-volatile
memory.
[0022] With reference to the third possible implementation manner of the second aspect,
in an eighth possible implementation manner of the second aspect, after the obtaining
a third AID, the method further includes:
comparing the third AID with all AIDs stored in a non-volatile memory of the NFC terminal;
and
if the third AID is different from all the AIDs stored in the non-volatile memory,
obtaining an identifier SE ID of the first SE, and saving, in the non-volatile memory,
a data record that includes at least the one AID that participates in the comparison
and the SE ID.
[0023] With reference to the eighth possible implementation manner of the second aspect,
in a ninth possible implementation manner of the second aspect, after the comparing
the third AID with all AIDs stored in a non-volatile memory of the NFC terminal, the
method further includes:
if the third AID is the same as one AID stored in the non-volatile memory, comparing
a first update counter UC value with a second UC value, where the first UC value is
a quantity of update times of a contactless application that has the third AID, and
the second UC value is a quantity, stored in the non-volatile memory, of update times
of the contactless application that has the third AID;
if the first UC value is different from the second UC value, sending a fourth command
to the first SE, where the fourth command is used to query a lifecycle state of the
third AID, and receiving a response message, sent by the first SE, of the fourth command;
parsing the response message of the fourth command, to obtain the lifecycle state
of the third AID; and
updating the lifecycle state and the UC values that are of the third AID and that
are stored in the non-volatile memory.
[0024] A third aspect of the present invention provides a near field communication NFC terminal,
including:
a secure element SE interface, configured to connect an SE to the NFC terminal;
a non-volatile memory, configured to store an application identifier AID of a contactless
application in the SE;
a Transmission Control Protocol TCP port; and
a processor, connected to the non-volatile memory, the SE interface, and the TCP port
by using a bus, and configured to:
monitor a state of a TCP connection that is established by at least one secure element
SE in a near field communication NFC terminal to a server by using a Transmission
Control Protocol TCP port of the NFC terminal;
when monitoring that the state of the TCP connection is disconnected, determine a
first SE from the at least one SE, where the first SE is an SE corresponding to a
TCP port whose TCP connection is disconnected; and
obtain an application identifier AID of a contactless application in the first SE.
[0025] With reference to the third aspect, in a first possible implementation manner of
the third aspect, the processor is further configured to:
send a first command to the first SE, where the first command is used to query a quantity
of update times of all contactless applications in the first SE, and receive a response
message, sent by the first SE, of the first command;
parse the response message of the first command, to obtain a first global update counter
GUC value, where the first GUC value is the quantity of update times of all the contactless
applications in the first SE; and
when the first GUC value is different from a second GUC value, obtain a first AID,
where the first AID is an AID in the response message of the first command, and the
second GUC value is a quantity, stored in a non-volatile memory of the NFC terminal,
of update times of all the contactless applications in the first SE.
[0026] With reference to the first possible implementation manner of the third aspect, in
a second possible implementation manner of the third aspect, the processor is further
configured to: after obtaining the first AID, compare the first AID with all AIDs
stored in the non-volatile memory; and
if the first AID is different from all the AIDs stored in the non-volatile memory,
obtain an identifier SE ID of the first SE, and save, in the non-volatile memory,
a data record that includes at least the first AID and the SE ID.
[0027] With reference to the second possible implementation manner of the third aspect,
in a third possible implementation manner of the third aspect, the processor is further
configured to:
after comparing the first AID with all the AIDs stored in the non-volatile memory,
if the first AID is the same as one AID stored in the non-volatile memory, send a
second command to the first SE, where the second command is used to query a lifecycle
state of the first AID, and receive a response message, sent by the first SE, of the
second command;
parse the response message of the second command, to obtain the lifecycle state of
the first AID; and
update the lifecycle state that is of the first AID and that is stored in the non-volatile
memory.
[0028] With reference to the third aspect, in a fourth possible implementation manner of
the third aspect, the processor is further configured to:
send a third command to the first SE, where the third command is used to obtain AIDs
of all contactless applications in the first SE, and receive a response message, sent
by the first SE, of the third command; and
parse the response message of the third command, to obtain a third AID, where the
third AID is an AID in the response message of the third command.
[0029] With reference to the fourth possible implementation manner of the third aspect,
in a fifth possible implementation manner of the third aspect, the processor is further
configured to:
after obtaining the third AID, compare the third AID with all AIDs stored in a non-volatile
memory of the NFC terminal; and
if the third AID is different from all the AIDs stored in the non-volatile memory,
obtain an identifier SE ID of the first SE, and save, in the non-volatile memory,
a data record that includes at least the third AID and the SE ID.
[0030] With reference to the fifth possible implementation manner of the third aspect, in
a sixth possible implementation manner of the third aspect, the processor is further
configured to:
after comparing the third AID with all the AIDs stored in the non-volatile memory
of the NFC terminal, if the third AID is the same as one AID stored in the non-volatile
memory, compare a first update counter UC value with a second UC value, where the
first UC value is a quantity of update times of a contactless application that has
the third AID, and the second UC value is a quantity, stored in the non-volatile memory,
of update times of the contactless application that has the third AID;
if the first UC value is different from the second UC value, send a fourth command
to the first SE, where the fourth command is used to query a lifecycle state of the
third AID, and receive a response message, sent by the first SE, of the fourth command;
parse the response message of the fourth command, to obtain the lifecycle state of
the third AID; and
update the lifecycle state and the UC values that are of the third AID and that are
stored in the non-volatile memory.
[0031] With reference to the third aspect, in a seventh possible implementation manner of
the third aspect, the processor is further configured to:
receive application change notification information sent by a server; and
obtain an application identifier AID of a contactless application in a first secure
element SE, where the first SE is an SE that is in a near field communication NFC
terminal and that communicates with the server.
[0032] With reference to the seventh possible implementation manner of the third aspect,
in an eighth possible implementation manner of the third aspect, the processor is
further configured to:
parse the application change notification information, to obtain an AID in the application
change notification information.
[0033] With reference to the seventh possible implementation manner of the third aspect,
in a ninth possible implementation manner of the third aspect, the processor is further
configured to:
send a first command to the first SE, where the first command is used to query a quantity
of update times of all contactless applications in the first SE, and receive a response
message, sent by the first SE, of the first command;
parse the response message of the first command, to obtain a first global update counter
GUC value, where the first GUC value is the quantity of update times of all the contactless
applications in the first SE; and
when the first GUC value is different from a second GUC value, obtain a first AID,
where the first AID is an AID in the response message of the first command, and the
second GUC value is the quantity, stored in a non-volatile memory of the NFC terminal,
of update times of all the contactless applications in the first SE.
[0034] With reference to the seventh possible implementation manner of the third aspect,
in a tenth possible implementation manner of the third aspect, the processor is further
configured to:
send a third command to the first SE, where the third command is used to obtain AIDs
of all contactless applications in the first SE, and receive a response message, sent
by the first SE, of the third command; and
parse the response message of the third command, to obtain a third AID, where the
third AID is an AID in the response message of the third command.
[0035] With reference to the eighth possible implementation manner of the third aspect,
in an eleventh possible implementation manner of the third aspect, the processor is
further configured to:
after obtaining the AID in the application change notification information, compare
the first AID with all AIDs stored in the non-volatile memory; and
if the first AID is different from all the AIDs stored in the non-volatile memory,
obtain an identifier SE ID of the first SE, and save, in the non-volatile memory,
a data record that includes at least the first AID and the SE ID.
[0036] With reference to the eleventh possible implementation manner of the third aspect,
in a twelfth possible implementation manner of the third aspect, the processor is
further configured to:
after comparing the first AID with all the AIDs stored in the non-volatile memory,
if the first AID is the same as one AID stored in the non-volatile memory, send a
second command to the first SE, where the second command is used to query a lifecycle
state of the first AID, and receive a response message, sent by the first SE, of the
second command;
parse the response message of the second command, to obtain the lifecycle state of
the first AID; and
update the lifecycle state that is of the first AID and that is stored in the non-volatile
memory.
[0037] With reference to the ninth possible implementation manner of the third aspect, in
a thirteenth possible implementation manner of the third aspect, the processor is
further configured to:
after obtaining the first AID, compare the first AID with all AIDs stored in a non-volatile
memory; and
if the first AID is different from all the AIDs stored in the non-volatile memory,
obtain an identifier SE ID of the first SE, and save, in the non-volatile memory,
a data record that includes at least the first AID and the SE ID.
[0038] With reference to the thirteenth possible implementation manner of the third aspect,
in a fourteenth possible implementation manner of the third aspect, the processor
is further configured to:
after comparing the first AID with all the AIDs stored in the non-volatile memory,
if the first AID is the same as one AID stored in the non-volatile memory, send a
second command to the first SE, where the second command is used to query a lifecycle
state of the first AID, and receive a response message, sent by the first SE, of the
second command;
parse the response message of the second command, to obtain the lifecycle state of
the first AID; and
update the lifecycle state that is of the first AID and that is stored in the non-volatile
memory.
[0039] With reference to the tenth possible implementation manner of the third aspect, in
a fifteenth possible implementation manner of the third aspect, the processor is further
configured to:
after obtaining the third AID, compare the third AID with all AIDs stored in a non-volatile
memory of the NFC terminal; and
if the third AID is different from all the AIDs stored in the non-volatile memory,
obtain an identifier SE ID of the first SE, and save, in the non-volatile memory,
a data record that includes at least the one AID that participates in the comparison
and the SE ID.
[0040] With reference to the fifteenth possible implementation manner of the third aspect,
in a sixteenth possible implementation manner of the third aspect, the processor is
further configured to:
after comparing the third AID with all the AIDs stored in the non-volatile memory
of the NFC terminal, if the third AID is the same as one AID stored in the non-volatile
memory, compare a first update counter UC value with a second UC value, where the
first UC value is a quantity of update times of a contactless application that has
the third AID, and the second UC value is a quantity, stored in the non-volatile memory,
of update times of the contactless application that has the third AID;
if the first UC value is different from the second UC value, send a fourth command
to the first SE, where the fourth command is used to query a lifecycle state of the
third AID, and receive a response message, sent by the first SE, of the fourth command;
parse the response message of the fourth command, to obtain the lifecycle state of
the third AID; and
update the lifecycle state and the UC values that are of the third AID and that are
stored in the non-volatile memory.
[0041] One or more technical solutions provided in the embodiments of the present invention
have at least the following technical effects or advantages:
[0042] In the embodiments of the present invention, a state of a TCP connection that is
established by at least one secure element SE in a near field communication NFC terminal
to a server by using a Transmission Control Protocol TCP port of the NFC terminal
is monitored. When it is monitored that the state of the TCP connection is disconnected,
an SE corresponding to a TCP port whose TCP connection is disconnected is determined
from the at least one SE. An application identifier AID of a contactless application
in the SE corresponding to the TCP port whose TCP connection is disconnected is obtained.
Alternatively, application change notification information sent by the server is received.
An application identifier AID of a contactless application in an SE that is in the
NFC terminal and that communicates with the server is obtained.
[0043] Therefore, in the embodiments of the present invention, that a state of a TCP connection
between an NFC terminal and a server changes to a disconnected state or that an NFC
terminal receives an application change notification message sent by a server is used
as a trigger condition, to trigger a DH of the NFC terminal to use, according to different
trigger conditions, different manners to obtain an AID in an SE corresponding to the
TCP port whose TCP connection is disconnected, or obtain an AID in an SE that communicates
with the server. It is implemented that the DH obtains an AID in an SE in real time,
so that the DH of the NFC terminal configures an NFCC routing table more properly
and effectively.
BRIEF DESCRIPTION OF DRAWINGS
[0044] To describe the technical solutions in the present invention or in the prior art
more clearly, the following briefly describes the accompanying drawings required for
describing the present invention or the prior art. Apparently, the accompanying drawings
in the following description show merely some embodiments of the present invention,
and persons of ordinary skill in the art may still derive other drawings from these
accompanying drawings without creative efforts.
FIG. 1 is a possible architectural diagram of a communications system applicable to
an information processing method according to an embodiment of the present invention;
FIG. 2 is a flowchart of an information processing method according to Embodiment
1 of the present invention;
FIG. 3 is a flowchart of a method for obtaining an application identifier AID of a
contactless application in a first SE according to Embodiment 1 of the present invention;
FIG. 4 is a flowchart of another method for obtaining an application identifier AID
of a contactless application in a first SE according to Embodiment 1 of the present
invention;
FIG. 5 is a detailed flowchart of an information processing method in which a first
manner is used according to Embodiment 1 of the present invention;
FIG. 6 is a detailed flowchart of an information processing method in which a first
manner is used according to Embodiment 1 of the present invention;
FIG. 7 is another flowchart of an information processing method according to Embodiment
2 of the present invention; and
FIG. 8 is a schematic structural diagram of an NFC terminal according to Embodiment
3 of the present invention.
DESCRIPTION OF EMBODIMENTS
[0045] Embodiments of the present invention provide an information processing method and
an NFC terminal, so as to resolve a technical problem in the prior art that an NFC
terminal cannot obtain an AID of a contactless application in an SE in real time,
and provide a technical solution for the NFC terminal to obtain the AID of the contactless
application in the SE in real time, so that the NFC terminal obtains the AID of the
contactless application in the SE in real time, and then a DH of the NFC terminal
configures an NFCC routing table more properly and effectively.
[0046] In the embodiments of the present invention, a state of a TCP connection that is
established by at least one secure element SE in a near field communication NFC terminal
to a server by using a Transmission Control Protocol TCP port of the NFC terminal
is monitored. When it is monitored that the state of the TCP connection is disconnected,
an SE corresponding to a TCP port whose TCP connection is disconnected is determined
from the at least one SE. An application identifier AID of a contactless application
in the SE corresponding to the TCP port whose TCP connection is disconnected is obtained.
Alternatively, application change notification information sent by the server is received.
An application identifier AID of a contactless application in an SE that is in the
NFC terminal and that communicates with the server is obtained.
[0047] Therefore, in the embodiments of the present invention, that a state of a TCP connection
between an NFC terminal and a server changes to a disconnected state or that an NFC
terminal receives an application change notification message sent by a server is used
as a trigger condition, to trigger a DH of the NFC terminal to use, according to different
trigger conditions, different manners to obtain an AID in an SE corresponding to the
TCP port whose TCP connection is disconnected, or obtain an AID in an SE that communicates
with the server. It is implemented that the DH obtains an AID in an SE in real time,
so that the DH of the NFC terminal configures an NFCC routing table more properly
and effectively.
[0048] To make the objectives, technical solutions, and advantages of the embodiments of
the present invention clearer, the following clearly and completely describes the
technical solutions in the embodiments of the present invention with reference to
the accompanying drawings in the embodiments of the present invention. Apparently,
the described embodiments are some but not all of the embodiments of the present invention.
All other embodiments obtained by persons of ordinary skill in the art based on the
embodiments of the present invention without creative efforts shall fall within the
protection scope of the present invention.
[0049] The term "and/or" in this specification describes only an association relationship
for describing associated objects and represents that three relationships may exist.
For example, A and/or B may represent the following three cases: Only A exists, both
A and B exist, and only B exists. In addition, the character "/" in this specification
generally indicates an "or" relationship between the associated objects.
[0050] The following describes implementation manners of the present invention in detail
with reference to accompanying drawings.
[0051] An embodiment of the present invention provides an information processing method.
Referring to FIG. 1, FIG. 1 is a possible architectural diagram of a communications
system applicable to an information processing method according to an embodiment of
the present invention. The communications system includes: an NFC (English: Near Field
Communication, NFC for short) terminal 10 and an NFC card reader 11.
[0052] The NFC terminal 10 includes:
a device host 101 (English: Device Host, DH for short), where it is generally considered
that a central processing unit (English: Central Progress Unit, CPU for short) of
the NFC terminal is the DH; according to a definition in a related standard of the
NFC Forum, the DH is a running environment responsible for managing an NFC Forum certification
device and all peripheral circuits of the NFC Forum certification device, and is an
entity configured to manage initialization, configurations, and power supplies of
all peripheral circuits and components including a near field communication controller;
generally a common operating system runs in the DH, such as a BlackBerry operating
system (an operating system used in a BlackBerry mobile phone of the Canadian BlackBerry
company), a Windows phone operating system (an operating system developed by Microsoft
for mobile devices), an Android operating system (an operating system that is based
on free and open source code of Linux, and is mainly used in a mobile device), an
iOS operating system (a mobile operating system developed by Apple), or the like;
a secure element (English: Secure Element, SE for short) interface 102, disposed in
the NFC terminal, where a most common SE is integrated into a subscriber identity
identification (English: Subscriber Identity Module, SIM for short) card, the SIM
card is inserted into the NFC terminal by using the SE interface, the SE is a part
of the SIM card, the SE is connected to an NFCC by using a pin of the SIM card, and
the SE can communicate with the DH by using the NFCC; it should be noted that, the
SE is not limited to being integrated into the SIM card; a lightweight operating system
different from that in the DH runs in the SE, for example, a Java Card platform (which
includes the Java Card platform; a Java Card runtime environment, that is, the JCRE;
and a Java Card API) of the Oracle (Oracle) company; therefore, communication between
the SE and the DH is communication across operating systems, and information is carried
by using an application protocol data unit (English: Application Protocol Data Unit,
ADPU for short); the ADPU refers to a data unit in a fixed format, and is used for
communication between an application or a security domain in the SE and an entity
outside the SE; and a related APDU command in this embodiment of the present invention
is defined in the Global Platform Card Specification V2.2.1 specification and a related
amendment (that is, an amendment C: Contactless Services, contactless services); and
the SE is a microcontroller that has a content tampering prevention function, and
provides a secure storage and running environment to a contactless application installed
in the SE. as a secure carrier of mobile payment, the SE is not only responsible for
performing secure storage and calculation on transaction key data, and ensuring that
a sensitive transaction that is performed has security authentication and non-repudiation,
but also needs to support dynamic management and running security of multiple applications;
and in the NFC terminal field, common SEs include: a UICC SE (English: Universal Integrated
Circuit Card with Secure Element, Chinese: universal integrated circuit card with
secure element), a µSD SE (English: microSD Secure Element, Chinese: micro SD secure
element) and an eSE (English: embedded Secure Element, Chinese: embedded secure element);
a near field communication controller 103 (English: Near Field Communication Controller,
NFCC for short), where the near field communication controller 103 communicates with
the DH by using an NCI (English: NFC Controller Interface, Chinese: near field communication
controller interface), and is connected to and communicates with the SE generally
by using a Single Wire Protocol (English: Single Wire Protocol, SWP for short) interface,
and according to a definition of a related standard of the NFC Forum, the NFCC is
a logical entity responsible for sending and receiving data by using an NFC radio
frequency interface; and
an NFC antenna 104, where the NFCC may send and receive data by using an antenna;
when the NFC terminal enters a radio frequency field of the NFC card reader 11, the
NFC antenna generates an induced current, to activate the SWP interface, so that the
NFC card reader can communicate with the contactless application in the SE, where
the contactless application (English: Contactless Application, CA for short) refers
to an application that is installed into the SE or the NFC terminal and that needs
to communicate with the outside by using a contactless interface (an NFC interface).
Generally, multiple CAs are installed in the SE, and to distinguish different CAs,
the different CAs are identified by using application identifiers (English: Application
Identification, AID for short). In an environment of one SE, an AID is unique and
is not repeated. An AID used in the present invention refers to an AID defined and
used in the GP (Global Platform) specification. A length of the AID is 5 to 16 bytes.
The AID complies with the ISO (English: International Standard Organization, Chinese:
International Standard Organization)/IEC (English: International Electrotechnical
Commission, Chinese: International Electrotechnical Commission) 7816-5 2004 specification
and the ETSI (English: European Telecommunications Standards Institute, Chinese: European
Telecommunications Standards Institute) TS 101 220 V3.0.0 (2000-05) specification,
and includes two parts: a 5-byte RID (English: Registered application provider Identifier,
Chinese: registered application provider identifier) and a PIX (English: Proprietary
application Identifier eXtension, Chinese: proprietary application identifier extension)
that is 11 bytes at most, where the RID is a mandatory field, and the PIX is an optional
field.
[0053] The following describes, from an NFC terminal side, the information processing method
provided in this embodiment of the present invention.
Embodiment 1
[0054] In this embodiment of the present invention, an NFC terminal establishes a TCP connection
to a server by using a group of fixed TCP ports. Specifically, each SE in the NFC
terminal establishes a TCP connection to the server by using a preset TCP port, for
example, a Hyper Text Transfer Protocol over Secure Socket Layer (English: Hyper Text
Transfer Protocol over Secure Socket Layer, HTTPS for short) port number 443, a WAP-push-http
(wap push that is based on HTTP) port number 4035, a wap-push-https (wap push that
is based on HTTPS) port number 4036, or a port number customized by another vendor.
[0055] Referring to FIG. 2, FIG. 2 is a flowchart of an information processing method according
to Embodiment 1 of the present invention. The method includes the following steps:
Step 21: Monitor a state of a TCP connection that is established by at least one secure
element SE in a near field communication NFC terminal to a server by using a Transmission
Control Protocol TCP port of the NFC terminal.
Step 22: When monitoring that the state of the TCP connection is disconnected, determine
a first SE from the at least one SE, where the first SE is an SE corresponding to
a TCP port whose TCP connection is disconnected.
Step 23: Obtain an application identifier AID of a contactless application in the
first SE.
[0056] Specifically, at least one SE is installed in the NFC terminal. Each SE establishes
a TCP connection to one server by using one TCP port in the NFC terminal. Multiple
SEs may successively establish TCP connections to servers by using a same TCP port.
Different SEs establish TCP connections to different servers, and the SEs communicate
with the servers by using the TCP connections. A remote server sends a content management
command, for example, a command for installing a contactless application or a command
for updating a configuration parameter of an application, to the SE by using a TCP
connection. Then, the SE executes the received command, and in a particular configuration,
sends command execution success acknowledgement information to the remote server,
and then disconnects from the server. Objectively, establishment or disconnection
of a connection, in particular, the disconnection, is related to installation of a
new application in the SE or a change of an application state. Therefore, a DH of
the NFC terminal may monitor a state of a TCP connection. When the state of the TCP
connection is disconnected, it indicates that a contactless application is newly installed
in an SE corresponding to a TCP port whose TCP connection is disconnected, or it indicates
that a lifecycle state of a contactless application in an SE corresponding to a TCP
port whose TCP connection is disconnected changes. For convenience of description,
the SE corresponding to the TCP port whose TCP connection is disconnected is referred
to a first SE.
[0057] When the DH monitors that the state of the TCP connection is disconnected, because
the SE establishes the TCP connection to the server by using a preset TCP port number,
an identifier SE ID of the first SE may be determined according to a correspondence
between the preset TCP port number and the SE, where the SE ID refers to an ID that
is allocated by the NFCC to each SE, and herein the SE ID is equivalent to an NFC
execution environment NFCEE ID in the NFC Forum specification.
[0058] When different SEs in the NFC terminal are connected to a remote server by using
a same TCP port, the identifier SE ID of the first SE may also be determined according
to a correspondence among the preset TCP port number, an Internet Protocol (English:
Internet Protocol, IP for short) address of the remote server, and an SE. An IP address
of a server is acquired and saved in an initiation process that is performed by the
NFC terminal when the NFC terminal activates an SE for the first time.
[0059] Similarly, when a program but not an SE in a terminal uses a monitored port number,
a monitor program may check whether an IP address of a remote server that establishes
a connection by using the port number is consistent with a remote server IP address
that is parsed out during SE initiation, and then may eliminate interference. In this
case, no SE communicates with the remote server.
[0060] After the first SE is determined, the application identifier AID of the contactless
application in the first SE may be obtained in the following two manners:
First manner: Referring to FIG. 3, FIG. 3 is a flowchart of a method for obtaining
the application identifier AID of the contactless application in the first SE according
to Embodiment 1 of the present invention. The method includes the following steps:
Step 31: Send a first command to the first SE, where the first command is used to
query a quantity of update times of all contactless applications in the first SE,
and receive a response message, sent by the first SE, of the first command.
Step 32: Parse the response message of the first command, to obtain a first global
update counter GUC value, where the first GUC value is the quantity of update times
of all the contactless applications in the first SE.
Step 33: When the first GUC value is different from a second GUC value, obtain a first
AID, where the first AID is an AID in the response message of the first command, and
the second GUC value is a quantity, stored in a non-volatile memory of the NFC terminal,
of update times of all the contactless applications in the first SE.
Second manner: Referring to FIG. 4, FIG. 4 is a flowchart of another method for obtaining
the application identifier AID of the contactless application in the first SE according
to Embodiment 1 of the present invention. The method includes the following steps:
Step 41: Send a third command to the first SE, where the third command is used to
obtain AIDs of all contactless applications in the first SE, and receive a response
message, sent by the first SE, of the third command.
Step 42: Parse the response message of the third command, to obtain a third AID, where
the third AID is an AID in the response message of the third command.
[0061] The following first describes the first manner in detail.
[0062] After the first SE is determined, a SELECT CRS APP command needs to be sent to the
first SE first, where a CRS (English: Contactless Registry Service, Chinese: contactless
registry service) APP is a management application in the SE. The Global Platform defines
that an AID of the CRS application is 'A00000015143525300'. Therefore, a SELECT 'A00000015143525300'
command is sent to the SE corresponding to the TCP port whose TCP connection is disconnected.
A format of the SELECT CRS APP command is shown in Table 1.
[0063] More specifically, a CRS refers to a function provided by software in the SE, and
is configured to manage actions related to a contactless application such as installation,
update, deletion, activation, deactivation, and priority change, and a contactless
communications protocol related to an application; the CRS further includes an application
programming interface (English: Application Programming Interface, Chinese: API) that
is provided to an authorized entity and that is related to the foregoing function.
An entity outside the SE accesses the CRS function by using the CRS application (CRS
APP).
Table 1 SELECT CRS APP command
Command header |
Command Data |
CLA |
INS |
P1 |
P2 |
Lc |
AID |
'80' |
'A4' |
'04' |
'00' |
'09' |
'A0' '00' '00' '01' '51' '43' '52' '53' '00' |
[0064] The first SE sends a response message of the SELECT CRS APP command to the DH, and
the DH determines whether the received response message of the SELECT CRS APP command
is correct. If the response message is correct, the DH determines to select the CRS
application. A format of the response message of the SELECT CRS APP command is shown
in Table 2.
Table 2 Response message of the SELECT CRS APP command
Data Field |
Status Bytes |
FCI |
SW1 |
SW2 |
FCI Template TLV |
'90' |
'00' |
[0065] A response is considered to be correct only if status words SW1 and SW2 are "9000".
Otherwise, if the status words are other values, that is, other values that are not
"9000", it indicates that the response of the command is abnormal, and troubleshooting
is performed.
[0066] After the CRS application is selected, step 31 may be performed: Send a first command
to the first SE, where the first command is used to query a quantity of update times
of all contactless applications in the first SE, and receive a response message, sent
by the first SE, of the first command. That is, the DH sends the first command to
the first SE, where the first command is used to query the quantity of update times
of all the contactless applications in the first SE.
Table 3 GET DATA command
Code |
Value |
Meaning |
CLA |
'80' |
|
INS |
'CA' |
GET DATA |
P1 |
'00' |
P1 value |
P2 |
'A5' |
P2 value |
Le |
'00' |
|
Table 4 Response message of the GET DATA command
Tag |
Length |
Value Description |
'A5' |
Var |
FCI Propiretatry Telemplate |
|
|
Tag |
Length |
Value Description |
|
|
'9F08' |
2 |
Version number (2 bytes), Value '01' '00' |
|
|
'80' |
2 |
Global Update Counter(big Endian) |
|
|
'xx' |
Var |
The number of APPs installed after SE responding to the last GET DATA commomand and
APPs whose state have been changed |
|
|
'4F' |
5-16 |
First AID |
|
|
'4F' |
5-16 |
Second AID |
|
|
'4F' |
5-16 |
...... |
|
|
'4F' |
5-16 |
The nth AID |
[0067] The first command may be a GET DATA command, and the response message of the first
command may be a response message of the GET DATA command. It should be noted that,
the first command is not limited to the GET DATA command, and the response message
of the first command is not limited to the response message of the GET DATA command.
[0068] An example in which the first command is the GET DATA command is used, and then the
response message of the first command is the response message of the GET DATA command.
Specifically, an operating system in the first SE distributes the GET DATA command
to the CRS application in the first SE, and the CRS application generates the response
message of the GET DATA command, and sends the response message to the DH. A format
of the GET DATA command is shown in Table 3, and a format of the response message
of the GET DATA command is shown in Table 4.
[0069] In this embodiment of the present invention, a response message of a GET DATA command
in the prior art is extended, where a format of the response message of the GET DATA
command in the prior art is shown in Table 5.
Table 5 Response message of the GET DATA command in the prior art
Tag |
Length |
Value Description |
'A5' |
Var |
FCI Propiretatry Telemplate |
|
|
Tag |
Length |
Value Description |
|
|
'9F08' |
2 |
Version number (2 bytes), Value '01' '00' |
|
|
'80' |
2 |
Global Update Counter(big Endian) |
[0070] It can be known from comparison with Table 5 that, in Table 4, at least one AID quantity
TLV (Tag: 'xx', Length: Var, Value Description: The number of APPs installed after
SE responding to the last GET DATA command and APPs whose state have been changed)
is added, to notify the DH that sends the GET DATA command of a quantity of contactless
applications that are newly installed in the first SE and a quantity of contactless
applications whose application states have changed in the first SE before the first
SE receives the GET DATA command. If the quantity of contactless applications that
are newly added and the quantity of contactless applications whose application states
have changed are greater than 0, the AID quantity TLV needs to be followed by at least
one AID TLV. Specifically, after the AID quantity TLV, AIDs of the first contactless
application, the second contactless application, ..., and the n
th contactless application that are in the SE and that are newly installed or whose
application states have changed are successively listed.
[0071] A TLV (English: Type-Length-Value, Chinese: type-length-value triplet) is a structure
that is used when information transmission is performed by using an APDU, and includes
a Tag/Type field of a fixed length, a Length field of a fixed length, and a Value
field of a variable length, and a TLV format complies with the ISO/IEC 8825-1:2002
standard.
[0072] In the SE, there is also a contactless registry event listener (English: Contactless
Registry Event Listener, CREL for short). The CREL refers to software in the SE, and
is configured to listen to a state change of an associated contactless application,
where the state change includes update, deletion, activation, deactivation, or the
like of the application. For each contactless application installed into the SE, one
CREL application needs to be set during the installation. A function of the CREL application
is to monitor a state change of the contactless application, so that the server manages
the contactless application; therefore, when the application state changes, invocation
of the CREL application is triggered, an AID of the contactless application and the
change of the application state are recorded in the CREL; and when the response message
of the GET DATA command is constructed, data recorded in the CREL is read. In Embodiment
1 of the present invention, only the AID is read. Certainly, the AID and an operation
type for each AID may also be read, for example, application installation, deletion,
or configuration modification.
[0073] After receiving the response message of the first command, the DH may perform step
32: Parse the response message of the first command, to obtain a first global update
counter GUC value, where the first GUC value is the quantity of update times of all
the contactless applications in the first SE.
[0074] An example in which the first command is the GET DATA command is still used, and
then the response message of the first command is the response message of the GET
DATA command. Specifically, in Table 4, there is a global update counter (English:
Global Update Counter, GUC for short) value. Therefore, the response message of the
GET DATA command is parsed, and then a global update counter GUC value of the first
SE may be obtained. For convenience of description, the GUC value of the first SE
is referred to as the first GUC value. A GUC is configured to identify a quantity
of update times of all contactless applications in an SE. When an application state
of any contactless application changes (application installation, deletion, configuration
modification, or the like), or a contactless application is updated, an operation
of increasing by 1 is performed on the counter.
[0075] Then, the first GUC value is compared with a GUC value that is of the first SE and
that is stored in the non-volatile memory of the NFC terminal. For convenience of
description, the GUC value that is of the first SE and that is stored in the non-volatile
memory of the NFC terminal is referred to as the second GUC value, where the GUC value
stored in the non-volatile memory is initiated when the SE is activated for the first
time, and is updated according to the response message of the GET DATA command each
time when the GET DATA command is invoked.
[0076] Next, step 33 is performed: When the first GUC value is different from a second GUC
value, obtain a first AID, where the first AID is an AID in the response message of
the first command, and the second GUC value is a quantity, stored in a non-volatile
memory of the NFC terminal, of update times of all the contactless applications in
the first SE. That is, if the obtained GUC value is different from the stored GUC
value, the AID in the response message of the first command is obtained.
[0077] An example in which the first command is the GET DATA command is still used, and
then the response message of the first command is the response message of the GET
DATA command. Specifically, the response message of GET DATA command shown in Table
4 includes AIDs whose application states have changed in the first SE, that is, AIDs
whose configurations are modified or that are newly installed. Therefore, the AID
that is obtained herein and that is carried in the response message of the GET DATA
command is not equal to all AIDs in the first SE.
[0078] Referring to FIG. 5, FIG. 5 is a detailed flowchart of the information processing
method in which the first manner is used according to Embodiment 1 of the present
invention. The method includes step 21 and step 22, and step 31 to step 38. As shown
in FIG. 5, after step 33 is performed to obtain the first AID, step 34 may be performed:
Compare the first AID with all AIDs stored in a non-volatile memory.
[0079] An example in which the first command is the GET DATA command is still used, and
then the response message of the first command is the response message of the GET
DATA command. Specifically, there is the first AID in the response message of the
GET DATA command. Therefore, the first AID is compared with all the AIDs stored in
the non-volatile memory, to determine whether the first AID is a newly added AID or
an AID that is already installed and whose state is updated. For an AID that is newly
added, a record is added to an AID list of the NFC terminal. For an AID that is not
newly added, that is, an AID that is already installed and whose state is updated,
a lifecycle state is queried.
[0080] After step 34 is performed, step 35 or step 36 to step 38 may be performed according
to a comparison result.
[0081] Step 35: If the first AID is different from all the AIDs stored in the non-volatile
memory, obtain an identifier SE ID of the first SE, and save, in the non-volatile
memory, a data record that includes at least the first AID and the SE ID.
[0082] Step 36: If the first AID is the same as one AID stored in the non-volatile memory,
send a second command to the first SE, where the second command is used to query a
lifecycle state of the first AID, and receive a response message, sent by the first
SE, of the second command.
[0083] Step 37: Parse the response message of the second command, to obtain the lifecycle
state of the first AID.
[0084] Step 38: Update the lifecycle state that is of the first AID and that is stored in
the non-volatile memory.
[0085] An example in which the first command is the GET DATA command is still used, and
then the response message of the first command is the response message of the GET
DATA command. Specifically, the response message of the GET DATA command may include
M AIDs, where M is an integer greater than or equal to 1. Assume that m is 1 to M
successively. An m
th AID in the response message of the GET DATA command is used as the first AID, and
the first AID is compared with all the AIDs stored in the non-volatile memory.
[0086] In a process in which the first AID is compared with all the AIDs stored in the non-volatile
memory, if the first AID is different from all the AIDs stored in the non-volatile
memory, it indicates that the first AID is not stored in the non-volatile memory,
and the first AID is a newly added AID.
[0087] In Embodiment 1 of the present invention, for the newly added AID, a data record
for the newly added AID and the SE ID of the first SE needs to be stored in the non-volatile
memory. A quantity of data records that need to be stored needs to be equal to a quantity
of newly added AIDs in the response message of the GET DATA command. The first AID
is a newly added AID, and therefore a data record for the first AID and the SE ID
of the first SE is stored in the non-volatile memory.
[0088] In a process in which the first AID is compared with all the AIDs stored in the non-volatile
memory, if the first AID is the same as one AID stored in the non-volatile memory,
it indicates that the first AID is already stored in the non-volatile memory, and
the first AID is an AID whose application state is updated.
[0089] In Embodiment 1 of the present invention, for the AID whose application state is
updated, the second command needs to be sent to the first SE, where the second command
is used to query the lifecycle state of the first AID.
[0090] The second command may be a GET STATUS command in a first format, and the response
message of the second command may be a response message of the GET STATUS command
in the first format. It should be noted that, the second command is not limited to
the GET STATUS command in the first format, and the response message of the second
command is not limited to the response message of the GET STATUS command in the first
format.
[0091] An example in which the second command is the GET STATUS command in the first format
is used, and then the response message of the second command is the response message
of the GET STATUS command in the first format. A format of the GET STATUS command
in the first format is shown in Table 6, and a format of the response message of the
GET STATUS command in the first format is shown in Table 7.
Table 6 GET STATUS command in the first format
Command header |
Command Data |
CLA |
INS |
P1 |
P2 |
Lc |
Search on: Specific AIDs |
'80' |
'F2' |
'4F' |
'00' |
'0#' |
'4F' '##' 'XXXX' |
Table 7 Response message of the GET STATUS command in the first format
Tag |
Length |
Value Description |
'61' |
7-n |
Application Template |
|
|
Tag |
Length |
Value Description |
|
|
'4F' |
7-16 |
Application AID |
|
|
'9F70' |
2 |
Application Lifecycle State |
[0092] In Table 6, 'XXXX' represents the first AID. '##' represents a length of the first
AID. In Table 7, Application AID is the first AID included in the GET STATUS command
in the first format, and Application Lifecycle State is the lifecycle state of the
first AID included in the GET STATUS command in the first format.
[0093] The first AID is an AID whose application state is updated. Therefore, the GET STATUS
command in the first format is sent to the first SE, the first AID is filled in 'XXXX',
and the response message of the GET STATUS command in the first format is received.
Application AID is the first AID, and Application Lifecycle State is the lifecycle
state of the first AID.
[0094] The lifecycle state includes: installed (installed), locked (locked), selectable
(selectable), and app specific (application specific). In Embodiment 1 of the present
invention, it is considered that installed and locked are abnormal states, and selectable
and app specific are normal states.
[0095] An example in which the second command is the GET STATUS command in the first format
is still used, and then the response message of the second command is the response
message of the GET STATUS command in the first format. After the response message
of the GET STATUS command in the first format is parsed, to obtain a lifecycle state
of each AID of AIDs whose application states are updated, the lifecycle state of the
AID whose application state is updated is compared with a lifecycle state that is
of an AID whose application state is not yet updated and that is already stored in
the non-volatile memory. If the lifecycle states are different, the lifecycle state
of the AID is updated to a lifecycle state in the response message of the GET STATUS
command in the first format.
[0096] The first AID is an AID whose application state is updated. Therefore, the lifecycle
state of the first AID may be obtained by parsing the response message of the GET
STATUS command in the first format. Then, the lifecycle state of the first AID is
compared with a lifecycle state that is of the first AID whose application state is
not yet updated and that is already stored in the non-volatile memory. If the lifecycle
states are different, the lifecycle state of the first AID is updated to the lifecycle
state in the response message of the GET STATUS command in the first format.
[0097] In Embodiment 1 of the present invention, not only the lifecycle state of each AID
of the AIDs whose application states are updated needs to be obtained, but also a
lifecycle state of each AID of newly added AIDs needs to be obtained. In other words,
for each AID of the newly added AIDs, the second command in the first format needs
to be sent to the SE corresponding to the TCP port whose TCP connection is disconnected,
and the response message of the second command needs to be received and parsed, to
obtain the lifecycle state. In Embodiment 1 of the present invention, after the lifecycle
state of each AID of the newly added AIDs is obtained, and the lifecycle state of
the AID whose application state is updated is updated, the DH selects only an AID
whose lifecycle state is a normal state to generate routing information, so that the
DH configures a routing table for the NFCC in an appropriate occasion.
[0098] The appropriate occasion may be a time when a user selects and activates a contactless
application by using a graphical user interface of a mobile phone. For example, when
a user opens a mobile wallet application, and taps and selects a virtual bank card,
an AID of the bank card application needs to be configured into an NFCC routing table,
and the routing table needs to be reconfigured; or when an SE is removed, several
AIDs become invalid, and an NFCC routing table needs to be refreshed, for example,
when a user manually disables an SE in the body of a mobile phone, which causes an
AID in the SE to be temporarily unavailable, it is necessary to refresh the routing
table, and delete a routing item that is in the routing table and that corresponds
to the AID in the disabled SE.
[0099] The following describes the second manner in detail.
[0100] After the first SE is determined, a SELECT CRS APP command needs to be sent to the
first SE first. A format of the SELECT CRS APP command is shown in Table 1. The first
SE sends a response message of the SELECT CRS APP command to the DH, and the DH determines
whether the received response message of the SELECT CRS APP command is correct. If
the response message is correct, the DH determines to select a CRS application. A
format of the response message of the SELECT CRS APP command is shown in Table 2.
A response is considered to be correct only if status words SW1 and SW2 are "9000".
Otherwise, if the status words are other values, that is, other values that are not
"9000", it indicates that the response of the command is abnormal, and troubleshooting
is performed.
[0101] After the CRS application is selected, step 41 may be performed: Send a third command
to the first SE, where the third command is used to obtain AIDs of all contactless
applications in the first SE, and receive a response message, sent by the first SE,
of the third command. That is, the DH sends a third command in a second format to
the first SE, where the third command is used to obtain the AIDs of all the contactless
applications in the first SE.
Table 8 GET STATUS command in the second format
Command header |
Command Data |
CLA |
INS |
P1 |
P2 |
Lc |
Search on: All AIDs |
Return: AID/Update Counter |
'80' |
'F2' |
'4F' |
'00' |
'0D' |
'4F' '00' |
'5C' '01' '80' |
Table 9 Response message of the GET STATUS command in the second format
Data Field |
Status bytes |
Application Related Data |
AID |
Update Counter |
SW1 |
SW2 |
'61##' |
'4F' '##' 'xx...xx' |
'80' '02' 'xxxx' |
'90' |
'00' |
|
... |
... |
|
|
|
... |
... |
|
|
|
'4F' '##' 'xx...xx' |
'80' '02' 'xxxx' |
|
|
[0102] The third command may be a GET STATUS command in a second format, and the response
message of the third command may be a response message of the GET STATUS command in
the second format. It should be noted that, the third command is not limited to the
GET STATUS command in the second format, and the response message of the third command
is not limited to the response message of the GET STATUS command in the second format.
[0103] An example in which the third command is the GET STATUS command in the second format
is used, and then the response message of the third command is the response message
of the GET STATUS command in the second format. Specifically, an operating system
in the first SE distributes the GET STATUS command in the second format to the CRS
application in the first SE, and the CRS application generates the response message
of the GET STATUS command in the second format, and sends the response message to
the DH. A format of the GET STATUS command in the second format is shown in Table
8, and a format of the response message of the GET STATUS command in the second format
is shown in Table 9.
[0104] In Table 9, Data Field carries all AIDs in the first SE and an update counter (English:
Update Counter, UC for short) value of each AID. When the status words SW1 and SW2
are "9000", it indicates that the response is correct, and when the status words SW1
and SW2 are not '9000', it indicates that an exception occurs.
[0105] After the DH receives the response message of the third command, step 42 may be performed:
Parse the response message of the third command, to obtain a third AID, where the
third AID is an AID in the response message of the third command.
[0106] An example in which the third command is the GET STATUS command in the second format
is still used, and then the response message of the third command is the response
message of the GET STATUS command in the second format. Specifically, the response
message of the GET STATUS command in the second format shown in Table 9 includes all
the AIDs in the first SE, where there are AIDs whose application states have changed,
and there are also AIDs whose application states have not changed. Therefore, the
AID that is obtained herein and that is carried in the response message of the GET
STATUS command in the second format is all the AIDs in the first SE.
[0107] Referring to FIG. 6, FIG. 6 is a detailed flowchart of the information processing
method in which the second manner is used according to Embodiment 1 of the present
invention. The method includes step 21 and step 22, and step 41 to step 48. As shown
in FIG. 6, to distinguish which AIDs in the obtained AIDs are newly added AIDs, and
which AIDs are AIDs whose application states are updated, step 43 needs to be performed:
Compare the third AID with all AIDs stored in a non-volatile memory of the NFC terminal.
[0108] An example in which the third command is the GET STATUS command in the second format
is still used, and then the response message of the third command is the response
message of the GET STATUS command in the second format. Specifically, there is the
third AID in the response message of the GET STATUS command in the second format.
Therefore, the third AID is compared with all the AIDs stored in the non-volatile
memory, to determine whether the third AID is a newly added AID or an AID that is
already installed and whose state is updated. For an AID that is newly added, a record
is added to an AID list of the NFC terminal. For an AID that is not newly added, that
is, an AID that is already installed and whose state is updated, a lifecycle state
is queried with reference to a UC value, and the UC value is updated.
[0109] After step 43 is performed, step 44 or step 45 to step 48 may be performed according
to a comparison result.
[0110] Step 44: If the third AID is different from all the AIDs stored in the non-volatile
memory, obtain an identifier SE ID of the first SE, and save, in the non-volatile
memory, a data record that includes at least the third AID and the SE ID.
[0111] Step 45: If the third AID is the same as one AID stored in the non-volatile memory,
compare a first update counter UC value with a second UC value, where the first UC
value is a quantity of update times of a contactless application that has the third
AID, and the second UC value is a quantity, stored in the non-volatile memory, of
update times of the contactless application that has the third AID.
[0112] Step 46: If the first UC value is different from the second UC value, send a fourth
command to the first SE, where the fourth command is used to query a lifecycle state
of the third AID, and receive a response message, sent by the first SE, of the fourth
command.
[0113] Step 47: Parse the response message of the fourth command, to obtain the lifecycle
state of the third AID.
[0114] Step 48: Update the lifecycle state and the UC values that are of the third AID and
that are stored in the non-volatile memory.
[0115] An example in which the third command is the GET STATUS command in the second format
is still used, and then the response message of the third command is the response
message of the GET STATUS command in the second format. Specifically, the response
message of the GET STATUS command in the second format includes M AIDs, where M is
an integer greater than or equal to 1. Assume that m is equal to 1 to M successively.
An m
th AID in the response message of the GET STATUS command in the second format is used
as the third AID, and the third AID is compared with all the AIDs stored in the non-volatile
memory.
[0116] In a process in which the third AID is compared with all the AIDs stored in the non-volatile
memory, if the third AID is different from all the AIDs stored in the non-volatile
memory, it indicates that the third AID is not stored in the non-volatile memory,
and the third AID is a newly added AID.
[0117] In Embodiment 1 of the present invention, for the newly added AID, a data record
for the newly added AID and the SE ID of the first SE needs to be stored in the non-volatile
memory. There is a UC value of each AID in the response message of the GET STATUS
command in the second format. Therefore, a UC value of a newly added AID may be further
stored in a data record, so as to monitor a change of an application state of a contactless
application that has an AID. A quantity of data records that need to be stored needs
to be equal to a quantity of newly added AIDs in the response message of the GET STATUS
command in the second format. The third AID is a newly added AID, and therefore a
data record for the third AID and the SE ID of the first SE is stored in the non-volatile
memory. Certainly, a UC value of the third AID may be further stored in the data record,
so as to monitor a change of an application state of the contactless application that
has the third AID.
[0118] In a process in which the third AID is compared with all the AIDs stored in the non-volatile
memory, if the third AID is the same as one AID stored in the non-volatile memory,
it indicates that the third AID is already stored in the non-volatile memory, and
the third AID is an AID whose application state is updated.
[0119] In Embodiment 1 of the present invention, when the third AID is an AID whose application
state is updated, the UC value of the third AID needs to be compared with a UC value
that is of the third AID and that is stored in the non-volatile memory. If the UC
values are different, the fourth command is sent to the first SE, where the fourth
command is used for the lifecycle state of the third AID, the response message of
the fourth command is received and parsed, and then the lifecycle state of the third
AID whose application state is updated and whose UC value is different from the UC
value in the non-volatile memory is obtained.
[0120] The fourth command may be a GET STATUS command in a first format, and the response
message of the fourth command may be a response message of the GET STATUS command
in the first format. It should be noted that, the fourth command is not limited to
the GET STATUS command in the first format, and the response message of the fourth
command is not limited to the response message of the GET STATUS command in the first
format. A format of the GET STATUS command in the first format is shown in Table 6,
and a format of the response message of the GET STATUS command in the first format
is shown in Table 7.
[0121] An example in which the fourth command is the GET STATUS command in the first format
is used, and then the response message of the fourth command is the response message
of the GET STATUS command in the first format. Specifically, the third AID is an AID
whose application state is updated and whose UC value is different from the UC value
in the non-volatile memory. Therefore, the GET STATUS command in the first format
is sent to the first SE, the third AID is filled in 'XXXX', and the response message
of the GET STATUS command in the first format is received. Application AID is the
third AID, and Application Lifecycle State is the lifecycle state of the third AID.
[0122] An example in which the fourth command is the GET STATUS command in the first format
is used, and then the response message of the fourth command is the response message
of the GET STATUS command in the first format. Specifically, after the response message
of the GET STATUS command in the first format is parsed, to obtain a lifecycle state
of each AID of AIDs whose application states are updated, the lifecycle state of the
AID whose application state is updated is compared with a lifecycle state that is
of an AID whose application state is not yet updated and that is already stored in
the non-volatile memory. If the lifecycle states are different, the lifecycle state
of the AID is updated to a lifecycle state in the response message of the GET STATUS
command in the first format, and a UC value of the AID is updated to a UC value in
the response message of the GET STATUS command in the first format; or if the lifecycle
states are the same, only a UC value of the AID is updated to a UC value in the response
message of the GET STATUS command in the first format.
[0123] The third AID is an AID whose application state is updated and whose UC value is
different from the UC value in the non-volatile memory. Therefore, the lifecycle state
of the third AID may be obtained by parsing the response message of the GET STATUS
command in the first format, and then the lifecycle state of the third AID is compared
with a lifecycle state that is of the third AID whose application state is not yet
updated and that is stored in the non-volatile memory. If the lifecycle states are
different, the lifecycle state of the third AID is updated to a lifecycle state in
the response message of the GET STATUS command in the first format, and the UC value
of the third AID is updated to a UC value in the response message of the GET STATUS
command in the first format; or if the lifecycle states are the same, only the UC
value of the third AID is updated to a UC value in the response message of the GET
STATUS command in the first format.
[0124] In Embodiment 1 of the present invention, not only the lifecycle state of each AID
of the AIDs whose application states are updated needs to be obtained, but also a
lifecycle state of each AID of newly added AIDs, and a lifecycle state of an AID whose
UC value is different from the UC value in the non-volatile memory need to be obtained.
In other words, for each AID of the newly added AIDs, and each AID whose UC value
is different from the UC value in the non-volatile memory, the GET STATUS command
in the first format needs to be sent to the first SE, and the response message of
the GET STATUS command in the first format needs to be received and parsed, to obtain
a lifecycle state. The format of the GET STATUS command in the first format is shown
in Table 6, and the format of the response message of the GET STATUS command in the
first format is shown in Table 7.
[0125] In Embodiment 1 of the present invention, after the lifecycle state of each AID of
the newly added AIDs, and the lifecycle state of each AID whose UC value is different
from the UC value in the non-volatile memory are obtained, the DH selects only an
AID whose lifecycle state is a normal state to generate routing information, so that
the DH configures a routing table to the NFCC in an appropriate occasion.
Embodiment 2
[0126] In this embodiment of the present invention, when an SE in an NFC terminal completes
installation or configuration modification of a contactless application, for example,
a user uses the NFC terminal to select a card application on a mobile wallet interface,
and performs an operation such as installation, update, or deletion on the card, after
the SE correspondingly executes a command of contactless application installation,
lifecycle state modification, deletion, or the like, the SE generally needs to report
a command execution success message to a server. After the server receives the command
execution success message, and learns that a contactless application is successfully
installed or an application state of a contactless application is updated, the server
pushes an application change notification message to a DH of the NFC terminal.
[0127] Referring to FIG. 7, FIG. 7 is another flowchart of an information processing method
according to Embodiment 2 of the present invention. The method includes the following
steps:
Step 51: Receive application change notification information sent by a server.
Step 52: Obtain an application identifier AID of a contactless application in a first
secure element SE, where the first SE is an SE that is in a near field communication
NFC terminal and that communicates with the server.
[0128] In this embodiment of the present invention, the application change notification
message received by the DH of the NFC terminal has multiple forms.
[0129] First form: When the server pushes the application change notification message to
the DH of the NFC terminal by using an HTTP message, the application change notification
message includes at least three tags: a message type, an AID of a newly installed
contactless application or an AID of a contactless application whose application state
is updated, and an SE ID of an SE in which a newly installed contactless application
or a contactless application whose application state is updated is located. A specific
format is as follows:
<ServiceDescriptor>
<AID>xx..xx</AID>
<SEID>xxx..xxx</SEID>
</ServiceDescriptor>
[0130] Second form: The application change notification message includes only a sending
source, that is, an IP address of the server that sends the application change notification
message, and an SE in which a contactless application is newly installed or an application
state of a contactless application is updated may be determined according to a correspondence
between the IP address of the server and the SE.
[0131] After step 51 is performed and the application change notification message sent by
the server is received, the first SE may be determined first, that is, an SE that
is in the near field communication NFC terminal and that communicates with the server.
Specifically, the SE that communicates with the server, that is, the SE that reports
the command execution success message to the server, is determined by parsing the
application change notification message is parsed, or by using the application change
notification message and the correspondence between the IP address of the server and
the SE. It is considered that, a contactless application is newly installed in the
SE that communicates with the server, or an application state of a contactless application
in the SE that communicates with the server changes.
[0132] After the first SE is determined, step 52 is performed. In Embodiment 2 of the present
invention, according to different forms of the application change notification message,
step 52 has at least the following three specific implementation manners:
a first specific implementation manner: parsing the application change notification
information, to obtain an AID in the application change notification information;
a second specific implementation manner: sending a first command to the first SE,
where the first command is used to query a quantity of update times of all contactless
applications in the first SE, and receiving a response message, sent by the first
SE, of the first command; parsing the response message of the first command, to obtain
a first global update counter GUC value, where the first GUC value is the quantity
of update times of all the contactless applications in the first SE; and when the
obtained first GUC value is different from a second GUC value, obtaining a first AID,
where the first AID is an AID in the response message of the first command, and the
second GUC value is a quantity, stored in a non-volatile memory of the NFC terminal,
of update times of all the contactless applications in the first SE; and
a third implementation manner:
sending a third command to the first SE, where the third command is used to obtain
AIDs of all contactless applications in the first SE, and receiving a response message,
sent by the first SE, of the third command; and
parsing the response message of the third command, to obtain a third AID, where the
third AID is an AID in the response message of the third command.
[0133] The following first describes the first specific implementation manner in detail.
[0134] When the application change notification message is in the foregoing first form,
the application change notification message may be directly parsed, and then an AID
in the first SE can be obtained. The application change notification information embodies
only an AID whose application state changes. Therefore, only some AIDs, that is, a
newly added AID and an AID whose lifecycle state is updated, in the first SE are obtained
herein, and all AIDs in the first SE are not obtained.
[0135] When the application change notification message is in the foregoing second form
or the foregoing third form, the SE that communicates with the server may be equivalent
to the SE corresponding to the TCP port whose TCP connection is disconnected in Embodiment
1. The first command is sent, to obtain the AID in the response message of the first
command, or the third command is sent, to obtain the AID in the response message of
the third command.
[0136] For details, refer to related descriptions in Embodiment 1. Details are not described
herein again.
[0137] The application change notification message includes AIDs whose application states
have changed in the first SE, that is, AIDs whose configurations are modified or that
are newly installed, but not all the AIDs in the first SE. Therefore, after the AID
in the application change notification information is obtained, the following steps
may be further performed:
comparing the first AID with all AIDs stored in the non-volatile memory; and
if the first AID is different from all the AIDs stored in the non-volatile memory,
obtaining an identifier SE ID of the first SE, and saving, in the non-volatile memory,
a data record that includes at least the first AID and the SE ID; or
if the first AID is the same as one AID stored in the non-volatile memory, sending
a second command to the first SE, where the second command is used to query a lifecycle
state of the first AID, and receiving a response message, sent by the first SE, of
the second command;
parsing the response message of the second command, to obtain the lifecycle state
of the first AID; and
updating the lifecycle state that is of the first AID and that is stored in the non-volatile
memory.
[0138] For a specific implementation manner, refer to related descriptions in Embodiment
1. Details are not described herein again.
[0139] Similarly, the response message of the first command includes AIDs whose application
states have changed in the first SE, that is, AIDs whose configurations are modified
or that are newly installed. The AIDs carried in the response message of the first
command are not equal to all the AIDs in the first SE. Therefore, after the first
AID is obtained, the following steps may be further performed:
comparing the first AID with all AIDs stored in the non-volatile memory; and
if the first AID is different from all the AIDs stored in the non-volatile memory,
obtaining an identifier SE ID of the first SE, and saving, in the non-volatile memory,
a data record that includes at least the first AID and the SE ID; or
if the first AID is the same as one AID stored in the non-volatile memory, sending
a second command to the first SE, where the second command is used to query a lifecycle
state of the first AID, and receiving a response message, sent by the first SE, of
the second command;
parsing the response message of the second command, to obtain the lifecycle state
of the first AID; and
updating the lifecycle state that is of the first AID and that is stored in the non-volatile
memory.
[0140] For details, refer to related descriptions in Embodiment 1. Details are not described
herein again.
[0141] The response message of the third command includes all the AIDs in the first SE,
including AIDs whose application states have changed, and AIDs whose application states
have not changed. Therefore, after the third AID is obtained, the following steps
may be further performed:
if the third AID is different from all the AIDs stored in the non-volatile memory,
obtaining an identifier SE ID of the first SE, and saving, in the non-volatile memory,
a data record that includes at least the one AID that participates in the comparison
and the SE ID; or
if the third AID is the same as one AID stored in the non-volatile memory, comparing
a first update counter UC value with a second UC value, where the first UC value is
a quantity of update times of a contactless application that has the third AID, and
the second UC value is a quantity, stored in the non-volatile memory, of update times
of the contactless application that has the third AID;
if the first UC value is different from the second UC value, sending a fourth command
to the first SE, where the fourth command is used to query a lifecycle state of the
third AID, and receiving a response message, sent by the first SE, of the fourth command;
parsing the response message of the fourth command, to obtain the lifecycle state
of the third AID; and
updating the lifecycle state and the UC values that are of the third AID and that
are stored in the non-volatile memory.
[0142] For a specific implementation manner, refer to related descriptions in Embodiment
1. Details are not described herein again.
Embodiment 3
[0143] Based on a same invention conception, this embodiment of the present invention provides
an NFC terminal. Referring to FIG. 8, FIG. 8 is a schematic structural diagram of
an NFC terminal according to Embodiment 3 of the present invention. The NFC terminal
80 includes: a processor 81, a bus 82, a non-volatile memory 83, a secure element
SE interface 102, and a Transmission Control Protocol TCP port 84.
[0144] The non-volatile memory 83 is configured to store an application identifier AID of
a contactless application in the SE;
the secure element SE interface 102 is configured to connect the SE to the NFC terminal;
the Transmission Control Protocol TCP port 84; and
a processor 81 is connected to the non-volatile memory 83, the SE interface 102, and
the TCP port 84 by using the bus, and configured to:
monitor a state of a TCP connection that is established by at least one secure element
SE in a near field communication NFC terminal to a server by using a Transmission
Control Protocol TCP port of the NFC terminal;
when monitoring that the state of the TCP connection is disconnected, determine a
first SE from the at least one SE, where the first SE is an SE corresponding to a
TCP port whose TCP connection is disconnected; and
obtain an application identifier AID of a contactless application in the first SE.
[0145] Optionally, the processor 81 is further configured to:
send a first command to the first SE, where the first command is used to query a quantity
of update times of all contactless applications in the first SE, and receive a response
message, sent by the first SE, of the first command;
parse the response message of the first command, to obtain a first global update counter
GUC value, where the first GUC value is the quantity of update times of all the contactless
applications in the first SE; and
when the first GUC value is different from a second GUC value, obtain a first AID,
where the first AID is an AID in the response message of the first command, and the
second GUC value is a quantity, stored in a non-volatile memory of the NFC terminal,
of update times of all the contactless applications in the first SE.
[0146] Optionally, the processor 81 is further configured to:
after obtaining the first AID, compare the first AID with all AIDs stored in the non-volatile
memory; and
if the first AID is different from all the AIDs stored in the non-volatile memory,
obtain an identifier SE ID of the first SE, and save, in the non-volatile memory,
a data record that includes at least the first AID and the SE ID.
[0147] Optionally, the processor 81 is further configured to:
after comparing the first AID with all AIDs stored in the non-volatile memory, if
the first AID is the same as one AID stored in the non-volatile memory, send a second
command to the first SE, where the second command is used to query a lifecycle state
of the first AID, and receive a response message, sent by the first SE, of the second
command;
parse the response message of the second command, to obtain the lifecycle state of
the first AID; and
update the lifecycle state that is of the first AID and that is stored in the non-volatile
memory.
[0148] Optionally, the processor 81 is further configured to:
send a third command to the first SE, where the third command is used to obtain AIDs
of all contactless applications in the first SE, and receive a response message, sent
by the first SE, of the third command; and
parse the response message of the third command, to obtain a third AID, where the
third AID is an AID in the response message of the third command.
[0149] Optionally, the processor 81 is further configured to:
after obtaining the third AID, compare the third AID with all AIDs stored in a non-volatile
memory of the NFC terminal; and
if the third AID is different from all the AIDs stored in the non-volatile memory,
obtain an identifier SE ID of the first SE, and save, in the non-volatile memory,
a data record that includes at least the third AID and the SE ID.
[0150] Optionally, the processor 81 is further configured to:
after comparing the third AID with all the AIDs stored in the non-volatile memory
of the NFC terminal, if the third AID is the same as one AID stored in the non-volatile
memory, compare a first update counter UC value with a second UC value, where the
first UC value is a quantity of update times of a contactless application that has
the third AID, and the second UC value is a quantity, stored in the non-volatile memory,
of update times of the contactless application that has the third AID;
if the first UC value is different from the second UC value, send a fourth command
to the first SE, where the fourth command is used to query a lifecycle state of the
third AID, and receive a response message, sent by the first SE, of the fourth command;
parse the response message of the fourth command, to obtain the lifecycle state of
the third AID; and
update the lifecycle state and the UC values that are of the third AID and that are
stored in the non-volatile memory.
[0151] Optionally, the processor 81 is further configured to:
receive application change notification information sent by a server; and
obtain an application identifier AID of a contactless application in a first secure
element SE, where the first SE is an SE that is in a near field communication NFC
terminal and that communicates with the server.
[0152] Optionally, the processor 81 is further configured to:
parse the application change notification information, to obtain an AID in the application
change notification information.
[0153] Optionally, the processor 81 is further configured to:
send a first command to the first SE, where the first command is used to query a quantity
of update times of all contactless applications in the first SE, and receive a response
message, sent by the first SE, of the first command;
parse the response message of the first command, to obtain a first global update counter
GUC value, where the first GUC value is the quantity of update times of all the contactless
applications in the first SE; and
when the first GUC value is different from a second GUC value, obtain a first AID,
where the first AID is an AID in the response message of the first command, and the
second GUC value is the quantity, stored in a non-volatile memory of the NFC terminal,
of update times of all the contactless applications in the first SE.
[0154] Optionally, the processor 81 is further configured to:
send a third command to the first SE, where the third command is used to obtain AIDs
of all contactless applications in the first SE, and receive a response message, sent
by the first SE, of the third command; and
parse the response message of the third command, to obtain a third AID, where the
third AID is an AID in the response message of the third command.
[0155] Optionally, the processor 81 is further configured to:
after obtaining the AID in the application change notification information, compare
the first AID with all AIDs stored in the non-volatile memory; and
if the first AID is different from all the AIDs stored in the non-volatile memory,
obtain an identifier SE ID of the first SE, and save, in the non-volatile memory,
a data record that includes at least the first AID and the SE ID.
[0156] Optionally, the processor 81 is further configured to:
after comparing the first AID with all the AIDs stored in the non-volatile memory,
if the first AID is the same as one AID stored in the non-volatile memory, send a
second command to the first SE, where the second command is used to query a lifecycle
state of the first AID, and receive a response message, sent by the first SE, of the
second command;
parse the response message of the second command, to obtain the lifecycle state of
the first AID; and
update the lifecycle state that is of the first AID and that is stored in the non-volatile
memory.
[0157] Optionally, the processor 81 is further configured to:
after obtaining the first AID, compare the first AID with all AIDs stored in a non-volatile
memory; and
if the first AID is different from all the AIDs stored in the non-volatile memory,
obtain an identifier SE ID of the first SE, and save, in the non-volatile memory,
a data record that includes at least the first AID and the SE ID.
[0158] Optionally, the processor 81 is further configured to:
after comparing the first AID with all the AIDs stored in the non-volatile memory,
if the first AID is the same as one AID stored in the non-volatile memory, send a
second command to the first SE, where the second command is used to query a lifecycle
state of the first AID, and receive a response message, sent by the first SE, of the
second command;
parse the response message of the second command, to obtain the lifecycle state of
the first AID; and
update the lifecycle state that is of the first AID and that is stored in the non-volatile
memory.
[0159] Optionally, the processor 81 is further configured to:
after obtaining the third AID, compare the third AID with all AIDs stored in a non-volatile
memory of the NFC terminal; and
if the third AID is different from all the AIDs stored in the non-volatile memory,
obtain an identifier SE ID of the first SE, and save, in the non-volatile memory,
a data record that includes at least the one AID that participates in the comparison
and the SE ID.
[0160] Optionally, the processor 81 is further configured to:
after comparing the third AID with all the AIDs stored in the non-volatile memory
of the NFC terminal, if the third AID is the same as one AID stored in the non-volatile
memory, compare a first update counter UC value with a second UC value, where the
first UC value is a quantity of update times of a contactless application that has
the third AID, and the second UC value is a quantity, stored in the non-volatile memory,
of update times of the contactless application that has the third AID;
if the first UC value is different from the second UC value, send a fourth command
to the first SE, where the fourth command is used to query a lifecycle state of the
third AID, and receive a response message, sent by the first SE, of the fourth command;
parse the response message of the fourth command, to obtain the lifecycle state of
the third AID; and
update the lifecycle state and the UC values that are of the third AID and that are
stored in the non-volatile memory.
[0161] In FIG. 8, a bus architecture (which is represented by the bus 82), that is, the
bus 82, may include any quantity of interconnected buses and bridges, and the bus
82 connects one or more processors that are represented by the processor 81 to various
circuits of the non-volatile memory 83. The bus 82 may further connect various other
circuits such as a peripheral device, a voltage stabilizer, and a power management
circuit. These are known in the art, and therefore are not further described in this
specification.
[0162] The processor 81 is responsible for managing the bus 82 and general processing, and
the non-volatile memory 83 may be configured to store data that is used by the processor
81 when the processor 81 performs an operation.
[0163] The NFC terminal 80 in Embodiment 3 may be the NFC terminal in FIG. 1, where the
NFC terminal is described in detail above. Details are not described herein again.
[0164] The NFC terminal in Embodiment 3 may perform various variation manners and specific
examples in the information processing methods in the embodiments in FIG. 2 to FIG.
7. By means of the detailed descriptions of the information processing methods, persons
skilled in the art can clearly know an implementation method of the NFC terminal in
Embodiment 3. Therefore, for simplicity of the specification, details are not described
herein again.
[0165] Persons skilled in the art should understand that the embodiments of the present
invention may be provided as a method, a system, or a computer program product. Therefore,
the present invention may use a form of hardware only embodiments, software only embodiments,
or embodiments with a combination of software and hardware. Moreover, the present
invention may use a form of a computer program product that is implemented on one
or more computer-usable storage media (including but not limited to a magnetic disk
storage, an optical memory, and the like) that include computer-usable program code.
[0166] The present invention is described with reference to the flowcharts and/or block
diagrams of the method, the device (system), and the computer program product according
to the embodiments of the present invention. It should be understood that computer
program instructions may be used to implement each process and/or each block in the
flowcharts and/or the block diagrams and a combination of a process and/or a block
in the flowcharts and/or the block diagrams. These computer program instructions may
be provided for a general-purpose computer, a dedicated computer, an embedded processor,
or a processor of any other programmable data processing device to generate a machine,
so that the instructions executed by a computer or a processor of any other programmable
data processing device generate an apparatus for implementing a specific function
in one or more processes in the flowcharts and/or in one or more blocks in the block
diagrams.
[0167] These computer program instructions may be stored in a computer readable memory that
can instruct the computer or any other programmable data processing device to work
in a specific manner, so that the instructions stored in the computer readable memory
generate an artifact that includes an instruction apparatus. The instruction apparatus
implements a specific function in one or more processes in the flowcharts and/or in
one or more blocks in the block diagrams.
[0168] These computer program instructions may be loaded onto a computer or another programmable
data processing device, so that a series of operations and steps are performed on
the computer or the another programmable device, thereby generating computer-implemented
processing. Therefore, the instructions executed on the computer or the another programmable
device provide steps for implementing a specific function in one or more processes
in the flowcharts and/or in one or more blocks in the block diagrams.
[0169] Although some preferred embodiments of the present invention have been described,
persons skilled in the art can make changes and modifications to these embodiments
once they learn the basic inventive concept. Therefore, the following claims are intended
to be construed as to cover the preferred embodiments and all changes and modifications
falling within the scope of the present invention.
[0170] Obviously, persons skilled in the art can make various modifications and variations
to the present invention without departing from the spirit and scope of the present
invention. The present invention is intended to cover these modifications and variations
provided that they fall within the scope of protection defined by the following claims
and their equivalent technologies.
1. An information processing method, comprising:
monitoring a state of a TCP connection that is established by at least one secure
element SE in a near field communication NFC terminal to a server by using a Transmission
Control Protocol TCP port of the NFC terminal;
when monitoring that the state of the TCP connection is disconnected, determining
a first SE from the at least one SE, wherein the first SE is an SE corresponding to
a TCP port whose TCP connection is disconnected; and
obtaining an application identifier AID of a contactless application in the first
SE.
2. The method according to claim 1, wherein the obtaining an application identifier AID
of a contactless application in the first SE specifically comprises:
sending a first command to the first SE, wherein the first command is used to query
a quantity of update times of all contactless applications in the first SE, and receiving
a response message, sent by the first SE, of the first command;
parsing the response message of the first command, to obtain a first global update
counter GUC value, wherein the first GUC value is the quantity of update times of
all the contactless applications in the first SE; and
when the first GUC value is different from a second GUC value, obtaining a first AID,
wherein the first AID is an AID in the response message of the first command, and
the second GUC value is a quantity, stored in a non-volatile memory of the NFC terminal,
of update times of all the contactless applications in the first SE.
3. The method according to claim 2, wherein after the obtaining a first AID, the method
further comprises:
comparing the first AID with all AIDs stored in the non-volatile memory; and
if the first AID is different from all the AIDs stored in the non-volatile memory,
obtaining an identifier SE ID of the first SE, and saving, in the non-volatile memory,
a data record that comprises at least the first AID and the SE ID.
4. The method according to claim 3, wherein after the comparing the first AID with all
AIDs stored in the non-volatile memory, the method further comprises:
if the first AID is the same as one AID stored in the non-volatile memory, sending
a second command to the first SE, wherein the second command is used to query a lifecycle
state of the first AID, and receiving a response message, sent by the first SE, of
the second command;
parsing the response message of the second command, to obtain the lifecycle state
of the first AID; and
updating the lifecycle state that is of the first AID and that is stored in the non-volatile
memory.
5. The method according to claim 1, wherein the obtaining an application identifier AID
of a contactless application in the first SE specifically comprises:
sending a third command to the first SE, wherein the third command is used to obtain
AIDs of all contactless applications in the first SE, and receiving a response message,
sent by the first SE, of the third command; and
parsing the response message of the third command, to obtain a third AID, wherein
the third AID is an AID in the response message of the third command.
6. The method according to claim 5, wherein after the obtaining a third AID, the method
further comprises:
comparing the third AID with all AIDs stored in a non-volatile memory of the NFC terminal;
and
if the third AID is different from all the AIDs stored in the non-volatile memory,
obtaining an identifier SE ID of the first SE, and saving, in the non-volatile memory,
a data record that comprises at least the third AID and the SE ID.
7. The method according to claim 6, wherein after the comparing the third AID with all
AIDs stored in a non-volatile memory of the NFC terminal, the method further comprises:
if the third AID is the same as one AID stored in the non-volatile memory, comparing
a first update counter UC value with a second UC value, wherein the first UC value
is a quantity of update times of a contactless application that has the third AID,
and the second UC value is a quantity, stored in the non-volatile memory, of update
times of the contactless application that has the third AID;
if the first UC value is different from the second UC value, sending a fourth command
to the first SE, wherein the fourth command is used to query a lifecycle state of
the third AID, and receiving a response message, sent by the first SE, of the fourth
command;
parsing the response message of the fourth command, to obtain the lifecycle state
of the third AID; and
updating the lifecycle state and the UC values that are of the third AID and that
are stored in the non-volatile memory.
8. An information processing method, comprising:
receiving application change notification information sent by a server; and
obtaining an application identifier AID of a contactless application in a first secure
element SE, wherein the first SE is an SE that is in a near field communication NFC
terminal and that communicates with the server.
9. The method according to claim 8, wherein the obtaining an AID of a contactless application
in a first SE specifically comprises:
parsing the application change notification information, to obtain an AID in the application
change notification information.
10. The method according to claim 8, wherein the obtaining an application identifier AID
of a contactless application in a first SE specifically comprises:
sending a first command to the first SE, wherein the first command is used to query
a quantity of update times of all contactless applications in the first SE, and receiving
a response message, sent by the first SE, of the first command;
parsing the response message of the first command, to obtain a first global update
counter GUC value, wherein the first GUC value is the quantity of update times of
all the contactless applications in the first SE; and
when the first GUC value is different from a second GUC value, obtaining a first AID,
wherein the first AID is an AID in the response message of the first command, and
the second GUC value is a quantity, stored in a non-volatile memory of the NFC terminal,
of update times of all the contactless applications in the first SE.
11. The method according to claim 8, wherein the obtaining an application identifier AID
of a contactless application in a first SE specifically comprises:
sending a third command to the first SE, wherein the third command is used to obtain
AIDs of all contactless applications in the first SE, and receiving a response message,
sent by the first SE, of the third command; and
parsing the response message of the third command, to obtain a third AID, wherein
the third AID is an AID in the response message of the third command.
12. The method according to claim 9, wherein after the obtaining an AID in the application
change notification information, the method further comprises:
comparing the first AID with all AIDs stored in the non-volatile memory; and
if the first AID is different from all the AIDs stored in the non-volatile memory,
obtaining an identifier SE ID of the first SE, and saving, in the non-volatile memory,
a data record that comprises at least the first AID and the SE ID.
13. The method according to claim 12, wherein after the comparing the first AID with all
AIDs stored in the non-volatile memory, the method further comprises:
if the first AID is the same as one AID stored in the non-volatile memory, sending
a second command to the first SE, wherein the second command is used to query a lifecycle
state of the first AID, and receiving a response message, sent by the first SE, of
the second command;
parsing the response message of the second command, to obtain the lifecycle state
of the first AID; and
updating the lifecycle state that is of the first AID and that is stored in the non-volatile
memory.
14. The method according to claim 10, wherein after the obtaining a first AID, the method
further comprises:
comparing the first AID with all AIDs stored in the non-volatile memory; and
if the first AID is different from all the AIDs stored in the non-volatile memory,
obtaining an identifier SE ID of the first SE, and saving, in the non-volatile memory,
a data record that comprises at least the first AID and the SE ID.
15. The method according to claim 14, wherein after the comparing the first AID with all
AIDs stored in the non-volatile memory, the method further comprises:
if the first AID is the same as one AID stored in the non-volatile memory, sending
a second command to the first SE, wherein the second command is used to query a lifecycle
state of the first AID, and receiving a response message, sent by the first SE, of
the second command;
parsing the response message of the second command, to obtain the lifecycle state
of the first AID; and
updating the lifecycle state that is of the first AID and that is stored in the non-volatile
memory.
16. The method according to claim 11, wherein after the obtaining a third AID, the method
further comprises:
comparing the third AID with all AIDs stored in a non-volatile memory of the NFC terminal;
and
if the third AID is different from all the AIDs stored in the non-volatile memory,
obtaining an identifier SE ID of the first SE, and saving, in the non-volatile memory,
a data record that comprises at least the one AID that participates in the comparison
and the SE ID.
17. The method according to claim 16, wherein after the comparing the third AID with all
AIDs stored in a non-volatile memory of the NFC terminal, the method further comprises:
if the third AID is the same as one AID stored in the non-volatile memory, comparing
a first update counter UC value with a second UC value, wherein the first UC value
is a quantity of update times of a contactless application that has the third AID,
and the second UC value is a quantity, stored in the non-volatile memory, of update
times of the contactless application that has the third AID;
if the first UC value is different from the second UC value, sending a fourth command
to the first SE, wherein the fourth command is used to query a lifecycle state of
the third AID, and receiving a response message, sent by the first SE, of the fourth
command;
parsing the response message of the fourth command, to obtain the lifecycle state
of the third AID; and
updating the lifecycle state and the UC values that are of the third AID and that
are stored in the non-volatile memory.
18. A near field communication NFC terminal, comprising:
a secure element SE interface, configured to connect an SE to the NFC terminal;
a non-volatile memory, configured to store an application identifier AID of a contactless
application in the SE;
a Transmission Control Protocol TCP port; and
a processor, connected to the non-volatile memory, the SE interface, and the TCP port
by using a bus, and configured to:
monitor a state of a TCP connection that is established by at least one secure element
SE in a near field communication NFC terminal to a server by using a Transmission
Control Protocol TCP port of the NFC terminal;
when monitoring that the state of the TCP connection is disconnected, determine a
first SE from the at least one SE, wherein the first SE is an SE corresponding to
a TCP port whose TCP connection is disconnected; and
obtain an application identifier AID of a contactless application in the first SE.
19. The NFC terminal according to claim 18, wherein the processor is further configured
to:
send a first command to the first SE, wherein the first command is used to query a
quantity of update times of all contactless applications in the first SE, and receive
a response message, sent by the first SE, of the first command;
parse the response message of the first command, to obtain a first global update counter
GUC value, wherein the first GUC value is the quantity of update times of all the
contactless applications in the first SE; and
when the first GUC value is different from a second GUC value, obtain a first AID,
wherein the first AID is an AID in the response message of the first command, and
the second GUC value is a quantity, stored in a non-volatile memory of the NFC terminal,
of update times of all the contactless applications in the first SE.
20. The NFC terminal according to claim 19, wherein the processor is further configured
to:
after obtaining the first AID, compare the first AID with all AIDs stored in the non-volatile
memory; and
if the first AID is different from all the AIDs stored in the non-volatile memory,
obtain an identifier SE ID of the first SE, and save, in the non-volatile memory,
a data record that comprises at least the first AID and the SE ID.
21. The NFC terminal according to claim 20, wherein the processor is further configured
to:
after comparing the first AID with all the AIDs stored in the non-volatile memory,
if the first AID is the same as one AID stored in the non-volatile memory, send a
second command to the first SE, wherein the second command is used to query a lifecycle
state of the first AID, and receive a response message, sent by the first SE, of the
second command;
parse the response message of the second command, to obtain the lifecycle state of
the first AID; and
update the lifecycle state that is of the first AID and that is stored in the non-volatile
memory.
22. The NFC terminal according to claim 18, wherein the processor is further configured
to:
send a third command to the first SE, wherein the third command is used to obtain
AIDs of all contactless applications in the first SE, and receive a response message,
sent by the first SE, of the third command; and
parse the response message of the third command, to obtain a third AID, wherein the
third AID is an AID in the response message of the third command.
23. The NFC terminal according to claim 22, wherein the processor is further configured
to:
after obtaining the third AID, compare the third AID with all AIDs stored in a non-volatile
memory of the NFC terminal; and
if the third AID is different from all the AIDs stored in the non-volatile memory,
obtain an identifier SE ID of the first SE, and save, in the non-volatile memory,
a data record that comprises at least the third AID and the SE ID.
24. The NFC terminal according to claim 23, wherein the processor is further configured
to:
after comparing the third AID with all the AIDs stored in the non-volatile memory
of the NFC terminal, if the third AID is the same as one AID stored in the non-volatile
memory, compare a first update counter UC value with a second UC value, wherein the
first UC value is a quantity of update times of a contactless application that has
the third AID, and the second UC value is a quantity, stored in the non-volatile memory,
of update times of the contactless application that has the third AID;
if the first UC value is different from the second UC value, send a fourth command
to the first SE, wherein the fourth command is used to query a lifecycle state of
the third AID, and receive a response message, sent by the first SE, of the fourth
command;
parse the response message of the fourth command, to obtain the lifecycle state of
the third AID; and
update the lifecycle state and the UC values that are of the third AID and that are
stored in the non-volatile memory.
25. The NFC terminal according to claim 18, wherein the processor is further configured
to:
receive application change notification information sent by a server; and
obtain an application identifier AID of a contactless application in a first secure
element SE, wherein the first SE is an SE that is in a near field communication NFC
terminal and that communicates with the server.
26. The NFC terminal according to claim 25, wherein the processor is further configured
to:
parse the application change notification information, to obtain an AID in the application
change notification information.
27. The NFC terminal according to claim 25, wherein the processor is further configured
to:
send a first command to the first SE, wherein the first command is used to query a
quantity of update times of all contactless applications in the first SE, and receive
a response message, sent by the first SE, of the first command;
parse the response message of the first command, to obtain a first global update counter
GUC value, wherein the first GUC value is the quantity of update times of all the
contactless applications in the first SE; and
when the first GUC value is different from a second GUC value, obtain a first AID,
wherein the first AID is an AID in the response message of the first command, and
the second GUC value is a quantity, stored in a non-volatile memory of the NFC terminal,
of update times of all the contactless applications in the first SE.
28. The NFC terminal according to claim 25, wherein the processor is further configured
to:
send a third command to the first SE, wherein the third command is used to obtain
AIDs of all contactless applications in the first SE, and receive a response message,
sent by the first SE, of the third command; and
parse the response message of the third command, to obtain a third AID, wherein the
third AID is an AID in the response message of the third command.
29. The NFC terminal according to claim 26, wherein the processor is further configured
to:
after obtaining the AID in the application change notification information, compare
the first AID with all AIDs stored in the non-volatile memory; and
if the first AID is different from all the AIDs stored in the non-volatile memory,
obtain an identifier SE ID of the first SE, and save, in the non-volatile memory,
a data record that comprises at least the first AID and the SE ID.
30. The NFC terminal according to claim 29, wherein the processor is further configured
to:
after comparing the first AID with all the AIDs stored in the non-volatile memory,
if the first AID is the same as one AID stored in the non-volatile memory, send a
second command to the first SE, wherein the second command is used to query a lifecycle
state of the first AID, and receive a response message, sent by the first SE, of the
second command;
parse the response message of the second command, to obtain the lifecycle state of
the first AID; and
update the lifecycle state that is of the first AID and that is stored in the non-volatile
memory.
31. The NFC terminal according to claim 27, wherein the processor is further configured
to:
after obtaining the first AID, compare the first AID with all AIDs stored in a non-volatile
memory; and
if the first AID is different from all the AIDs stored in the non-volatile memory,
obtain an identifier SE ID of the first SE, and save, in the non-volatile memory,
a data record that comprises at least the first AID and the SE ID.
32. The NFC terminal according to claim 31, wherein the processor is further configured
to:
after comparing the first AID with all the AIDs stored in the non-volatile memory,
if the first AID is the same as one AID stored in the non-volatile memory, send a
second command to the first SE, wherein the second command is used to query a lifecycle
state of the first AID, and receive a response message, sent by the first SE, of the
second command;
parse the response message of the second command, to obtain the lifecycle state of
the first AID; and
update the lifecycle state that is of the first AID and that is stored in the non-volatile
memory.
33. The NFC terminal according to claim 28, wherein the processor is further configured
to:
after obtaining the third AID, compare the third AID with all AIDs stored in a non-volatile
memory of the NFC terminal; and
if the third AID is different from all the AIDs stored in the non-volatile memory,
obtain an identifier SE ID of the first SE, and save, in the non-volatile memory,
a data record that comprises at least the one AID that participates in the comparison
and the SE ID.
34. The NFC terminal according to claim 33, wherein the processor is further configured
to:
after comparing the third AID with all the AIDs stored in the non-volatile memory
of the NFC terminal, if the third AID is the same as one AID stored in the non-volatile
memory, compare a first update counter UC value with a second UC value, wherein the
first UC value is a quantity of update times of a contactless application that has
the third AID, and the second UC value is a quantity, stored in the non-volatile memory,
of update times of the contactless application that has the third AID;
if the first UC value is different from the second UC value, send a fourth command
to the first SE, wherein the fourth command is used to query a lifecycle state of
the third AID, and receive a response message, sent by the first SE, of the fourth
command;
parse the response message of the fourth command, to obtain the lifecycle state of
the third AID; and
update the lifecycle state and the UC values that are of the third AID and that are
stored in the non-volatile memory.