WO2022042363A1 - 一种共享库的复用方法及电子设备 - Google Patents

一种共享库的复用方法及电子设备 Download PDF

Info

Publication number
WO2022042363A1
WO2022042363A1 PCT/CN2021/112853 CN2021112853W WO2022042363A1 WO 2022042363 A1 WO2022042363 A1 WO 2022042363A1 CN 2021112853 W CN2021112853 W CN 2021112853W WO 2022042363 A1 WO2022042363 A1 WO 2022042363A1
Authority
WO
WIPO (PCT)
Prior art keywords
shared library
inode
electronic device
app
file data
Prior art date
Application number
PCT/CN2021/112853
Other languages
English (en)
French (fr)
Inventor
肖继伟
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to JP2023513836A priority Critical patent/JP2023539879A/ja
Priority to US18/042,980 priority patent/US20230350738A1/en
Priority to EP21860201.9A priority patent/EP4191409A4/en
Publication of WO2022042363A1 publication Critical patent/WO2022042363A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/36Software reuse
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/544Buffers; Shared memory; Pipes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4482Procedural
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/176Support for shared access to files; File sharing support
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/543Local
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/61Installation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/61Installation
    • G06F8/62Uninstallation

Definitions

  • the embodiments of the present application relate to the technical field of electronic devices, and in particular, to a method for multiplexing a shared library and an electronic device.
  • each APP includes executable programs and multiple shared libraries.
  • the shared library includes a dynamic link library in a Windows operating system, a shared object in a Linux operating system, and the like. That is to say, after a user installs an APP in an electronic product, the executable program and multiple shared libraries of the APP will be stored in the electronic product.
  • the embodiment of the present application provides a method for multiplexing a shared library, which can enable different APPs to call the same shared library when running, thereby improving the utilization rate of the storage space of electronic products.
  • an embodiment of the present application provides a method for multiplexing a shared library, and the method can be applied to an electronic device in which multiple APPs are installed, and each APP in the multiple APPs includes at least one shared library.
  • the at least one shared library may include the second shared library.
  • the electronic device can determine whether there is a second shared library in the electronic device that has the same file data as the first shared library of the first APP.
  • the first shared library is any shared library in the first APP. If the second shared library exists in the electronic device, the correspondence between the first inode and the file name of the first shared library is saved, and the file data of the first shared library is deleted from the electronic device.
  • the first inode is allocated by the electronic device for the second shared library, and the first inode may indicate a first storage area for storing file data of the second shared library. That is to say, the electronic device can determine, according to the first inode, the first storage area in the electronic device in which the file data of the second shared library is stored. After that, when the electronic device runs the first APP to call the first shared library, the electronic device can search for the first inode corresponding to the file name of the first shared library to read the second shared library stored in the storage area indicated by the first inode Library file data.
  • the electronic device may also save the correspondence between the first inode and the file name of the first shared library. In this way, when the electronic device runs the first APP to call the first shared library, the electronic device does not need to call the file data of the first shared library, but only needs to search the first inode through the file name of the first shared library to read the second The file data of the shared library can ensure the normal operation of the APP.
  • the shared library can be mapped into the memory, and then the shared library can be called from the memory. In this way, the performance of the electronic device can be improved.
  • the electronic device runs multiple APPs (such as the first APP and the second APP including the second shared library)
  • the first shared library and the second shared library are respectively mapped into the memory, because the mapped data If the amount is large, it will not only affect the I/O performance, but also cause a waste of memory space.
  • the electronic device only maps the second shared library into the memory, and both the first APP and the second APP can call the file data of the second shared library from the memory when running. In this way, not only the amount of data mapped to the memory is reduced, the I/O performance is improved, but also the space occupied by the memory can be reduced, and the utilization rate of the memory can be improved.
  • the above-mentioned method for "the electronic device determines whether there is a second shared library that is the same as the file data of the first shared library of the first APP" in the electronic device includes: an electronic device When the first APP is installed, the electronic device determines whether there is a second shared library in the electronic device that has the same file data as the first shared library of the first APP; or, when the electronic device finishes running the first APP, the electronic device determines whether the electronic device Whether there is a second shared library that is the same as the file data of the first shared library of the first APP.
  • the electronic device when the APP (such as the first APP) in the electronic device is downloaded from the platform to the electronic device, the electronic device can monitor the installation process of the first APP, and when the first APP is installed on the electronic device, detect the electronic device. Whether the device stores the second shared library with the same file data as the first shared library, so that the electronic device can find out in time whether the same shared library is stored. In addition, the electronic device performs detection when the first APP is installed, which can prevent the operation of the first APP from being affected.
  • the APP such as the first APP
  • the electronic device cannot monitor the copying process of the first APP. Therefore, only when the copied first APP is running, the electronic device can monitor it to detect whether it stores the second shared library that is the same as the file data of the first shared library, so that the electronic device can find out in time whether there are stored the same shared library. In addition, the electronic device detects when the first APP is finished running, which can prevent the running of the APP from being affected.
  • the APP eg, the first APP
  • the above when the electronic device finishes running the first APP, the electronic device determines whether there is a second file in the electronic device that is the same as the file data of the first shared library of the first APP.
  • "Shared library” may include: when the electronic device finishes running the first APP for the first time, the electronic device determines whether there is a second shared library in the electronic device that is identical to the file data of the first shared library of the first APP.
  • the electronic device determines that there is a second shared library in the electronic device that is the same as the file data of the first shared library of the first APP, the electronic device can delete the file data of the first shared library. Then, after the electronic device finishes running the first APP for the first time, the electronic device can delete the file data of the first shared library. Therefore, after the electronic device runs the first APP again, it is no longer necessary to determine that there is a second shared library in the electronic device that is the same as the file data of the first shared library of the first APP. In this way, the computing pressure of the electronic device can be reduced.
  • the method further includes: if the second shared library does not exist in the electronic device, the electronic device allocates a second inode to the first shared library, and saves the second inode and the Correspondence between file names of the first shared library.
  • the second inode indicates a second storage area for storing file data of the first shared library.
  • the electronic device can store the first shared library. In this way, when the electronic device runs the first APP to call the first shared library, the electronic device can search for the second inode through the file name of the first shared library, so as to read the file data of the first shared library to ensure the APP's normal operation.
  • the method further includes: if the second shared library exists in the electronic device, adding 1 to the link number of the first inode by the electronic device; wherein , the link number of the first inode is the number of shared libraries corresponding to the first inode; if the second shared library does not exist in the electronic device, the electronic device is the link number of the second inode plus the number of 1; wherein, the link number of the second inode is the number of shared libraries corresponding to the second inode, and the initial value of the link number of each inode is 0.
  • the electronic device determines the number of shared libraries to be replaced by the second shared library according to the number of links of the first inode.
  • the electronic device changes the link number of the second inode by adding 1 to the link number of the second inode, thereby updating the number of shared libraries corresponding to the second inode, so that the electronic device can determine the first shared library according to the link number of the second inode Number of alternate shared libraries.
  • the method further includes: when the electronic device deletes the second APP, searching for a third inode corresponding to the file name of the third shared library; if the third inode The number of links is equal to 1, then delete the file data of the third shared library, the third inode, and the correspondence between the file name of the third shared library and the third inode from the electronic device relationship; if the number of links of the third inode is greater than 1, the number of links of the third inode is reduced by 1.
  • the link number of the third inode is equal to 1, it means that the third shared library does not need to replace other shared libraries, that is, the APPs other than the second APP will not call the third shared library when running.
  • the electronic device after the electronic device deletes the second APP, there is no APP in the electronic device to call the third shared library. Therefore, when the electronic device deletes the second APP, the electronic device can delete the file data of the third shared library, the third inode, and the third shared library. The correspondence between the file names of the three shared libraries and the third inode, thereby saving the storage space of the electronic device.
  • the electronic device cannot delete the third shared library.
  • the electronic device since the electronic device will delete the second APP, that is, the number of APPs that call the third shared library is reduced, the electronic device changes the number of links of the third inode, thereby updating the number of shared libraries corresponding to the third inode, so that the electronic device can The link count of the third inode determines the number of shared libraries that the third shared library replaces.
  • the above-mentioned method for "the electronic device to determine whether there is a second shared library that is the same as the file data of the first shared library of the first APP" in the electronic device includes: The electronic device uses a preset algorithm according to the file data of the first shared library to generate the first identification of the first shared library, and determines whether the first identification and the second identification are the same; wherein, the second identification is the The electronic device is generated by using the preset algorithm according to the file data of any shared library in the electronic device.
  • the first identifier is the same as the second identifier, it is determined that the second shared library with the same file data as the first shared library exists in the electronic device; if the first identifier Different from the second identification, it is determined that the second shared library that is the same as the file data of the first shared library does not exist in the electronic device.
  • the method further includes: the first identifier is different from the second identifier, and the electronic device saves the correspondence between the first identifier and the second inode.
  • the difference between the first identifier and the second identifier indicates that the second shared library that is the same as the file data of the first shared library does not exist in the electronic device. Therefore, the electronic device needs to save the correspondence between the first identifier and the second inode, so that after storing the first shared library, it can determine whether the file data of other shared libraries stored in the electronic device is the same as the first shared library according to the first identifier. same.
  • the method further includes: the link number of the third inode is equal to 1, then deleting the third inode and the third identifier from the electronic device
  • the third identifier is generated by the electronic device using the preset algorithm according to the file data of the third shared library.
  • the link number of the third inode is equal to 1, it means that the third shared library does not need to replace other shared libraries, that is, the APPs other than the second APP will not call the third shared library when running. Also, after the electronic device deletes the second APP, there is no APP in the electronic device to call the third shared library. Therefore, when the electronic device deletes the second APP, the electronic device deletes the correspondence between the third inode and the third identifier, thereby Save storage space for electronic devices.
  • the method further includes: the electronic device compares the file data of the first shared library with the file data of each shared library in the electronic device, and determines the electronic device Whether the second shared library with the same file data as the first shared library exists in the device.
  • an embodiment of the present application provides an electronic device in which multiple application programs are installed, each of the multiple APPs includes at least one shared library, and the electronic device includes: a processing unit and a storage unit.
  • the processing unit is configured to determine whether there is a second shared library with the same file data as the first shared library of the first APP in the storage unit, where the first shared library is any shared library in the first APP.
  • the storage unit is further configured to save the correspondence between the inode of the first index node and the file name of the first shared library if there is a second shared library in the storage unit, where the first inode is the processing unit for the second shared library Allocated, the first inode indicates a first storage area for storing file data of the second shared library.
  • the processing unit is further configured to delete the file data of the first shared library from the storage unit.
  • the processing unit is further configured to search for the first inode corresponding to the file name of the first shared library when running the first APP to call the first shared library, and read the file of the second shared library stored in the storage area indicated by the first inode data.
  • the processing unit is specifically configured to: when the first APP is installed, determine whether there is a first APP that is the same as the file data of the first shared library of the first APP in the storage unit. two shared libraries; or, when the first APP is finished running, determine whether there is a second shared library in the storage unit that has the same file data as the first shared library of the first APP.
  • the processing unit is specifically configured to: when the first APP is finished running for the first time, determine whether there is a file in the storage unit with the first shared library of the first APP A second shared library with the same data.
  • the processing unit is further configured to allocate a second inode to the first shared library if the second shared library does not exist in the storage unit; wherein, the second inode indicates the use of The second storage area is used to store the file data of the first shared library; the storage unit is also used to store the correspondence between the second inode and the file name of the first shared library.
  • the processing unit is further configured to search for the second inode corresponding to the file name of the first shared library when running the first APP to call the first shared library, and read the first shared library stored in the second storage area indicated by the second inode file data.
  • the processing unit is further configured to: if there is a second shared library in the storage unit, add 1 to the link number of the first inode; wherein, the link of the first inode The number is the number of shared libraries corresponding to the first inode; if there is no second shared library in the storage unit, the number of links of the second inode plus 1; wherein, the number of links of the second inode is the shared library corresponding to the second inode ; where the initial value of the number of links per inode is 0.
  • the processing unit is further configured to: when the second APP is deleted, find the third inode corresponding to the file name of the third shared library; if the number of links of the third inode is equal to 1, the file data of the third shared library, the third inode, and the correspondence between the file name of the third shared library and the third inode are deleted from the storage unit; if the number of links of the third inode is greater than 1, it is The link count of the third inode is decreased by 1.
  • the processing unit is specifically configured to: generate a first identifier of the first shared library by using a preset algorithm according to the file data of the first shared library, and determine the first identifier Whether it is the same as the second identification; wherein, the second identification is generated by the processing unit using a preset algorithm according to the file data of any shared library in the storage unit; wherein, if the first identification is the same as the second identification, then determine the storage unit in the There is a second shared library with the same file data as the first shared library; if the first identification is different from the second identification, it is determined that there is no second shared library with the same file data as the first shared library in the storage unit.
  • the storage unit is further configured to store the correspondence between the first identifier and the second inode if the first identifier is different from the second identifier.
  • the processing unit is also used to delete the correspondence between the third inode and the third identifier from the storage unit if the link number of the third inode is equal to 1;
  • the third identifier is generated by the processing unit using a preset algorithm according to the file data of the third shared library.
  • the processing unit is specifically configured to compare the file data of the first shared library with the file data of each shared library in the storage unit, and determine whether there is a file in the storage unit that is different from the first shared library.
  • the file data of the shared library is the same as the second shared library.
  • an embodiment of the present application provides an electronic device, in which a plurality of application programs APPs are installed, and each APP in the above-mentioned plurality of APPs includes at least one shared library; the electronic device includes: a memory and a processor , the above-mentioned memory is coupled with the above-mentioned processor; the above-mentioned at least one shared library is stored in the memory, and the memory is also used to store computer program codes, and the computer program codes include computer instructions; when the computer instructions are executed by the processor, the electronic device is executed.
  • the method as described in the first aspect and any possible design manners thereof.
  • an embodiment of the present application provides a chip system, the chip system is applied to an electronic device, a plurality of APPs are installed in the electronic device, and each APP of the plurality of APPs includes at least one shared library.
  • the chip system includes one or more interface circuits and one or more processors.
  • the interface circuit and the processor are interconnected by wires.
  • the interface circuit is used to receive signals from the memory of the electronic device and send the signals to the processor, the signals including computer instructions stored in the memory.
  • the processor executes the computer instructions
  • the electronic device executes the method described in the first aspect and any possible design manners thereof.
  • an embodiment of the present application provides a computer storage medium, where the computer storage medium includes computer instructions, when the computer instructions are executed on an electronic device, the electronic device is made to perform the first aspect and any one thereof. possible design methods described.
  • an embodiment of the present application provides a computer program product, which, when the computer program product runs on a computer, causes the computer to execute the method described in the first aspect and any possible design manners thereof.
  • the electronic device described in the second aspect and any possible design manner thereof provided above the electronic device described in the third aspect, the chip system described in the fourth aspect, and the computer described in the fifth aspect
  • the beneficial effects that can be achieved by the computer program product described in the sixth aspect may refer to the beneficial effects in the first aspect and any possible design manners thereof, which will not be repeated here.
  • FIG. 1 is a schematic diagram of a hardware structure of an electronic device provided by an embodiment of the present application.
  • 2A is a system frame diagram of an electronic device provided by an embodiment of the present application.
  • FIG. 2B is a system frame diagram of another electronic device provided by an embodiment of the present application.
  • 2C is a flowchart of a method for multiplexing a shared library provided by an embodiment of the present application
  • FIG. 2D is a system frame diagram of another electronic device provided by an embodiment of the present application.
  • FIG. 3 is a flowchart of another method for multiplexing a shared library provided by an embodiment of the present application.
  • FIG. 4 is a flowchart of another method for multiplexing a shared library provided by an embodiment of the present application.
  • 5A is a schematic diagram of the relationship between an APP, a shared library, an inode, and a storage area provided by an embodiment of the present application;
  • 5B is a schematic diagram of the relationship between another APP, a shared library, an inode, and a storage area provided by an embodiment of the present application;
  • FIG. 6 is a schematic diagram of the composition of a shared library multiplexing apparatus provided by an embodiment of the present application.
  • FIG. 7 is a schematic structural composition diagram of a chip system according to an embodiment of the present application.
  • first and second are only used for descriptive purposes, and should not be construed as indicating or implying relative importance or implicitly indicating the number of indicated technical features.
  • a feature defined as “first” or “second” may expressly or implicitly include one or more of that feature.
  • plural means two or more.
  • An embodiment of the present application provides a method for multiplexing a shared library, and the method can be applied to an electronic device installed with multiple APPs.
  • Each APP in the multiple APPs eg, a first APP and a second APP
  • the APP in this embodiment of the present application may be a downloadable application program installed in an electronic device.
  • a downloadable application is an application that can provide its own Internet Protocol Multimedia Subsystem (IMS) connection, the downloadable application can be pre-installed in an electronic device or can be downloaded and installed by the user on Third-party applications (such as the first APP and the second APP) in the electronic device.
  • IMS Internet Protocol Multimedia Subsystem
  • the first APP may be an application such as "calendar”, “notepad”, etc. that are pre-installed in the electronic device
  • the second APP may be a payment application, a video application, etc. downloaded by the user and installed in the electronic device. third-party usage.
  • the electronic device when the electronic device has installed the first APP, it can execute the shared library multiplexing method provided by the embodiment of the present application.
  • the above-mentioned electronic device may have an operating system of Android ( ), the above-mentioned first APP may be a shopping application.
  • the shopping application When the shopping application is installed on the mobile phone, the mobile phone completes the Android application package ( Application package, APK) decompression process, and the executable program of the shopping application is stored in the mobile phone, and the method can be executed when the executable program needs to call the first shared library and the third shared library.
  • Android application package Application package, APK
  • the electronic device can The installation process is monitored, and when the electronic device has installed the first APP, the method is executed, so that the electronic device can discover in time whether the same shared library is stored.
  • the electronic device when the electronic device finishes running the first APP, it can execute the shared library multiplexing method provided by the embodiment of the present application.
  • the above electronic device may have an operating system of mobile phone
  • the above-mentioned first APP may be a shopping application.
  • the method can be executed when the mobile phone runs the shopping application until the process of the shopping application is closed, that is, when the mobile phone stops running the shopping application for the first time.
  • the electronic device when the APP (eg, the first APP) in the electronic device is copied to the electronic device from other removable storage devices, the electronic device cannot monitor the copying process of the first APP. Therefore, only when the copied first APP is running, the electronic device can monitor it to detect whether it stores the second shared library that is the same as the file data of the first shared library, so that the electronic device can find out in time whether there are stored the same shared library. In addition, the electronic device detects when the first APP is finished running, which can prevent the running of the APP from being affected.
  • the APP eg, the first APP
  • the electronic device when it finishes running the first APP for the first time, it may execute the shared library multiplexing method provided by the embodiment of the present application.
  • the electronic device can delete the file data of the first shared library. Then, after the electronic device finishes running the first APP for the first time, the electronic device can delete the file data of the first shared library. Therefore, after the electronic device runs the first APP again, it is no longer necessary to determine that there is a second shared library in the electronic device that is the same as the file data of the first shared library of the first APP. In this way, the computing pressure of the electronic device can be reduced.
  • the shared library (such as the first shared library) that is the same as the file data of the shared library (such as the second shared library) stored in the electronic device can be deleted, and the utilization rate of the storage space of the electronic device can be improved; and , the second shared library replaces the first shared library, so that different APPs can call the same shared library, thereby ensuring that the APP can run normally.
  • the electronic device in the embodiment of the present application may be a tablet computer, a mobile phone, a desktop, a laptop, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, and a cellular Phones, personal digital assistants (PDAs), augmented reality (AR) ⁇ virtual reality (VR) devices, in-vehicle devices, etc. are installed with multiple APPs (each APP in the multiple APPs includes at least one shared library), the specific form of the electronic device is not particularly limited in this embodiment of the present application.
  • the execution body of the shared library multiplexing method provided by the present application may be a shared library multiplexing apparatus (hereinafter referred to as "multiplexing apparatus"), and the multiplexing apparatus may be the electronic device shown in FIG. 1 . Meanwhile, the multiplexing device may also be a central processing unit (Central Processing Unit, CPU) of the electronic device, or a control module in the electronic device for multiplexing a shared library.
  • CPU Central Processing Unit
  • the method for multiplexing a shared library executed by an electronic device is used as an example to describe the method for multiplexing a shared library provided by the embodiment of the present application.
  • the electronic device provided by the present application is introduced by taking the electronic device as the mobile phone 100 shown in FIG. 1 as an example.
  • the mobile phone 100 shown in FIG. 1 is only an example of an electronic device, and the mobile phone 100 may have more or less components than those shown in the figure, two or more components may be combined, or Available in different parts configurations.
  • the various components shown in FIG. 1 may be implemented in hardware, software, or a combination of hardware and software, including one or more signal processing and/or application specific integrated circuits.
  • the mobile phone 100 may include: a processor 110 , an external memory interface 120 , an internal memory 121 , a universal serial bus (USB) interface 130 , a charging management module 140 , a power management module 141 , and a battery 142 , Antenna 1, Antenna 2, Mobile Communication Module 150, Wireless Communication Module 160, Audio Module 170, Speaker 170A, Receiver 170B, Microphone 170C, Headphone Interface 170D, Sensor Module 180, Key 190, Motor 191, Indicator 192, Camera 193 , a display screen 194, and a subscriber identification module (subscriber identification module, SIM) card interface 195 and the like.
  • a processor 110 an external memory interface 120
  • an internal memory 121 a universal serial bus (USB) interface 130
  • USB universal serial bus
  • the aforementioned sensor module 180 may include sensors such as pressure sensors, gyroscope sensors, air pressure sensors, magnetic sensors, acceleration sensors, distance sensors, proximity light sensors, fingerprint sensors, temperature sensors, touch sensors, ambient light sensors, and bone conduction sensors.
  • sensors such as pressure sensors, gyroscope sensors, air pressure sensors, magnetic sensors, acceleration sensors, distance sensors, proximity light sensors, fingerprint sensors, temperature sensors, touch sensors, ambient light sensors, and bone conduction sensors.
  • the structure illustrated in this embodiment does not constitute a specific limitation on the mobile phone 100 .
  • the cell phone 100 may include more or fewer components than shown, or some components may be combined, or some components may be split, or a different arrangement of components.
  • the illustrated components may be implemented in hardware, software, or a combination of software and hardware.
  • the processor 110 is the control center of the mobile phone 100, uses various interfaces and lines to connect various parts of the mobile phone 100, and executes the mobile phone by running or executing the application program stored in the internal memory 121 and calling the data stored in the internal memory 121. 100 various functions and processing data.
  • processor 110 may include one or more processing units.
  • the above-mentioned processor 110 may further include a program execution chip for running an executable program and a shared library of an APP.
  • the processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), controller, memory, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural-network processing unit (NPU) Wait. Wherein, different processing units may be independent devices, or may be integrated in one or more processors.
  • application processor application processor, AP
  • modem processor graphics processor
  • graphics processor graphics processor
  • ISP image signal processor
  • controller memory
  • video codec digital signal processor
  • DSP digital signal processor
  • NPU neural-network processing unit
  • the controller may be the nerve center and command center of the cell phone 100 .
  • the controller can generate an operation control signal according to the instruction operation code and timing signal, and complete the control of fetching and executing instructions.
  • a memory may also be provided in the processor 110 for storing instructions and data.
  • the memory in processor 110 is cache memory. This memory may hold instructions or data that have just been used or recycled by the processor 110 . If the processor 110 needs to use the instruction or data again, it can be called directly from the memory. Repeated accesses are avoided and the latency of the processor 110 is reduced, thereby increasing the efficiency of the system.
  • the processor 110 may include one or more interfaces.
  • the interface may include an integrated circuit (inter-integrated circuit, I2C) interface, an integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, a universal asynchronous transceiver (universal asynchronous transmitter) receiver/transmitter, UART) interface, mobile industry processor interface (MIPI), general-purpose input/output (GPIO) interface, subscriber identity module (SIM) interface, and / or universal serial bus (universal serial bus, USB) interface, etc.
  • I2C integrated circuit
  • I2S integrated circuit built-in audio
  • PCM pulse code modulation
  • PCM pulse code modulation
  • UART universal asynchronous transceiver
  • MIPI mobile industry processor interface
  • GPIO general-purpose input/output
  • SIM subscriber identity module
  • USB universal serial bus
  • the interface connection relationship between the modules illustrated in this embodiment is only a schematic illustration, and does not constitute a structural limitation of the mobile phone 100 .
  • the mobile phone 100 may also adopt different interface connection manners in the foregoing embodiments, or a combination of multiple interface connection manners.
  • the charging management module 140 is used to receive charging input from the charger.
  • the charger may be a wireless charger or a wired charger. While the charging management module 140 charges the battery 142 , it can also supply power to the electronic device through the power management module 141 .
  • the power management module 141 is used for connecting the battery 142 , the charging management module 140 and the processor 110 .
  • the power management module 141 receives input from the battery 142 and/or the charging management module 140 and supplies power to the processor 110 , the internal memory 121 , the external memory, the display screen 194 , the camera 193 , and the wireless communication module 160 .
  • the power management module 141 and the charging management module 140 may also be provided in the same device.
  • the wireless communication function of the mobile phone 100 may be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modulation and demodulation processor, the baseband processor, and the like.
  • the antenna 1 of the mobile phone 100 is coupled with the mobile communication module 150
  • the antenna 2 is coupled with the wireless communication module 160, so that the mobile phone 100 can communicate with the network and other devices through wireless communication technology.
  • the mobile phone 100 may send the above-mentioned first account number and login password to other devices through a wireless communication technology.
  • Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals.
  • Each antenna in handset 100 may be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization.
  • the antenna 1 can be multiplexed as a diversity antenna of the wireless local area network. In other embodiments, the antenna may be used in conjunction with a tuning switch.
  • the mobile communication module 150 can provide wireless communication solutions including 2G/3G/4G/5G etc. applied on the mobile phone 100 .
  • the mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA) and the like.
  • the mobile communication module 150 can receive electromagnetic waves from the antenna 1, filter and amplify the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation.
  • LNA low noise amplifier
  • the mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and then turn it into an electromagnetic wave for radiation through the antenna 1 .
  • at least part of the functional modules of the mobile communication module 150 may be provided in the processor 110 .
  • at least part of the functional modules of the mobile communication module 150 may be provided in the same device as at least part of the modules of the processor 110 .
  • the wireless communication module 160 can provide applications on the mobile phone 100 including wireless local area networks (WLAN) (such as (wireless fidelity, Wi-Fi) networks), bluetooth (BT), global navigation satellite system (global navigation satellite system) Satellite system, GNSS), frequency modulation (frequency modulation, FM), near field communication technology (near field communication, NFC), infrared technology (infrared, IR) and other wireless communication solutions.
  • WLAN wireless local area networks
  • BT wireless fidelity, Wi-Fi
  • BT global navigation satellite system Satellite system
  • GNSS global navigation satellite system Satellite system
  • frequency modulation frequency modulation, FM
  • NFC near field communication technology
  • infrared technology infrared, IR
  • the wireless communication module 160 may be one or more devices integrating at least one communication processing module.
  • the wireless communication module 160 receives electromagnetic waves via the antenna 2 , frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110 .
  • the wireless communication module 160 can also receive the signal to be sent from the processor 110 , perform frequency modulation on it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2 .
  • the mobile phone 100 realizes the display function through the GPU, the display screen 194, and the application processor.
  • the GPU is a microprocessor for image processing, and is connected to the display screen 194 and the application processor.
  • the GPU is used to perform mathematical and geometric calculations for graphics rendering.
  • Processor 110 may include one or more GPUs that execute program instructions to generate or alter display information.
  • Display screen 194 is used to display images, videos, and the like.
  • the display screen 194 includes a display panel.
  • the display screen 194 may be used to display the application interface of the above-mentioned first APP, such as a device sharing interface, a device search interface, and a two-dimensional code scanning interface.
  • the mobile phone 100 can realize the shooting function through the ISP, the camera 193, the video codec, the GPU, the display screen 194 and the application processor.
  • the ISP is used to process the data fed back by the camera 193 .
  • Camera 193 is used to capture still images or video.
  • the mobile phone 100 may include one or N cameras 193 , where N is a positive integer greater than one.
  • the external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the mobile phone 100 .
  • the external memory card communicates with the processor 110 through the external memory interface 120 to realize the data storage function. For example to save files like music, video etc in external memory card.
  • the internal memory 121 is used to store application programs and data, and the processor 110 executes various functions of the mobile phone 100 and data processing by running the application programs and data stored in the internal memory 121 .
  • the internal memory 121 mainly includes a storage program area and a storage data area, wherein the storage program area can store binary files such as operating systems, executable programs, and shared libraries; the storage data area can store the correspondence between data.
  • the internal memory 121 may include a high-speed random access memory (Random Access Memory, RAM), and may also include a non-volatile memory, such as a magnetic disk storage device, a flash memory device, or other volatile solid-state storage devices.
  • RAM Random Access Memory
  • the internal memory 121 may store various operating systems.
  • the above-mentioned internal memory 121 may be independent and connected to the processor 110 through the above-mentioned communication bus; the internal memory 121 may also be integrated with the processor 110 .
  • the mobile phone 100 can implement audio functions through an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, and an application processor. Such as music playback, recording, etc.
  • the keys 190 include a power-on key, a volume key, and the like. Keys 190 may be mechanical keys. It can also be a touch key. Motor 191 can generate vibrating cues. The motor 191 can be used for vibrating alerts for incoming calls, and can also be used for touch vibration feedback.
  • the indicator 192 can be an indicator light, which can be used to indicate the charging state, the change of the power, and can also be used to indicate a message, a missed call, a notification, and the like.
  • the SIM card interface 195 is used to connect a SIM card. The SIM card can be contacted and separated from the mobile phone 100 by being inserted into the SIM card interface 195 or pulled out from the SIM card interface 195 .
  • the mobile phone 100 may support 1 or N SIM card interfaces, where N is a positive integer greater than 1.
  • the SIM card interface 195 can support Nano SIM card, Micro SIM card, SIM card and so on.
  • the mobile phone 100 may also use a flashlight, a pico-projection device, a near field communication (Near Field Communication, NFC) device, etc., which will not be repeated here.
  • a flashlight a pico-projection device
  • a near field communication (Near Field Communication, NFC) device etc., which will not be repeated here.
  • the present application takes the electronic device as the mobile phone 100 as an example to introduce the system architecture of the electronic device provided by the present application.
  • the system architecture of the mobile phone 100 may include: an application layer, an operating system (Operating System, OS) (such as Android system), kernel layer, hardware layer.
  • OS Operating System
  • OS operating System
  • kernel layer hardware layer.
  • the application layer can include a series of application packages.
  • APP(A), APP(B), etc. by
  • the shared library files in the system are all so files (*.so).
  • APP(A) includes A1.so, A2.so, A3.so, etc.
  • APP(B) includes B1.so, B2.so, B3.so, and the like.
  • the system is a computer program that manages hardware and software resources of the mobile phone 100 .
  • the system needs to handle basic tasks such as managing and configuring memory, prioritizing the supply and demand of system resources, controlling input and output devices, operating the network, and managing the file system.
  • the system may also provide an operating interface that enables the user to interact with the system.
  • the system includes an installation package manager service (Package Manager Service, PMS).
  • PMS is One of the system services, mainly responsible for management
  • the application of the system provides installation, uninstallation, optimization and query services for various APK files.
  • the PMS includes an APP monitoring component
  • the APP monitoring component runs in the PMS, can monitor the installation, update, and deletion of the APP, and sends a notification message to the multiplexing component.
  • the APP monitoring component will send a notification message to the multiplexing component to inform the multiplexing component APP(A) that the installation has been completed.
  • the kernel layer is the layer between hardware and software.
  • the kernel layer contains at least display drivers, camera drivers, audio drivers, and sensor drivers.
  • the kernel layer further includes a file system and a memory operating system.
  • the file system is used to manage data stored in the internal memory 121 .
  • the file system can abstract the data stored in the internal memory 121 into specific files, and provide operations such as adding, deleting, and modifying files.
  • the file system may store the executable program A, the first shared library, and the second shared library in the first APP, as well as the executable program B and the third shared library in the second APP, in the in the internal memory 121.
  • the processor 110 calls the shared library through the file system.
  • the Memory Operating System is used to manage memory. Because the memory access speed is faster than the hardware layer. Therefore, when the processor 110 runs the APP, the shared library of the APP needs to be loaded into the memory operating system to improve the running speed of the APP.
  • the file system includes a multiplexing component, and the multiplexing component can realize the multiplexing of shared libraries in the file system. Exemplarily, the file data of A1.so and B1.so are the same, the file data of A2.so and B2.so are the same, and the multiplexing component can make APP(A) and APP(B) call B1.so together , B2.so.
  • Hardware layer including memory (eg flash memory).
  • the flash memory can keep data for a long time even without current supply, and its storage characteristic is equivalent to that of a hard disk.
  • Exemplarily, S1.so, S2.so, S3.so, etc. are stored in the Flash memory.
  • system architecture of the electronic device shown in FIG. 2A can support the electronic device to execute the shared library multiplexing method provided by the embodiment of the present application when the electronic device completes the installation of the first APP.
  • FIG. 2C a flowchart of a method for multiplexing a shared library provided by an embodiment of the present application.
  • the method for multiplexing the shared library in the embodiment of the present application is introduced.
  • the file data of A1.so is the same as that of B1.so
  • the file data of A2.so is the same as that of B2.so.
  • the APP monitoring component sends a notification message to the multiplexing component.
  • the multiplexing component detects the existence of B1.so with the same file data as A1.so and B2.so with the same file data as A2.so in the hardware layer (eg, the internal memory 121 ), and deletes A1.so and A2.so.
  • the mobile phone 100 runs APP(A) or APP(B) calls a shared library (eg B1.so)
  • the memory operating system maps B1.so into the memory, so that the processor 110 calls B1.so in the memory.
  • the electronic device is the mobile phone 100 as an example to introduce the system architecture of another electronic device provided in this application.
  • the system architecture of the mobile phone 100 includes: an application layer, a kernel layer, and a hardware layer.
  • the application layer for the introduction of the application layer, reference may be made to the above-mentioned introduction to the application layer in FIG. 2A , which will not be repeated here.
  • the kernel layer in addition to the above description of the kernel layer in FIG. 2A , the memory operating system of the kernel layer also includes a monitoring component.
  • the monitoring component runs on the memory operating system, can monitor the calls made by the mobile phone 100 to the shared library, and sends a notification message to the multiplexing component.
  • the multiplexing component detects that the mobile phone 100 stops calling B1.so, and sends a notification message to the multiplexing component to inform the multiplexing component that the process of APP(A) is closed.
  • the hardware layer for the introduction of the hardware layer, reference may be made to the above-mentioned introduction to the hardware layer in FIG. 2A , which will not be repeated here.
  • system architecture of the electronic device shown in FIG. 2D can support the electronic device to execute the shared library multiplexing method provided by the embodiment of the present application when the electronic device finishes running the first APP.
  • the multiplexing method of the shared library in the embodiment of the present application is introduced.
  • the file data of A1.so is the same as that of B1.so
  • the file data of A2.so is the same as that of B2.so.
  • the APP monitoring component sends a notification message to the multiplexing component.
  • the multiplexing component detects the existence of B1.so with the same file data as A1.so and B2.so with the same file data as A2.so in the hardware layer (eg, the internal memory 121 ), and deletes A1.so and A2.so.
  • the memory operating system maps B1.so into the memory, so that the processor 110 calls B1.so in the memory.
  • the methods in the following embodiments can all be implemented in an electronic device having the above-mentioned hardware structure and the above-mentioned system architecture.
  • the above-mentioned electronic device is a mobile phone 100 as an example to describe the methods of the embodiments of the present application.
  • a plurality of APPs are installed in the mobile phone 100, and each APP in the plurality of APPs includes at least one shared library.
  • the first APP can be a shopping application 1, and the shopping application 1 includes a shared library a and a shared library b; the second APP can be a shopping application 2, and the shopping application 2 includes a shared library c; the third APP can be a payment application,
  • the payment application includes a shared library d, a shared library e, and a shared library f.
  • each APP in the mobile phone 100 includes an executable program and at least one shared library.
  • the file data of each shared library contains multiple library functions.
  • the executable program will call the library function in the shared library to complete a certain function of the APP.
  • the first APP is a shopping application
  • the shopping application includes an executable program a, a shared library b, and a shared library c.
  • the executable program a may be run first.
  • the mobile phone 100 maps the shared library b and the shared library c into the memory, so that the executable program a can access the library from the memory function.
  • the following three relationships may exist between any shared library in the first APP and any shared library in the second APP.
  • the first APP and the second APP are any shared libraries in the mobile phone 100 .
  • Relationship 1 The two shared libraries are different.
  • the two shared libraries are different, which specifically means that the file data of the two shared libraries are different.
  • the file data of the two shared libraries is different, which means that the binary files of the two shared libraries are different.
  • the mobile phone 100 compiles the file data of the two shared libraries respectively to obtain two different secondary files.
  • the shared library a in the first APP includes library function 1 , library function 2 and library function 3
  • the shared library b in the second APP includes library function 4 and library function 5
  • the library function 1, the library function 2, the library function 3, the library function 4 and the library function 5 are different in pairs. So shared library a is completely different from shared library b.
  • the shared library a in the first APP includes library function 1, library function 2, and library function 3, and the shared library b in the second APP includes library function 3, library function 4, and library function 5.
  • the library function 1, the library function 2, the library function 3, the library function 4 and the library function 5 are different in pairs. So shared library a is partially different from shared library b.
  • file names of two different shared libraries may be the same or different.
  • Relationship 2 The two shared libraries are the same.
  • the two shared libraries are the same, which specifically means that the file data of the two shared libraries are the same.
  • the file data of the two shared libraries is the same, which means that the binary files of the two shared libraries are the same.
  • the library functions included in the two shared libraries are the same, and the mobile phone 100 respectively compiles the file data of the two shared libraries, two identical secondary files can be obtained.
  • file names of two identical shared libraries may be the same or different.
  • each shared library in an APP is different.
  • the first APP includes a shared library a, a shared library b, and a shared library c
  • the shared library a includes a first library function
  • the shared library b includes a second library function and a third library function
  • the shared library c includes a fourth library function.
  • the file name of shared library a is "shared library a"
  • the file data of shared library a is the first library function
  • the file name of shared library b is "shared library b”
  • the file data of shared library b is the second library function and the third library function
  • the file name of the shared library c is "shared library c”
  • the file data of the shared library c is the fourth library function. That is, the file names and file data of the shared library a, the shared library b, and the shared library c are different. Therefore, shared library a, shared library b, and shared library c are different.
  • An embodiment of the present application provides a method for multiplexing a shared library. As shown in FIG. 3 , the method for multiplexing a shared library may include S301-S304.
  • the mobile phone 100 determines whether there is a second shared library in the mobile phone 100 that has the same file data as the first shared library of the first APP.
  • the first APP includes at least one shared library, and the first shared library is any shared library in the first APP.
  • the first APP includes three shared libraries, and the three shared libraries are shared library a, shared library b, and shared library c, respectively.
  • the first shared library may be either a shared library a, a shared library b, or a shared library c.
  • the mobile phone 100 may execute the method of the embodiment of the present application for each shared library of the first APP.
  • the mobile phone 100 can determine whether there is a second shared library in the mobile phone 100 that has the same file data as the first shared library of the first APP in the following two ways.
  • Manner 1 The mobile phone 100 uses a preset algorithm according to the file data of the first shared library to generate the first identifier of the first shared library.
  • the preset algorithm may be Secure Hash Algorithm 1 (SHA-1), MD5 Message-Digest Algorithm (MD5), or Data Encryption Standard (Data Encryption) Standard, DES) algorithm, etc., which are not limited in this embodiment of the present application.
  • SHA-1 Secure Hash Algorithm 1
  • MD5 Message-Digest Algorithm MD5 Message-Digest Algorithm
  • DES Data Encryption Standard
  • the mobile phone 100 may use SHA-1 according to the file data of the first shared library to generate a hash value of 6cd7a for the file data of the first shared library.
  • the cell phone 100 determines whether the first identification and the second identification are the same.
  • the second identifier is generated by the mobile phone 100 using a preset algorithm according to the file data of any shared library in the mobile phone 100 .
  • the method for the mobile phone 100 to determine whether the first identification and the second identification are the same may include: the mobile phone 100 searches the first data table whether there is an identification that is the same as the first identification.
  • the first data table is used to store the correspondence between the identifier of the shared library and the number (Number) of the inode. In the first data table, each identification is different.
  • the inode corresponding to the identifier of the shared library is allocated by the mobile phone 100 for the shared library. For the specific allocation process, reference may be made to the description in step 302, which will not be repeated here.
  • Table 1 it shows the correspondence between the inode allocated to the shared library by the mobile phone 100 and the identification (Identification) of the shared library.
  • the first inode and the identification a of the shared library a the number of the first inode is 01, and the identification a is e908;
  • the second inode and the identification b of the shared library b the second inode is The number is 02, and the identifier b is 6cd7a;
  • the first data table can be called a ShareMap table.
  • the mobile phone 100 stores the correspondence between the inode number and the identifier of the shared library in the first data table, and can store the correspondence between the inode and the identifier of the shared library.
  • the mobile phone 100 may also store the correspondence between the number of the inode and the identifier of the shared library in other data tables , the embodiments of the present application do not limit this.
  • the mobile phone 100 may also store the correspondence between the number of the inode and the identifier of the shared library in a tree structure, which is not limited in this embodiment of the present application.
  • the mobile phone 100 stores the correspondence between the number of the inode and the identifier of the shared library in the first data table as an example to describe the method of the embodiment of the present application.
  • the mobile phone 100 determines that there is a second shared library in the mobile phone 100 that has the same file data as the first shared library.
  • the mobile phone 100 uses SHA-1 according to the file data of the shared library c, and determines that the identifier c of the shared library c is e908.
  • the mobile phone 100 traverses the identifiers in the first data table, and determines that the identifier a is e908. Therefore, the identity c is the same as the identity a.
  • both the first identifier and the second identifier are generated by the mobile phone 100 using a preset algorithm according to the file data of the shared library, therefore, when the first identifier and the second identifier are the same, the mobile phone 100 determines that the mobile phone 100 There is a second shared library that has the same file data as the first shared library.
  • the mobile phone 100 determines that there is no second shared library in the mobile phone 100 that is the same as the file data of the first shared library. It can be understood that, since both the first identifier and the second identifier are generated by the mobile phone 100 according to the file data of the shared library using a preset algorithm, therefore, in the case where the first identifier and the second identifier are different, the mobile phone 100 determines that the mobile phone 100 There is no second shared library that has the same file data as the first shared library.
  • the mobile phone 100 saves the correspondence between the first identifier and the second inode.
  • the correspondence between the first identifier and the second inode stored by the mobile phone 100 reference may be made to the description of step 401, which will not be repeated here.
  • the difference between the first identifier and the second identifier indicates that the second shared library that is the same as the file data of the first shared library does not exist in the electronic device. Therefore, the electronic device needs to save the correspondence between the first identifier and the second inode, so that after storing the first shared library, it can determine whether the file data of other shared libraries stored in the electronic device is the same as the first shared library according to the first identifier. same.
  • Method 2 The mobile phone 100 compares the file data of the first shared library with the file data of each shared library in the mobile phone 100 to determine whether there is a second shared library in the mobile phone 100 that is the same as the file data of the first shared library.
  • the mobile phone 100 compares the file data of the first shared library with the file data of each shared library in the mobile phone 100 through a preset comparison algorithm or a preset comparison tool, and determines whether there is any file data in the mobile phone 100.
  • a second shared library with the same file data as the first shared library.
  • the mobile phone 100 may compare the file data of the first shared library with the file data of a shared library in the mobile phone 100 each time.
  • the mobile phone 100 includes a shared library a, a shared library b, a shared library c, and a shared library d.
  • the mobile phone 100 compares the file data of the first shared library with the file data of the shared library a through a preset comparison tool, and determines The file data of the first shared library is different from the file data of the shared library a; after that, the mobile phone 100 compares the file data of the first shared library with the file data of the shared library b to determine the file data of the first shared library and the shared library The file data of b are different; after that, the mobile phone 100 compares the file data of the first shared library with the file data of the shared library c, and determines that the file data of the first shared library is the same as the file data of the shared library c.
  • the mobile phone 100 stops comparing the file data of the first shared library with the file data of the shared library of the mobile phone 100 , that is, the mobile phone 100 no longer compares the file data of the first shared library with the file data of the shared library d.
  • the mobile phone 100 may compare the file data of the first shared library with the file data of multiple shared libraries in the mobile phone 100 at the same time.
  • the mobile phone 100 includes a shared library a, a shared library b, a shared library c, and a shared library d, and the mobile phone 100 compares the file data of the first shared library with the shared library a, shared library b, and The file data of the shared library c is compared, and it is determined that the file data of the first shared library is the same as the file data of the shared library c. Then the mobile phone 100 stops comparing the file data of the first shared library with the file data of the shared library of the mobile phone 100 , that is, the mobile phone 100 no longer compares the file data of the first shared library with the file data of the shared library d.
  • the mobile phone 100 executes step 302; if the second shared library does not exist in the mobile phone 100, the mobile phone 100 executes step 401.
  • the mobile phone 100 saves the correspondence between the first index node inode and the file name of the first shared library.
  • the first inode is allocated by the mobile phone 100 for the second shared library.
  • the mobile phone 100 may save the correspondence between the first inode and the file names of the second shared library. Specifically, the mobile phone 100 saves the correspondence between the first inode and the file name of the second shared library by saving the correspondence between the number of the first inode and the file name of the second shared library.
  • the mobile phone 100 stores the correspondence between the serial number of the first inode and the file name of the second shared library in the second data table.
  • Table 2 it shows the correspondence between the number of the inode allocated by the mobile phone 100 for the shared library and the file name (File name) of the shared library.
  • the number of the first inode is 01
  • the file name of the second shared library is the shared library a
  • the second data table is the Directory table.
  • the mobile phone 100 may also store the correspondence between the inode number and the file name of the shared library.
  • the relationship is stored in other data tables, which is not limited in this embodiment of the present application.
  • the mobile phone 100 may also store the correspondence between the inode number and the file name of the shared library in a tree structure, which is not limited in this embodiment of the present application.
  • the method of the embodiment of the present application is described by taking the mobile phone 100 storing the correspondence between the inode number and the file name of the shared library in the second data table as an example.
  • the first inode indicates a first storage area for storing file data of the second shared library.
  • each shared library meta information includes: creation time (Creation time), file size (File size), storage location (Storage location), and the like.
  • creation time Create time
  • file size File size
  • Storage location Storage location
  • the number of the first inode is 01
  • the file name of the second shared library is shared library a
  • the creation date of the second shared library is "2020-08-10 09:00”
  • the file size of the second shared library is It is "100 kilobytes (Kilobyte, kb)”
  • the storage location of the second shared library is "/data/app1/”.
  • the first inode can be "Number: 01, File name: Shared library a, Creation time: 2020-08-10 09:00, File size: 100, Storage location: /data/app1/".
  • the mobile phone 100 can determine the inode corresponding to the file name through the file name of the shared library. In this way, the mobile phone 100 can obtain the storage location of the shared library from the inode, and read the file data of the shared library from the storage location.
  • the mobile phone 100 determines that there is a second shared library in the mobile phone 100 that is the same as the file data of the first shared library of the first APP, the first APP has been stored in the mobile phone 100 . That is, the file data of the first shared library has been stored in the mobile phone 100 .
  • the mobile phone 100 allocates a second inode to the first shared library, the mobile phone 100 saves the correspondence between the file name of the first shared library and the second inode, and the second inode stores the meta information of the first shared library.
  • Table 2 shows the correspondence between the number of the inode allocated by the mobile phone 100 for the shared library and the file name (File name) of the shared library.
  • the number of the second inode is 02, the file name of the first shared library is shared library b, and the second data table is the Directory table.
  • the mobile phone 100 determines the number of the first inode corresponding to the second identification from the first data table according to the second identification of the second shared library, that is, the first inode number.
  • the number of the first inode corresponding to the second shared library save the correspondence between the number of the first inode and the file name of the first shared library, and delete the correspondence between the number of the second inode and the file name of the first shared library relation.
  • Table 3 as shown in Table 4, it is the correspondence between the number of the inode and the file name (File name) of the shared library.
  • the number of the first inode is 01
  • the file name of the second shared library is shared library a
  • the file name of the first shared library is shared library b
  • the second data table is the Directory table.
  • the mobile phone 100 determines the number of the first inode corresponding to the second shared library according to the file data of the second shared library, and uses the file name of the first shared library The corresponding relationship with the number of the second inode is modified to the corresponding relationship between the file name of the first shared library and the number of the first inode.
  • the mobile phone 100 saves the correspondence between the first inode and the file name of the first shared library. Therefore, when the mobile phone 100 runs the first APP to call the first shared library, the mobile phone 100 can find the first inode according to the file name of the first shared library. In addition, since the first inode indicates the first storage area for storing the file data of the second shared library, the mobile phone 100 can read the file data of the second shared library according to the first inode, that is, the mobile phone 100 actually calls the file data at this time.
  • the shared library is the second shared library. Since the file data of the second shared library is the same as the file data of the first shared library, the mobile phone 100 can still ensure the normal operation of the first APP by calling the second shared library.
  • the mobile phone 100 deletes the file data of the first shared library.
  • the mobile phone 100 searches the second inode corresponding to the first shared library through the second data table according to the file name of the first shared library.
  • the mobile phone 100 determines, according to the second inode, a second storage area for storing the file data of the first shared library.
  • the mobile phone 100 deletes the file data of the first shared library according to the second storage area.
  • the mobile phone 100 may also search the tree structure for the second inode corresponding to the first shared library, which is not limited in this embodiment of the present application.
  • deleting the file data of the first shared library by the mobile phone 100 not only does not affect the normal operation of the first APP, but also saves the storage space of the electronic device, avoids storing multiple identical shared libraries in the electronic device, and improves the performance of the electronic device. Utilization of storage space for electronic products.
  • the mobile phone 100 needs to delete the file data of the first shared library according to the corresponding relationship between the file name of the first shared library and the second inode. Therefore, the mobile phone 100 needs to delete the file data of the first shared library before deleting or modifying the correspondence between the file name of the first shared library and the second inode. Under the condition that this condition is satisfied, this embodiment of the present application does not limit the order in which step 302 and step 303 are performed by the mobile phone 100 . That is, the mobile phone 100 may perform step 302 first, and then perform step 303; or, the mobile phone 100 may perform step 303 first, and then perform step 302; or, the mobile phone 100 may perform step 302 and step 303 at the same time.
  • the mobile phone 100 runs the first APP to call the first shared library, the mobile phone 100 searches for the first inode corresponding to the file name of the first shared library, and reads the file of the second shared library stored in the storage area indicated by the first inode data.
  • the mobile phone 100 when the mobile phone 100 runs the first APP to call the first shared library, the mobile phone 100 searches the first inode corresponding to the first shared library through the second data table according to the file name of the first shared library. The mobile phone 100 determines, according to the first inode, a first storage area for storing the file data of the second shared library. After that, the mobile phone 100 reads the file data of the second shared library in the first storage area according to the first storage area.
  • the first inode is "Number: 01, File name: shared library a, Creation time: 2020-08-1009:00, File size: 100, Storage location: /data/app1/".
  • the mobile phone 100 searches the second data table for the inode number 01 corresponding to the shared library b, and determines the first inode number 01. After that, the mobile phone 100 determines the storage location as "/data/app1/" according to the first inode, and reads the file data of the second shared library from "/data/app1/".
  • the mobile phone 100 may also search for the first inode corresponding to the first shared library through the tree structure, which is not limited in this embodiment of the present application.
  • the mobile phone 100 runs the first APP to call the first shared library
  • what the mobile phone 100 actually calls is the second shared library.
  • the electronic device only maps the second shared library into the memory, and both the first APP and the second APP can call the second APP from the memory
  • the file data of the shared library reduces the space occupied by the memory and improves the utilization of the memory.
  • the electronic device may also save the correspondence between the first inode and the file name of the first shared library. In this way, when the electronic device runs the first APP to call the first shared library, the electronic device does not need to call the file data of the first shared library, but only needs to search the first inode through the file name of the first shared library to read the second The file data of the shared library can ensure the normal operation of the APP.
  • the electronic device runs the APP to call the shared library
  • the shared library can be mapped into the memory, and then the shared library can be called from the memory.
  • the performance of the electronic device can be improved.
  • the electronic device runs multiple APPs (such as the first APP and the second APP including the second shared library)
  • the first shared library and the second shared library are respectively mapped into the memory, because the mapped data If the amount is large, it will not only affect the I/O performance, but also cause a waste of memory space.
  • the electronic device only maps the second shared library into the memory, and both the first APP and the second APP can call the file data of the second shared library from the memory when running. In this way, not only the amount of data mapped to the memory is reduced, the I/O performance is improved, but also the space occupied by the memory can be reduced, and the utilization rate of the memory can be improved.
  • an embodiment of the present application provides a method for multiplexing a shared library. As shown in FIG. 4 , after S301 , the method for multiplexing a shared library may further include S401 to S403 .
  • the mobile phone 100 allocates a second inode for the first shared library.
  • the second inode indicates a second storage area for saving the file data of the first shared library.
  • the mobile phone 100 allocates a second inode to the first shared library, so that when the first APP runs and calls the first shared library, the mobile phone 100 can read the file data of the first shared library according to the second inode , to ensure the normal operation of the first APP.
  • the mobile phone 100 saves the correspondence between the first identifier and the second inode. Specifically, the mobile phone 100 determines the number of the second inode allocated to the first shared library, and stores the first identifier and the number of the second inode in the first data table.
  • the mobile phone 100 saves the correspondence between the second inode and the file name of the first shared library.
  • the mobile phone 100 saves the correspondence between the second inode and the file name of the first shared library, so that when the first APP runs and calls the first shared library, the mobile phone 100 can search for the first shared library according to the file name of the first shared library.
  • the corresponding second inode and read the file data of the first shared library according to the second inode, so as to ensure the normal operation of the first APP.
  • the mobile phone 100 when the mobile phone 100 runs the first APP to electrophorese the first shared library, the mobile phone 100 searches the second inode corresponding to the first shared library through the second data table according to the file name of the first shared library. The mobile phone 100 determines, according to the second inode, a second storage area for storing the file data of the first shared library. After that, the mobile phone reads the file data of the first shared library in the second storage area according to the second storage area.
  • the electronic device needs to store the first shared library. In this way, when the electronic device runs the first APP to call the first shared library, the electronic device can search for the second inode through the file name of the first shared library, thereby reading the file of the first shared library data to ensure the normal operation of the APP.
  • the inode in addition to storing the meta information of the shared library corresponding to the inode, the inode also includes the number of links (Links).
  • the number of inode links is the number of shared libraries corresponding to the inode.
  • the shared library corresponding to the first inode includes the second shared library, the number of shared libraries corresponding to the first inode is 1, and the number of links of the first inode is 1;
  • the shared library corresponding to the second inode includes The number of shared libraries corresponding to the first shared library and the second inode is 1, and the number of links of the second inode is 1.
  • the shared library corresponding to the first inode includes a first shared library and a second shared library, the number of shared libraries corresponding to the first inode is 2, and the number of links of the first inode is 2.
  • the initial value of the number of links per inode is 0. That is, when the mobile phone 100 has not allocated an inode to a shared library, the number of shared libraries corresponding to the inode is 0. Therefore, the initial value of the link count of the inode is 0.
  • the mobile phone 100 adds 1 to the link number of the first inode.
  • the number of links of the first inode is the number of shared libraries corresponding to the first inode. Exemplarily, in combination with Table 3 and Table 4, before the file name of the first shared library is established with the first inode, the number of links of the first inode is 1; the file name of the first shared library is established with the first inode. After the correspondence, the number of links of the first inode is 2.
  • the mobile phone 100 determines the first inode corresponding to the second identifier of the second shared library.
  • the mobile phone 100 stores the file name of the first shared library and the number of the first inode in the second data table according to the file name and the first inode of the first shared library, and adds 1 to the link number of the first inode.
  • the mobile phone 100 changes the link number of the first inode by adding 1 to the link number of the first inode, thereby updating the shared library corresponding to the first inode. The number enables the mobile phone 100 to determine the number of shared libraries to be replaced by the second shared library according to the number of links of the first inode.
  • the mobile phone 100 adds 1 to the link number of the second inode.
  • the number of links of the second inode is the number of shared libraries corresponding to the second inode.
  • the mobile phone 100 creates a second inode. At this time, the second inode has no corresponding shared library, and the link number of the second inode is 0.
  • the shared library corresponding to the second inode includes the first shared library, and the link number of the second inode is 1.
  • the mobile phone 100 changes the link number of the second inode by adding 1 to the link number of the second inode, thereby updating the number of shared libraries corresponding to the second inode, so that the mobile phone 100 can determine the first shared library according to the link number of the second inode Number of alternate shared libraries.
  • the above embodiments are only for adding an APP (eg, a first APP including a first shared library) in the mobile phone 100 , that is, for adding a first shared library in the mobile phone 100 , and related steps performed by the mobile phone 100 .
  • the following embodiments of the present application provide a method for multiplexing a shared library, and the method for multiplexing the shared library is introduced in combination with an application scenario where the mobile phone 100 deletes an APP.
  • the method of this embodiment of the present application may further include S601-S604.
  • the mobile phone 100 may perform S601-S604 before executing the above method process, during the process of executing the above method process, or after executing the above method process.
  • the mobile phone 100 searches for the third inode corresponding to the file name of the third shared library.
  • the third shared library is any one of the at least one shared library included in the second APP.
  • the second APP includes a shared library a, a shared library b, and a shared library c
  • the third shared library may be a shared library a, a shared library b, or a shared library c.
  • the mobile phone 100 may execute the methods of the embodiments of the present application for each shared library of the second APP.
  • the mobile phone 100 determines the file name of the third shared library of the second APP, and searches the second data table for the third shared library corresponding to the file name of the third shared library. inodes.
  • Table 5 it shows the correspondence between the number of the inode allocated by the mobile phone 100 for the shared library and the file name of the shared library.
  • the number of the third inode is 03
  • the file name of the third shared library is the shared library c
  • the second data table is the Directory table.
  • the mobile phone 100 determines a third inode corresponding to the number of the third inode according to the number of the third inode.
  • the mobile phone 100 determines whether the link number of the third inode is equal to 1.
  • the mobile phone 100 performs step 503; if the link number of the third inode is greater than 1, the mobile phone 100 performs step 504.
  • the third inode since the correspondence between the third inode and the shared library is stored in the mobile phone 100 at this time, the third inode corresponds to at least one shared library. Therefore, the link count of the third inode will not be less than 1, that is, the link count of the third inode will not be equal to 0.
  • the mobile phone 100 deletes the file data of the third shared library, the third inode, and the correspondence between the file name of the third shared library and the third inode from the mobile phone 100.
  • the mobile phone 100 determines the storage area of the file data of the third shared library according to the storage location of the third shared library in the inode, and deletes the storage area of the third shared library. file data.
  • the mobile phone 100 deletes the correspondence between the file name of the third shared library and the third inode in the second data table according to the file name of the third shared library; or, the mobile phone 100 deletes the second data table according to the number of the third inode
  • the mobile phone 100 deletes the third inode according to the number of the third inode.
  • the mobile phone 100 deletes the correspondence between the number of the third inode and the third identifier from the first data table according to the number of the third inode.
  • the mobile phone 100 deletes the correspondence between the third inode and the third identifier from the mobile phone 100 .
  • the link number of the third inode is equal to 1, it means that the shared library corresponding to the third inode is only the third shared library. That is to say, the third shared library does not need to replace other shared libraries, that is, the APPs other than the second APP will not call the third shared library when running. Also, after the mobile phone 100 deletes the second APP, no APP in the mobile phone 100 calls the third shared library. Therefore, when the mobile phone 100 deletes the second APP, the mobile phone 100 deletes the file data, the third inode, the third shared library, and the third shared library. The correspondence between the file name of the shared library and the third inode, and the correspondence between the third inode and the third identifier, thereby saving the storage space of the mobile phone 100 .
  • APP(A) includes shared library a
  • APP(B) includes shared library b
  • APP(C) includes shared library c
  • the file data of shared library a, shared library b, and shared library c are all the same.
  • the shared library corresponding to the third inode includes: shared library a, shared library b, and shared library c, therefore, the number of links of the third inode is 3.
  • the mobile phone 100 calls the shared library a, the shared library b, or the shared library c
  • the mobile phone 100 calls the file data of the shared library a.
  • the mobile phone 100 deletes APP (C) the mobile phone 100 does not delete the file data of the shared library c, but only reduces the number of links of the third inode by 1.
  • the shared library corresponding to the third inode includes the shared library a and the shared library b.
  • the third inode corresponds to the shared library a and the shared library b.
  • the number of inode links is 2.
  • the link number of the third inode determines the number of shared libraries that the third shared library replaces.
  • the electronic device can determine whether there is still APP in the electronic device that needs to call the file data of the shared library (such as the third shared library) according to the link number of the inode (for example, the third inode), so as to determine whether the third shared library can be deleted.
  • the file data of the shared library corresponding to the three inodes, the third inode, and the correspondence between the file name of the third shared library and the third inode. In this way, it can not only reduce the waste of storage space, but also ensure that the APP in the electronic device will not fail to run normally due to the lack of the shared library.
  • the electronic device can not only store the executable program of the APP and at least one shared library, but also store information data in the APP such as text files, pictures, audio, etc.
  • the executable program can call the information data in the APP, and display the information data (such as pictures) to the user.
  • the electronic device will repeatedly store the picture a, which only results in a waste of storage space.
  • the shared library multiplexing method provided by the embodiment of the present application is not only applicable to the management of the shared library in the electronic device, but also can be used to manage the information data of the APP in the electronic device, which is not limited in the embodiment of the present application.
  • the specific multiplexing method of information data reference may be made to the descriptions in the foregoing embodiments, which will not be repeated here.
  • the attribute of the information data in the electronic device is a read-only attribute. In this way, the information data can be prevented from being tampered with, thereby ensuring that the information data of the APP will not change.
  • the electronic device includes corresponding hardware structures and/or software modules for executing each function.
  • the steps of a method for multiplexing a shared library in each example described in conjunction with the embodiments disclosed in this application can be implemented in hardware or in a combination of hardware and computer software. Whether a function is performed by hardware or electronic device software driving hardware depends on the specific application and design constraints of the technical solution. Skilled artisans may implement the described functionality using different methods for each particular application, but such implementations should not be considered beyond the scope of this application.
  • the multiplexing device of the shared library may be divided into functional modules or functional units according to the foregoing method examples.
  • each functional module or functional unit may be divided corresponding to each function, or two or more functions may be divided into two or more functional units.
  • integrated in a processing module can be implemented in the form of hardware, and can also be implemented in the form of software function modules or functional units.
  • the division of modules or units in the embodiments of the present application is schematic, and is only a logical function division, and there may be other division manners in actual implementation.
  • FIG. 6 shows a schematic diagram of an apparatus for multiplexing a shared library provided by an embodiment of the present application.
  • the apparatus for multiplexing the shared library may be a functional module in the above-mentioned electronic device (eg, the mobile phone 100 ) for implementing the method of the embodiment of the present application.
  • the apparatus for multiplexing the shared library may include: a processing unit 601 and a storage unit 602 .
  • the storage unit 602 is used for saving at least one shared library.
  • the storage unit may be used to store the shared library a.
  • the processing unit 601 is configured to determine whether there is a second shared library in the storage list 602 that has the same file data as the first shared library of the first APP, where the first shared library is any shared library in the first APP.
  • the processing unit 601 may be configured to perform S301.
  • the storage unit 602 is further configured to save the correspondence between the inode of the first index node and the file name of the first shared library if the second shared library exists in the storage unit, wherein the first inode is the processing unit for the second shared library For the library allocation, the first inode indicates a first storage area for storing file data of the second shared library.
  • the processing unit 601 may be configured to perform S302.
  • the processing unit 601 is further configured to delete the file data of the first shared library from the storage unit.
  • the processing unit 601 is further configured to search for the first inode corresponding to the file name of the first shared library when the first shared library is called from the first APP, and read the second shared library stored in the storage area indicated by the first inode file data.
  • the processing unit 601 may also be used to perform S304.
  • the processing unit 601 is specifically configured to, when the first APP is installed, determine whether there is a second shared library that is identical to the file data of the first shared library of the first APP in the storage unit; In the case of an APP, it is determined whether there is a second shared library that is identical to the file data of the first shared library of the first APP in the storage unit.
  • the mobile phone 100 downloads and stores the APK of the first APP in the storage unit 602 through the network; when the APK of the first APP is decompressed, that is, when the first APP is installed, the processing unit 601 determines whether there is an APK with the first APP in the storage unit.
  • the file data of the first shared library of the APP is the same as the second shared library.
  • processing unit 601 is further specifically configured to determine whether there is a second shared library with the same file data as the first shared library of the first APP in the storage unit when the first APP is finished running for the first time.
  • the processing unit 601 is further configured to allocate a second inode for the first shared library if the second shared library does not exist in the storage unit 602; wherein the second inode indicates the file data used to save the first shared library the second storage area.
  • the processing unit 601 may also be used to perform S401.
  • the storage unit 602 is further configured to save the correspondence between the second inode and the file name of the first shared library.
  • the storage unit 602 may also be used to perform S402.
  • the processing unit 601 is further configured to search the second inode corresponding to the file name of the first shared library when running the first APP to call the first shared library, and read the first shared storage area stored in the second storage area indicated by the second inode Library file data.
  • the processing unit 601 may also be used to perform S403.
  • the processing unit 601 is further configured to add 1 to the link number of the first inode if there is a second shared library in the storage unit; wherein, the link number of the first inode is the number of shared libraries corresponding to the first inode ; If there is no second shared library in the storage unit, then add 1 to the number of links of the second inode; wherein, the number of links of the second inode is the number of shared libraries corresponding to the second inode; wherein, the number of links of each inode The initial value of is 0.
  • the processing unit 601 is further configured to search the storage unit 602 for the third inode corresponding to the file name of the third shared library when the second APP is deleted.
  • the processing unit 601 may perform S601 in the foregoing method embodiments.
  • the processing unit 601 is further configured to determine whether the link number of the third inode is equal to 1. For example, the processing unit 601 may perform S602 in the foregoing method embodiments.
  • the processing unit 601 is further configured to delete the file data of the third shared library, the third inode, and the relationship between the file name of the third shared library and the third inode from the storage unit 602 if the link number of the third inode is equal to 1 corresponding relationship.
  • the processing unit 601 may perform S603 in the above method embodiments.
  • the processing unit 601 is further configured to reduce the link number of the third inode by 1 if the link number of the third inode is greater than 1.
  • the processing unit 601 may perform S604 in the above method embodiments.
  • the processing unit 601 is specifically configured to use a preset algorithm according to the file data of the first shared library to generate the first identification of the first shared library, and to determine whether the first identification and the second identification are the same; wherein, the second identification
  • the identifier is generated by the processing unit using a preset algorithm according to the file data of any shared library in the storage unit; wherein, if the first identifier is the same as the second identifier, it is determined that there is a file data identical to the file data of the first shared library in the storage unit.
  • the second shared library if the first identification is different from the second identification, it is determined that there is no second shared library with the same file data as the first shared library in the storage unit.
  • the storage unit 602 is further configured to save the correspondence between the first identifier and the second inode if the first identifier is different from the second identifier.
  • the processing unit 601 is further configured to delete the correspondence between the third inode and the third identifier from the storage unit 602 if the number of links of the third inode is equal to 1;
  • the file data of the third shared library is generated using a preset algorithm.
  • the processing unit 601 is further specifically configured to compare the file data of the first shared library with the file data of each shared library in the storage unit, and determine whether there is a first shared library in the storage unit 602 that is the same as the file data of the first shared library. Two shared libraries.
  • an electronic device such as the mobile phone 100 shown in FIG. 1
  • multiple APPs are installed in the electronic device, and each APP in the multiple APPs includes at least one shared library.
  • the at least one shared library may include the second shared library.
  • the electronic device may include: memory and one or more processors.
  • the memory is coupled to the processor.
  • the electronic device may also include a camera. Alternatively, the electronic device may be externally connected to a camera.
  • the memory is used to store computer program code comprising computer instructions.
  • the processor executes the computer instructions, the electronic device can execute various functions or steps executed by the mobile phone in the foregoing method embodiments.
  • the chip system includes at least one processor 701 and at least one interface circuit 702 .
  • the processor 701 and the interface circuit 702 may be interconnected by wires.
  • the interface circuit 702 may be used to receive signals from other devices, such as the memory of an electronic device.
  • the interface circuit 702 may be used to send signals to other devices (eg, the processor 701).
  • the interface circuit 702 can read the instructions stored in the memory and send the instructions to the processor 701 .
  • the electronic device such as the mobile phone 100 as shown in FIG. 1 can be made to execute each step in the above embodiment.
  • the chip system may also include other discrete devices, which are not specifically limited in this embodiment of the present application.
  • An embodiment of the present application further provides a computer storage medium, where the computer storage medium includes computer instructions, when the computer instructions are executed on the above electronic device (the mobile phone 100 shown in FIG. 1 ), the electronic device is made to execute the above method. Each function or step performed by the mobile phone in the embodiment.
  • Embodiments of the present application further provide a computer program product, which, when the computer program product runs on a computer, enables the computer to perform various functions or steps performed by the mobile phone in the above method embodiments.
  • the disclosed apparatus and method may be implemented in other manners.
  • the device embodiments described above are only illustrative.
  • the division of the modules or units is only a logical function division. In actual implementation, there may be other division methods.
  • multiple units or components may be Incorporation may either be integrated into another device, or some features may be omitted, or not implemented.
  • the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, indirect coupling or communication connection of devices or units, and may be in electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place, or may be distributed to multiple different places . Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit.
  • the above-mentioned integrated units may be implemented in the form of hardware, or may be implemented in the form of software functional units.
  • the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it may be stored in a readable storage medium.
  • the technical solutions of the embodiments of the present application can be embodied in the form of software products in essence, or the parts that contribute to the prior art, or all or part of the technical solutions, which are stored in a storage medium , including several instructions to make a device (may be a single chip microcomputer, a chip, etc.) or a processor (processor) to execute all or part of the steps of the methods described in the various embodiments of the present application.
  • the aforementioned storage medium includes: U disk, mobile hard disk, read only memory (ROM), random access memory (random access memory, RAM), magnetic disk or optical disk and other media that can store program codes.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Stored Programmes (AREA)

Abstract

一种共享库的复用方法及电子设备,涉及电子设备技术领域,可以使不同的应用程序APP在运行时调用同一个共享库,提高电子产品的存储空间的利用率。具体方案包括:电子设备可以确定电子设备中是否存在与第一APP的第一共享库的文件数据相同的第二共享库。若电子设备中存在第二共享库,则保存第一索引节点(inode)与第一共享库的文件名称之间的对应关系,并从电子设备中删除第一共享库的文件数据。之后,当电子设备运行第一APP调用第一共享库时,电子设备就可以查找该第一共享库的文件名称对应的第一inode,以读取第一inode指示的存储区域保存的第二共享库的文件数据。

Description

一种共享库的复用方法及电子设备
本申请要求于2020年8月31日提交国家知识产权局、申请号为202010899468.4、申请名称为“一种共享库的复用方法及电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请实施例涉及电子设备技术领域,尤其涉及一种共享库的复用方法及电子设备。
背景技术
随着科技的发展,用户对电子产品如手机、智能穿戴设备等功能的需求越来越多。为了满足用户对电子产品的使用需求,电子产品中的应用(Application,App)也逐渐增多。目前,每一个APP中均包括可执行程序和多个共享库。其中,共享库包括Windows操作系统中的动态链接库,Linux操作系统中的共享目标等。也就是说,当用户在电子产品中安装一个APP后,该APP的可执行程序和多个共享库会存储在电子产品中。
然而,随着代码开源化和平台化技术的发展,不同的APP在开发过程中可能会使用到相同的共享库。因此,当电子产品中的APP数量越来越多时,电子产品中可能会存储多个相同的共享库,导致电子产品的存储空间被浪费。
发明内容
本申请实施例提供一种共享库的复用方法,可以使不同的APP在运行时调用同一个共享库,提高电子产品的存储空间的利用率。
第一方面,本申请实施例提供一种共享库的复用方法,该方法可以应用于电子设备,该电子设备中安装有多个APP,多个APP中的每个APP包括至少一个共享库。例如,该至少一个共享库可以包括第二共享库。
在该共享库的复用方法中,电子设备可以确定电子设备中是否存在与第一APP的第一共享库的文件数据相同的第二共享库。该第一共享库是第一APP中任意一个共享库。若电子设备中存在第二共享库,则保存第一索引节点(inode)与第一共享库的文件名称之间的对应关系,并从电子设备中删除第一共享库的文件数据。其中,第一inode是电子设备为第二共享库分配的,该第一inode可以指示用于保存该第二共享库的文件数据的第一存储区域。也就是说,电子设备根据该第一inode可以确定出电子设备中、保存第二共享库的文件数据的第一存储区域。之后,当电子设备运行第一APP调用第一共享库时,电子设备就可以查找该第一共享库的文件名称对应的第一inode,以读取第一inode指示的存储区域保存的第二共享库的文件数据。
基于上述技术方案,若电子设备中存在与第一APP的第一共享库的文件数据相同的第二共享库;那么,如果电子设备不仅保存第二共享库的文件数据,还保存该第一共享库的文件数据,则会存在电子设备存储空间的浪费。因此,在电子设备中存在与第一APP的第一共享库的文件数据相同的第二共享库的情况下,该电子设备可以删除第一共享库 的文件数据。这样,可以提供电子设备的存储空间的利用率。
进一步的,为了保证电子设备正常运行第一APP;该电子设备还可以保存第一inode与第一共享库的文件名称之间的对应关系。这样一来,当电子设备运行第一APP调用第一共享库时,电子设备无需调用第一共享库的文件数据,只需要通过第一共享库的文件名称查找第一inode,以读取第二共享库的文件数据,从而可以保障APP的正常运行。
结合第一方面,在一种可能的设计方式中,电子设备运行APP调用共享库时,可以将共享库映射到内存中,再从内存中调用共享库。这样,可以提高电子设备的性能。常规技术中,电子设备运行多个APP时(如第一APP和包含有第二共享库的第二APP),会分别将第一共享库和第二共享库映射到内存中,由于映射的数据量较大,不仅影响I/O性能,还会造成内存空间的浪费。而本申请实施例中,电子设备只将第二共享库映射到内存中,第一APP和第二APP运行时,均可从内存中调用第二共享库的文件数据。这样一来,不仅减小了映射到内存的数据量,提高了I/O性能,而且能够减少内存的占用空间,提高了内存的利用率。
结合第一方面,在另一种可能的设计方式中,上述“电子设备确定电子设备中是否存在与第一APP的第一共享库的文件数据相同的第二共享库”的方法包括:电子设备安装完第一APP时,电子设备确定电子设备中是否存在与第一APP的第一共享库的文件数据相同的第二共享库;或者,电子设备运行完第一APP时,电子设备确定电子设备中是否存在与第一APP的第一共享库的文件数据相同的第二共享库。
基于上述技术方案,当电子设备中的APP(如第一APP)是从平台下载到电子设备时,电子设备可以监控第一APP的安装过程,并在电子设备安装完第一APP时,检测电子设备是否存储有与第一共享库的文件数据相同的第二共享库,从而使电子设备可以及时发现是否存储有相同的共享库。并且,电子设备在安装完第一APP的时候进行检测,可以避免第一APP的运行受到影响。
然而,当电子设备中的APP(如第一APP)是从其他可移动存储设备中拷贝到该电子设备中时,电子设备无法监控第一APP的拷贝过程。因此,只有当该拷贝的第一APP运行时,电子设备才可以对其进行监控,检测其是否存储有与第一共享库的文件数据相同的第二共享库,使电子设备及时发现是否存储有相同的共享库。并且,电子设备在第一APP运行完的时候进行检测,可以避免APP的运行受到影响。
结合第一方面,在另一种可能的设计方式中,上述“电子设备运行完第一APP时,电子设备确定电子设备中是否存在与第一APP的第一共享库的文件数据相同的第二共享库”可以包括:电子设备第一次运行完第一APP时,电子设备确定电子设备中是否存在与第一APP的第一共享库的文件数据相同的第二共享库。
可以理解的是,通过上述方案,如果电子设备确定电子设备中存在与第一APP的第一共享库的文件数据相同的第二共享库,电子设备则可以删除该第一共享库的文件数据。那么,电子设备第一次运行完第一APP后,该电子设备便可以删除该第一共享库的文件数据。因此,该电子设备再次运行该第一APP后,则不需要再判断电子设备中存在与第一APP的第一共享库的文件数据相同的第二共享库。这样,可以减小了电子设备的运算压力。
结合第一方面,在另一种可能的设计方式中,该方法还包括:若电子设备中不存在 第二共享库,则电子设备为第一共享库分配第二inode,并保存第二inode与第一共享库的文件名称之间的对应关系。第二inode指示用于保存第一共享库的文件数据的第二存储区域。之后,当电子设备运行第一APP调用第一共享库时,查找第一共享库的文件名称对应的第二inode,并读取第二inode指示的第二存储区域保存的第一共享库的文件数据。
基于这种情况,如果电子设备中不存在与第一APP的第一共享库的文件数据相同的第二共享库,则表示该电子设备中没有可以替代第一共享库的共享库。因此,电子设备可以存储该第一共享库。这样一来,在电子设备运行第一APP调用第一共享库时,电子设备就可以通过第一共享库的文件名称查找第二inode,从而读取第一共享库的文件数据,以保障APP的正常运行。
结合第一方面,在另一种可能的设计方式中,该方法还包括:若所述电子设备中存在所述第二共享库,则电子设备为所述第一inode的链接数加1;其中,所述第一inode的链接数为所述第一inode对应的共享库的数量;若所述电子设备中不存在所述第二共享库,则电子设备为所述第二inode的链接数加1;其中,所述第二inode的链接数为所述第二inode对应的共享库的数量,每个inode的链接数的初始值为0。
也就是说,若电子设备中存在第二共享库,说明第一共享库可以被第二共享库替代。又由于第一inode是电子设备为第二共享库分配的,因此,电子设备改变第一inode的链接数,为第一inode的链接数加1,从而更新第一inode对应的共享库的数量,使电子设备能够根据第一inode的链接数确定第二共享库替代的共享库的数量。
若电子设备中不存在第二共享库,说明电子设备中没有共享库能够替代第一共享库。因此,电子设备改变第二inode的链接数,为第二inode的链接数加1,从而更新第二inode对应的共享库的数量,使电子设备能够根据第二inode的链接数确定第一共享库替代的共享库的数量。
结合第一方面,在另一种可能的设计方式中,该方法还包括:所述电子设备删除第二APP时,查找第三共享库的文件名称对应的第三inode;若所述第三inode的链接数等于1,则从所述电子设备中删除所述第三共享库的文件数据、所述第三inode、以及所述第三共享库的文件名称与所述第三inode之间的对应关系;若所述第三inode的链接数大于1,为所述第三inode的链接数减1。
可以理解的,若第三inode的链接数等于1,说明第三共享库不需要替代其他的共享库,即除了第二APP以外的APP在运行时,均不会调用第三共享库。又由于电子设备在删除第二APP后,电子设备中没有APP调用第三共享库,因此,电子设备删除第二APP时,电子设备可以删除第三共享库的文件数据、第三inode、以及第三共享库的文件名称与第三inode之间的对应关系,从而节约电子设备的存储空间。
若第三inode的链接数大于1,说明第三共享库需要替代其他的共享库,即除了第二APP以外的APP在运行时,可能需要调用第三共享库。因此,为了保障其他APP正常运行,电子设备不能删除第三共享库。又由于电子设备将删除第二APP,即调用第三共享库的APP的数量减少,因此电子设备改变第三inode的链接数,从而更新第三inode对应的共享库的数量,使电子设备能够根据第三inode的链接数确定第三共享库替代的共享库的数量。
结合第一方面,在另一种可能的设计方式中,上述“电子设备确定所述电子设备中 是否存在与第一APP的第一共享库的文件数据相同的第二共享库”的方法包括:电子设备根据第一共享库的文件数据采用预设算法,生成所述第一共享库的第一标识,并确定所述第一标识与第二标识是否相同;其中,所述第二标识是所述电子设备根据所述电子设备中任一个共享库的文件数据采用所述预设算法生成的。
具体的,若所述第一标识与所述第二标识相同,则确定所述电子设备中存在与所述第一共享库的文件数据相同的所述第二共享库;若所述第一标识与第二标识不同,则确定所述电子设备中不存在与所述第一共享库的文件数据相同的所述第二共享库。
结合第一方面,在另一种可能的设计方式中,该方法还包括:所述第一标识与第二标识不同,电子设备保存所述第一标识与所述第二inode的对应关系。
可以理解的是,第一标识与第二标识不同,说明电子设备中不存在与第一共享库的文件数据相同的所述第二共享库。因此,电子设备要保存第一标识与第二inode的对应关系,使得在存储第一共享库之后,能够根据第一标识确定其他存储在电子设备中的共享库的文件数据是否与第一共享库相同。
结合第一方面,在另一种可能的设计方式中,该方法还包括:所述第三inode的链接数等于1,则从所述电子设备中删除所述第三inode与所述第三标识之间的对应关系,该第三标识是所述电子设备根据所述第三共享库的文件数据采用所述预设算法生成的。
可以理解的,若第三inode的链接数等于1,说明第三共享库不需要替代其他的共享库,即除了第二APP以外的APP在运行时,均不会调用第三共享库。又由于电子设备在删除第二APP后,电子设备中没有APP调用第三共享库,因此,电子设备删除第二APP时,电子设备会删除第三inode与第三标识之间的对应关系,从而节约电子设备的存储空间。
结合第一方面,在另一种可能的设计方式中,该方法还包括:电子设备对比所述第一共享库的文件数据与所述电子设备中每一个共享库的文件数据,确定所述电子设备中是否存在与所述第一共享库的文件数据相同的所述第二共享库。
第二方面,本申请实施例提供一种电子设备,该电子设备中安装有多个应用程序,多个APP中的每个APP包括至少一个共享库,电子设备包括:处理单元和存储单元。
存储单元,用于保存至少一个共享库。处理单元,用于确定存储单元中是否存在与第一APP的第一共享库的文件数据相同的第二共享库,第一共享库为第一APP中任意一个共享库。存储单元,还用于若存储单元中存在第二共享库,则保存第一索引节点inode与第一共享库的文件名称之间的对应关系,其中,第一inode是处理单元为第二共享库分配的,第一inode指示用于保存第二共享库的文件数据的第一存储区域。处理单元,还用于从存储单元中删除第一共享库的文件数据。处理单元,还用于当运行第一APP调用第一共享库时,查找第一共享库的文件名称对应的第一inode,并读取第一inode指示的存储区域保存的第二共享库的文件数据。
结合第二方面,在一种可能的设计方式中,处理单元,具体用于:当安装完第一APP时,确定存储单元中是否存在与第一APP的第一共享库的文件数据相同的第二共享库;或者,当运行完第一APP时,确定存储单元中是否存在与第一APP的第一共享库的文件数据相同的第二共享库。
结合第二方面,在另一种可能的设计方式中,处理单元,具体用于:当第一次运行 完毕第一APP时,确定存储单元中是否存在与第一APP的第一共享库的文件数据相同的第二共享库。
结合第二方面,在另一种可能的设计方式中,处理单元,还用于若存储单元中不存在第二共享库,则为第一共享库分配第二inode;其中,第二inode指示用于保存第一共享库的文件数据的第二存储区域;存储单元,还用于保存第二inode与第一共享库的文件名称之间的对应关系。
处理单元,还用于当运行第一APP调用第一共享库时,查找第一共享库的文件名称对应的第二inode,并读取第二inode指示的第二存储区域保存的第一共享库的文件数据。
结合第二方面,在另一种可能的设计方式中,处理单元,还用于:若存储单元中存在第二共享库,则为第一inode的链接数加1;其中,第一inode的链接数为第一inode对应的共享库的数量;若存储单元中不存在第二共享库,则为第二inode的链接数加1;其中,第二inode的链接数为第二inode对应的共享库的数量;其中,每个inode的链接数的初始值为0。
结合第二方面,在另一种可能的设计方式中,处理单元,还用于:当删除第二APP时,查找第三共享库的文件名称对应的第三inode;若第三inode的链接数等于1,则从存储单元中删除第三共享库的文件数据、第三inode、以及第三共享库的文件名称与第三inode之间的对应关系;若第三inode的链接数大于1,为第三inode的链接数减1。
结合第二方面,在另一种可能的设计方式中,处理单元,具体用于:根据第一共享库的文件数据采用预设算法,生成第一共享库的第一标识,并确定第一标识与第二标识是否相同;其中,第二标识是处理单元根据存储单元中任一个共享库的文件数据采用预设算法生成的;其中,若第一标识与第二标识相同,则确定存储单元中存在与第一共享库的文件数据相同的第二共享库;若第一标识与第二标识不同,则确定存储单元中不存在与第一共享库的文件数据相同的第二共享库。
结合第二方面,在另一种可能的设计方式中,存储单元,还用于若第一标识与第二标识不同,保存第一标识与第二inode的对应关系。
结合第二方面,在另一种可能的设计方式中,处理单元,还用于若第三inode的链接数等于1,则从存储单元中删除第三inode与第三标识之间的对应关系;其中,第三标识是处理单元根据第三共享库的文件数据采用预设算法生成的。
结合第二方面,在另一种可能的设计方式中,处理单元,具体用于对比第一共享库的文件数据与存储单元中每一个共享库的文件数据,确定存储单元中是否存在与第一共享库的文件数据相同的第二共享库。
第三方面,本申请实施例提供一种电子设备,该电子设备中安装有多个应用程序APP,上述多个APP中的每个APP包括至少一个共享库;该电子设备包括:存储器和处理器,上述存储器与上述处理器耦合;上述至少一个共享库保存在存储器中,存储器还用于存储计算机程序代码,计算机程序代码包括计算机指令;当计算机指令被所述处理器执行时,使得电子设备执行如第一方面及其任一种可能的设计方式所述的方法。
第四方面,本申请实施例提供一种芯片系统,该芯片系统应用于电子设备,该电子设备中安装有多个APP,多个APP中的每个APP包括至少一个共享库。该芯片系统包括一个或多个接口电路和一个或多个处理器。该接口电路和处理器通过线路互联。该接口 电路用于从电子设备的存储器接收信号,并向处理器发送该信号,该信号包括存储器中存储的计算机指令。当处理器执行所述计算机指令时,电子设备执行如第一方面及其任一种可能的设计方式所述的方法。
第五方面,本申请实施例提供一种计算机存储介质,该计算机存储介质包括计算机指令,当所述计算机指令在电子设备上运行时,使得所述电子设备执行如第一方面及其任一种可能的设计方式所述的方法。
第六方面,本申请实施例提供一种计算机程序产品,当所述计算机程序产品在计算机上运行时,使得所述计算机执行如第一方面及其任一种可能的设计方式所述的方法。
可以理解地,上述提供的第二方面及其任一种可能的设计方式所述的电子设备,第三方面所述的电子设备,第四方面所述的芯片系统,第五方面所述的计算机存储介质,第六方面所述的计算机程序产品所能达到的有益效果,可参考如第一方面及其任一种可能的设计方式中的有益效果,此处不再赘述。
附图说明
图1为本申请实施例提供的一种电子设备的硬件结构示意图;
图2A为本申请实施例提供的一种电子设备的系统框架图;
图2B为本申请实施例提供的另一种电子设备的系统框架图;
图2C为本申请实施例提供的一种共享库的复用方法流程图;
图2D为本申请实施例提供的另一种电子设备的系统框架图;
图3为本申请实施例提供的另一种共享库的复用方法流程图;
图4为本申请实施例提供的另一种共享库的复用方法流程图;
图5A为本申请实施例提供的一种APP、共享库、inode、以及存储区域之间的关系示意图;
图5B为本申请实施例提供的另一种APP、共享库、inode、以及存储区域之间的关系示意图;
图6为本申请实施例提供的一种共享库的复用装置的组成示意图;
图7为本申请实施例提供的一种芯片系统的结构组成示意图。
具体实施方式
以下,术语“第一”、“第二”仅用于描述目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括一个或者更多个该特征。在本实施例的描述中,除非另有说明,“多个”的含义是两个或两个以上。
本申请实施例提供一种共享库的复用方法,该方法可以应用于安装有多个APP的电子设备,多个APP(如第一APP和第二APP)中的每个APP包括至少一个共享库。
其中,本申请实施例中的APP可以是安装在电子设备中的可下载应用程序。可下载应用程序是一个可以提供自己的因特网协议多媒体子系统(Internet Protocol Multimedia Subsystem,IMS)连接的应用程序,该可下载应用程序可以预先安装在电子设备中的应用或可以由用户下载并安装在电子设备中的第三方应用(如第一APP和第二APP)。
示例性的,该第一APP可以是“日历”、“记事本”等预先安装在电子设备中的应用,该第二APP可以是支付应用、视频应用等由用户下载并安装在电子设备中的第三方应用。
一种可能的设计中,电子设备安装完第一APP时,可以执行本申请实施例提供的共享库的复用方法。
举例来说,上述电子设备可以是操作系统为安卓(
Figure PCTCN2021112853-appb-000001
)的手机,上述第一APP可以是购物应用。手机在安装完购物应用时,即手机完成了安卓应用程序包(
Figure PCTCN2021112853-appb-000002
application package,APK)的解压过程,并在手机中存储了购物应用的可执行程序,可执行程序需要调用的第一共享库和第三共享库时,可以执行该方法。
可以理解的是,当电子设备中的APP(如第一APP)安装包是从网络平台下载到电子设备,或者电子设备中预先存储有第一APP安装包时,电子设备可以对第一APP的安装过程进行监控,并在电子设备安装完第一APP时,执行该方法,从而使电子设备及时发现是否存储有相同的共享库。
另一种可能的设计中,电子设备在运行完第一APP时,可以执行本申请实施例提供的共享库的复用方法。
举例来说,上述电子设备可以是操作系统为
Figure PCTCN2021112853-appb-000003
的手机,上述第一APP可以是购物应用。手机在运行购物应用,直至关闭购物应用的进程时,即手机第一次停止运行购物应用时,可以执行该方法。
可以理解的是,当电子设备中的APP(如第一APP)是从其他可移动存储设备中拷贝到该电子设备中时,电子设备无法监控第一APP的拷贝过程。因此,只有当该拷贝的第一APP运行时,电子设备才可以对其进行监控,检测其是否存储有与第一共享库的文件数据相同的第二共享库,使电子设备及时发现是否存储有相同的共享库。并且,电子设备在第一APP运行完的时候进行检测,可以避免APP的运行受到影响。
可选的,电子设备在第一次运行完第一APP时,可以执行本申请实施例提供的共享库的复用方法。
可以理解的是,如果电子设备确定电子设备中存在与第一APP的第一共享库的文件数据相同的第二共享库,电子设备则可以删除该第一共享库的文件数据。那么,电子设备第一次运行完第一APP后,该电子设备便可以删除该第一共享库的文件数据。因此,该电子设备再次运行该第一APP后,则不需要再判断电子设备中存在与第一APP的第一共享库的文件数据相同的第二共享库。这样,可以减小了电子设备的运算压力。
电子设备执行该方法,能够删除与电子设备中存储的共享库(如第二共享库)的文件数据相同的共享库(如第一共享库),可以提高电子设备的存储空间的利用率;并且,第二共享库替代第一共享库,可以使不同的APP调用同一个共享库,从而保障APP可以正常运行。
示例性的,本申请实施例中的电子设备可以是平板电脑、手机、桌面型、膝上型、手持计算机、笔记本电脑、超级移动个人计算机(ultra-mobile personal computer,UMPC)、上网本,以及蜂窝电话、个人数字助理(personal digital assistant,PDA)、增强现实(augmented reality,AR)\虚拟现实(virtual reality,VR)设备、车载设备等安装有多个APP(多个APP中的每个APP包括至少一个共享库)的设备,本申请实施例对该电 子设备的具体形态不作特殊限制。
本申请提供的共享库的复用方法的执行主体可以为共享库的复用装置(下面简称为“复用装置”),该复用装置可以为图1所示的电子设备。同时,该复用装置还可以为该电子设备的中央处理器(Central Processing Unit,CPU),或者该电子设备中的用于复用共享库的控制模块。本申请实施例中以电子设备执行共享库的复用方法为例,说明本申请实施例提供的共享库的复用方法。
请参考图1,本申请这里以电子设备为图1所示的手机100为例,对本申请提供的电子设备进行介绍。其中,图1所示的手机100仅仅是电子设备的一个范例,并且手机100可以具有比图中所示出的更多的或者更少的部件,可以组合两个或更多的部件,或者可以具有不同的部件配置。图1中所示出的各种部件可以在包括一个或多个信号处理和/或专用集成电路在内的硬件、软件、或硬件和软件的组合中实现。
如图1所示,手机100可以包括:处理器110,外部存储器接口120,内部存储器121,通用串行总线(universal serial bus,USB)接口130,充电管理模块140,电源管理模块141,电池142,天线1,天线2,移动通信模块150,无线通信模块160,音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,传感器模块180,按键190,马达191,指示器192,摄像头193,显示屏194,以及用户标识模块(subscriber identification module,SIM)卡接口195等。
其中,上述传感器模块180可以包括压力传感器,陀螺仪传感器,气压传感器,磁传感器,加速度传感器,距离传感器,接近光传感器,指纹传感器,温度传感器,触摸传感器,环境光传感器和骨传导传感器等传感器。
可以理解的是,本实施例示意的结构并不构成对手机100的具体限定。在另一些实施例中,手机100可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。
处理器110是手机100的控制中心,利用各种接口和线路连接手机100的各个部分,通过运行或执行存储在内部存储器121内的应用程序,以及调用存储在内部存储器121内的数据,执行手机100的各种功能和处理数据。在一些实施例中,处理器110可包括一个或多个处理单元。在本申请一些实施例中,上述处理器110还可以包括程序执行芯片,用于运行APP的可执行程序和共享库。
处理器110可以包括一个或多个处理单元,例如:处理器110可以包括应用处理器(application processor,AP),调制解调处理器,图形处理器(graphics processing unit,GPU),图像信号处理器(image signal processor,ISP),控制器,存储器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。
控制器可以是手机100的神经中枢和指挥中心。控制器可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。
处理器110中还可以设置存储器,用于存储指令和数据。在一些实施例中,处理器110中的存储器为高速缓冲存储器。该存储器可以保存处理器110刚用过或循环使用的指令或数据。如果处理器110需要再次使用该指令或数据,可从所述存储器中直接调用。 避免了重复存取,减少了处理器110的等待时间,因而提高了系统的效率。
在一些实施例中,处理器110可以包括一个或多个接口。接口可以包括集成电路(inter-integrated circuit,I2C)接口,集成电路内置音频(inter-integrated circuit sound,I2S)接口,脉冲编码调制(pulse code modulation,PCM)接口,通用异步收发传输器(universal asynchronous receiver/transmitter,UART)接口,移动产业处理器接口(mobile industry processor interface,MIPI),通用输入输出(general-purpose input/output,GPIO)接口,用户标识模块(subscriber identity module,SIM)接口,和/或通用串行总线(universal serial bus,USB)接口等。
可以理解的是,本实施例示意的各模块间的接口连接关系,只是示意性说明,并不构成对手机100的结构限定。在另一些实施例中,手机100也可以采用上述实施例中不同的接口连接方式,或多种接口连接方式的组合。
充电管理模块140用于从充电器接收充电输入。其中,充电器可以是无线充电器,也可以是有线充电器。充电管理模块140为电池142充电的同时,还可以通过电源管理模块141为电子设备供电。
电源管理模块141用于连接电池142,充电管理模块140与处理器110。电源管理模块141接收电池142和/或充电管理模块140的输入,为处理器110,内部存储器121,外部存储器,显示屏194,摄像头193,和无线通信模块160等供电。在一些实施例中,电源管理模块141和充电管理模块140也可以设置于同一个器件中。
手机100的无线通信功能可以通过天线1,天线2,移动通信模块150,无线通信模块160,调制解调处理器以及基带处理器等实现。在一些实施例中,手机100的天线1和移动通信模块150耦合,天线2和无线通信模块160耦合,使得手机100可以通过无线通信技术与网络以及其他设备通信。例如,本申请实施例中,手机100可以通过无线通信技术向其他设备发送上述第一账号和登录密码。
天线1和天线2用于发射和接收电磁波信号。手机100中的每个天线可用于覆盖单个或多个通信频带。不同的天线还可以复用,以提高天线的利用率。例如:可以将天线1复用为无线局域网的分集天线。在另外一些实施例中,天线可以和调谐开关结合使用。
移动通信模块150可以提供应用在手机100上的包括2G/3G/4G/5G等无线通信的解决方案。移动通信模块150可以包括至少一个滤波器,开关,功率放大器,低噪声放大器(low noise amplifier,LNA)等。移动通信模块150可以由天线1接收电磁波,并对接收的电磁波进行滤波,放大等处理,传送至调制解调处理器进行解调。
移动通信模块150还可以对经调制解调处理器调制后的信号放大,经天线1转为电磁波辐射出去。在一些实施例中,移动通信模块150的至少部分功能模块可以被设置于处理器110中。在一些实施例中,移动通信模块150的至少部分功能模块可以与处理器110的至少部分模块被设置在同一个器件中。
无线通信模块160可以提供应用在手机100上的包括无线局域网(wireless local area networks,WLAN)(如(wireless fidelity,Wi-Fi)网络),蓝牙(bluetooth,BT),全球导航卫星系统(global navigation satellite system,GNSS),调频(frequency modulation,FM),近距离无线通信技术(near field communication,NFC),红外技术(infrared,IR)等无线通信的解决方案。例如,本申请实施例中,手机100(如第一设备110)可以通过 无线通信模块160接入Wi-Fi网络。
无线通信模块160可以是集成至少一个通信处理模块的一个或多个器件。无线通信模块160经由天线2接收电磁波,将电磁波信号调频以及滤波处理,将处理后的信号发送到处理器110。无线通信模块160还可以从处理器110接收待发送的信号,对其进行调频,放大,经天线2转为电磁波辐射出去。
手机100通过GPU,显示屏194,以及应用处理器等实现显示功能。GPU为图像处理的微处理器,连接显示屏194和应用处理器。GPU用于执行数学和几何计算,用于图形渲染。处理器110可包括一个或多个GPU,其执行程序指令以生成或改变显示信息。
显示屏194用于显示图像,视频等。该显示屏194包括显示面板。例如,本申请实施例中,显示屏194可以用于显示上述第一APP的应用界面,如设备分享界面、设备搜索界面和二维码扫描界面等。
手机100可以通过ISP,摄像头193,视频编解码器,GPU,显示屏194以及应用处理器等实现拍摄功能。ISP用于处理摄像头193反馈的数据。摄像头193用于捕获静态图像或视频。在一些实施例中,手机100可以包括1个或N个摄像头193,N为大于1的正整数。
外部存储器接口120可以用于连接外部存储卡,例如Micro SD卡,实现扩展手机100的存储能力。外部存储卡通过外部存储器接口120与处理器110通信,实现数据存储功能。例如将音乐,视频等文件保存在外部存储卡中。
内部存储器121用于存储应用程序以及数据,处理器110通过运行存储在内部存储器121的应用程序以及数据,执行手机100的各种功能以及数据处理。内部存储器121主要包括存储程序区以及存储数据区,其中,存储程序区可存储操作系统、可执行程序、共享库等二进制文件;存储数据区可以存储数据间的对应关系。
此外,内部存储器121可以包括高速随机存取存储器(Random Access Memory,RAM),还可以包括非易失存储器,例如磁盘存储器件、闪存器件或其他易失性固态存储器件等。内部存储器121可以存储各种操作系统。上述内部存储器121可以是独立的,通过上述通信总线与处理器110相连接;内部存储器121也可以和处理器110集成在一起。
手机100可以通过音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,以及应用处理器等实现音频功能。例如音乐播放,录音等。
按键190包括开机键,音量键等。按键190可以是机械按键。也可以是触摸式按键。马达191可以产生振动提示。马达191可以用于来电振动提示,也可以用于触摸振动反馈。指示器192可以是指示灯,可以用于指示充电状态,电量变化,也可以用于指示消息,未接来电,通知等。SIM卡接口195用于连接SIM卡。SIM卡可以通过插入SIM卡接口195,或从SIM卡接口195拔出,实现和手机100的接触和分离。手机100可以支持1个或N个SIM卡接口,N为大于1的正整数。SIM卡接口195可以支持Nano SIM卡,Micro SIM卡,SIM卡等。
尽管图1未示出,手机100还可以闪光灯、微型投影装置、近场通信(Near Field Communication,NFC)装置等,在此不再赘述。
在对电子设备的硬件结构进行介绍之后,本申请这里以电子设备为手机100为例,对本申请提供的电子设备的系统架构进行介绍。如图2A所示,手机100的系统架构可以 包括:应用程序层、操作系统(Operating System,OS)(如安卓
Figure PCTCN2021112853-appb-000004
系统)、内核(kernel)层、硬件层。
其中,应用程序层,可以包括一系列应用程序包。例如APP(A)、APP(B)等。以
Figure PCTCN2021112853-appb-000005
系统为例,
Figure PCTCN2021112853-appb-000006
系统中的共享库文件均为so文件(*.so)。如图2A所示,APP(A)包括A1.so、A2.so、A3.so等,APP(B)包括B1.so、B2.so、B3.so等。
Figure PCTCN2021112853-appb-000007
系统,是管理手机100的硬件与软件资源的计算机程序。
Figure PCTCN2021112853-appb-000008
系统需要处理如管理与配置内存、决定系统资源供需的优先次序、控制输入设备与输出设备、操作网络与管理文件系统等基本事务。
Figure PCTCN2021112853-appb-000009
系统也可以提供一个使用户能够与系统交互的操作界面。在本申请实施例中,
Figure PCTCN2021112853-appb-000010
系统包括安装包管理器服务(Package Manager Service,PMS)。PMS是
Figure PCTCN2021112853-appb-000011
系统服务之一,主要负责管理
Figure PCTCN2021112853-appb-000012
系统的应用,提供对各种APK文件的安装、卸载、优化和查询服务。具体的,PMS包括APP监控组件,该APP监控组件运行在PMS中,可以监控APP的安装、更新、删除,并向复用组件发送通知消息。示例性的,在手机100安装APP(A)后,该APP监控组件会向复用组件发送通知消息,以告知复用组件APP(A)已经安装完成。
内核层,是硬件和软件之间的层。内核层至少包含显示驱动,摄像头驱动,音频驱动,传感器驱动。在本申请实施例中,内核层还包括文件系统和内存操作系统。该文件系统用于管理内部存储器121中存储的数据。具体的,文件系统可以将内部存储器121中存储的数据抽象为具体的文件,并提供对文件的增、删、改等操作。例如,如图2B所示,文件系统可以将第一APP中的可执行程序A、第一共享库、第二共享库,以及第二APP中的可执行程序B、第三共享库,存储在内部存储器121中。可选的,处理器110通过文件系统调用共享库。该内存操作系统(RAM OS)用于管理内存。由于相较于硬件层,内存的存取速度更快。因此,在处理器110运行APP时,需要将APP的共享库加载到内存操作系统,以提高APP的运行速度。该文件系统包括复用组件,该复用组件可以在文件系统实现共享库的复用。示例性的,A1.so和B1.so的文件数据相同,A2.so的文件数据和B2.so的文件数据相同,复用组件可以使APP(A)和APP(B)共同调用B1.so、B2.so。
硬件层,包括存储器(例如flash存储器)。该flash存储器在没有电流供应的条件下也能够长久地保持数据,其存储特性相当于硬盘。示例性的,该Flash存储器中存储有S1.so、S2.so、S3.so等。
需要说明的是,图2A所示的电子设备的系统架构可以支持在电子设备安装完成第一APP时,电子设备执行本申请实施例提供的共享库的复用方法。如图2C所示,为本申请实施例提供的一种共享库的复用方法流程图。
具体的,以APP(A)的安装完成时间晚于APP(B)的安装完成时间为例,对本申请实施例的共享库的复用方法进行介绍。其中,A1.so的文件数据与B1.so的文件数据相同,A2.so的文件数据与B2.so的文件数据相同。在APP(A)安装完成时,APP监控组件向复用组件发送通知消息。复用组件检测硬件层(如内部存储器121)中存在与A1.so的文件数据相同的B1.so,与A2.so的文件数据相同的B2.so,删除A1.so和A2.so。在手机100运行APP(A)或者APP(B)调用共享库(如B1.so)时,内存操作系统将B1.so映射到内存中,使处理器110在内存中调用B1.so。
可选的,本申请这里以电子设备为手机100为例,对本申请提供的另一种电子设备的系统架构进行介绍。如图2D所示,手机100的系统架构包括:应用程序层、内核(kernel)层、硬件层。
其中,应用程序层,对于应用程序层的介绍可参考上述对图2A中的应用程序层的介绍,此处不再赘述。
内核层,除了上述对图2A内核层的介绍以外,该内核层的内存操作系统还包括监控组件。该监控组件运行在内存操作系统,可以监控手机100对于共享库的调用,并向复用组件发送通知消息。示例性的,当手机100停止运行APP(A)时,复用组件监测到手机100停止调用B1.so,向复用组件发送通知消息,以告知复用组件APP(A)的进程被关闭。
硬件层,对于硬件层的介绍可参考上述对图2A中的硬件层的介绍,此处不再赘述。
需要说明的是,图2D所示的电子设备的系统架构可以支持在电子设备运行完第一APP时,电子设备执行本申请实施例提供的共享库的复用方法。
具体的,以APP(A)的运行完的时间晚于APP(B)的运行完的时间为例,对本申请实施例的共享库的复用方法进行介绍。其中,A1.so的文件数据与B1.so的文件数据相同,A2.so的文件数据与B2.so的文件数据相同。在APP(A)运行完时,APP监控组件向复用组件发送通知消息。复用组件检测硬件层(如内部存储器121)中存在与A1.so的文件数据相同的B1.so,与A2.so的文件数据相同的B2.so,删除A1.so和A2.so。在手机100运行APP(A)或者APP(B)调用共享库(如B1.so)时,内存操作系统将B1.so映射到内存中,使处理器110在内存中调用B1.so。
以下实施例中的方法均可以在具有上述硬件结构和上述系统架构的电子设备中实现。以下实施例中以上述电子设备是手机100为例,对本申请实施例的方法进行说明。
在本申请实施例中,手机100中安装有多个APP(如第一APP、第二APP、第三APP),多个APP中的每个APP包括至少一个共享库。示例性的,第一APP可以为购物应用一,购物应用一包括共享库a和共享库b;第二APP可以为购物应用二,购物应用二包括共享库c;第三APP可以为支付应用,支付应用包括共享库d、共享库e、以及共享库f。
其中,手机100中的每一个APP均包括一个可执行程序和至少一个共享库。每一个共享库的文件数据包含有多个库函数。这样一来,在APP运行时,可执行程序会调用共享库中的库函数,以完成该APP的某一项功能。示例性的,第一APP为购物应用,购物应用包括可执行程序a、共享库b、以及共享库c。手机100在运行购物应用时,可以先运行可执行程序a。在可执行程序a需要调用共享库b中的库函数和共享库c中的库函数时,手机100将共享库b和共享库c映射到内存中,使得可执行程序a可以从内存中访问库函数。
在本申请实施例中,第一APP中任一共享库与第二APP种任一共享库之间可能存在以下三种关系。第一APP和第二APP为手机100中的任一共享库。
关系一:两个共享库不同。
其中,两个共享库不同,具体是指两个共享库的文件数据不同。两个共享库的文件数据不同,具体是指两个共享库的二进制文件不同。例如,两个共享库中包括的库函数不同,手机100分别对两个共享库的文件数据进行编译,可以得到两个不同的二级制文 件。
需要说明的是,两个不同的共享库的库函数不同,可以分为以下两种情况。情况(1)两个不同的共享库的库函数完全不同;情况(2)两个不同的共享库的库函数部分相同,另一部分不同。
例如,假设第一APP中的共享库a包括库函数1、库函数2和库函数3,第二APP中的共享库b包括库函数4和库函数5。其中,库函数1、库函数2、库函数3、库函数4和库函数5两两不同。因此,共享库a与共享库b完全不同。
又例如,假设第一APP中的共享库a包括库函数1、库函数2和库函数3,第二APP中的共享库b包括库函数3、库函数4和库函数5。其中,库函数1、库函数2、库函数3、库函数4和库函数5两两不同。因此,共享库a与共享库b部分不同。
需要说明的是,两个不同的共享库(即两个文件数据不同的共享库)的文件名称可以相同,也可以不同。
关系二:两个共享库相同。
其中,两个共享库相同,具体是指两个共享库的文件数据相同。两个共享库的文件数据相同,具体是指两个共享库的二进制文件相同。例如,两个共享库中包括的库函数相同,手机100分别对两个共享库的文件数据进行编译,可以得到两个相同的二级制文件。
需要说明的是,两个相同的共享库(即两个文件数据相同的共享库)的文件名称可以相同,也可以不同。
在本申请实施例中,一个APP中的每个共享库均不同。示例性的,第一APP包括共享库a、共享库b、共享库c,共享库a包括第一库函数,共享库b包括第二库函数和第三库函数,共享库c包括第四库函数。其中,共享库a的文件名称为“共享库a”,共享库a的文件数据为第一库函数;共享库b的文件名称为“共享库b”,共享库b的文件数据为第二库函数和第三库函数;共享库c的文件名称为“共享库c”,共享库c的文件数据为第四库函数。也就是说,共享库a、共享库b、以及共享库c的文件名称、文件数据均不相同。因此,共享库a、共享库b、共享库c不同。
本申请实施例提供一种共享库的复用方法,如图3所示,该共享库的复用方法可以包括S301-S304。
S301、手机100确定手机100中是否存在与第一APP的第一共享库的文件数据相同的第二共享库。
其中,第一APP包括至少一个共享库,第一共享库为第一APP中任意一个共享库。示例性的,第一APP包括三个共享库,三个共享库分别为共享库a、共享库b、以及共享库c。第一共享库既可以为共享库a,又可以为共享库b,还可以为共享库c。本申请实施例中,手机100可以对第一APP的每个共享库均执行本申请实施例的方法。
在本申请实施例中,手机100可以通过以下两种方式确定手机100中是否存在与第一APP的第一共享库的文件数据相同的第二共享库。
方式一,手机100根据第一共享库的文件数据采用预设算法,生成第一共享库的第一标识。其中,该预设算法可以为安全散列算法1(Secure Hash Algorithm 1,SHA-1),也可以为MD5信息摘要算法(MD5 Message-Digest Algorithm,MD5),还可以为数据 加密标准(Data Encryption Standard,DES)算法等,本申请实施例对此不作限定。
示例性的,手机100可以根据第一共享库的文件数据采用SHA-1,生成第一共享库的文件数据的哈希值为6cd7a。手机100确定第一标识与第二标识是否相同。其中,第二标识是手机100根据手机100中任一个共享库的文件数据采用预设算法生成的。
一种可能的实现方式,手机100确定第一标识与第二标识是否相同的方法可以包括:手机100在第一数据表中查找是否存在与第一标识相同的标识。其中,第一数据表用于存储共享库的标识与inode的编号(Number)之间的对应关系。在第一数据表中,每一个标识均不相同。共享库的标识对应的inode是手机100为该共享库分配的,具体的分配过程可参考步骤302中的描述,此处不再赘述。
示例性的,如表一所示,其示出手机100为共享库分配的inode与共享库的标识(Identification)之间的对应关系。其中,第一inode与共享库a的标识a之间存在对应关系,第一inode的编号为01,标识a为e908;第二inode与共享库b的标识b之间存在对应关系,第二inode的编号为02,标识b为6cd7a;第一数据表可以称为ShareMap表。
表一
Number Identification
01 e908
02 6cd7a
需要说明的是,手机100将inode的编号与共享库的标识之间的对应关系存储在第一数据表,可以保存inode与共享库的标识之间的对应关系。除了上述手机100将inode的编号与共享库的标识之间的对应关系存储在第一数据表以外,手机100还可以将inode的编号与共享库的标识之间的对应关系存储在其他的数据表中,本申请实施例对此不作限定。此外,手机100还可以将inode的编号与共享库的标识之间的对应关系存储在树结构中,本申请实施例对此不作限定。本申请实施例中,以手机100将inode的编号与共享库的标识之间的对应关系存储在第一数据表为例,对本申请实施例的方法进行说明。
若第一标识与第二标识相同,则手机100确定手机100中存在与第一共享库的文件数据相同的第二共享库。示例性的,手机100根据共享库c的文件数据采用SHA-1,确定共享库c的标识c为e908。结合表一,手机100遍历第一数据表中的标识,确定标识a为e908。因此,标识c与标识a相同。
可以理解的是,由于第一标识和第二标识均是手机100根据共享库的文件数据采用预设算法生成的,因此,在第一标识和第二标识相同的情况下,手机100确定手机100中存在与第一共享库的文件数据相同的第二共享库。
若第一标识与第二标识不同,则手机100确定手机100中不存在与第一共享库的文件数据相同的第二共享库。可以理解的是,由于第一标识和第二标识均是手机100根据共享库的文件数据采用预设算法生成的,因此,在第一标识和第二标识不同的情况下,手机100确定手机100中不存在与第一共享库的文件数据相同的第二共享库。
可选的,若第一标识与第二标识不同,手机100保存第一标识与第二inode之间的对应关系。具体对于手机100保存第一标识与第二inode之间的对应关系的说明,可参考步骤401的描述,此处不再赘述。
可以理解的是,第一标识与第二标识不同,说明电子设备中不存在与第一共享库的文件数据相同的所述第二共享库。因此,电子设备要保存第一标识与第二inode的对应关系,使得在存储第一共享库之后,能够根据第一标识确定其他存储在电子设备中的共享库的文件数据是否与第一共享库相同。
方式二,手机100对比第一共享库的文件数据与手机100中每一个共享库的文件数据,确定手机100中是否存在与第一共享库的文件数据相同的第二共享库。
一种可能的实现方式,手机100将第一共享库的文件数据通过预设对比算法或者预设对比工具,分别与手机100中的每一个共享库的文件数据进行对比,确定手机100中是否存在与第一共享库的文件数据相同的第二共享库。
一种可能的设计中,手机100可以每次将第一共享库的文件数据与手机100中的一个共享库的文件数据进行对比。示例性的,手机100中包括共享库a、共享库b、共享库c、共享库d,手机100将第一共享库的文件数据通过预设对比工具与共享库a的文件数据进行对比,确定第一共享库的文件数据与共享库a的文件数据不同;之后,手机100再将第一共享库的文件数据与共享库b的文件数据进行对比,确定第一共享库的文件数据与共享库b的文件数据不同;之后,手机100再将第一共享库的文件数据与共享库c的文件数据进行对比,确定第一共享库的文件数据与共享库c的文件数据相同。手机100停止将第一共享库的文件数据与手机100的共享库的文件数据进行对比,即手机100不再将第一共享库的文件数据与共享库d的文件数据进行对比。
另一种可能的设计中,手机100可以将第一共享库的文件数据同时与手机100中的多个共享库文件数据进行对比。示例性的,手机100中包括共享库a、共享库b、共享库c、共享库d,手机100将第一共享库的文件数据通过预设对比工具同时与共享库a、共享库b、以及共享库c的文件数据进行对比,确定第一共享库的文件数据与共享库c的文件数据相同。之后手机100停止将第一共享库的文件数据与手机100的共享库的文件数据进行对比,即手机100不再将第一共享库的文件数据与共享库d的文件数据进行对比。
可选的,若手机100中存在第二共享库,则手机100执行步骤302;若手机100中不存在第二共享库,则手机100执行步骤401。
S302、若手机100中存在第二共享库,则手机100保存第一索引节点inode与第一共享库的文件名称之间的对应关系。
其中,第一inode是手机100为第二共享库分配的。在第二共享库存储在手机100中时,手机100可以保存第一inode与第二共享库的文件名称之间的对应关系。具体的,手机100通过保存第一inode的编号与第二共享库的文件名称之间的对应关系,保存第一inode与第二共享库的文件名称之间的对应关系。
一种可能的设计,手机100将第一inode的编号与第二共享库的文件名称之间的对应关系保存在第二数据表中。示例性的,如表二所示,其示出手机100为共享库分配的inode的编号与共享库的文件名称(File name)之间的对应关系。其中,第一inode的编号为01,第二共享库的文件名称为共享库a,第二数据表为Directory表。
表二
Number File name
01 共享库a
需要说明的是,除了上述手机100将inode的编号与共享库的文件名称之间的对应关系存储在第二数据表以外,手机100还可以将inode的编号与共享库的文件名称之间的对应关系存储在其他的数据表中,本申请实施例对此不作限定。此外,手机100还可以将inode的编号与共享库的文件名称之间的对应关系存储在树结构中,本申请实施例对此不作限定。本申请实施例中,以手机100将inode的编号与共享库的文件名称之间的对应关系存储在第二数据表为例,对本申请实施例的方法进行说明。
一种可能的设计中,第一inode指示用于保存第二共享库的文件数据的第一存储区域。
需要说明的是,手机100保存第二共享库后,手机100可以将第二共享库的元信息存储在第一inode。其中,每一个共享库元信息包括:创建时间(Creation time)、文件大小(File size)、存储位置(Storage location)等。示例性的,第一inode的编号为01,第二共享库的文件名称为共享库a,第二共享库的创建日期为“2020-08-10 09:00”,第二共享库的文件大小为“100千字节(Kilobyte,kb)”,第二共享库的存储位置为“/data/app1/”。则第一inode可以为“Number:01,File name:共享库a,Creation time:2020-08-10 09:00,File size:100,Storage location:/data/app1/”。
可以理解的是,在手机100需要调用第二共享库时,手机100可以通过共享库的文件名称确定该文件名称对应的inode。这样一来,手机100就可以从inode中获取到该共享库的存储位置,并从该存储位置读取共享库的文件数据。
在本申请实施例中,在手机100确定手机100中存在与第一APP的第一共享库的文件数据相同的第二共享库时,第一APP已经存储在手机100中。也就是说,第一共享库的文件数据已经存储在手机100中。并且,手机100为第一共享库分配第二inode,手机100保存第一共享库的文件名称与第二inode之间的对应关系,第二inode中存储有第一共享库的元信息。示例性的,结合表二,如表三所示,其示出了手机100为共享库分配的inode的编号与共享库的文件名称(File name)之间的对应关系。其中,第二inode的编号为02,第一共享库的文件名称为共享库b,第二数据表为Directory表。
表三
Number File name
01(即第一inode) 共享库a(即第二共享库)
02(即第二inode) 共享库b(即第一共享库)
一种可能的实现方式,若手机100中存在第二共享库,则手机100根据第二共享库的第二标识,从第一数据表中确定第二标识对应的第一inode的编号,即第二共享库对应的第一inode的编号,保存第一inode的编号与第一共享库的文件名称之间的对应关系,并删除第二inode的编号与第一共享库的文件名称之间的对应关系。示例性的,结合表三,如表四所示,为inode的编号与共享库的文件名称(File name)之间的对应关系。其中,第一inode的编号为01,第二共享库的文件名称为共享库a,第一共享库的文件名称为共享库b,第二数据表为Directory表。
表四
Number File name
01(即第一inode) 共享库a(即第二共享库)
01(即第一inode) 共享库b(即第一共享库)
另一种可能的实现方式,若手机100中存在第二共享库,则手机100根据第二共享库的文件数据确定第二共享库对应的第一inode的编号,将第一共享库的文件名称与第二inode的编号之间的对应关系修改为第一共享库的文件名称与第一inode的编号之间的对应关系。
可以理解的是,由于手机100保存第一inode与第一共享库的文件名称之间的对应关系。因此,手机100在运行第一APP调用第一共享库时,能够根据第一共享库的文件名称查找到第一inode。并且,由于第一inode指示用于保存第二共享库的文件数据的第一存储区域,因此,手机100能够根据第一inode读取第二共享库的文件数据,即此时手机100实际调用的共享库为第二共享库。又由于第二共享库的文件数据与第一共享库的文件数据相同,因此,手机100调用第二共享库仍然可以保障第一APP的正常运行。
S303、手机100删除第一共享库的文件数据。
一种可能的实现方式,若手机100中存在第二共享库,则手机100根据第一共享库的文件名称,通过第二数据表查找与第一共享库对应的第二inode。手机100根据第二inode,确定用于保存第一共享库的文件数据的第二存储区域。手机100根据第二存储区域,删除第一共享库的文件数据。
可选的,手机100还可以在树结构中查找与第一共享库对应的第二inode,本申请实施例对此不作限定。
可以理解的是,手机100删除第一共享库的文件数据,不仅不影响第一APP的正常运行,还可以节约电子设备的存储空间,避免了电子设备中存储多个相同的共享库,提高了电子产品的存储空间的利用率。
需要说明的是,由于本申请实施例中手机100需要根据第一共享库的文件名称与第二inode之间的对应关系,删除第一共享库的文件数据。因此,手机100需要在删除或者修改第一共享库的文件名称与第二inode之间的对应关系之前,删除第一共享库的文件数据。在满足该条件的情况下,本申请实施例对手机100执行步骤302和步骤303的顺序不作限定。也就是说,手机100可以先执行步骤302,再执行步骤303;或者,手机100可以先执行步骤303,再执行步骤302;或者,手机100可以同时执行步骤302和步骤303。
S304、当手机100运行第一APP调用第一共享库时,手机100查找第一共享库的文件名称对应的第一inode,并读取第一inode指示的存储区域保存的第二共享库的文件数据。
一种可能的实现方式,当手机100运行第一APP调用第一共享库时,手机100根据第一共享库的文件名称,通过第二数据表查找与第一共享库对应的第一inode。手机100根据第一inode,确定用于保存第二共享库的文件数据的第一存储区域。之后,手机100根据第一存储区域,读取第一存储区域中的第二共享库的文件数据。
示例性的,第一inode为“Number:01,File name:共享库a,Creation time:2020-08-1009:00,File size:100,Storage location:/data/app1/”。结合表四,手机100在调用共享库b时,通过第二数据表查找共享库b对应的inode的编号为01,并确定编号为01的第一inode。之后,手机100根据第一inode,确定存储位置为“/data/app1/”,并从“/data/app1/”中读取第二共享库的文件数据。
可选的,手机100还可以通过树结构查找与第一共享库对应的第一inode,本申请实施例对此不作限定。
可以理解的是,当手机100运行第一APP调用第一共享库时,手机100实际调用的是第二共享库。这样一来,当第一APP和包含有第二共享库的第二APP运行时,电子设备只将第二共享库映射到内存中,第一APP和第二APP均可从内存中调用第二共享库的文件数据,减少了内存的占用空间,提高了内存的利用率。
基于上述技术方案,若电子设备中存在与第一APP的第一共享库的文件数据相同的第二共享库;那么,如果电子设备不仅保存第二共享库的文件数据,还保存该第一共享库的文件数据,则会存在电子设备存储空间的浪费。因此,在电子设备中存在与第一APP的第一共享库的文件数据相同的第二共享库的情况下,该电子设备可以删除第一共享库的文件数据。这样,可以提供电子设备的存储空间的利用率。
进一步的,为了保证电子设备正常运行第一APP;该电子设备还可以保存第一inode与第一共享库的文件名称之间的对应关系。这样一来,当电子设备运行第一APP调用第一共享库时,电子设备无需调用第一共享库的文件数据,只需要通过第一共享库的文件名称查找第一inode,以读取第二共享库的文件数据,从而可以保障APP的正常运行。
此外,电子设备运行APP调用共享库时,可以将共享库映射到内存中,再从内存中调用共享库。这样,可以提高电子设备的性能。常规技术中,电子设备运行多个APP时(如第一APP和包含有第二共享库的第二APP),会分别将第一共享库和第二共享库映射到内存中,由于映射的数据量较大,不仅影响I/O性能,还会造成内存空间的浪费。而本申请实施例中,电子设备只将第二共享库映射到内存中,第一APP和第二APP运行时,均可从内存中调用第二共享库的文件数据。这样一来,不仅减小了映射到内存的数据量,提高了I/O性能,而且能够减少内存的占用空间,提高了内存的利用率。
可选的,本申请实施例提供一种共享库的复用方法,如图4所示,在S301之后,该共享库的复用方法还可以包括S401-S403。
S401、若手机100中不存在第二共享库,则手机100为第一共享库分配第二inode。
其中,第二inode指示用于保存第一共享库的文件数据的第二存储区域。
可以理解的是,若手机100中不存在第二共享库,说明手机100中没有共享库能够替代第一共享库。因此,手机100在存储第一共享库后,为第一共享库分配第二inode,使得第一APP运行调用第一共享库时,手机100可以根据第二inode读取第一共享库的文件数据,保障第一APP的正常运行。
可选的,若手机100中不存在第二共享库,则手机100为第一共享库分配第二inode之后,手机100保存第一标识与第二inode的对应关系。具体的,手机100将确定为第一共享库分配的第二inode的编号,将第一标识与第二inode的编号存储在第一数据表中。
S402、手机100保存第二inode与第一共享库的文件名称之间的对应关系。
具体可参考上述步骤302中,对手机100保存第二inode与第一共享库的文件名称之间的对应关系的说明,本申请实施例在此不再赘述。
可以理解的是,手机100保存第二inode与第一共享库的文件名称之间的对应关系,使得第一APP运行调用第一共享库时,手机100可以根据第一共享库的文件名称查找其对应的第二inode,并根据第二inode读取第一共享库的文件数据,从而保障第一APP的 正常运行。
S403、当手机100运行第一APP调用第一共享库时,查找第一共享库的文件名称对应的第二inode,并读取第二inode指示的第二存储区域保存的第一共享库的文件数据。
一种可能的实现方式,当手机100运行第一APP电泳第一共享库时,手机100根据第一共享库的文件名称,通过第二数据表查找与第一共享库对应的第二inode。手机100根据第二inode,确定用于保存第一共享库的文件数据的第二存储区域。之后,手机根据第二存储区域,读取第二存储区域中的第一共享库的文件数据。
基于图4所示的技术方案,电子设备中不存在与所述第一APP的所述第一共享库的文件数据相同的第二共享库时,说明电子设备中没有可以替代第一共享库的共享库。因此,电子设备需要存储该第一共享库。这样一来,在所述电子设备运行所述第一APP调用所述第一共享库时,电子设备就可以通过第一共享库的文件名称查找第二inode,从而读取第一共享库的文件数据,以保障APP的正常运行。
可选的,inode中除了存储有该inode对应的共享库的元信息以外,inode还包括链接数(Links)。inode的链接数为该inode对应的共享库的数量。示例性的,结合表三,第一inode对应的共享库包括第二共享库,第一inode对应的共享库的数量为1,第一inode的链接数为1;第二inode对应的共享库包括第一共享库,第二inode对应的共享库的数量为1,第二inode的链接数为1。结合表四,第一inode对应的共享库包括第一共享库和第二共享库,第一inode对应的共享库的数量为2,第一inode的链接数为2。
其中,每个inode的链接数的初始值为0。也就是说,当手机100还未将inode分配给共享库时,该inode对应的共享库的数量为0。因此,inode的链接数的初始值为0。
一种可能的设计中,若手机100中存在第二共享库,则手机100为第一inode的链接数加1。其中,第一inode的链接数为第一inode对应的共享库的数量。示例性的,结合表三和表四,在第一共享库的文件名称与第一inode建立对应关系之前,第一inode的链接数为1;在第一共享库的文件名称与第一inode建立对应关系之后,第一inode的链接数为2。
一种可能的实现方式,若手机100中存在第二共享库,则手机100确定第二共享库的第二标识对应的第一inode。手机100根据第一共享库的文件名称和第一inode,将第一共享库的文件名称和第一inode的编号存储在第二数据表中,并为第一inode的链接数加1。
具体的,如图5A所示,为手机100保存第一inode与第一共享库的文件名称之间的对应关系之前,APP(A)、A.so(共享库的文件名称)、inode A、以及存储区域A之间的对应关系,APP(B)、B.so(共享库的文件名称)、inode B、以及存储区域B之间的对应关系。结合图5A,如图5B所示,为手机100保存第一inode与第一共享库的文件名称之间的对应关系之后,APP(A)、A.so(共享库的文件名称)、inode A、以及存储区域A之间的对应关系,APP(B)、B.so(共享库的文件名称)、inode A、以及存储区域A之间的对应关系。
可以理解的是,若手机100中存在第二共享库,说明第一共享库可以被第二共享库替代。又由于第一inode是手机100为所述第二共享库分配的,因此,手机100改变第一inode的链接数,为第一inode的链接数加1,从而更新第一inode对应的共享库的数量, 使手机100能够根据第一inode的链接数确定第二共享库替代的共享库的数量。
另一种可能的设计中,若手机100中不存在第二共享库,则手机100为第二inode的链接数加1。其中,第二inode的链接数为第二inode对应的共享库的数量。示例性的,结合表三,手机100创建第二inode,此时第二inode没有对应的共享库,第二inode的链接数为0。在手机100将第二inode的编号与第一共享库的文件名称之间的对应关系保存在第二数据表中之后,第二inode对应的共享库包括第一共享库,第二inode的链接数为1。
可以理解的是,若手机100中不存在第二共享库,说明手机100中没有共享库能够替代第一共享库。因此,手机100改变第二inode的链接数,为第二inode的链接数加1,从而更新第二inode对应的共享库的数量,使手机100能够根据第二inode的链接数确定第一共享库替代的共享库的数量。
以上实施例只是针对手机100中新增APP(如包含有第一共享库的第一APP),即手机100中新增第一共享库,手机100执行的相关步骤。下面本申请实施例提供一种共享库的复用方法,结合手机100删除APP的应用场景,对该共享库的复用方法进行介绍。本申请实施例的方法还可以包括S601-S604。手机100可以在执行上述方法流程之前,或者在执行上述方法流程的过程中,或者在执行上述方法流程之后,执行S601-S604。
S601、在手机100删除第二APP时,手机100查找第三共享库的文件名称对应的第三inode。
其中,第三共享库为第二APP包括的至少一个共享库中的任意一个共享库。示例性的,第二APP包括共享库a、共享库b、共享库c,第三共享库可以为共享库a,也可以为共享库b,还可以为共享库c。本申请实施例中,手机100可以对第二APP的每个共享库均执行本申请实施例的方法。一种可能的实现方式,在手机100删除第二APP时,手机100确定第二APP的第三共享库的文件名称,并通过第二数据表查找与第三共享库的文件名称对应的第三inode。示例性的,如表五所示,其示出手机100为共享库分配的inode的编号与共享库的文件名称之间的对应关系。其中,第三inode的编号为03,第三共享库的文件名称为共享库c,第二数据表为Directory表。在手机100确定共享库的文件名称为共享库c时,便可以通过表五查找出共享库c对应的第三inode的编号为03。
表五
Number File name
03 共享库c
手机100根据第三inode的编号,确定第三inode的编号对应的第三inode。
S602、手机100确定第三inode的链接数是否等于1。
其中,若第三inode的链接数等于1,则手机100执行步骤503;若第三inode的链接数大于1,则手机100执行步骤504。
需要说明的是,由于此时手机100中存储有第三inode与共享库的对应关系,因此第三inode至少对应一个共享库。因此,第三inode的链接数不会小于1,即第三inode的链接数不会等于0。
S603、若第三inode的链接数等于1,则手机100从手机100中删除第三共享库的文 件数据、第三inode、以及第三共享库的文件名称与第三inode之间的对应关系。
一种可能的实现方式,若第三inode的链接数等于1,则手机100根据inode中第三共享库的存储位置,确定第三共享库的文件数据的存储区域,并删除第三共享库的文件数据。手机100根据第三共享库的文件名称,删除第二数据表中第三共享库的文件名称与第三inode之间的对应关系;或者,手机100根据第三inode的编号,删除第二数据表中第三共享库的文件名称与第三inode之间的对应关系。手机100根据第三inode的编号,删除第三inode。
另一种可能的实现方式,若第三inode的链接数等于1,则手机100根据第三inode的编号,从第一数据表中删除第三inode的编号与第三标识之间的对应关系。
可选的,若第三inode的链接数等于1,则手机100从手机100中删除第三inode与第三标识之间的对应关系。
可以理解的,若第三inode的链接数等于1,说明该第三inode对应的共享库只有第三共享库。也就是说,第三共享库不需要替代其他的共享库,即除了第二APP以外的APP在运行时,均不会调用第三共享库。又由于手机100在删除第二APP后,手机100中没有APP调用第三共享库,因此,手机100删除第二APP时,手机100会删除第三共享库的文件数据、第三inode、第三共享库的文件名称与第三inode之间的对应关系、以及第三inode与第三标识之间的对应关系,从而节约手机100的存储空间。
S604、若第三inode的链接数大于1,手机100为第三inode的链接数减1。
示例性的,APP(A)包括共享库a,APP(B)包括共享库b,APP(C)包括共享库c,共享库a、共享库b、以及共享库c的文件数据均相同。第三inode对应的共享库包括:共享库a、共享库b、共享库c,因此,第三inode的链接数为3。在手机100调用共享库a、共享库b、或者共享库c时,手机100均会调用共享库a的文件数据。若手机100删除APP(C),则手机100不删除共享库c的文件数据,仅为第三inode的链接数减1,第三inode对应的共享库包括共享库a和共享库b,第三inode的链接数为2。
可以理解的是,若第三inode的链接数大于1,说明第三共享库需要替代其他的共享库,即除了第二APP以外的APP在运行时,需要调用第三共享库。因此,为了保障其他APP正常运行,手机100不能删除第三共享库。又由于手机100将删除第二APP,即调用第三共享库的APP的数量减少,因此手机100改变第三inode的链接数,从而更新第三inode对应的共享库的数量,使手机100可以根据第三inode的链接数确定第三共享库替代的共享库的数量。
基于上述技术方案,电子设备可以根据inode(例如第三inode)的链接数,确定电子设备中是否还有APP需要调用该共享库(例如第三共享库)的文件数据,从而确定是否可以删除第三inode对应的共享库的文件数据、第三inode、以及第三共享库的文件名称与第三inode之间的对应关系。这样一来,不仅可以减少存储空间的浪费,还可以保障电子设备中的APP不会因为共享库缺失而无法正常运行。
需要说明的是,在APP安装到电子设备中时,电子设备中不仅可以存储APP的可执行程序和至少一个共享库,还可以存储APP中的信息数据例如文本文件、图片、音频等。这样一来,在APP运行时,可执行程序可以调用APP中的信息数据,并将信息数据(如图片)展示给用户。然而,若电子设备中不同的APP中包括相同的信息数据,例如第一 APP包括图片a,第二APP也包括图片a,电子设备会重复存储图片a,仅造成存储空间的浪费,并且,在第一APP和第二APP运行时,内存操作系统将图片a均映射到内存中,不仅影响影响I/O性能,还会造成内存空间的浪费。因此,本申请实施例提供的一种共享库的复用方法不仅适用于对电子设备中共享库的管理,还可以对电子设备中APP的信息数据管理,本申请实施例对此不作限定。具体对于信息数据的复用方法可参考上述实施例中的描述,此处不再赘述。
其中,电子设备中的信息数据的属性为只读属性。这样一来,可以避免信息数据被篡改,从而保障APP的信息数据不会发生变化。
上述主要从电子设备的角度对本申请实施例提供的方案进行了介绍。可以理解的是,电子设备为了实现上述功能,其包含了执行各个功能相应的硬件结构和/或软件模块。本领域技术人员应该很容易意识到,结合本申请所公开的实施例描述的各示例的一种共享库的复用方法步骤,本申请能够以硬件或硬件和计算机软件的结合形式来实现。某个功能究竟以硬件还是电子设备软件驱动硬件的方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
本申请实施例可以根据上述方法示例对共享库的复用装置进行功能模块或者功能单元的划分,例如,可以对应各个功能划分各个功能模块或者功能单元,也可以将两个或两个以上的功能集成在一个处理模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块或者功能单元的形式实现。其中,本申请实施例中对模块或者单元的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。
请参考图6,其示出本申请实施例提供的一种共享库的复用装置的示意图。该共享库的复用装置可以是上述电子设备(如手机100)中,用于实现本申请实施例的方法的功能模块。如图6所示,该共享库的复用装置可以包括:处理单元601、存储单元602。
存储单元602,用于保存至少一个共享库。例如,在手机100中包括第一APP,第一APP包括共享库a时,存储单元可以用于存储该共享库a。
处理单元601,用于确定存储单602中是否存在与第一APP的第一共享库的文件数据相同的第二共享库,第一共享库为第一APP中任意一个共享库。例如,结合图3,处理单元601可以用于执行S301。
存储单元602,还用于若存储单元中存在第二共享库,则保存第一索引节点inode与第一共享库的文件名称之间的对应关系,其中,第一inode是处理单元为第二共享库分配的,第一inode指示用于保存第二共享库的文件数据的第一存储区域。例如,结合图3,处理单元601可以用于执行S302。
处理单元601,还用于从存储单元中删除第一共享库的文件数据。
处理单元601,还用于从当运行第一APP调用第一共享库时,查找第一共享库的文件名称对应的第一inode,并读取第一inode指示的存储区域保存的第二共享库的文件数据。例如,结合图3,处理单元601还可以用于执行S304。
可选的,处理单元601,具体用于当安装完第一APP时,确定存储单元中是否存在与第一APP的第一共享库的文件数据相同的第二共享库;或者,当运行完第一APP时,确定存储单元中是否存在与第一APP的第一共享库的文件数据相同的第二共享库。例如, 手机100通过网络将第一APP的APK下载并存储在存储单元602;在解压完成第一APP的APK时,即安装完第一APP时,处理单元601确定存储单元中是否存在与第一APP的第一共享库的文件数据相同的第二共享库。
可选的,处理单元601,还具体用于当第一次运行完毕第一APP时,确定存储单元中是否存在与第一APP的第一共享库的文件数据相同的第二共享库。
可选的,处理单元601,还用于若存储单元602中不存在第二共享库,则为第一共享库分配第二inode;其中,第二inode指示用于保存第一共享库的文件数据的第二存储区域。例如,结合图4,处理单元601还可以用于执行S401。
存储单元602,还用于保存第二inode与第一共享库的文件名称之间的对应关系。例如,结合图4,存储单元602还可以用于执行S402。
处理单元601,还用于当运行第一APP调用第一共享库时,查找第一共享库的文件名称对应的第二inode,并读取第二inode指示的第二存储区域保存的第一共享库的文件数据。例如,结合图4,处理单元601还可以用于执行S403。
可选的,处理单元601,还用于若存储单元中存在第二共享库,则为第一inode的链接数加1;其中,第一inode的链接数为第一inode对应的共享库的数量;若存储单元中不存在第二共享库,则为第二inode的链接数加1;其中,第二inode的链接数为第二inode对应的共享库的数量;其中,每个inode的链接数的初始值为0。
可选的,处理单元601,还用于当删除第二APP时,从存储单元602中查找第三共享库的文件名称对应的第三inode。例如,处理单元601可以执行上述方法实施例中的S601。
处理单元601,还用于确定第三inode的链接数是否等于1。例如,处理单元601可以执行上述方法实施例中的S602。
处理单元601,还用于若第三inode的链接数等于1,则从存储单元602中删除第三共享库的文件数据、第三inode、以及第三共享库的文件名称与第三inode之间的对应关系。例如,处理单元601可以执行上述方法实施例中的S603。
处理单元601,还用于若第三inode的链接数大于1,为第三inode的链接数减1。例如,处理单元601可以执行上述方法实施例中的S604。
可选的,处理单元601,具体用于根据第一共享库的文件数据采用预设算法,生成第一共享库的第一标识,并确定第一标识与第二标识是否相同;其中,第二标识是处理单元根据存储单元中任一个共享库的文件数据采用预设算法生成的;其中,若第一标识与第二标识相同,则确定存储单元中存在与第一共享库的文件数据相同的第二共享库;若第一标识与第二标识不同,则确定存储单元中不存在与第一共享库的文件数据相同的第二共享库。
可选的,存储单元602,还用于若第一标识与第二标识不同,保存第一标识与第二inode的对应关系。
可选的,处理单元601,还用于若第三inode的链接数等于1,则从存储单元602中删除第三inode与第三标识之间的对应关系;其中,第三标识是处理单元根据第三共享库的文件数据采用预设算法生成的。
可选的,处理单元601,还具体用于对比第一共享库的文件数据与存储单元中每一 个共享库的文件数据,确定存储单元602中是否存在与第一共享库的文件数据相同的第二共享库。
本申请另一些实施例提供了一种电子设备(如图1所示的手机100),该电子设备中安装有多个APP,多个APP中的每个APP包括至少一个共享库。例如,该至少一个共享库可以包括第二共享库。
该电子设备可以包括:存储器和一个或多个处理器。该存储器和处理器耦合。该电子设备还可以包括摄像头。或者,该电子设备可以外接摄像头。该存储器用于存储计算机程序代码,该计算机程序代码包括计算机指令。当处理器执行计算机指令时,电子设备可执行上述方法实施例中手机执行的各个功能或者步骤。该电子设备的结构可以参考图1所示的手机100的结构。
本申请实施例还提供一种芯片系统,如图7所示,该芯片系统包括至少一个处理器701和至少一个接口电路702。处理器701和接口电路702可通过线路互联。例如,接口电路702可用于从其它装置(例如电子设备的存储器)接收信号。又例如,接口电路702可用于向其它装置(例如处理器701)发送信号。示例性的,接口电路702可读取存储器中存储的指令,并将该指令发送给处理器701。当所述指令被处理器701执行时,可使得电子设备(如图1所示的手机100)执行上述实施例中的各个步骤。当然,该芯片系统还可以包含其他分立器件,本申请实施例对此不作具体限定。
本申请实施例还提供一种计算机存储介质,该计算机存储介质包括计算机指令,当所述计算机指令在上述电子设备(如图1所示的手机100)上运行时,使得该电子设备执行上述方法实施例中手机执行的各个功能或者步骤。
本申请实施例还提供一种计算机程序产品,当所述计算机程序产品在计算机上运行时,使得所述计算机执行上述方法实施例中手机执行的各个功能或者步骤。
通过以上实施方式的描述,所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。
在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个装置,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是一个物理单元或多个物理单元,即可以位于一个地方,或者也可以分布到多个不同地方。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个可读取存储介质中。基于这样的理解,本申请实施例的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该软件产品存储在一个存储介质中,包括若干指令用以使得一个设备(可以是单片机,芯片等)或处理器(processor)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(read only memory,ROM)、随机存取存储器(random access memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。
以上内容,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何在本申请揭露的技术范围内的变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。

Claims (21)

  1. 一种共享库的复用方法,其特征在于,应用于电子设备,所述电子设备中安装有多个应用程序APP,所述多个APP中的每个APP包括至少一个共享库,所述复用方法包括:
    确定所述电子设备中是否存在与第一APP的第一共享库的文件数据相同的第二共享库,所述第一共享库为所述第一APP中任意一个共享库;
    若所述电子设备中存在所述第二共享库,则保存第一索引节点inode与所述第一共享库的文件名称之间的对应关系,并从所述电子设备中删除所述第一共享库的文件数据;其中,所述第一inode是所述电子设备为所述第二共享库分配的,所述第一inode指示用于保存所述第二共享库的文件数据的第一存储区域;
    当所述电子设备运行所述第一APP调用所述第一共享库时,查找所述第一共享库的文件名称对应的所述第一inode,并读取所述第一inode指示的存储区域保存的所述第二共享库的文件数据。
  2. 根据权利要求1所述的共享库的复用方法,其特征在于,所述确定所述电子设备中是否存在与第一APP的第一共享库的文件数据相同的第二共享库,包括:
    所述电子设备安装完所述第一APP时,确定所述电子设备中是否存在与所述第一APP的所述第一共享库的文件数据相同的第二共享库;或者,
    所述电子设备在运行完所述第一APP时,确定所述电子设备中是否存在与所述第一APP的所述第一共享库的文件数据相同的第二共享库。
  3. 根据权利要求1或2所述的共享库的复用方法,其特征在于,所述方法还包括:
    若所述电子设备中不存在所述第二共享库,则为所述第一共享库分配第二inode;其中,所述第二inode指示用于保存所述第一共享库的文件数据的第二存储区域;
    保存所述第二inode与所述第一共享库的文件名称之间的对应关系;
    当所述电子设备运行所述第一APP调用所述第一共享库时,查找所述第一共享库的文件名称对应的所述第二inode,并读取所述第二inode指示的第二存储区域保存的所述第一共享库的文件数据。
  4. 根据权利要求3所述的共享库的复用方法,其特征在于,所述方法还包括:
    若所述电子设备中存在所述第二共享库,则为所述第一inode的链接数加1;其中,所述第一inode的链接数为所述第一inode对应的共享库的数量;
    若所述电子设备中不存在所述第二共享库,则为所述第二inode的链接数加1;其中,所述第二inode的链接数为所述第二inode对应的共享库的数量;
    其中,每个inode的链接数的初始值为0。
  5. 根据权利要求3或4所述的共享库的复用方法,其特征在于,所述方法还包括:
    所述电子设备删除第二APP时,查找第三共享库的文件名称对应的第三inode;
    若所述第三inode的链接数等于1,则从所述电子设备中删除所述第三共享库的文件数据、所述第三inode、以及所述第三共享库的文件名称与所述第三inode之间的对应关系;
    若所述第三inode的链接数大于1,为所述第三inode的链接数减1。
  6. 根据权利要求3-5中任一项所述的共享库的复用方法,其特征在于,所述确定所述 电子设备中是否存在与第一APP的第一共享库的文件数据相同的第二共享库,包括:
    根据所述第一共享库的文件数据采用预设算法,生成所述第一共享库的第一标识,并确定所述第一标识与第二标识是否相同;其中,所述第二标识是所述电子设备根据所述电子设备中任一个共享库的文件数据采用所述预设算法生成的;
    其中,若所述第一标识与所述第二标识相同,则确定所述电子设备中存在与所述第一共享库的文件数据相同的所述第二共享库;
    若所述第一标识与第二标识不同,则确定所述电子设备中不存在与所述第一共享库的文件数据相同的所述第二共享库。
  7. 根据权利要求6所述的共享库的复用方法,其特征在于,所述方法还包括:
    若所述第一标识与第二标识不同,保存所述第一标识与所述第二inode的对应关系。
  8. 根据权利要求5所述的共享库的复用方法,其特征在于,所述方法还包括:
    若所述第三inode的链接数等于1,则从所述电子设备中删除所述第三inode与所述第三标识之间的对应关系;
    其中,所述第三标识是所述电子设备根据所述第三共享库的文件数据采用所述预设算法生成的。
  9. 根据权利要求1-5中任一项所述的共享库的复用方法,其特征在于,所述确定所述电子设备中是否存在与第一APP的第一共享库的文件数据相同的第二共享库,包括:
    对比所述第一共享库的文件数据与所述电子设备中每一个共享库的文件数据,确定所述电子设备中是否存在与所述第一共享库的文件数据相同的所述第二共享库。
  10. 一种电子设备,其特征在于,所述电子设备中安装有多个应用程序APP,所述多个APP中的每个APP包括至少一个共享库;所述电子设备包括存储器和处理器,所述存储器与所述处理器耦合;所述至少一个共享库保存在所述存储器中,所述存储器还用于存储计算机程序代码,所述计算机程序代码包括计算机指令;当所述计算机指令被所述处理器执行时,使得所述电子设备执行以下操作:
    确定所述存储器中是否存在与第一APP的第一共享库的文件数据相同的第二共享库,所述第一共享库为所述第一APP中任意一个共享库;
    若所述存储器中存在所述第二共享库,则保存第一索引节点inode与第一共享库的文件名称之间的对应关系,并从所述存储器中删除所述第一共享库的文件数据;其中,所述第一inode是所述处理器为所述第二共享库分配的,所述第一inode指示所述存储器中用于保存所述第二共享库的文件数据的第一存储区域;
    当运行所述第一APP从所述存储器调用所述第一共享库时,查找所述第一共享库的文件名称对应的所述第一inode,并读取所述第一inode指示的存储区域保存的所述第二共享库的文件数据。
  11. 根据权利要求10所述的电子设备,其特征在于,当所述计算机指令被所述一个或多个处理器执行时,使得所述电子设备还执行以下步骤:
    当安装完所述第一APP时,确定所述存储器中是否存在与所述第一APP的所述第一共享库的文件数据相同的第二共享库;或者,
    当运行完所述第一APP时,确定所述存储器中是否存在与所述第一APP的所述第一共享库的文件数据相同的第二共享库。
  12. 根据权利要求10或11所述的电子设备,其特征在于,当所述计算机指令被所述一个或多个处理器执行时,使得所述电子设备还执行以下步骤:
    若所述存储器中不存在所述第二共享库,则为所述第一共享库分配第二inode;其中,所述第二inode指示用于保存所述第一共享库的文件数据的第二存储区域;
    保存所述第二inode与所述第一共享库的文件名称之间的对应关系;
    当运行所述第一APP调用所述第一共享库时,查找所述第一共享库的文件名称对应的所述第二inode,并读取所述第二inode指示的第二存储区域保存的所述第一共享库的文件数据。
  13. 根据权利要求12所述的电子设备,其特征在于,当所述计算机指令被所述一个或多个处理器执行时,使得所述电子设备还执行以下步骤:
    若所述存储器中存在所述第二共享库,则为所述第一inode的链接数加1;其中,所述第一inode的链接数为所述第一inode对应的共享库的数量;
    若所述存储器中不存在所述第二共享库,则为所述第二inode的链接数加1;其中,所述第二inode的链接数为所述第二inode对应的共享库的数量;
    其中,每个inode的链接数的初始值为0。
  14. 根据权利要求12或13所述的电子设备,其特征在于,当所述计算机指令被所述一个或多个处理器执行时,使得所述电子设备还执行以下步骤:
    当删除第二APP时,查找第三共享库的文件名称对应的第三inode;
    若所述第三inode的链接数等于1,则从所述存储器中删除所述第三共享库的文件数据、所述第三inode、以及所述第三共享库的文件名称与所述第三inode之间的对应关系;
    若所述第三inode的链接数大于1,为所述第三inode的链接数减1。
  15. 根据权利要求12-14中任一项所述的电子设备,其特征在于,当所述计算机指令被所述一个或多个处理器执行时,使得所述电子设备还执行以下步骤:
    根据所述第一共享库的文件数据采用预设算法,生成所述第一共享库的第一标识,并确定所述第一标识与第二标识是否相同;其中,所述第二标识是所述处理器根据所述存储器中任一个共享库的文件数据采用所述预设算法生成的;
    其中,若所述第一标识与所述第二标识相同,则确定所述存储器中存在与所述第一共享库的文件数据相同的所述第二共享库;
    若所述第一标识与第二标识不同,则确定所述存储器中不存在与所述第一共享库的文件数据相同的所述第二共享库。
  16. 根据权利要求15所述的电子设备,其特征在于,当所述计算机指令被所述一个或多个处理器执行时,使得所述电子设备还执行以下步骤:
    若所述第一标识与第二标识不同,保存所述第一标识与所述第二inode的对应关系。
  17. 根据权利要求16所述的电子设备,其特征在于,当所述计算机指令被所述一个或多个处理器执行时,使得所述电子设备还执行以下步骤:
    若所述第三inode的链接数等于1,则从所述存储器中删除所述第三inode与所述第三标识之间的对应关系;
    其中,所述第三标识是所述处理器根据所述第三共享库的文件数据采用所述预设算法生成的。
  18. 根据权利要求17所述的电子设备,其特征在于,当所述计算机指令被所述一个或多个处理器执行时,使得所述电子设备还执行以下步骤:
    对比所述第一共享库的文件数据与所述存储器中每一个共享库的文件数据,确定所述存储器中是否存在与所述第一共享库的文件数据相同的所述第二共享库。
  19. 一种芯片系统,其特征在于,所述芯片系统应用于电子设备,所述电子设备中安装有多个APP,所述多个APP中的每个APP包括至少一个共享库;所述芯片系统包括一个或多个接口电路和一个或多个处理器;所述接口电路和所述处理器通过线路互联;所述接口电路用于从所述电子设备的存储器接收信号,并向所述处理器发送所述信号,所述信号包括所述存储器中存储的计算机指令;当所述处理器执行所述计算机指令时,所述电子设备执行如权利要求1-9中任一项所述的方法。
  20. 一种计算机存储介质,其特征在于,包括计算机指令,当所述计算机指令在电子设备上运行时,使得所述电子设备执行如权利要求1-9中任一项所述的方法。
  21. 一种计算机程序产品,其特征在于,当所述计算机程序产品在计算机上运行时,使得所述计算机执行如权利要求1-9中任一项所述的方法。
PCT/CN2021/112853 2020-08-31 2021-08-16 一种共享库的复用方法及电子设备 WO2022042363A1 (zh)

Priority Applications (3)

Application Number Priority Date Filing Date Title
JP2023513836A JP2023539879A (ja) 2020-08-31 2021-08-16 共有ライブラリを再利用するための方法および電子デバイス
US18/042,980 US20230350738A1 (en) 2020-08-31 2021-08-16 Method for Reusing Shared Library and Electronic Device
EP21860201.9A EP4191409A4 (en) 2020-08-31 2021-08-16 MULTIPLEX METHOD FOR COMMON LIBRARY AND ELECTRONIC DEVICE

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010899468.4 2020-08-31
CN202010899468.4A CN114116072A (zh) 2020-08-31 2020-08-31 一种共享库的复用方法及电子设备

Publications (1)

Publication Number Publication Date
WO2022042363A1 true WO2022042363A1 (zh) 2022-03-03

Family

ID=80354593

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/112853 WO2022042363A1 (zh) 2020-08-31 2021-08-16 一种共享库的复用方法及电子设备

Country Status (5)

Country Link
US (1) US20230350738A1 (zh)
EP (1) EP4191409A4 (zh)
JP (1) JP2023539879A (zh)
CN (1) CN114116072A (zh)
WO (1) WO2022042363A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116048562B (zh) * 2022-05-30 2023-10-27 荣耀终端有限公司 一种数据更新方法、电子设备及存储介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102854853A (zh) * 2012-08-13 2013-01-02 北京和利时系统工程有限公司 一种跨平台轻量级的分布式控制系统
US20130103744A1 (en) * 2011-10-24 2013-04-25 Electronics And Telecommunications Research Institute Method and apparatus for executing web service program based on javascript
CN106203006A (zh) * 2016-08-31 2016-12-07 北京鼎源科技有限公司 基于dex与so文件动态执行的Android应用加固方法
CN106897089A (zh) * 2017-01-19 2017-06-27 上海帝联信息科技股份有限公司 系统操作执行方法及装置
CN107102888A (zh) * 2017-04-25 2017-08-29 华中科技大学 一种基于硬件虚拟化技术的共享库隔离保护方法及系统

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6389433B1 (en) * 1999-07-16 2002-05-14 Microsoft Corporation Method and system for automatically merging files into a single instance store
US8190835B1 (en) * 2007-12-31 2012-05-29 Emc Corporation Global de-duplication in shared architectures
US8706703B2 (en) * 2011-06-27 2014-04-22 International Business Machines Corporation Efficient file system object-based deduplication

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130103744A1 (en) * 2011-10-24 2013-04-25 Electronics And Telecommunications Research Institute Method and apparatus for executing web service program based on javascript
CN102854853A (zh) * 2012-08-13 2013-01-02 北京和利时系统工程有限公司 一种跨平台轻量级的分布式控制系统
CN106203006A (zh) * 2016-08-31 2016-12-07 北京鼎源科技有限公司 基于dex与so文件动态执行的Android应用加固方法
CN106897089A (zh) * 2017-01-19 2017-06-27 上海帝联信息科技股份有限公司 系统操作执行方法及装置
CN107102888A (zh) * 2017-04-25 2017-08-29 华中科技大学 一种基于硬件虚拟化技术的共享库隔离保护方法及系统

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP4191409A4

Also Published As

Publication number Publication date
EP4191409A1 (en) 2023-06-07
JP2023539879A (ja) 2023-09-20
EP4191409A4 (en) 2024-01-10
CN114116072A (zh) 2022-03-01
US20230350738A1 (en) 2023-11-02

Similar Documents

Publication Publication Date Title
US7873758B2 (en) Cellular phone and portable storage device using the same
WO2020211712A1 (zh) 补丁方法、相关装置及系统
US12118128B2 (en) Running a trusted application using a dynamic library
WO2021027630A1 (zh) 补丁方法、相关装置及系统
CN112055424B (zh) 电子装置以及切换电子装置的方法
WO2022057742A1 (zh) 一种跨设备调用应用的方法及电子设备
CN112119623B (zh) 基于帐户组共享内容的方法和执行该方法的电子装置
WO2021022729A1 (zh) root权限的分配方法、装置、存储介质及终端设备
CN114968384B (zh) 一种功能调用方法和装置
WO2022156535A1 (zh) 分布式应用的处理方法和装置
WO2022042363A1 (zh) 一种共享库的复用方法及电子设备
WO2022063037A1 (zh) 一种补丁包安装方法和装置
WO2023109607A1 (zh) 应用界面跨设备显示方法、设备系统
CN114253737B (zh) 电子设备及其内存回收方法、介质
CN115756868A (zh) 内存分配方法、装置、设备、存储介质及计算机程序产品
WO2023142696A1 (zh) 缩略图存储方法及电子设备
WO2024140279A1 (zh) 传输文件的方法及电子设备
WO2024037006A1 (zh) 升级包的生成方法、安装方法、设备及存储介质
WO2023088090A1 (zh) 文件验证方法及相关设备
WO2023088289A1 (zh) 补丁方法及相关设备
WO2024007944A1 (zh) 扩展内存隔离域的方法和电子设备
WO2023066036A1 (zh) 一种跨设备文件显示方法、设备及系统
EP4436265A1 (en) Control method for cellular network, and electronic device
CN117520279A (zh) 文件存储的方法及电子设备
CN116257486A (zh) 一种访问请求的处理方法以及相关设备

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21860201

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2023513836

Country of ref document: JP

Kind code of ref document: A

WWE Wipo information: entry into national phase

Ref document number: 202317014178

Country of ref document: IN

ENP Entry into the national phase

Ref document number: 2021860201

Country of ref document: EP

Effective date: 20230301

NENP Non-entry into the national phase

Ref country code: DE