A method and device for generating UDID

By obtaining and writing UDIDs to vendor partitions and sharedpreferences in smart terminal devices, the problem of UDID loss is solved, ensuring that the relationship between the device and cloud data remains unchanged.

CN114118016BActive Publication Date: 2024-11-01BEIJING UNISOUND INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111434474.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-29
Publication Date
2024-11-01
Estimated Expiration
2041-11-29

AI Technical Summary

Technical Problem

The UDID of the smart terminal device may be lost after the application is uninstalled or re-burned, or it cannot be generated due to the absence of the hardware module, resulting in the inability to associate with cloud data.

Method used

Get the UDID in sharedpreferences. If it does not exist, get the MAC address information through the system API interface. If it cannot be obtained, read the UDID in the vendor partition of the system through the Adb command. If it still cannot be read, generate the UDID based on the pre-acquisitioned UUID. and write it to vendor partition and sharedpreferences.

Benefits of technology

Ensure that UDID is not lost after software application uninstallation or reinstallation or ROM re-burning, and keep the relationship between smart terminal devices and cloud data consistent.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114118016B_ABST
    Figure CN114118016B_ABST
Patent Text Reader

Abstract

The present invention relates to a method, device, terminal and storage medium for generating UDID, the method comprising: executing an operation of obtaining UDID in sharedpreferences; if UDID does not exist in sharedpreferences, executing an operation of obtaining MAC address information through a system API interface; if MAC address information cannot be obtained, reading the UDID written in the vendor partition of the system through an Adb command; if the written UDID cannot be read, generating UDID based on a pre-acquired UUID; writing the generated UDID into the vendor partition of the system through an Adb command, and saving the generated UDID in sharedpreferences. This solution realizes that the unique UDID identification generated before will not be lost whether the smart terminal device uninstalls and reinstalls the software application or re-burns the ROM, thereby ensuring that the association relationship between the smart terminal device and the relevant data of the device already stored in the cloud remains unchanged.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method and device for generating a UDID. Background Art

[0002] Currently, UDID (Unique Device Identifier) ​​is used in many fields. For example, it can solve the problem that data stored in the cloud cannot be associated with smart terminal devices. However, the UDID of the smart terminal device may be lost. Currently, there are the following ways to solve this problem:

[0003] Method 1: Generate a unique identifier through the application, save the generated unique identifier to the sharedpreferences (i.e. software sandbox) in the application storage directory, and save a copy to the SDcard (Secure Digital MemoryCard / SD card) directory;

[0004] Method 2: Obtain the system serial number or MAC (Media Access Control) address through the API (Application Programming Interface), and then generate a unique identifier after MD5 (message digest algorithm);

[0005] However, both methods have problems: in method 1, the unique UDID generated will be lost after the application is uninstalled or the ROM (read-only memory) is re-burned; in method 2, although the UDID generated by the application will not be lost after the application is uninstalled or the ROM is burned, the hardware module on which the serial number or MAC address obtained by some smart terminal devices through the API does not exist, resulting in the inability to generate a unique UDID.

[0006] Therefore, there is a need for a better method to solve the problems in the prior art. Summary of the invention

[0007] The present invention provides a method, device, terminal and storage medium for generating a UDID, which can solve the technical problem of UDID loss in the prior art.

[0008] The technical solution of the present invention to solve the above technical problems is as follows:

[0009] The embodiment of the present invention provides a method for generating a UDID, including:

[0010] Execute the operation of obtaining UDID in sharedpreferences;

[0011] If the sharedpreferences does not have UDID, the operation of obtaining MAC address information is performed through the system API interface;

[0012] If the MAC address information cannot be obtained, use the Adb command to read the UDID written in the vendor partition of the system;

[0013] If the written UDID cannot be read, a UDID is generated based on the pre-obtained UUID;

[0014] Write the generated UDID to the system's vendor partition through the Adb command, and save the generated UDID to sharedpreferences.

[0015] In a specific embodiment, it also includes:

[0016] If the UDID is obtained in sharedpreferences, the obtained UDID will be returned.

[0017] In a specific embodiment, it also includes:

[0018] If the MAC address information is obtained through the system API interface, the MAC address information is processed by MD5 to generate the UDID;

[0019] The UDID generated by performing MD5 processing on the MAC address information is saved in sharedpreferences, and the UDID generated by performing MD5 processing is returned.

[0020] In a specific embodiment, it also includes:

[0021] If the UDID written in the vendor partition of the system is read through the Adb command, the read UDID is saved in sharedpreferences and the read UDID is returned.

[0022] The embodiment of the present invention further provides a device for generating a UDID, comprising:

[0023] The acquisition module is used to perform the operation of obtaining UDID in sharedpreferences;

[0024] An interface module, used for obtaining MAC address information through a system API interface if the sharedpreferences does not have a UDID;

[0025] The reading module is used to read the UDID written in the vendor partition of the system through the Adb command if the MAC address information cannot be obtained;

[0026] A generation module, for generating a UDID based on a pre-acquired UUID if the written UDID cannot be read;

[0027] The writing module is used to write the generated UDID to the system's vendor partition through the Adb command and save the generated UDID to sharedpreferences.

[0028] In a specific embodiment, it also includes:

[0029] The first processing module is used to return the obtained UDID if the UDID is obtained in the sharedpreferences.

[0030] In a specific embodiment, it also includes:

[0031] The second processing module is used to perform MD5 processing on the MAC address information to generate a UDID if the MAC address information is obtained through the system API interface;

[0032] The UDID generated by performing MD5 processing on the MAC address information is saved in sharedpreferences, and the UDID generated by performing MD5 processing is returned.

[0033] In a specific embodiment, it also includes:

[0034] The third processing module is used for saving the read UDID into sharedpreferences and returning the read UDID if the UDID written in the vendor partition of the system is read through the Adb command.

[0035] An embodiment of the present invention further provides a terminal, including a processor and a memory, wherein the memory stores an application program, and the processor executes the above method when executing the application program in the memory.

[0036] The embodiment of the present invention further provides a storage medium, in which an application is stored, and the above method is implemented when the application is executed.

[0037] The beneficial effects of the present invention are:

[0038] The embodiment of the present invention proposes a method, device, terminal and storage medium for generating UDID, the method comprising: executing an operation of obtaining UDID in sharedpreferences; if the sharedpreferences does not contain UDID, executing an operation of obtaining MAC address information through a system API interface; if the MAC address information cannot be obtained, reading the UDID written in the vendor partition of the system through an Adb command; if the written UDID cannot be read, generating a UDID based on a pre-acquired UUID; writing the generated UDID into the vendor partition of the system through an Adb command, and saving the generated UDID into sharedpreferences. In this solution, the UDID is written into the vendor partition of the system, and the data of the vendor partition of the system will not be lost after the ROM is reburned, thereby realizing that the unique UDID identifier generated before will not be lost whether the smart terminal device uninstalls and reinstalls the software application or reburns the ROM, thereby ensuring that the association relationship between the smart terminal device and the relevant data of this device that has been saved in the cloud remains unchanged. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 A flow chart of a method for generating a UDID provided in an embodiment of the present invention;

[0040] Figure 2 A flowchart of a method for generating a UDID provided by an embodiment of the present invention in a specific application scenario;

[0041] Figure 3 A schematic diagram of the structure of a device for generating a UDID provided by an embodiment of the present invention;

[0042] Figure 4 Another structural schematic diagram of a device for generating a UDID provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0043] The principles and features of the present invention are described below in conjunction with the accompanying drawings. The examples given are only used to explain the present invention and are not used to limit the scope of the present invention.

[0044] Example 1

[0045] Embodiment 1 of the present invention discloses a method for generating a UDID, such as Figure 1 as well as Figure 2 As shown, the following steps are included:

[0046] Step S101, executing the operation of obtaining UDID in sharedpreferences;

[0047] Specifically, sharedpreferences is a software sandbox. After the software is uninstalled, all information stored in the sandbox will be lost, but information related to software upgrades will not be lost.

[0048] Step S102: If the sharedpreferences does not contain UDID, the operation of obtaining MAC address information is performed through the system API interface;

[0049] Specifically, if the sharedpreferences does not have a UDID, other methods are selected to perform subsequent operations, such as obtaining MAC address information through a system API interface. If the MAC address information cannot be obtained, the following steps are performed.

[0050] Of course, in another embodiment, if the UDID is obtained in sharedpreferences, the obtained UDID is returned.

[0051] Step S103: If the MAC address information cannot be obtained, the UDID written in the vendor partition of the system is read through the Adb command;

[0052] Specifically, in another embodiment, if the MAC address information is obtained through the system API interface, the MAC address information is processed by MD5 to generate the UDID;

[0053] The UDID generated by performing MD5 processing on the MAC address information is saved in sharedpreferences, and the UDID generated by performing MD5 processing is returned.

[0054] Step S104: if the written UDID cannot be read, generate a UDID based on the pre-acquired UUID;

[0055] Specifically, if the UDID written in the vendor partition of the system is read through the Adb command, the read UDID is saved in sharedpreferences and the read UDID is returned.

[0056] Step S105: Write the generated UDID into the vendor partition of the system through the Adb command, and save the generated UDID into sharedpreferences.

[0057] In addition, after step S105 is executed, the generated UDID may also be returned.

[0058] In a specific embodiment, Figure 2As shown, first obtain the UDID through sharedpreferences, and directly return the relevant information after obtaining the UDID information;

[0059] If sharedpreferences does not have UDID information, the MAC address information is obtained through the system API interface. If the MAC address is obtained, the MAC address is processed by MD5 to generate the UDID. The generated UDID is saved in sharedpreferences and the UDID information is returned.

[0060] If the MAC address information cannot be obtained through the system API interface, the UDID unique identifier written in the vendor partition is read through the Adb command. If the acquisition is successful, the UDID is saved in sharedpreferences and the UDID information is returned;

[0061] If the UDID unique identifier written in the vendor partition fails to be read through the Adb command, the UDID of the device unique identifier is generated through the UUID (Universally Unique Identifier), the generated UDID is written to the system's vendor partition through the Adb command, the UDID is saved in sharedpreferences, and the UDID information is returned.

[0062] Specifically, since the data of the system's vendor partition will not be lost after re-burning the ROM, the unique UDID identifier previously generated will not be lost regardless of whether the smart terminal device uninstalls and reinstalls the software application or re-burns the ROM, thereby ensuring that the association between the smart terminal device and the relevant data of this device already saved in the cloud remains unchanged.

[0063] Example 2

[0064] In order to further illustrate the present invention, the embodiment 2 of the present invention further discloses a device for generating a UDID, such as Figure 3 As shown, including:

[0065] The acquisition module 201 is used to execute the operation of acquiring the UDID in the sharedpreferences;

[0066] The interface module 202 is used to obtain the MAC address information through the system API interface if the sharedpreferences does not have the UDID;

[0067] The reading module 203 is used to read the UDID written in the vendor partition of the system through the Adb command if the MAC address information cannot be obtained;

[0068] A generating module 204, configured to generate a UDID based on a pre-acquired UUID if the written UDID cannot be read;

[0069] The writing module 205 is used to write the generated UDID into the vendor partition of the system through the Adb command, and save the generated UDID into sharedpreferences.

[0070] Further, such as Figure 4 As shown, it also includes:

[0071] The first processing module 206 is configured to return the obtained UDID if the UDID is obtained in the sharedpreferences.

[0072] In a specific embodiment, it also includes:

[0073] The second processing module is used to perform MD5 processing on the MAC address information to generate a UDID if the MAC address information is obtained through the system API interface;

[0074] The UDID generated by performing MD5 processing on the MAC address information is saved in sharedpreferences, and the UDID generated by performing MD5 processing is returned.

[0075] In a specific embodiment, it also includes:

[0076] The third processing module is used for saving the read UDID into sharedpreferences and returning the read UDID if the UDID written in the vendor partition of the system is read through the Adb command.

[0077] Example 3

[0078] Embodiment 3 of the present invention further discloses a terminal, characterized in that it includes a processor and a memory, wherein the memory stores an application program, and the processor executes the following method when executing the application program in the memory:

[0079] Step A, perform the operation of obtaining UDID in sharedpreferences;

[0080] Specifically, sharedpreferences is a software sandbox. After the software is uninstalled, all information stored in the sandbox will be lost, but information related to software upgrades will not be lost.

[0081] Step B: If the sharedpreferences does not contain UDID, the operation of obtaining MAC address information is performed through the system API interface;

[0082] Step C: If the MAC address information cannot be obtained, use the Adb command to read the UDID written in the vendor partition of the system;

[0083] Step D: If the written UDID cannot be read, generate a UDID based on the pre-acquired UUID;

[0084] Step E: Write the generated UDID to the vendor partition of the system through the Adb command, and save the generated UDID to sharedpreferences.

[0085] The processor further executes the following method when executing the application in the memory:

[0086] If the UDID is obtained in sharedpreferences, the obtained UDID will be returned.

[0087] The processor further executes the following method when executing the application in the memory:

[0088] If the MAC address information is obtained through the system API interface, the MAC address information is processed by MD5 to generate the UDID;

[0089] The UDID generated by performing MD5 processing on the MAC address information is saved in sharedpreferences, and the UDID generated by performing MD5 processing is returned.

[0090] The processor further executes the following method when executing the application in the memory:

[0091] If the UDID written in the vendor partition of the system is read through the Adb command, the read UDID is saved in sharedpreferences and the read UDID is returned.

[0092] Example 4

[0093] Embodiment 4 of the present invention further discloses a storage medium, in which an application is stored. When the application is executed, the method described in Embodiment 1 is implemented.

[0094] The embodiment of the present invention proposes a method, device, terminal and storage medium for generating UDID, the method comprising: executing an operation of obtaining UDID in sharedpreferences; if the sharedpreferences does not contain UDID, executing an operation of obtaining MAC address information through a system API interface; if the MAC address information cannot be obtained, reading the UDID written in the vendor partition of the system through an Adb command; if the written UDID cannot be read, generating a UDID based on a pre-acquired UUID; writing the generated UDID into the vendor partition of the system through an Adb command, and saving the generated UDID into sharedpreferences. In this solution, the UDID is written into the vendor partition of the system, and the data of the vendor partition of the system will not be lost after the ROM is reburned, thereby realizing that the unique UDID identifier generated before will not be lost whether the smart terminal device uninstalls and reinstalls the software application or reburns the ROM, thereby ensuring that the association relationship between the smart terminal device and the relevant data of this device that has been saved in the cloud remains unchanged.

[0095] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.

Claims

1. A method for generating a UDID, characterized in that: include: Execute the operation of obtaining UDID in sharedpreferences; If the sharedpreferences does not have UDID, the operation of obtaining MAC address information is performed through the system API interface; If the MAC address information is obtained through the system API interface, the MAC address information is processed by MD5 to generate the UDID; The UDID generated by performing MD5 processing on the MAC address information is saved in sharedpreferences, and the UDID generated by performing MD5 processing is returned; If the MAC address information cannot be obtained, use the Adb command to read the UDID written in the vendor partition of the system; If the written UDID cannot be read, a UDID is generated based on the pre-obtained UUID; Write the generated UDID to the system's vendor partition through the Adb command, and save the generated UDID to sharedpreferences.

2. The method according to claim 1, characterized in that Also includes: If the UDID is obtained in sharedpreferences, the obtained UDID will be returned.

3. The method according to claim 1, characterized in that Also includes: If the UDID written in the vendor partition of the system is read through the Adb command, the read UDID is saved in sharedpreferences and the read UDID is returned.

4. A device for generating a UDID, characterized in that: include: The acquisition module is used to perform the operation of obtaining UDID in sharedpreferences; An interface module, used for obtaining MAC address information through a system API interface if the sharedpreferences does not have a UDID; The second processing module is used to perform MD5 processing on the MAC address information to generate a UDID if the MAC address information is obtained through the system API interface; The UDID generated by performing MD5 processing on the MAC address information is saved in sharedpreferences, and the UDID generated by performing MD5 processing is returned; The reading module is used to read the UDID written in the vendor partition of the system through the Adb command if the MAC address information cannot be obtained; A generation module for generating a UDID based on a pre-acquired UUID if the written UDID cannot be read; The writing module is used to write the generated UDID to the system's vendor partition through the Adb command and save the generated UDID to sharedpreferences.

5. The device according to claim 4, characterized in that Also includes: The first processing module is used to return the obtained UDID if the UDID is obtained in the sharedpreferences.

6. The device according to claim 4, characterized in that Also includes: The third processing module is used for saving the read UDID into sharedpreferences and returning the read UDID if the UDID written in the vendor partition of the system is read through the Adb command.

7. A terminal, characterized in that: The method comprises a processor and a memory, wherein the memory stores an application program, and the processor executes the method according to any one of claims 1 to 3 when executing the application program in the memory.

8. A storage medium, characterized in that: The storage medium stores an application program, and when the application program is executed, the method according to any one of claims 1 to 3 is implemented.