Application upgrade method, smart card and electronic device

By introducing upgrade patch applications and upgrade space in smart cards and unbinding old application code and data, the update complexity problem caused by the coupling of application code and data in smart cards is solved, a flexible and reliable application upgrade process is achieved, and storage space utilization and user experience are improved.

CN119987813BActive Publication Date: 2025-09-30GUANGDONG CHUTIAN DRAGON SMART CARD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510118215.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-24
Publication Date
2025-09-30
Estimated Expiration
2045-01-24

AI Technical Summary

Technical Problem

In smart cards, application code and application data are highly coupled, resulting in a complex update process and high resource consumption. It is impossible to update the application code alone while retaining the application data, which affects the flexibility and efficiency of the smart card.

Method used

By introducing upgrade patch applications and upgrade spaces, unbundling old application code and data, saving application data to the upgrade space, and loading new application code, data independence and efficient use of storage space are ensured, and a dedicated interface is used to manage the separation and recovery process of data and code.

Benefits of technology

It enables flexible upgrades of smart card applications, reduces storage resource waste, simplifies personalized operations between suppliers, and improves the reliability of the upgrade process and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119987813B_ABST
    Figure CN119987813B_ABST
Patent Text Reader

Abstract

The present invention provides an application upgrade method, a smart card, and an electronic device, comprising: upon receiving an upgrade patch application and new application code of a target application sent by a terminal device, installing the upgrade patch application; creating an upgrade space for performing the upgrade operation of the target application; saving application data of the target application to the upgrade space based on the upgrade patch application, unbinding the old application code and application data of the target application, and deleting the unbound old application code; loading the new application code; obtaining the application data saved in the upgrade space, and associating the application data with the new application code based on the upgrade patch application to complete the upgrade operation of the target application. By applying the upgrade patch, the application data can be separated from the old application code during the upgrade process, thereby simplifying the application upgrade process and improving the flexibility and space utilization of application upgrades on the smart card.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of smart cards, and in particular to an application upgrading method, a smart card and an electronic device. Background Art

[0002] On smart cards, application code and data are typically stored together, resulting in a high degree of coupling between the two. If the card application needs to be updated, the application data is deleted, making it impossible to update the application code separately while retaining the data. Because each application is typically shared and used by multiple vendors, if the application code and data are not separated, updating the application requires re-customization for each vendor. This makes the update process complex, resource-intensive, and cumbersome. Summary of the Invention

[0003] In view of this, the purpose of the present invention is to provide an application upgrade method, smart card and electronic device, which can separate application data from old application code during the upgrade process, thereby simplifying the application upgrade process, reducing personalized operations between suppliers, and further improving the overall performance of the smart card and the flexibility of application upgrades.

[0004] In a first aspect, an embodiment of the present invention provides an application upgrade method, which is applied to a smart card, and the smart card is communicatively connected to an external terminal device; the method includes: when an upgrade patch application and a new application code of a target application sent by a terminal device are received, installing the upgrade patch application; creating an upgrade space for executing the upgrade operation of the target application, based on the upgrade patch application, saving the application data of the target application to the upgrade space, and unbinding the old application code and application data of the target application, and deleting the unbound old application code; the upgrade space is a continuous memory area; loading the new application code; obtaining the application data saved in the upgrade space, and based on the upgrade patch application, associating the application data with the new application code to complete the upgrade operation of the target application.

[0005] Furthermore, the method further includes: after the upgrade operation is completed, reclaiming the upgrade space and deleting the upgrade patch application.

[0006] Furthermore, the upgrade patch application includes an upgrade management interface; the upgrade management interface includes a data save interface; the application data includes personalized data, application registration information and application implementation data; an upgrade space is created for performing an upgrade operation of the target application, and based on the upgrade patch application, the application data of the target application is saved to the upgrade space, including: creating an upgrade space in response to an upgrade application instruction sent by the terminal device; obtaining an object data index and an array data index of the application implementation data in the application data; calling the data save interface to save the personalized data, application registration information, object data index and array data index to the upgrade space.

[0007] Furthermore, the step of obtaining the object data index and array data index of the application implementation data in the application data includes: obtaining the application implementation data in the application data; the application implementation data includes object data and array data; the object data includes fields; the array data includes elements; traversing each field in the application implementation data to determine the field memory address corresponding to each field; traversing each element in the application implementation data to determine the element memory address corresponding to each element; generating the object data index based on the correspondence between the field and the field memory address; generating the array data index based on the correspondence between the element and the element memory address.

[0008] Furthermore, the upgrade patch application includes an upgrade management interface; the upgrade management interface includes a data decoupling interface and a data deletion interface; and the steps of unbinding the old application code and application data of the target application and deleting the unbound old application code include: calling the data decoupling interface to unbind the old application code from the application data to obtain the unbound old application code; calling the data deletion interface to delete the unbound old application code.

[0009] Furthermore, the step of loading the new application code includes: responding to the new application loading instruction sent by the terminal device and loading the new application code.

[0010] Furthermore, the upgrade patch application includes an upgrade management interface; the upgrade management interface includes a recovery data interface; the application data includes personalized data, application registration information and application implementation data; the steps of obtaining the application data stored in the upgrade space, and based on the upgrade patch application, associating the application data with the new application code to complete the upgrade operation of the target application include: responding to the upgrade data restore instruction sent by the terminal device, obtaining the application data stored in the upgrade space; calling the recovery data interface, adapting the personalized data, application registration information and application implementation data to the new application code, and establishing an association relationship between the application data and the new application code; performing an initialization operation on the target application to complete the upgrade operation of the target application.

[0011] Furthermore, the upgrade patch application includes an upgrade management interface; the upgrade management interface includes an upgrade status management interface; after performing an initialization operation on the target application to complete the upgrade operation of the target application, the method also includes: identifying the initialization operation result of the initialization operation; if the initialization operation result is initialization success, generating upgrade success information, and sending the upgrade success information to the terminal device through the upgrade status management interface; if the initialization operation result is initialization failure, generating upgrade failure information, and sending the upgrade failure information to the terminal device through the upgrade status management interface.

[0012] In a second aspect, an embodiment of the present invention provides a smart card, which is communicatively connected to an external terminal device; the smart card includes: an upgrade application receiving module, which is used to install the upgrade patch application when receiving the upgrade patch application and the new application code of the target application sent by the terminal device; an upgrade space creation module, which is used to create an upgrade space for performing the upgrade operation of the target application, save the application data of the target application to the upgrade space based on the upgrade patch application, unbind the old application code and application data of the target application, and delete the unbound old application code; the upgrade space is a continuous memory area; a new application code loading module, which is used to load the new application code; an application data restoration module, which is used to obtain the application data saved in the upgrade space, and associate the application data with the new application code based on the upgrade patch application to complete the upgrade operation of the target application.

[0013] In a third aspect, an embodiment of the present invention provides an electronic device, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and the processor implements the above-mentioned method when executing the computer program.

[0014] Embodiments of the present invention provide an application upgrade method, smart card, and electronic device, comprising: upon receiving an upgrade patch application and new application code of a target application sent by a terminal device, installing the upgrade patch application; creating an upgrade space for performing the upgrade operation of the target application; saving the target application's application data to the upgrade space based on the upgrade patch application, unbinding the target application's old application code and application data, and deleting the unbound old application code; the upgrade space being a continuous memory area; loading the new application code; obtaining the application data stored in the upgrade space, and associating the application data with the new application code based on the upgrade patch application to complete the upgrade operation of the target application. In this method, application data can be managed independently of the old application code through the upgrade patch application and a dedicated interface. During the upgrade, application data is not directly deleted or overwritten, thereby avoiding the data loss problem during the upgrade process in traditional methods. By introducing the upgrade space to store application data, the old code is unbound from the data during the upgrade process, and the old code that is no longer needed is deleted, saving storage space. Reclaiming the upgrade space reduces storage resource waste. In scenarios where multiple vendors share applications, the separation of application data and code makes the upgrade process more flexible, avoiding the complex process of reconfiguring each upgrade, thereby saving resources and interaction costs. The recovery interface and upgrade status management interface enable flexible restoration of application data during the upgrade process, providing real-time feedback on upgrade success or failure, improving operational reliability and user experience.

[0015] Other features and advantages of the present invention will be described in the following description, and in part will become apparent from the description, or understood by practicing the present invention. The purposes and other advantages of the present invention are realized and obtained by the structures particularly pointed out in the description, claims and drawings.

[0016] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the specific embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0018] Figure 1 A flow chart of the application upgrade method provided by an embodiment of the present invention;

[0019] Figure 2 A flow chart of a method for saving application data provided by an embodiment of the present invention;

[0020] Figure 3 A flow chart of the object data index and the array data index acquisition method provided in an embodiment of the present invention;

[0021] Figure 4 Flowchart of the application data unbinding method provided by an embodiment of the present invention;

[0022] Figure 5 A flow chart of a method for associating application data with new application code provided in an embodiment of the present invention;

[0023] Figure 6 A flow chart of a method for sending initialization operation results provided by an embodiment of the present invention;

[0024] Figure 7 A schematic diagram of a smart card provided in an embodiment of the present invention;

[0025] Figure 8 A schematic diagram of another smart card provided by an embodiment of the present invention.

[0026] Icons: 1-Upgrade application receiving module; 2-Upgrade space creation module; 3-New application code loading module; 4-Application data restoration module; 5-Space recovery module. DETAILED DESCRIPTION

[0027] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0028] A card application (hereafter referred to as an "application") is an application program that runs on the smart card's operating system. If you update a card application, the existing application data is deleted. You can't simply update the application code on the card while retaining the old application data. Because applications are typically shared and used by multiple vendors, updating an application without separating the application code and data requires customization for each vendor.

[0029] In existing technologies, card application upgrades typically involve upgrading both the application code and data as a whole. This means that the old personalized data (application data) is discarded when the application is upgraded. Alternatively, code and data can be kept separate during the upgrade process, but additional code space must still be created on the smart card for the upgraded application. After the upgrade is complete, the space consumed by the upgraded application's functional code is not released and remains stored on the smart card as part of the upgraded application, significantly reducing the utilization of the smart card's storage space.

[0030] The application upgrade method provided in this application optimizes the upgrade process of smart card applications by decoupling application code and application data, and realizes efficient use of storage space, flexible application upgrades and data management.

[0031] To facilitate understanding of this embodiment, the embodiment of the present invention is described in detail below.

[0032] Example 1:

[0033] Figure 1 This is a flow chart of the application upgrade method provided by an embodiment of the present invention.

[0034] The application upgrade method is applied to a smart card, and the smart card is connected to an external terminal device for communication.

[0035] Here, a smart card is a card with an integrated chip that is used for data storage, identity authentication, and application execution. A smart card can be a communication SIM card or a transportation card, etc.

[0036] The terminal device is a hardware device that interacts with the smart card, sending upgrade data and instructions and receiving feedback from the smart card. It can be a mobile device or a card reader. The card application in the SIM card can be updated via a mobile device, while the card application in the transportation card can be updated via a card reader.

[0037] Reference Figure 1 , application upgrade methods, including:

[0038] Step S101: upon receiving the upgrade patch application and the new application code of the target application sent by the terminal device, the upgrade patch application is installed.

[0039] Here, the smart card connects to the terminal device via an external communication interface and receives the upgrade patch application and the new application code for the target application from the terminal device. The upgrade patch application contains code and interfaces specifically designed to manage the upgrade process. When the smart card receives the upgrade content, it first installs the upgrade patch application. The installation of the upgrade patch application is necessary because it provides the logical support and interfaces required for the upgrade process, such as data saving, unbinding, and restoration.

[0040] By installing the upgrade patch application first, you can ensure that subsequent upgrade operations can proceed smoothly without being interfered with by other applications in the card operating system, thus avoiding potential conflicts.

[0041] Step S102: Create an upgrade space for performing the upgrade operation of the target application. Based on the upgrade patch application, save the application data of the target application to the upgrade space, unbind the old application code and application data of the target application, and delete the unbound old application code; the upgrade space is a continuous memory area.

[0042] Here, an independent, contiguous memory area is allocated within the smart card's memory as an upgrade space. This upgrade space is used to temporarily store application data and perform related operations during the upgrade process. The upgrade space ensures that the target application's data can be temporarily preserved during the upgrade process without affecting the current application or resources shared with other applications. After the upgrade is complete, the smart card reclaims the upgrade space.

[0043] Creating an upgrade space ensures efficient data read and write operations without fragmentation when storing application data. This contiguous memory area makes data storage and subsequent recovery more efficient, and reduces the system's frequent memory operations during the upgrade process.

[0044] By creating an independent upgrade space, you can avoid directly operating existing application data, ensuring data integrity and independence during the upgrade process while avoiding impacts on other applications or data.

[0045] Application data includes personalization data, application registration information, and application implementation data.

[0046] The upgrade patch application manages the separation of data and code. By calling an API, the upgrade patch application saves the target application's application data to the upgrade space. The upgrade patch application also calls an API to unbind the target application's old application code and application data. After unbinding, the old application code is deleted, leaving sufficient memory for the new code.

[0047] By unbundling old application code and data, we achieve physical and logical separation of code and data. After unbundling, the old application code is deleted, freeing up storage space and preventing unnecessary redundant data from impacting system performance.

[0048] The above step S102 is further described below in conjunction with some specific implementations. The upgrade patch application includes an upgrade management interface; the upgrade management interface includes a data saving interface; and the application data includes personalized data, application registration information, and application implementation data.

[0049] Here, the upgrade management interface includes one or more of a save data interface, a coupling and decoupling interface, a delete data interface, a restore data interface, and an upgrade status management interface.

[0050] Save data interface: When this interface is called, it is used to save the application data of the old application to the upgrade space.

[0051] Data decoupling interface: When this interface is called, it is used to decouple the old application code from the application data of the old application.

[0052] Delete data interface: When this interface is called, it is used to delete the old application code after the old application code is unbound from the application data of the old application.

[0053] Recovery data interface: When this interface is called, it is used to associate application data with new application code.

[0054] Upgrade status management interface: When this interface is called, it is used to return the upgrade status to the terminal device.

[0055] In one embodiment, referring to Figure 2 The step of creating an upgrade space for performing an upgrade operation of the target application in step S102 and saving the application data of the target application to the upgrade space based on the application of the upgrade patch includes:

[0056] Step S201: creating an upgrade space in response to an application upgrade instruction sent by a terminal device.

[0057] Here, after receiving the application upgrade instruction sent by the terminal device, the smart card calls the upgrade patch application and starts the upgrade space allocation operation through its management interface.

[0058] Dynamically allocate a contiguous memory area of ​​appropriate size based on the specific data volume of the target application to ensure that the space can accommodate all data and index information.

[0059] Create a structured storage layout within the allocated memory area, including reserved locations for personalization data, application registration information, and data indexes.

[0060] Step S202: Obtain the object data index and array data index of the application implementation data in the application data.

[0061] Here, the object data index and the array data index are used to identify and locate different types of data in the target application so that the data can be efficiently stored and restored during the upgrade process.

[0062] The upgrade patch application parses the application implementation data of the target application program and obtains the structure and storage location of each application implementation data.

[0063] The above step S202 is further described below in conjunction with some specific implementations.

[0064] Reference Figure 3 Step S202 includes:

[0065] Step S301, obtaining application implementation data in the application data; the application implementation data includes object data and array data; the object data includes fields; and the array data includes elements.

[0066] Application implementation data refers to the runtime data of the target application, including specific internal structures such as object data and array data. This data is used to support the normal operation of the application, such as user configuration, operation history, or function parameters.

[0067] Object data is a structured data unit that contains multiple fields, each of which stores a specific value (such as a key-value pair).

[0068] Array data is used to store a group of elements arranged in a specific order.

[0069] Step S302: traverse each field in the application implementation data to determine the field memory address corresponding to each field; traverse each element in the application implementation data to determine the element memory address corresponding to each element.

[0070] Here, object data contains multiple fields, each of which has a fixed name and storage location. The field memory address is the specific location of the field in the storage, which is used to identify the data storage location of the field.

[0071] Iterate over each field in the object data, read its name and associated storage location, and obtain the memory address (or storage offset) of each field in the smart card memory.

[0072] Array data consists of multiple elements, each of which has a fixed storage order. The element memory address is the specific location of the element in the memory and is used to identify the data storage location in the array.

[0073] Iterate over each element in the array data, read its content and associated storage location, and obtain the memory address of each element in the smart card memory.

[0074] Step S303: Generate an object data index based on the correspondence between fields and field memory addresses; and generate an array data index based on the correspondence between elements and element memory addresses.

[0075] Here, for each field, a correspondence is established between the field name and its memory address. These correspondences are stored as object data indexes. Object data indexes are usually a set of logical identifiers used to quickly locate the storage location of a field.

[0076] For each element, a correspondence is established between the element's storage location and its index position (e.g., array subscript). These correspondences are stored as array data indices. Array data indices are a set of logical identifiers used to quickly locate the storage location of array elements.

[0077] Step S203: calling the data saving interface to save the personalized data, application registration information, object data index and array data index to the upgrade space.

[0078] Here, the data saving interface is provided by the upgrade patch application and is a core component of data storage. It is responsible for transferring application data and indexes from the storage location of the application to the upgrade space.

[0079] Personalized data refers to the user's personalized settings and preferences. Application registration information includes information such as the application's ID and registration key. Object data indexes identify object data fields. Array data indexes identify array element positions.

[0080] The smart card calls the save data interface through the upgrade patch application, writes the data into the corresponding area of ​​the upgrade space according to type, and records the storage location for subsequent recovery.

[0081] During the upgrade process, all application data is securely saved to the upgrade space to prevent data loss or overwriting. The data saving process is uniformly managed through the data saving interface, reducing the complexity of the upgrade process.

[0082] In one embodiment, referring to Figure 4 In step S102, the steps of unbinding the old application code and application data of the target application and deleting the unbound old application code include:

[0083] Step S401: calling a data decoupling interface to unbind the old application code from the application data to obtain the unbound old application code.

[0084] Here, in the prior art, the target application's code and data (such as personalized data, application registration information, etc.) are stored in the same structure, and the two are tightly coupled logically and in storage, resulting in data being overwritten or deleted when the code is updated.

[0085] The upgrade patch application releases the binding relationship between the old application code and data by calling the data decoupling interface.

[0086] The specific steps to decouple legacy application code from application data include:

[0087] Retrieve the storage locations and dependencies associated with application data in the legacy application code. Remove the code's dependencies on data access, ensuring that the application data can exist independently of the legacy application code. Update the storage mapping table or memory management structures to remove the connection between the data and the legacy application code.

[0088] After data unbinding, the application data is stored independently and retained in the upgrade space, waiting for subsequent operation to resume. The old application code is marked as "unbound" and can be deleted later.

[0089] Through the data decoupling interface, the logical separation of application data and code is achieved, ensuring that data can still be recovered and used after the old code is deleted, avoiding the risk of data loss.

[0090] Step S402: call the delete data interface to delete the unbound old application code.

[0091] Here, after the old application code is decoupled, it no longer has the ability to run or manage. Deleting the old application code can free up storage space on the smart card and provide sufficient memory resources for the new application code.

[0092] The upgrade patch application completely deletes the unbound old application code from the smart card memory by calling the delete data interface.

[0093] The specific steps to completely delete the unbound old application code from the smart card memory include:

[0094] Retrieve the storage location of the old application code and confirm that it has been decoupled and has no subsequent dependencies. Mark the storage area of ​​the old application code as recyclable. Physically remove the old application code content from the storage area to prevent redundant data from remaining.

[0095] At the same time, the code metadata and registration information of the old application code in the smart card system, such as version number, identifier, etc., are cleared.

[0096] Deleting old code frees up storage space, providing resources for loading and running new application code, and preventing potential logic conflicts or security risks between old and new code.

[0097] Step S103: loading new application code.

[0098] After unbinding and deleting the old code, the smart card receives the new application code from the terminal device and loads it into the target application's memory. Loading the new application code updates the target application's functionality, improving performance or adding new functional modules, providing the smart card with the latest functional support.

[0099] The above step S103 is further described below in conjunction with some specific implementations. Step S103 includes:

[0100] In response to the new application loading instruction sent by the terminal device, new application program code is loaded.

[0101] Here, after the code and data of the old application are unbound and the old code is deleted, the terminal device sends a command to the smart card to load the new application code. The command to load the new application is transmitted to the smart card via the communication interface between the smart card and the terminal device (such as NFC, Bluetooth, USB, etc.).

[0102] After receiving the instruction, the smart card will perform the loading operation according to the instruction content.

[0103] Through command control of the terminal device, the process of loading new application code is ensured to be executed on demand, avoiding misoperation or unauthorized code loading.

[0104] Before loading new application code, ensure that the old application code has been deleted and that sufficient storage resources are available in the upgrade space. Verify the integrity and security of the new application code, such as by checking the code signature or checksum.

[0105] The steps to load a new application include:

[0106] Allocate memory space within the smart card to store the new application code. The new application code is transmitted piecemeal to the smart card via the terminal device's communication interface. Encryption or verification mechanisms are used during data transmission to ensure transmission security and data integrity. The received new application code is written to a designated storage area on the smart card. This storage area can be a contiguous memory block to ensure efficient code execution.

[0107] Register a unique identifier (such as version number, application ID) for the new application code in the smart card system. Update the storage management table and mark the new code as loaded.

[0108] Verify that the new code is correctly written to the memory area and perform basic test runs to confirm that there are no obvious errors in the code logic and functionality.

[0109] After the new application code is loaded, you need to restore the application data and initialize the new application to ensure that the upgraded application can run normally.

[0110] Step S104 , obtaining the application data stored in the upgrade space, and associating the application data with the new application code based on the upgrade patch application, so as to complete the upgrade operation of the target application.

[0111] After loading the new application code, the upgrade patch application retrieves the application data previously saved to the upgrade space. It then associates the application data with the new application code based on a specific interface. This ensures compatibility between the old data and the new code, and completes data recovery, allowing the target application to continue running and using the upgraded data with the new code.

[0112] By adapting and associating old data with new application code, data continuity and consistency are guaranteed, allowing upgraded applications to seamlessly use previous personalized data or configuration information, avoiding data loss or functional failures caused by upgrades.

[0113] Next, the above step S104 will be further described in conjunction with some specific implementations. Figure 5 The steps of step S104 include:

[0114] Step S501: In response to an upgrade data restoration instruction sent by a terminal device, application data stored in an upgrade space is obtained.

[0115] After loading the new application code, the terminal device sends an upgrade data restore command to the smart card via the communication interface. This upgrade data restore command triggers the restoration of the old application data and its association with the new application code. The smart card can also automatically retrieve the application data stored in the upgrade space at preset intervals after loading the new application code.

[0116] Before obtaining application data, verify the integrity of the application data, such as verifying the matching of data indexes and stored content, to ensure that the data is not damaged or lost.

[0117] Step S502: calling the data recovery interface to adapt the personalized data, application registration information and application implementation data to the new application code, and establishing an association relationship between the application data and the new application code.

[0118] Here, the recovery data interface provided by the upgrade patch application is used to manage the adaptation and association of data with the new application code.

[0119] The steps to recover personal data include:

[0120] Restore user settings or preference data (such as account information, user configuration) and map personalized data to the corresponding storage structure of the new code.

[0121] The steps to restore application registration information include:

[0122] Restore the application's version number, application ID, and other metadata, and update the registry in the smart card's operating system so that the new code can normally identify and manage this information.

[0123] According to the requirements of the new application code, the compatibility of the data structure of the new application code with the old data is checked to adapt the object data and array data.

[0124] Remap the indexes saved in the upgrade space to the memory management structure of the new code. Through indexes or other adaptation mechanisms, correctly map the old data to the storage structure of the new code to ensure the logical consistency of the data with the new code.

[0125] Step S503: Initialize the target application to complete the upgrade operation of the target application.

[0126] Here, the initialization operation refers to the configuration and startup of the new application code after the data recovery is completed to ensure that it can run normally.

[0127] Initialize the environment variables and dependencies required for application operation. Load the recovered personalized data, registration information, and implementation data into the corresponding memory locations according to the requirements of the new code. Perform basic functional testing to ensure that all modules of the application can operate normally. Mark the application status as initialized, allowing it to enter the normal use stage.

[0128] In one embodiment, referring to Figure 6 After step S403, the method further includes:

[0129] Step S601: Identify the initialization operation result of the initialization operation.

[0130] Here, the initialization operation result is the status information fed back by the target application after the initialization process is completed, which is used to determine whether the upgrade is successful.

[0131] Initialization results include success and failure. Success means the application has successfully loaded the required data and started. Failure means the application failed to load or start properly, which may be caused by data incompatibility, code defects, insufficient storage, or other issues.

[0132] Step S602: If the initialization operation result is successful, generate upgrade success information, and send the upgrade success information to the terminal device through the upgrade status management interface.

[0133] Here, if the identification result is that the initialization is successful, the upgrade patch application will generate an upgrade success message. The upgrade success message includes the application ID, the new application version number, and the initialization success flag status.

[0134] Call the upgrade status management interface to send the upgrade success information from the smart card to the terminal device. After receiving the information, the terminal device can record the upgrade result or notify the user.

[0135] Step S603: If the initialization operation result is initialization failure, an upgrade failure message is generated and sent to the terminal device through the upgrade status management interface.

[0136] If the identification result is initialization failure, the upgrade patch application will generate an upgrade failure message. The upgrade failure message includes the application ID, the failure reason (such as data incompatibility, insufficient storage space, code loading error, etc.), and the initialization failure flag status.

[0137] Call the upgrade status management interface to send the upgrade failure information from the smart card to the terminal device. After receiving the information, the terminal device can prompt the user or take corrective measures (such as retrying the upgrade, performing troubleshooting, etc.).

[0138] In an optional embodiment, the method further includes:

[0139] After the upgrade is complete, reclaim the upgrade space and delete the upgrade patch application.

[0140] Here, after the new application code is loaded, the old data has been restored from the upgrade space and correctly associated with the new code, and the new application is initialized successfully, the smart card calls the storage management function in the upgrade patch application to reclaim the upgrade space.

[0141] The steps to reclaim upgrade space include:

[0142] Delete temporarily saved index data and other temporary information related to the upgrade. Re-mark the upgrade space as available storage for use by other applications or features. Through continuous storage design and memory management algorithms, ensure that the recovery of upgrade space does not cause memory fragmentation.

[0143] The upgrade patch application is a temporary application loaded specifically for the current upgrade task. Its role is limited to assisting the upgrade process, including data saving, unbinding, and restoration operations.

[0144] After the upgrade operation is complete, the upgrade space is successfully reclaimed, and the new application is running correctly and no longer needs to use the upgrade patch application, delete the upgrade patch application.

[0145] The steps to remove the upgrade patch application include:

[0146] Call the smart card operating system's uninstall function to delete the upgrade patch application code and related temporary files. Clear all temporary records or status flags of the patch application in the smart card storage to ensure that the upgrade patch application is completely exited from the system. Release the storage area occupied by the upgrade patch application so that it can be used by other applications.

[0147] An embodiment of the present invention provides an application upgrade method, comprising: upon receiving an upgrade patch application and new application code of a target application from a terminal device, installing the upgrade patch application; creating an upgrade space for performing the upgrade operation of the target application; saving the target application's application data to the upgrade space based on the upgrade patch application, unbinding the target application's old application code and application data, and deleting the unbound old application code; the upgrade space being a continuous memory area; loading the new application code; obtaining the application data stored in the upgrade space, and associating the application data with the new application code based on the upgrade patch application to complete the upgrade operation of the target application. In this method, application data can be managed independently of the old application code through the upgrade patch application and a dedicated interface. During the upgrade, application data is not directly deleted or overwritten, thereby avoiding the data loss problem during the upgrade process in traditional methods. By introducing the upgrade space to store application data, the old code is unbound from the data during the upgrade process, and the old code that is no longer needed is deleted, thereby saving storage space. Reclaiming the upgrade space reduces storage resource waste. In scenarios where multiple vendors share applications, the separation of application data and code makes the upgrade process more flexible, avoiding the complex process of reconfiguring each upgrade, thereby saving resources and interaction costs. The recovery interface and upgrade status management interface enable flexible restoration of application data during the upgrade process, providing real-time feedback on upgrade success or failure, improving operational reliability and user experience.

[0148] Example 2:

[0149] Figure 7 A schematic diagram of a smart card provided by an embodiment of the present invention.

[0150] The smart card communicates with the external terminal device. Figure 7 , smart cards include:

[0151] The upgrade application receiving module 1 is used to install the upgrade patch application upon receiving the upgrade patch application and the new application code of the target application sent by the terminal device.

[0152] The upgrade space creation module 2 is used to create an upgrade space for performing upgrade operations on the target application. Based on the upgrade patch application, the application data of the target application is saved to the upgrade space, and the old application code and application data of the target application are unbound, and the unbound old application code is deleted; the upgrade space is a continuous memory area.

[0153] The new application code loading module 3 is used to load the new application code.

[0154] The application data restoration module 4 is used to obtain the application data stored in the upgrade space and associate the application data with the new application code based on the upgrade patch application to complete the upgrade operation of the target application.

[0155] In one embodiment, referring to Figure 8 The smart card further includes a space recovery module 5, the space recovery module 5 is used to:

[0156] After the upgrade is complete, reclaim the upgrade space and delete the upgrade patch application.

[0157] In one embodiment, the upgrade patch application includes an upgrade management interface; the upgrade management interface includes a data storage interface; the application data includes personalized data, application registration information, and application implementation data. The upgrade space creation module 2 is also used to:

[0158] In response to an application upgrade instruction sent by the terminal device, an upgrade space is created.

[0159] Gets the object data index and array data index of the application implementation data in the application data.

[0160] Call the save data interface to save personalized data, application registration information, object data index, and array data index to the upgrade space.

[0161] In one embodiment, the upgrade space creation module 2 is further configured to:

[0162] Obtain application implementation data from the application data; the application implementation data includes object data and array data; the object data includes fields; and the array data includes elements.

[0163] Each field in the application implementation data is traversed to determine the field memory address corresponding to each field; each element in the application implementation data is traversed to determine the element memory address corresponding to each element.

[0164] Generate object data index based on the correspondence between fields and field memory addresses; generate array data index based on the correspondence between elements and element memory addresses.

[0165] In one embodiment, the upgrade patch application includes an upgrade management interface; the upgrade management interface includes a data decoupling interface and a data deletion interface. The upgrade space creation module 2 is also used to:

[0166] Call the data decoupling interface to unbind the old application code from the application data to obtain the unbound old application code.

[0167] Call the delete data interface to delete the old application code after unbinding.

[0168] In one embodiment, the new application code loading module 3 is further configured to:

[0169] In response to the new application loading instruction sent by the terminal device, new application program code is loaded.

[0170] In one embodiment, the upgrade patch application includes an upgrade management interface; the upgrade management interface includes a data recovery interface; the application data includes personalized data, application registration information and application implementation data. The application data recovery module 4 is also used to:

[0171] In response to the upgrade data restoration instruction sent by the terminal device, the application data stored in the upgrade space is obtained.

[0172] Call the recovery data interface to adapt the personalized data, application registration information, and application implementation data to the new application code, and establish an association relationship between the application data and the new application code.

[0173] Initialize the target application to complete the upgrade operation of the target application.

[0174] In one embodiment, the upgrade patch application includes an upgrade management interface; the upgrade management interface includes an upgrade status management interface. The application data restoration module 4 is further used to:

[0175] An initialization operation result identifying the initialization operation.

[0176] If the initialization operation result is that the initialization is successful, an upgrade success message is generated and sent to the terminal device through the upgrade status management interface.

[0177] If the initialization operation result is initialization failure, an upgrade failure message is generated and sent to the terminal device through the upgrade status management interface.

[0178] An embodiment of the present invention provides a smart card that, through modular design, implements efficient collaboration of functions such as data preservation, code loading, and data restoration during application upgrades. The design of the upgrade space supports timely deletion of old application code and optimized utilization of storage resources. The application of upgrade patches decouples code from data, ensuring data integrity and security and improving upgrade reliability. The application data restoration module ensures seamless adaptation of old data to new application code, supporting application continuity and user experience. The overall design reduces the operational complexity of terminal devices and enables flexible, secure, and efficient upgrade process management.

[0179] An embodiment of the present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the application upgrade method provided in the above embodiment are implemented.

[0180] The computer program product provided in the embodiments of the present invention includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the methods described in the previous method embodiments. For specific implementation, please refer to the method embodiments and will not be repeated here.

[0181] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described systems and devices can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0182] In addition, in the description of the embodiments of the present invention, unless otherwise expressly specified or limited, the terms "mounted," "connected," and "connected" should be understood in a broad sense. For example, they may refer to fixed connections, detachable connections, or integral connections; they may refer to mechanical connections or electrical connections; they may refer to direct connections or indirect connections through an intermediate medium; and they may refer to internal communication between two components. Those skilled in the art will understand the specific meanings of the above terms in the present invention based on the specific circumstances.

[0183] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0184] In the description of the present invention, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicating orientations or positional relationships, are based on the orientations or positional relationships shown in the accompanying drawings and are intended solely to facilitate and simplify the description of the present invention. They are not intended to indicate or imply that the devices or components referred to must have, be constructed, or operate in a specific orientation, and therefore should not be construed as limitations on the present invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.

[0185] Finally, it should be noted that the above-described embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The scope of protection of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the above-described embodiments, those skilled in the art should understand that any person skilled in the art can modify or easily conceive of changes to the technical solutions described in the above-described embodiments within the technical scope disclosed by the present invention, or replace some of the technical features therein with equivalents. Such modifications, changes, or replacements do not deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be based on the scope of protection of the claims.

Claims

1. An application upgrade method, characterized in that: Applied to a smart card, the smart card is communicatively connected to an external terminal device; the method comprises: Upon receiving the upgrade patch application and the new application code of the target application sent by the terminal device, installing the upgrade patch application; Creating an upgrade space for performing an upgrade operation on a target application; applying the upgrade patch; saving application data of the target application to the upgrade space; unbinding old application code of the target application from the application data; and deleting the unbound old application code; wherein the upgrade space is a continuous memory area; loading the new application code; Acquiring the application data stored in the upgrade space, and associating the application data with the new application code based on the upgrade patch application to complete the upgrade operation of the target application; The upgrade patch application includes an upgrade management interface; the upgrade management interface includes a data save interface; the application data includes personalized data, application registration information, and application implementation data; the upgrade management interface also includes a data decoupling interface, a data deletion interface, a data recovery interface, and an upgrade status management interface; The step of creating an upgrade space for performing an upgrade operation on a target application and saving application data of the target application to the upgrade space based on applying the upgrade patch includes: creating the upgrade space in response to an application upgrade instruction sent by the terminal device; Obtaining an object data index and an array data index of the application implementation data in the application data; Calling the data saving interface to save the personalized data, the application registration information, the object data index, and the array data index to the upgrade space; The step of obtaining the object data index and array data index of the application implementation data in the application data includes: Acquire the application implementation data in the application data; the application implementation data includes object data and array data; the object data includes fields; the array data includes elements; Traversing each of the fields in the application implementation data to determine a field memory address corresponding to each of the fields; traversing each of the elements in the application implementation data to determine an element memory address corresponding to each of the elements; Based on the correspondence between the fields and the field memory addresses, the object data index is generated; based on the correspondence between the elements and the element memory addresses, the array data index is generated.

2. The application upgrade method according to claim 1, characterized in that: The method further comprises: After the upgrade operation is completed, the upgrade space is reclaimed and the upgrade patch application is deleted.

3. The application upgrade method according to claim 1, characterized in that: The step of unbinding the old application code of the target application from the application data and deleting the unbound old application code includes: Calling the data decoupling interface to unbind the old application code from the application data to obtain the unbound old application code; The data deletion interface is called to delete the unbound old application code.

4. The application upgrade method according to claim 1, characterized in that: The step of loading the new application code includes: In response to the new application loading instruction sent by the terminal device, the new application program code is loaded.

5. The application upgrade method according to claim 1, characterized in that: The step of obtaining the application data stored in the upgrade space and associating the application data with the new application code based on the upgrade patch application to complete the upgrade operation of the target application includes: Responding to an upgrade data restoration instruction sent by the terminal device, obtaining the application data stored in the upgrade space; Calling the data recovery interface to adapt the personalized data, application registration information, and application implementation data to the new application code, and establishing an association relationship between the application data and the new application code; An initialization operation is performed on the target application to complete an upgrade operation of the target application.

6. The application upgrade method according to claim 5, characterized in that: After the step of performing an initialization operation on the target application to complete the upgrade operation of the target application, the method further includes: identifying an initialization operation result of the initialization operation; If the initialization operation result is that the initialization is successful, generating upgrade success information, and sending the upgrade success information to the terminal device through the upgrade status management interface; If the initialization operation result is initialization failure, upgrade failure information is generated and sent to the terminal device through the upgrade status management interface.

7. A smart card, characterized in that: The smart card is connected to an external terminal device for communication; the smart card includes: an upgrade application receiving module, configured to install the upgrade patch application upon receiving the upgrade patch application and the new application code of the target application sent by the terminal device; an upgrade space creation module, configured to create an upgrade space for performing an upgrade operation on a target application, save the application data of the target application to the upgrade space based on the application of the upgrade patch, unbind the old application code of the target application from the application data, and delete the old application code after unbinding; the upgrade space is a continuous memory area; A new application code loading module, used for loading the new application code; an application data restoration module, configured to obtain the application data stored in the upgrade space and, based on the application of the upgrade patch, associate the application data with the new application code to complete the upgrade operation of the target application; The upgrade patch application includes an upgrade management interface; the upgrade management interface includes a data save interface; the application data includes personalized data, application registration information, and application implementation data; the upgrade management interface also includes a data decoupling interface, a data deletion interface, a data recovery interface, and an upgrade status management interface; The upgrade space creation module is further configured to: create the upgrade space in response to an application upgrade instruction sent by the terminal device; obtain the object data index and array data index of the application implementation data in the application data; and call the data saving interface to save the personalized data, the application registration information, the object data index, and the array data index to the upgrade space; The upgrade space creation module is further used to: obtain the application implementation data in the application data; the application implementation data includes object data and array data; the object data includes fields; the array data includes elements; traverse each of the fields in the application implementation data to determine the field memory address corresponding to each field; traverse each of the elements in the application implementation data to determine the element memory address corresponding to each element; generate the object data index based on the correspondence between the fields and the field memory addresses; generate the array data index based on the correspondence between the elements and the element memory addresses.

8. An electronic device, characterized in that: It includes a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and is characterized in that when the processor executes the computer program, it implements the application upgrade method described in any one of claims 1 to 6 above.

Citation Information

Patent Citations

  • Smart card, method and system for smart card data security update

    CN108228211A

  • Method and system for upgrading application program of intelligent card

    CN113282320A