Detailed Description
In the following description, numerous technical details are set forth in order to provide a better understanding of the present application. However, it will be understood by those skilled in the art that the technical solutions claimed in the present application can be implemented without these technical details and with various changes and modifications based on the following embodiments.
In order to make the objects, technical solutions and advantages of the present invention more apparent, embodiments of the present invention will be described in detail with reference to the accompanying drawings.
In the present embodiment, a description is given by taking an example of writing a long multimedia message Notification record (MMS Notification) in an SIM card, where the MMS Notification record is divided into 2 components and is respectively stored in EF of record typeMMsNAnd EFEXT8In (1) by EFMMsNAs a flag bit for marking whether the data has been completely written into the SIM card. The specific flow is shown in figure 1.
In step 110, the mobile terminal sends a message to the SIM cardA special command APDU, to EFMMsNThe flag bit in (1) is assigned to a particular value (e.g., assigned to 1) indicating that data is being written.
Specifically, when the multimedia message notification record is long (if 2 EFs need to be occupied), the multimedia message notification record is usually stored in the EFMMsNAnd EFEXT8In (1). Wherein, EFMMsNThe recording format of the beginning part containing the multimedia message notification is shown in table 1:
TABLE 1
The X +4 th byte "Extension file record number" identifies that the information Extension part of the same multimedia message notification record is located in EFEXT8Record number in (1). In addition, on the basis of the 3 GPP-specified recording format, an X +5 th byte "Dirty Flag" is added, and the format thereof includes 8 bits "b 1" to "b 8", a "b 1" as a Flag for marking whether data has been completely written into the SIM card, and "b 2" to "b 8" as reserved bits that can be used in the future, as shown in fig. 2.
In the prior art, at least two command APDUs are required to be sent by a mobile terminal to update a certain long multimedia message notification message from an SIM, wherein a first write command APDU updates an EFEXT8Of a second write command APDU updates the EFMMsNOne record in (2).
In this embodiment, the mobile terminal writes the EFEXT8Before, a special command APDU is sent to the SIM card, and the EF is sentMMsNThe "b 1" in the middle X +5 byte is assigned a particular value (e.g., assigned a value of 1) indicating that data is being written.
In step 120, the mobile terminal sends a write command APDU to the SIM card to update the EFEXT8The recording of (1).
Then, atIn step 130, the mobile terminal sends a write command APDU to the SIM card to update the EFMMsNAnd, at the same time, the EFMMsN"b 1" in byte X +5 is reset, i.e., "b 1" is assigned a specific value, such as 0, indicating that the data has been completely written.
In the embodiment, a data record with a relatively large length is currently written by using a bit (bit) mark in the EF file, and whether the writing of the data record is completed is identified by the value of the bit. Therefore, when the mobile terminal or the SIM is abnormal or suddenly powered off, the mobile terminal can know that the content part of the updated data is lost through the value of the bit, that is, the data record is an incorrect data record, so that the data being updated in the SIM card can be judged as invalid data, so that the data can be rewritten or deleted after the mobile terminal or the SIM is recovered to be normal or powered on again, and the accuracy of the updated data in the SIM card is ensured.
Moreover, when the current mobile terminal updates data, if a plurality of EFs need to be occupied, the write command of the EF occupied by the information extension part is generally sent first, and finally, the write command of the basic EF with the extension record identifier is sent. Thus, this embodiment writes to EFEXT8Before, EF beginsMMsNThe value of "b 1" in the middle X +5 byte is assigned as a specific value indicating that data is being written, and when the last write command APDU is sent, not only the EF is updatedMMsNThe recorded multimedia message notification information is recorded, and meanwhile, the flag bit 'b 1' is reset to 0, which indicates that the operation of writing data is completely finished, and the existing mobile terminal does not need to be changed greatly, so that the embodiment can be conveniently applied.
A second embodiment of the present invention relates to a method of writing data in a SIM card. The second embodiment is substantially the same as the first embodiment, differing primarily in that: in the first embodiment, before sending the first write command to the SIM card, the mobile terminal sends a command for assigning a flag bit to the SIM card, and assigns the flag bit to indicate that data is being writtenThen sends the EF occupied by the information extension portion (i.e., EF)EXT8) Finally sends the EF containing the flag bit (i.e. EF)MMsN) At sending EFMMsNThe write command of (2) indicates that the flag bit is reset.
However, in this embodiment (as shown in fig. 3), the mobile terminal first sends EF (i.e. EF) containing flag bit to the SIM cardMMsN) And indicates in the write command that flag bit "b 1" be assigned to a particular value indicating that data is being written. Then, the EF occupied by the information extension part is sent again (namely, the EFEXT8) The write command of (1). And finally, sending an APDU again, resetting the flag bit and indicating that the operation of writing data is completely finished.
In addition, it can be understood that, in addition to the first and second embodiments of the present application, other implementation manners are also possible, for example, before the mobile terminal sends the first write command to the subscriber identity module card, the mobile terminal sends a command for assigning a flag bit to the subscriber identity module card, and assigns the flag bit to a specific value indicating that data is being written. After the writing of the data is completed, a command for resetting the flag bit is sent to the SIM card. That is, the assignment of the flag bits is realized by a separate command regardless of the execution order of the write commands.
A third embodiment of the present invention relates to a method of writing data in a SIM card. The third embodiment is substantially the same as the first embodiment, and differs mainly in that: in the first embodiment, the bit "b 1" as the flag bit is a bit in one byte (X +5 bytes) added in the EF. However, in the present embodiment, the bits as the flag bits are bits that are not effectively used in the byte defined by the specification in EF, and a description will be given below by taking as an example writing a long Mailbox number record (Mailbox numbering Numbers) in the sim card.
The mailbox number record is divided into multiple components and stored in EFMBDNAnd EFEXT6In (1). Wherein, EFMBDNContaining records of mailbox numbersAt the beginning, the record format is shown in table 2:
TABLE 2
The X +2 th byte "TON and NPI" identifies the type of mailbox number, but the "b 8" of this byte is always 1 and is not used effectively, so in this embodiment, this "b 8" can be used as a "flag bit", i.e., the whole byte format is as shown in fig. 4.
The updating process of the mailbox number record is similar to that of the first embodiment, that is, before sending the first write command to the SIM card, the mobile terminal sends a command for assigning the flag bit to the SIM card, and then the EF is assignedMBDNThe "b 8" of the X +2 th byte is assigned a specific value indicating that data is being written, and then the EF occupied by the information extension (i.e., EF) is transmittedEXT6) Finally sends the EF containing the flag bit (i.e. EF)MBDN) At sending EFMBDNThe flag bit is reset as instructed in the write command of (1), and will not be described in detail herein.
It is easy to find that, in this embodiment, by using a bit that has been defined by the 3GPP specification but is not effectively used in the EF file to mark that a data record with a relatively large length is currently being written, all currently commercially available SIM cards can support the implementation of the technical solution of the present invention.
In addition, it is understood that the bits as the flag bits may be other idle bits or bits that are assigned but have no practical meaning.
A fourth embodiment of the present invention relates to a method of writing data in a SIM card. The embodiment is further improved on the basis of the third embodiment, and the main improvement is as follows: in the third embodiment, the updated mailbox number record is a complete data record, that is, the flag bit indicates the complete data to be updated; in the present embodiment, the flag indicating whether the operation of writing data has been completed completely indicates whether the update of one component in the data to be updated has been completed completely.
For example, the mobile terminal needs to update a certain record in the user's phone book, and needs to update the following 3 files:
EFADN(Abbreviated dialling numbers),EFEXT1(E×tension1),EFANR(Additional Number)
wherein, EFADN(Abbreviated calling numbers) and EFEXT1(E × tension1) is used to store a long main number, EFANR(Additional Number) and EFEXT1(E × tension1) is used to store a long secondary number. Whether the updating operation of the primary number and the secondary number is completely finished or not is indicated through the two flag bits respectively.
Due to EFADNAnd EFANRRecording format and EFMBDNThe recording formats of (a) are completely similar. Therefore, like the third embodiment, EF is used in the present embodimentADNAnd EFANRThe "b 8" in the X +2 th bytes "TON and NPI" of these two EF bits is used as a flag. Moreover, since in the prior art, the update flow of the record is generally as follows:
for simplicity, this embodiment only considers a case where the extension parts of the primary number and the secondary number are short. Updating the subscriber's directory entry to the SIM by the mobile terminal requires sending four command APDUs, the first of which updates the EFEXT1Of (2) one record (storing the second half of the secondary number), the second write command APDU updating the EFANROne record (storing the first half of the secondary number), and a third write command APDU to update the EFEXT1Of the fourth write command APDU updates the EFADNOne record (first half of the main number stored)
Therefore, for better compatibility with the prior art, the update procedure of the present embodiment is actually similar to that of the third embodiment, and specifically as follows:
before sending the first write command APDU, adding a special command APDU to update EFANRThe role of (1) is to record the EFANRThe flag bit in the record (i.e., "b 8" in the X +2 th byte "TONAND NPI") is assigned a particular value, such as 0, indicating that data is being written. Then sends APDU update EF to SIM according to the original sequenceEXT1The recording of (1). Then sends an updated EFANRWhen APDU is written, not only EF is updatedANRThe flag bit is reset to 1, indicating that the operation of writing the sub-number is completed. Before the original third write command APDU (the second half of the main number), a special command APDU is added, and the EF is converted into the first halfADNThe flag bit in the record (i.e., "b 8" in the X +2 th byte "TON and NPI") is assigned a value that indicates that data is being written, such as 0. Then sends APDU update EF to SIM according to the original sequenceEXT1The recording of (1). Then sends an updated EFADNWhen APDU is written, not only EF is updatedADNWhile also resetting the dirty flag bit to 1, indicating that the operation of writing the main number has been completed.
It is readily appreciated that as communications technologies develop, the capacity of a single SIM card data record increases, such as a large-capacity subscriber directory record, a subscriber record including a subscriber's primary telephone number, secondary telephone number, email address, primary name string, secondary name string, corresponding telecommunications bearer capability, corresponding directory packet information, and so on, may be stored in a distribution of dozens of different but interrelated EFs. Therefore, in the present embodiment, when the data size being updated is relatively large, the large data size can be divided into a plurality of components, and when each component is written into the SIM card, whether the data of the component is completely written is identified by the flag bit in the EF. That is, by marking a plurality of components currently writing a data record with a large data volume with one bit of each associated EF file, so that the mobile terminal or the SIM is abnormal or suddenly powered down, a specific component of the data being updated in the SIM card can be determined to be invalid. After the mobile terminal or the SIM returns to normal, the part of data can be rewritten or deleted.
It should be noted that, in each of the above embodiments, the data to be written into the SIM card occupies a plurality of different EFs, and the EF occupied by the information extension portion and the EF including the flag bit are different EFs. In practical application, however, when the data to be written into the SIM card only occupies one EF, but multiple write commands need to be asynchronously sent to the SIM card when the data is written, the above embodiment of the present application may also be adopted, that is, one bit in the occupied EF is used as a flag bit for marking whether the data has been completely written into the SIM card, and in the process of writing the data, the flag bit is assigned as a specific value indicating that the data is being written; after the writing of the data is completed, the flag bit is assigned to a specific value indicating that the data has been completely written.
Additionally, method embodiments of the present invention may be implemented in software, hardware, firmware, and the like. Whether implemented in software, hardware, or firmware, the instruction code may be stored in any type of computer-accessible memory (e.g., permanent or modifiable, volatile or non-volatile, solid or non-solid, fixed or removable, etc.). Also, the Memory may be, for example, Programmable Array Logic (PAL), Random Access Memory (RAM), Programmable Read Only Memory (PROM), Read-Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), a magnetic disk, an optical disk, a Digital Versatile Disk (DVD), or the like.
A fifth embodiment of the present invention relates to a mobile terminal including:
the judging module is used for judging whether the data to be written into the SIM card needs to occupy at least two basic files EF or whether the data needs to asynchronously send a plurality of writing commands to the SIM card when being written into the SIM card although only one EF is occupied; and the assignment module is used for assigning the zone bit to a specific value indicating that the data is being written in the write-in process of the data, and assigning the zone bit to a specific value indicating that the data is completely written in the write-in process after the write-in of the data is completed. The flag bit is a bit in EF and is used to mark whether the data has been completely written into the SIM card. The judging module indicates the assignment module to assign the flag bit when judging that the data needs to occupy at least two basic files EF or only occupies one EF but needs to asynchronously send a plurality of write commands to the SIM card when writing the data.
Wherein, the assignment module comprises the following sub-modules:
and the write command submodule is used for writing data into the SIM card by sending a write command to the SIM card.
And the special value setting submodule is used for assigning the zone bit to a special value by sending a setting command to the SIM card. Before the write command submodule sends the first write command to the SIM card, the specific value setting submodule sends a setting command to the SIM card and assigns the flag bit to a specific value representing that data is being written.
The write command submodule first sends a write command of the EF occupied by the information extension portion to the SIM card, and finally sends a write command of the EF including the flag bit, and in the write command sent finally, indicates the specific value setting submodule to reset the flag bit, it should be noted that these EFs may also be the same EF.
In the present embodiment, the bits as the flag bits are bits in one byte added to EF.
Because the embodiment utilizes a flag bit (dirty flag bit) in the EF file to mark that a data record with a relatively large length is currently written, if the mobile terminal or the SIM is abnormal or suddenly powered off, the data which is being updated but has not been updated in the SIM card can be determined as invalid data. After the mobile terminal or the SIM recovers to be normal, the dirty flag bit can be read for identification, and then the data is selected to be rewritten or deleted.
It is to be understood that the first embodiment is a method embodiment corresponding to the present embodiment, and the present embodiment can be implemented in cooperation with the first embodiment. The related technical details mentioned in the first embodiment are still valid in this embodiment, and are not described herein again in order to reduce repetition. Accordingly, the related-art details mentioned in the present embodiment can also be applied to the first embodiment.
A sixth embodiment of the present invention relates to a mobile terminal, and is basically the same as the fifth embodiment except that: in a fifth embodiment, before the write command submodule sends the first write command to the SIM card, the specific value setting submodule of the assignment module sends the set command to the SIM card first, and assigns the flag bit to the specific value indicating that data is being written, and the write command submodule sends the write command of the EF occupied by the information extension portion to the SIM card first, and finally sends the write command of the EF including the flag bit, and in the write command sent last, instructs the specific value setting submodule to reset the flag bit.
However, in this embodiment, the write command submodule in the assignment module first sends a write command including the EF of the flag bit to the SIM card, and indicates the specific value setting submodule in the write command to assign the flag bit to the specific value indicating that data is being written, and then sends the write command of the EF occupied by the information extension portion to the SIM card. And the specific value setting submodule sends a command for resetting the zone bit to the SIM card after the write command submodule sends the last write command.
It is to be understood that the second embodiment is a method embodiment corresponding to the present embodiment, and the present embodiment can be implemented in cooperation with the second embodiment. The related technical details mentioned in the second embodiment are still valid in this embodiment, and are not described herein again in order to reduce repetition. Accordingly, the related-art details mentioned in the present embodiment can also be applied to the second embodiment.
A seventh embodiment of the present invention relates to a mobile terminal, and is basically the same as the fifth embodiment except that: in the fifth embodiment, the bit as the flag bit is a bit in one byte added to EF; in the present embodiment, the bits as the flag bits are bits that are not effectively utilized in the byte defined by the specification, and if a longer Mailbox number record (Mailbox numbering Numbers) is written in the SIM card, the EF is setMBDN"b 8" of the X +2 th byte "TON and NPI" is used as a flag bit.
In the embodiment, a bit which is already defined by the specification of the 3GPP SIM card but is not effectively utilized in the EF file is used to mark that a data record with a relatively large length is currently written, so that all currently commercial SIM cards or SIM cards conforming to the specification of the 3GPP SIM card can support the realization that the integrity of the data record in the SIM card can be recognized by the mobile terminal, thereby ensuring the accuracy of the updated data in the SIM card.
It is to be understood that the third embodiment is a method embodiment corresponding to the present embodiment, and the present embodiment can be implemented in cooperation with the third embodiment. The related technical details mentioned in the third embodiment are still valid in this embodiment, and therefore, in order to reduce the repetition, the details are not described here. Accordingly, the related-art details mentioned in the present embodiment can also be applied to the third embodiment.
An eighth embodiment of the present invention relates to a mobile terminal, and the present embodiment is basically the same as the seventh embodiment except that: in the seventh embodiment, it is indicated by the flag whether the writing operation of the complete data to be updated (e.g. a mailbox number record) has been completed completely; in the present embodiment, the flag indicating whether the operation of writing data has been completed completely indicates whether the update of one component in the data to be updated has been completed completely.
For example, by updating EFADN、EFEXT1And EFANRWriting a longer record (containing a long primary number and a long secondary number) in the user's telephone directory into the SIM card, then passing through EFANR"b 8" in "TON and NPI" of the X +2 th byte, marks whether the secondary number information has been completely written into the SIM card; by EFADNThe "b 8" in the X +2 th byte "TON and NPI" marks whether the primary number information has been completely written into the SIM card.
It is to be understood that the fourth embodiment is a method embodiment corresponding to the present embodiment, and the present embodiment can be implemented in cooperation with the fourth embodiment. The related technical details mentioned in the fourth embodiment are still valid in this embodiment, and therefore, in order to reduce the repetition, the details are not described here. Accordingly, the related-art details mentioned in the present embodiment can also be applied to the fourth embodiment.
It should be noted that, each unit mentioned in each device embodiment of the present invention is a logical unit, and physically, one logical unit may be one physical unit, or may be a part of one physical unit, or may be implemented by a combination of multiple physical units, and the physical implementation manner of these logical units itself is not the most important, and the combination of the functions implemented by these logical units is the key to solve the technical problem provided by the present invention. Furthermore, the above-mentioned embodiments of the apparatus of the present invention do not introduce elements that are less relevant for solving the technical problems of the present invention in order to highlight the innovative part of the present invention, which does not indicate that there are no other elements in the above-mentioned embodiments of the apparatus.
While the invention has been shown and described with reference to certain preferred embodiments thereof, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention.