Application installation method and electronic equipment
By processing the upper-layer installation and lower-layer optimization processes in parallel within electronic devices, the problem of long batch application installation times is solved, improving installation speed and user experience.
Patent Information
- Application Number
- CN202512023349.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-23
- Publication Date
- 2026-04-14
AI Technical Summary
When installing applications in batches on electronic devices, the upper-level installation process and the lower-level optimization process are performed sequentially, resulting in a significant time consumption during the installation process and a reduced user experience.
By running the application's upper-layer installation process and lower-layer optimization process in parallel, and by utilizing task queue management and thread scheduling, the task queue is optimized to achieve parallel processing.
It improves the speed of installing multiple applications on electronic devices, enhances the user experience, and avoids issues such as backlog of underlying optimization tasks and excessive device temperature.
Smart Images

Figure CN121858121A_ABST
Abstract
Description
[0001] This application is a divisional application. The original application has the application number 202010713889.3 and the original application date is July 23, 2020. The entire contents of the original application are incorporated herein by reference. Technical Field
[0002] This application relates to the field of electronic technology, and more particularly to a method for installation and application and an electronic device. Background Technology
[0003] When installing applications (Apps) on electronic devices, there is generally an upper-level installation process and an underlying optimization process. For example, when installing Apps in batches or cloning and restoring multiple Apps from backups on electronic devices, the number of Apps to be installed is large. Since the upper-level installation process and the underlying optimization process of multiple Apps are performed sequentially, and the underlying optimization process of Apps takes a long time, the installation process consumes a lot of time and reduces the user experience.
[0004] Therefore, how to quickly and efficiently install apps in batches has become a technical problem that needs to be solved. Summary of the Invention
[0005] This application provides a method for installing applications and an electronic device, which helps to improve the installation speed of multiple applications on an electronic device, thereby improving the user experience.
[0006] In a first aspect, a method for installing an application is provided, the method being applied to an electronic device, the method comprising: detecting that a user triggers an operation to install a first application and a second application; in response to the operation, copying and scanning a first application package, the first application package being an application package corresponding to the first application; within a first time period following the copying and scanning of the first application package, copying and scanning a second application package, the second application package being an application package corresponding to the second application; and within a second time period following the copying and scanning of the first application package, performing optimization of the first application; wherein the first time period and the second time period at least partially overlap.
[0007] Based on this technical solution, when installing applications on electronic devices, the upper-level installation process and the lower-level optimization process are carried out in parallel, which helps to improve the installation speed of multiple applications on electronic devices, thereby improving the user experience.
[0008] In conjunction with the first aspect, in some implementations of the first aspect, the method further includes: detecting that the user triggers the operation of installing a third application and a fourth application; copying and scanning a third application package, wherein the third application package is the application package corresponding to the third application, during a third time period after copying and scanning the first application package; wherein, when the duration of the second time period is greater than the sum of the durations of the first time period and the third time period, the start time of copying and scanning the fourth application package is later than or equal to the start time of performing optimization on the second application.
[0009] Based on this technical solution, when the underlying optimization process of an application takes a long time to execute, this technical solution helps to avoid excessive optimization tasks accumulating in the underlying optimization queue.
[0010] In conjunction with the first aspect, in some implementations of the first aspect, the method further includes: detecting that the user triggers the operation of installing a third application; detecting the temperature of the central processing unit (CPU) of the electronic device when the copying and scanning of the second application package is completed; determining that the temperature is greater than or equal to a preset value; pausing for a first preset duration when the optimization of the second application ends; and copying and scanning the third application package after the first preset duration, wherein the third application package is the application package corresponding to the third application.
[0011] Based on this technical solution, the temperature of electronic devices is monitored during the installation of multiple applications. When the temperature of the electronic device is too high, the underlying optimization tasks are allowed to rest for a period of time, which helps to reduce the phenomenon of short-term overheating of electronic devices.
[0012] Based on this technical solution, when the temperature of an electronic device becomes abnormal, the currently executing optimization task is not stopped immediately. Instead, the task is allowed to complete before the optimization task is stopped for a period of time, which helps to avoid problems such as insufficient application stability of the electronic device.
[0013] In conjunction with the first aspect, in some implementations of the first aspect, before optimizing the first application, optimizing the fourth application is performed to determine that the temperature is greater than or equal to a preset value, including: determining that the temperature is greater than or equal to the preset value and the duration of the fourth time period is greater than or equal to a second preset duration; wherein the fourth time period is the same as the second time period; or, when the time interval between the second time period and the fifth time period is less than or equal to a third preset duration, the fourth time period is the sum of the second time period and the fifth time period, and the fifth time period is the time period during which the electronic device performs the optimization of the fourth application.
[0014] Based on this technical solution, when an electronic device experiences abnormal temperature, it can determine whether the underlying optimization task has been running for a long time. This solution is helpful in determining whether the abnormal temperature of the electronic device is caused by the underlying optimization application.
[0015] In conjunction with the first aspect, in some implementations of the first aspect, the optimization of the first application is performed during the second time period after copying and scanning the first application package, including: adding a first optimization task to a first task queue, the first optimization task being used to optimize the first application; starting a first thread, the first thread being used to retrieve the first optimization task from the first task queue; and calling a first interface, the first interface being used to start a second thread, the second thread being used to execute the first optimization task.
[0016] In this technical solution, when installing applications in batches on electronic devices, the optimization tasks corresponding to the applications can be placed in a task queue. The first thread manages and schedules the task queue. That is, the first thread retrieves the optimization tasks from the task queue, and then calls the first interface to start the second thread to actually execute the application optimization tasks. This ensures that the underlying optimization of the application does not affect the upper-level installation of the application. In other words, the upper-level application installation and the underlying optimization process can be processed in parallel, thereby speeding up the installation of batch applications and improving the user experience.
[0017] In a second aspect, an electronic device is provided, comprising: one or more processors; one or more memories; the one or more memories storing one or more computer programs, the one or more computer programs including instructions that, when executed by the one or more processors, cause the electronic device to perform the following steps: detecting that a user triggers an operation to install a first application and a second application; in response to the operation, copying and scanning a first application package, the first application package being an application package corresponding to the first application; copying and scanning a second application package, the second application package being an application package corresponding to the second application, during a first time period after copying and scanning the first application package; and performing optimization of the first application during a second time period after copying and scanning the first application package; wherein the first time period and the second time period at least partially overlap.
[0018] In conjunction with the second aspect, in some implementations of the second aspect, when the instruction is executed by the one or more processors, the electronic device performs the following steps: detecting that a user has triggered the installation of a third application and a fourth application; copying and scanning a third application package, which is the application package corresponding to the third application, during a third time period after copying and scanning the first application package; wherein, when the duration of the second time period is greater than the sum of the durations of the first time period and the third time period, the start time of copying and scanning the fourth application package is later than or equal to the start time of optimizing the second application.
[0019] In conjunction with the second aspect, in some implementations of the second aspect, when the instruction is executed by one or more processors, the electronic device performs the following steps: detecting that a user has triggered an operation to install a third application; detecting the CPU temperature of the electronic device when the copying and scanning of the second application package is completed; determining that the temperature is greater than or equal to a preset value; pausing for a first preset duration after the optimization of the second application is completed; and copying and scanning the third application package, which is the application package corresponding to the third application, after the first preset duration.
[0020] In conjunction with the second aspect, in some implementations of the second aspect, before optimizing the first application, the fourth application is optimized. Specifically, the electronic device is used to: determine that the temperature is greater than or equal to a preset value and the duration of the fourth time period is greater than or equal to a second preset duration; wherein the fourth time period is the same as the second time period; or, when the time interval between the second time period and the fifth time period is less than or equal to a third preset duration, the fourth time period is the sum of the second time period and the fifth time period, and the fifth time period is the time period during which the electronic device performs the optimization of the fourth application.
[0021] In conjunction with the second aspect, in some implementations of the second aspect, the electronic device is specifically used to: add a first optimization task to a first task queue, the first optimization task being used to optimize a first application; start a first thread, the first thread being used to retrieve the first optimization task from the first task queue; and call a first interface, the first interface being used to start a second thread, the second thread being used to execute the first optimization task.
[0022] Thirdly, a computer-readable storage medium is provided that stores computer instructions that, when executed on an electronic device, cause the electronic device to perform the method of installing an application as described in the first aspect and any possible implementation thereof.
[0023] Fourthly, a computer program product is provided that, when the computer program product is run on a computer, causes the computer to perform the method of installing the application as described in the first aspect and any possible implementation thereof. Attached Figure Description
[0024] Figure 1 This is a schematic diagram of the structure of an electronic device 100 to which the embodiments of this application can be applied.
[0025] Figure 2 This is a software structure block diagram of the electronic device 100 according to an embodiment of this application.
[0026] Figure 3 This is a schematic diagram of a set of GUIs provided in the embodiments of this application.
[0027] Figure 4 This is a schematic diagram of an application installation process provided in an embodiment of this application.
[0028] Figure 5 This is a schematic diagram of the timing process for installing an application within a PMS, provided in an embodiment of this application.
[0029] Figure 6 This is a schematic diagram of the timing process for installing applications within a PMS, as provided in an embodiment of this application.
[0030] Figure 7 This is a flowchart of a method for installing an application provided in an embodiment of this application.
[0031] Figure 8 This is a timing diagram of an application installation provided in an embodiment of this application.
[0032] Figure 9 This is a timing diagram of another application installation provided in an embodiment of this application.
[0033] Figure 10 This is a flowchart illustrating a method for installing an application provided in an embodiment of this application.
[0034] Figure 11 This is a timing flowchart illustrating a method for temperature control strategy during installation and application provided in an embodiment of this application.
[0035] Figure 12 This is a flowchart illustrating the process of calculating the working time of a dex2oat task, as provided in an embodiment of this application.
[0036] Figure 13 This is a schematic diagram of an optimized control process for a temperature control strategy provided in an embodiment of this application.
[0037] Figure 14This is a schematic flowchart illustrating an application installation method provided in an embodiment of this application. Detailed Implementation
[0038] The technical solutions of the embodiments of this application will be described below with reference to the accompanying drawings. In the description of the embodiments of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B; "and / or" in this text is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, in the description of the embodiments of this application, "multiple" refers to two or more than two.
[0039] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature.
[0040] The application installation method provided in this application can be applied to electronic devices such as mobile phones, tablets, wearable devices, in-vehicle devices, augmented reality (AR) / virtual reality (VR) devices, laptops, ultra-mobile personal computers (UMPCs), netbooks, and personal digital assistants (PDAs). This application does not impose any restrictions on the specific type of electronic device.
[0041] For example, Figure 1A schematic diagram of the structure of electronic device 100 is shown. Electronic device 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, a battery 142, antenna 1, antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, buttons 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an accelerometer sensor 180E, a distance sensor 180F, a proximity sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0042] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0043] Processor 110 may include one or more processing units, such as: application processor (AP), modem processor, graphics processing unit (GPU), image signal processor (ISP), controller, memory, video codec, digital signal processor (DSP), baseband processor, and / or neural network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0044] The controller can be the nerve center and command center of the electronic device 100. The controller can generate operation control signals according to the instruction opcode and timing signals to complete the control of fetching and executing instructions.
[0045] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0046] In some embodiments, the processor 110 may include one or more interfaces. Interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0047] The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may include multiple I2C buses. The processor 110 can couple to the touch sensor 180K, charger, flash, camera 193, etc., through different I2C bus interfaces. For example, the processor 110 can couple to the touch sensor 180K through the I2C interface, enabling the processor 110 and the touch sensor 180K to communicate through the I2C bus interface, thereby realizing the touch function of the electronic device 100.
[0048] The I2S interface can be used for audio communication. In some embodiments, the processor 110 may include multiple I2S buses. The processor 110 can be coupled to the audio module 170 via the I2S bus to enable communication between the processor 110 and the audio module 170. In some embodiments, the audio module 170 can transmit audio signals to the wireless communication module 160 via the I2S interface to enable the function of answering phone calls through a Bluetooth headset.
[0049] The PCM interface can also be used for audio communication, sampling, quantizing, and encoding analog signals. In some embodiments, the audio module 170 and the wireless communication module 160 can be coupled via the PCM bus interface. In some embodiments, the audio module 170 can also transmit audio signals to the wireless communication module 160 via the PCM interface, enabling the function of answering phone calls through a Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.
[0050] The UART interface is a universal serial data bus used for asynchronous communication. This bus can be a bidirectional communication bus. It converts the data to be transmitted between serial and parallel communication. In some embodiments, the UART interface is typically used to connect the processor 110 and the wireless communication module 160. For example, the processor 110 communicates with the Bluetooth module in the wireless communication module 160 via the UART interface to implement Bluetooth functionality. In some embodiments, the audio module 170 can transmit audio signals to the wireless communication module 160 via the UART interface to enable music playback through Bluetooth headphones.
[0051] The MIPI interface can be used to connect the processor 110 to peripheral devices such as the display screen 194 and the camera 193. The MIPI interface includes a camera serial interface (CSI) and a display serial interface (DSI). In some embodiments, the processor 110 and the camera 193 communicate via the CSI interface to enable the electronic device 100 to capture images. The processor 110 and the display screen 194 communicate via the DSI interface to enable the electronic device 100 to display images.
[0052] The GPIO interface is configurable via software. It can be configured as a control signal or a data signal. In some embodiments, the GPIO interface can be used to connect the processor 110 to a camera 193, a display screen 194, a wireless communication module 160, an audio module 170, a sensor module 180, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.
[0053] USB port 130 is a USB standard compliant interface, specifically a Mini USB port, Micro USB port, USB Type-C port, etc. USB port 130 can be used to connect a charger to charge electronic device 100, and can also be used for data transfer between electronic device 100 and peripheral devices. It can also be used to connect headphones for audio playback. This interface can also be used to connect other electronic devices, such as AR devices.
[0054] It is understood that the interface connection relationships between the modules illustrated in the embodiments of this application are merely illustrative and do not constitute a structural limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.
[0055] The charging management module 140 receives charging input from a charger. The charger can be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 receives charging input from the wired charger via the USB interface 130. In some wireless charging embodiments, the charging management module 140 receives wireless charging input via the wireless charging coil of the electronic device 100. While charging the battery 142, the charging management module 140 can also supply power to the electronic device via the power management module 141.
[0056] The power management module 141 connects 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, providing power to the processor 110, internal memory 121, external memory, display screen 194, camera 193, and wireless communication module 160, etc. The power management module 141 can also monitor parameters such as battery capacity, battery cycle count, and battery health status (leakage current, impedance). In some other embodiments, the power management module 141 may also be located within the processor 110. In other embodiments, the power management module 141 and the charging management module 140 may be located in the same device.
[0057] The wireless communication function of electronic device 100 can be realized through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor and baseband processor, etc.
[0058] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover one or more communication frequency bands. Different antennas can also be multiplexed to improve antenna utilization. For example, antenna 1 can be multiplexed as a diversity antenna for a wireless local area network. In some other embodiments, the antennas can be used in conjunction with a tuning switch.
[0059] The mobile communication module 150 can provide solutions for wireless communication, including 2G / 3G / 4G / 5G, applied to the electronic device 100. The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves via antenna 1, and perform filtering, amplification, and other processing on the received electromagnetic waves before transmitting them to a modem processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves for radiation via antenna 1. In some embodiments, at least some functional modules of the mobile communication module 150 may be housed in the processor 110. In some embodiments, at least some functional modules of the mobile communication module 150 and at least some modules of the processor 110 may be housed in the same device.
[0060] The modem processor may include a modulator and a demodulator. The modulator modulates the low-frequency baseband signal to be transmitted into a mid-to-high frequency signal. The demodulator demodulates the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After processing by the baseband processor, the low-frequency baseband signal is transmitted to the application processor. The application processor outputs sound signals through an audio device (not limited to speaker 170A, receiver 170B, etc.) or displays images or videos through the display screen 194. In some embodiments, the modem processor may be a separate device. In other embodiments, the modem processor may be independent of the processor 110 and may be housed in the same device as the mobile communication module 150 or other functional modules.
[0061] The wireless communication module 160 can provide solutions for wireless communication applications on the electronic device 100, including wireless local area networks (WLANs) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via antenna 2, performs frequency modulation and filtering of the electromagnetic wave signals, and sends the processed signal to processor 110. The wireless communication module 160 can also receive signals to be transmitted from processor 110, perform frequency modulation and amplification, and convert them into electromagnetic waves for radiation via antenna 2.
[0062] In some embodiments, antenna 1 of electronic device 100 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, enabling electronic device 100 to communicate with networks and other devices via wireless communication technology. The wireless communication technology may include Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Time Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technologies, etc. The GNSS may include the Global Positioning System (GPS), the Global Navigation Satellite System (GLONASS), the BeiDou Navigation Satellite System (BDS), the Quasi-Zenith Satellite System (QZSS), and / or satellite-based augmentation systems (SBAS).
[0063] Electronic device 100 implements display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.
[0064] Display screen 194 is used to display images, videos, etc. Display screen 194 includes a display panel. The display panel may be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a miniature LED, a microLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, electronic device 100 may include one or N displays 194, where N is a positive integer greater than 1.
[0065] Electronic device 100 can perform shooting functions through ISP, camera 193, video codec, GPU, display 194 and application processor.
[0066] The ISP is used to process data fed back from the camera 193. For example, when taking a picture, the shutter is opened, and light is transmitted through the lens to the camera's photosensitive element. The light signal is converted into an electrical signal, and the camera's photosensitive element transmits the electrical signal to the ISP for processing, converting it into an image visible to the naked eye. The ISP can also perform algorithmic optimization on image noise and brightness. The ISP can also optimize parameters such as exposure and color temperature of the shooting scene. In some embodiments, the ISP can be set in the camera 193.
[0067] Camera 193 is used to capture still images or videos. An object is projected onto a photosensitive element by generating an optical image through the lens. The photosensitive element can be a charge-coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, which is then passed to an ISP for conversion into a digital image signal. The ISP outputs the digital image signal to a DSP for processing. The DSP converts the digital image signal into image signals in standard RGB, YUV, or other formats. In some embodiments, the electronic device 100 may include one or N cameras 193, where N is a positive integer greater than 1.
[0068] Digital signal processors (DSPs) are used to process digital signals. Besides digital image signals, they can also process other digital signals. For example, when electronic device 100 selects a frequency, the DSP can perform Fourier transforms on the frequency energy.
[0069] Video codecs are used to compress or decompress digital video. Electronic device 100 may support one or more video codecs. Thus, electronic device 100 can play or record videos in various encoding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
[0070] An NPU (Neural Processing Unit) is a computational processor for neural networks (NNs). By borrowing the structure of biological neural networks, such as the transmission patterns between neurons in the human brain, it can rapidly process input information and continuously learn on its own. NPUs enable intelligent cognitive applications in electronic devices, such as image recognition, facial recognition, speech recognition, and text understanding.
[0071] The external storage interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external storage interface 120 to perform data storage functions. For example, music, video, and other files can be saved on the external memory card.
[0072] Internal memory 121 can be used to store computer executable program code, which includes instructions. Processor 110 executes various functional applications and data processing of electronic device 100 by running the instructions stored in internal memory 121. Internal memory 121 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback, image playback, etc.), etc. The data storage area may store data created during the use of electronic device 100 (such as audio data, phonebook, etc.). Furthermore, internal memory 121 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.
[0073] Electronic device 100 can implement audio functions, such as music playback and recording, through audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, and application processor.
[0074] The audio module 170 is used to convert digital audio information into analog audio signals for output, and also to convert analog audio input into digital audio signals. The audio module 170 can also be used for encoding and decoding audio signals. In some embodiments, the audio module 170 may be located in the processor 110, or some functional modules of the audio module 170 may be located in the processor 110.
[0075] The speaker 170A, also known as a "loudspeaker," is used to convert audio electrical signals into sound signals. The electronic device 100 can listen to music or make hands-free calls through the speaker 170A.
[0076] The receiver 170B, also known as the "earpiece," is used to convert audio electrical signals into sound signals. When the electronic device 100 answers a telephone call or voice message, the receiver 170B can be brought close to the ear to listen to the voice.
[0077] Microphone 170C, also known as a "microphone" or "voice transducer," is used to convert sound signals into electrical signals. When making a phone call or sending a voice message, the user can speak by bringing their mouth close to microphone 170C, inputting the sound signal into microphone 170C. Electronic device 100 may have at least one microphone 170C. In some embodiments, electronic device 100 may have two microphones 170C, which, in addition to collecting sound signals, can also perform noise reduction. In other embodiments, electronic device 100 may also have three, four, or more microphones 170C, which can collect sound signals, reduce noise, identify the sound source, and perform directional recording, etc.
[0078] The 170D headphone jack is used to connect wired headphones. The 170D headphone jack can be a USB 130 interface or a 3.5mm Open Mobile Terminal Platform (OMTP) standard interface, a CTIA (Cellular Telecommunications Industry Association of the USA) standard interface.
[0079] The pressure sensor 180A is used to sense pressure signals and can convert pressure signals into electrical signals.
[0080] The gyroscope sensor 180B can be used to determine the motion attitude of the electronic device 100. The barometric pressure sensor 180C is used to measure barometric pressure. The magnetic sensor 180D includes a Hall effect sensor. The electronic device 100 can use the magnetic sensor 180D to detect the opening and closing of the flip cover. The accelerometer sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in various directions (generally three axes).
[0081] Distance sensor 180F is used to measure distance. Electronic device 100 can measure distance via infrared or laser.
[0082] The proximity sensor 180G may include, for example, a light-emitting diode (LED) and a light detector, such as a photodiode. The LED may be an infrared LED. The electronic device 100 emits infrared light outward through the LED. The electronic device 100 uses the photodiode to detect infrared reflected light from nearby objects. When sufficient reflected light is detected, it can be determined that there is an object near the electronic device 100. When insufficient reflected light is detected, the electronic device 100 can determine that there is no object near the electronic device 100. The electronic device 100 may use the proximity sensor 180G to detect when a user holds the electronic device 100 close to their ear for a call, so as to automatically turn off the screen to save power. The proximity sensor 180G can also be used in holster mode and pocket mode for automatic unlocking and locking of the screen.
[0083] An ambient light sensor 180L is used to sense the ambient light intensity. Electronic device 100 can adaptively adjust the brightness of display screen 194 according to the sensed ambient light intensity.
[0084] The fingerprint sensor 180H is used to collect fingerprints.
[0085] Temperature sensor 180J is used to detect temperature. In some embodiments, electronic device 100 uses the temperature detected by temperature sensor 180J to execute a temperature processing strategy. For example, when the temperature reported by temperature sensor 180J exceeds a threshold, electronic device 100 performs thermal protection by reducing the performance of a processor located near temperature sensor 180J to reduce power consumption.
[0086] Touch sensor 180K, also known as "touch panel". Touch sensor 180K can be set on display screen 194. Touch sensor 180K and display screen 194 together form touch screen, also known as "touch screen". The bone conduction sensor 180M can acquire vibration signals.
[0087] Buttons 190 include a power button, volume buttons, etc. Buttons 190 can be mechanical buttons or touch-sensitive buttons. Electronic device 100 can receive button input and generate key signal inputs related to user settings and function control of electronic device 100.
[0088] Motor 191 can generate vibration alerts.
[0089] Indicator 192 can be an indicator light, used to indicate charging status, power changes, or to indicate messages, missed calls, notifications, etc.
[0090] The SIM card interface 195 is used to connect the SIM card.
[0091] The software system of electronic device 100 can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application embodiment uses the layered architecture Android system as an example to exemplify the software structure of electronic device 100.
[0092] Figure 2 This is a software structure block diagram of an electronic device 100 according to an embodiment of this application. The layered architecture divides the software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: the application layer, the application framework layer, the Android runtime and system libraries, and the kernel layer. The application layer may include a series of application packages.
[0093] like Figure 2 As shown, the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, and SMS.
[0094] The application framework layer provides application programming interfaces (APIs) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.
[0095] like Figure 2 As shown, the application framework layer may include a package manager service (PMS), a window manager, a content provider, a view system, a resource manager, a notification manager, etc.
[0096] PMS is used to manage the installation and uninstallation of various software.
[0097] The window manager is used to manage windowed applications. It can retrieve screen size, determine the presence of a status bar, lock the screen, and capture screenshots, among other things.
[0098] Content providers store and retrieve data, making that data accessible to applications. This data may include videos, images, audio, made and received phone calls, browsing history and bookmarks, phone books, etc.
[0099] A view system includes visual controls, such as controls for displaying text and controls for displaying images. View systems can be used to build applications. A display interface can consist of one or more views. For example, a display interface including a text notification icon could include views for displaying text and views for displaying images.
[0100] The file explorer provides applications with various resources, such as localized strings, icons, images, layout files, video files, and more.
[0101] The notification manager allows applications to display notifications in the status bar. These notifications can be used to deliver informational messages and can disappear automatically after a short pause, requiring no user interaction. For example, the notification manager can be used to notify users of completed downloads or message alerts. The notification manager can also display notifications as icons or scrolling text in the top status bar, such as notifications from background applications, or as dialog boxes on the screen. Examples include displaying text messages in the status bar, emitting sounds, vibrating electronic devices, and flashing indicator lights.
[0102] The Android runtime consists of core libraries and a virtual machine. The Android runtime is responsible for scheduling and managing the Android system.
[0103] The core library consists of two parts: one part is the functionalities that need to be called by the Java language, and the other part is the Android core library.
[0104] The application layer and application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.
[0105] System libraries can include multiple functional modules. For example: installd, media libraries, 3D graphics processing libraries (e.g., OpenGL ES), 2D graphics engines (e.g., SGL), etc.
[0106] The kernel layer is the layer between hardware and software. The kernel layer includes at least display drivers, camera drivers, storage drivers, and sensor drivers.
[0107] For ease of understanding, the following embodiments of this application will be described using the following methods: Figure 1 and Figure 2 Taking the electronic device with the structure shown as an example, and in conjunction with the accompanying drawings and application scenarios, the installation and application method provided in this application will be specifically described.
[0108] Before describing the method of installing the application in the embodiments of this application, the terminology used in the embodiments of this application will be briefly introduced first.
[0109] 1. Android Application Package (APK): This is an application package file format used by the Android operating system for distributing and installing mobile applications and middleware. For an Android application's code to run on an Android device, it must first be compiled and then packaged into a file that the Android system can recognize and run. This file format that the Android system can recognize and run is the "APK". An APK consists of XML, resource files, and DEX (binary bytecode) files.
[0110] 2. Blocking call: The current thread will be suspended until the call result is returned.
[0111] 3. The dexopt thread: This thread executes the dexopt task, which verifies and optimizes dex files to generate executable odex files. This process can improve application startup and component loading performance.
[0112] 4. dex2oat thread: Used to execute dex2oat tasks. dex2oat is the process of optimizing APK files and generating oat files. An oat file is a proprietary Android ELF file format. It contains not only native machine instructions translated from the dex file but also the original dex file content. For an APK, the oat file is essentially a wrapper around an odex file; that is, oat = odex.
[0113] 5. dex2oat job queue management thread: Used to manage the dex2oat job queue and to retrieve dex2oat jobs from the dex2oat job queue.
[0114] Figure 3 This is a schematic diagram of a set of graphical user interfaces (GUIs) provided in an embodiment of this application. This embodiment uses the example of a user installing multiple applications on a mobile phone. Among them, from... Figure 3 (a) through (d) in the diagram illustrate the process of a user installing multiple applications at once.
[0115] See Figure 3 In (a), the GUI is the phone's desktop 200. When the phone detects that the user clicks the app store icon 210 on the desktop 200, it can display something like this. Figure 3 The GUI shown in (b) is shown in the image.
[0116] See Figure 3In (b), the GUI displays the app market interface, where users can download various applications they need. For example, if a user downloads multiple applications at once, the phone will start downloading the applications when it detects that the user clicks the download controls 220, 230, and 240 in sequence. The interface may display something like... Figure 3 The GUI shown in (c) is shown in the image.
[0117] See Figure 3 In (c), the phone can display the progress of multiple applications currently being downloaded on this interface.
[0118] See Figure 3 (d) When the multiple applications are downloaded and installed, their icons can be displayed on the phone's desktop 220.
[0119] Figure 4 This is a schematic diagram illustrating an application installation process provided in an embodiment of this application. Taking an Android-based electronic device as an example, the electronic device installs the application through a package installer interface. Figure 4 As shown, this step includes steps 101 to 107.
[0120] Step 101: Create a task at the application layer.
[0121] In this process, the application installer creates the task through a package installer session (PIS).
[0122] Step 102: Submit the task to the PMS in the application framework layer, and the PMS will install the application.
[0123] Step 103, PMS application installation.
[0124] When installing an application, PMS copies the application's APK file from the application's download directory to the system directory and scans the APK file. The scanning process parses the APK file to obtain information such as the application's components and configuration files.
[0125] Step 104: PMS calls the system-level installd interface to execute dexopt to optimize the APK file.
[0126] During this process, PMS blocks calls to the installd interface.
[0127] Step 105: installd calls the dex2oat thread.
[0128] When installd executes dexopt, it internally calls the dex2oat thread to perform binary optimization on the APK file to improve application startup speed and component loading performance.
[0129] Step 106: installd sends a message to PMS indicating that the dex2oat thread has finished executing.
[0130] In step 107, if the PMS determines that dexopt has been completed, it will send a message to the application installer indicating that the app installation is complete.
[0131] During the application installation process described above, for a single application installation, the installation process needs to block and wait for the dex2oat optimization process, which generally takes a long time. For example, installing a typical application WeChat (approximately 120MB in size) on an electronic device takes a total of 14 seconds, of which the dex2oat optimization process takes about 7 seconds, accounting for about half of the total application installation time.
[0132] Figure 5 This is a schematic diagram of the timing flow for installing an application within a PMS, provided in an embodiment of this application. For example... Figure 5 As shown, the process may include steps 201 to 206.
[0133] 201, PMS begins installing App1.
[0134] When PMS starts installing App1, it holds an mInstallLock, which is an installation lock protection file that prevents other applications from installing while the current application installation is not complete.
[0135] 202, PMS submits the dexopt1 task.
[0136] Specifically, PMS submits the dexopt1 task to the package dex optimizer to optimize the APK file of App1.
[0137] 203, The package dex optimizer sends the dexopt1 task to installd.
[0138] This process holds the mInstallLock again, which prevents other dexopt tasks from proceeding while the current dexopt task is not completed.
[0139] 204. Installd internally calls the dex2oat thread to execute dex2oat tasks, performing binary optimization on the APK file.
[0140] 205. After the dex2oat task is completed, installd sends a message to PMS that App1 has been installed.
[0141] 206. After receiving the message that App1 has been installed, PMS sends the message to the application installer.
[0142] 207, PMS begins installing App2.
[0143] It should be understood that after the dex2oat job is completed, the mInstallLock will be released sequentially. During this period, the installation application is blocked and waiting, and installation requests from other applications cannot be executed.
[0144] Therefore, during batch application installation, the presence of the mInstallLock causes the installation of multiple applications and the dex2oat task to proceed sequentially, resulting in a slow installation process and a poor user experience. Therefore, a faster application installation method is needed to improve the user experience.
[0145] It should be understood that the process of PMS copying and scanning APK files in the embodiments of this application can be referred to as "upper layer" or "upper layer installation", while the optimization process of dexopt or dex2oat can be referred to as "lower layer" or "lower layer optimization".
[0146] As mentioned earlier, when multiple apps are installed on electronic devices, the upper-level installation process and the lower-level optimization process of multiple apps are carried out sequentially, resulting in a slow installation process and a poor user experience.
[0147] This application provides a method for installing applications. When installing multiple apps on an electronic device, the execution process of the dex2oat task, i.e. the underlying optimization process of the app, is decomposed from the entire installation process, so that the upper-level installation of the app and the underlying optimization of the app can be processed in parallel, thereby speeding up the installation of multiple apps and improving the user experience.
[0148] Figure 6 This is a schematic diagram of the timing flow for another PMS internal application installation provided in an embodiment of this application. For example... Figure 6 As shown, the process may include steps 201a to 206a.
[0149] 201a, PMS begins installing App1.
[0150] In 202a, PMS submits the dex2oat job of App1 to the optimizer.
[0151] Specifically, PMS submits dex2oat jobs to the dex2oat job queue, which is managed by the dex2oat job queue management thread.
[0152] 203a, PMS sends a message to the application installer that App1 has been installed.
[0153] It should be understood that steps 202a and 203a can be performed simultaneously.
[0154] 204a, PMS begins installing App2.
[0155] 204b, the optimizer calls the installd interface.
[0156] Specifically, the dex2oat job queue management thread is used to retrieve dex2oat jobs from the queue.
[0157] 205b, after retrieving the dex2oat job corresponding to App1, the installd interface internally calls the dex2oat thread to execute the dex2oat job.
[0158] It should be understood that steps 204b and 205b are performed in parallel with step 204a, and the execution of steps 204b and 205b will not affect the execution of step 204a.
[0159] 205a, PMS submits the dex2oat job of App2 to the optimizer.
[0160] 206a, PMS sends a message to the application installer that App2 installation is complete.
[0161] 206b After step 205b is completed, the dex2oat job management thread will retrieve the dex2oat job corresponding to App2 from the queue and call the installd interface.
[0162] 207b, The installd interface internally calls the dex2oat thread to execute the dex2oat job corresponding to App2.
[0163] Similarly, steps 207b and 208b will not affect the installation of the next application.
[0164] In this embodiment, the upper-layer application installation process of PMS and the lower-layer optimization process of the application are carried out in parallel. Compared with the existing serial installation process, this technical solution can improve the installation speed when installing applications in batches and improve the user experience.
[0165] Figure 7This is a flowchart illustrating a method for installing an application, as provided in an embodiment of this application. Figure 7 As shown, the method may include steps 301 to 305.
[0166] 301, the user installed the application.
[0167] For example, a user might download and install multiple apps from an app store, or use a clone backup to restore multiple apps.
[0168] 302, Copy APK file.
[0169] The application installer copies the APK file to facilitate subsequent installation.
[0170] 303, Scanning APK files.
[0171] Among them, PMS scanning of APK files is used to parse APK files to obtain information such as application components and configuration files.
[0172] 304, submit dex2oat job.
[0173] Specifically, PMS calls the installd interface to perform dexopt optimization, while installd internally calls the dex2oat thread to perform the dex2oat optimization process to optimize the APK file.
[0174] It should be understood that during the batch installation of applications on electronic devices, each application corresponds to a dex2oat task. Electronic devices can arrange the dex2oat tasks corresponding to the applications into a queue according to the order of application installation. For example, if an electronic device installs App1, App2, and App3 sequentially, their corresponding dex2oat tasks would be dex2oat1, dex2oat2, and dex2oat3, respectively. The dex2oat task queue would then be dex2oat1, dex2oat2, and dex2oat3. During application installation, a background dex2oat task queue management thread retrieves the dex2oat task from the queue sequentially. The installd process internally calls the dex2oat thread to perform a dex2oat optimization process, ensuring that the dex2oat task execution does not hinder the installation process. This process decouples the dex2oat task execution from the overall application installation process, allowing for parallel processing of application installation and dex2oat execution, thus enabling rapid batch application installation.
[0175] Specifically, step 304 may include steps 3041 to 3046.
[0176] 3041, Start the background dex2oat task queue management thread.
[0177] The dex2oat task queue management thread manages the dex2oat task queue and retrieves dex2oat tasks from the queue sequentially.
[0178] 3042, waiting for the dex2oat job queue.
[0179] For example, if an electronic device installs App1, App2, and App3 in sequence, then the dex2oat task is dex2oat1, dex2oat2, and dex2oat3.
[0180] 3043. If a dex2oat job times out while idle, terminate the dex2oat job queue management thread.
[0181] The idle timeout can be understood as the time during which no task is executed in the dex2oat task queue exceeds a preset value. In other words, it can be considered that all dex2oat tasks in the dex2oat task queue have been completed. At this time, the system stops the task queue management thread, which helps to reduce the power consumption of electronic devices.
[0182] 3044, if dex2oat is not idle, then obtain the dex2oat job.
[0183] 3045, execute the dex2oat job.
[0184] installd performs binary optimization on the application's APK file by calling the dex2oat thread to execute dex2oat worker tasks.
[0185] 3046, the dex2oat task has been completed.
[0186] Once the dex2oat thread compiles the dex file into the oat file format, the dex2oat task of the application is completed.
[0187] It should be understood that the above process is the execution process of a dex2oat job task of an application. After the dex2oat job task of this application is completed, the execution process of the dex2oat job task of the next application is the same as steps 3042 to 3046 above, and will not be repeated.
[0188] It should also be understood that the order in which the applications are installed can be the order in which the electronic devices download the applications, or it can be the order according to a preset priority. This application embodiment does not specifically limit this.
[0189] 305, Application installation complete.
[0190] It should be understood that in step 305, once the dex2oat job corresponding to the application has been submitted in step 304, the application installation can be considered complete, and the installation of the next application can proceed. The corresponding dex2oat job will then run in the background. At this time, the PMS will send a broadcast message to the application installer indicating that the application installation is complete.
[0191] For example, if the application currently being installed is App1, and after submitting dex2oat1 corresponding to App1 in step 304, it can be considered that App1 is installed successfully and App2 can be installed. While App2 is being installed, dex2oat1 is executed in the background.
[0192] Based on the above technical solution, when installing applications in batches on electronic devices, the dex2oat tasks corresponding to the applications can be decomposed from the installation process, so that the upper-layer application installation and the lower-layer dex2oat optimization process can be processed in parallel, thereby speeding up the installation of batch applications and improving the user experience.
[0193] Figure 8 This is a timing diagram illustrating the installation of an application according to an embodiment of this application. For example... Figure 8 As shown, in the original technical solution, when installing applications in batches on electronic devices, multiple applications are installed sequentially. For example, before installing App2, the dex2oat task of App1 must be completed; similarly, before installing App3, the dex2oat task of App2 must be completed. This results in slow batch application installation, negatively impacting the user experience.
[0194] In the embodiments of this application, such as Figure 8 As shown, in response to the user-triggered operation of installing an application, the APK1 corresponding to the first application (i.e., the upper-layer installed App1) is copied and scanned. In the first time period t1 after copying and scanning APK1, the APK2 corresponding to the second application (i.e., the upper-layer installed App2) is copied and scanned. In the second time period t2 after copying and scanning the APK1 corresponding to the first application, optimization of the first application is performed, that is, dex2oat1 is executed in time t2. The first time period t1 and the second time period t2 at least partially overlap.
[0195] like Figure 8 As shown, the start time of the first time period t1 and the second time period t2 are the same. At this time, the installation of dex2oat1 and App2 on the upper layer is carried out in parallel, which can improve the installation speed of the application and improve the user experience.
[0196] In another example, the start times of t1 and t2 can also be different. For example, the start time of t2 is earlier than the start time of t1, but the time periods of t1 and t2 overlap at least partially. This can also enable the parallel execution of the upper-level installation of App2 and the lower-level optimization of App1, thereby improving the installation speed of multiple applications.
[0197] In one possible implementation, the first optimization task corresponding to App1, namely the dex2oat task, can be added to the first task queue; the first thread can retrieve the first optimization task from the first task queue; and the first interface can be called to start the second thread to execute the first optimization task.
[0198] For example, the first task queue is the dex2oat task queue, the first thread is the dex2oat task queue management thread, the first interface is the installd interface, and the second thread is the dex2oat thread.
[0199] Based on the application installation method provided in this application embodiment, when installing App1 and App2, the time that can be optimized compared to the original application installation method is the sum of the time spent executing dex2oat1 and executing dex2oat2.
[0200] Figure 9 This is a timing diagram illustrating the installation of an application according to an embodiment of this application. In this embodiment, during batch application installation, the following situation may occur: the execution process of dex2oat1 corresponding to App1 takes a long time, such as... Figure 9 As shown in (a), after App1 is installed, App2 begins installation, and simultaneously, dex2oat1 is executed on App1 at the lower level. After App2 is installed, dex2oat2 is added to the dex2oat task queue. Since dex2oat1 has not yet finished executing, dex2oat2 can only wait in the queue for execution. At this point, App3 begins installation. After App3 is installed, dex2oat3 is added to the dex2oat task queue for execution. Then, App4 begins installation. After App4 is installed, dex2oat4 is added to the dex2oat task queue for execution. Again, dex2oat1 has not yet finished executing. Therefore, the result is a backlog of tasks in the dex2oat task queue that are not actually executed. If the electronic device experiences an abnormal situation (e.g., shutdown or restart), some apps may not have executed their corresponding dex2oat tasks. In this case, when the user activates the application, it will start in normal mode.
[0201] It should be understood that optimizing an app with dex2oat can improve its startup speed and component loading performance. In normal mode, which does not optimize the app, the app may start up slowly.
[0202] To address the aforementioned potential issues, this application provides a method for controlling the number of tasks backlogged in the dex2oat task queue. For example... Figure 9 As shown in (b) above, the method may include the following steps: (1) After the upper layer of App1 is installed, App2 is installed in the first time period t1 after the upper layer of App1 is installed. In the second time period t2 after the upper layer of App1 is installed, App1 is optimized.
[0203] For example, the first time period t1 and the second time period t2 start at the same time, that is, while the upper layer is installing App2, the lower layer starts executing dex2oat1 on App1.
[0204] (2) During the third time period t3 after the installation of App1 is completed, App3 is installed on the upper layer.
[0205] For example, if the upper layer of App2 has finished installing, but dex2oat1 has not yet finished executing, then add dex2oat2 corresponding to App2 to the waiting queue, and at the same time, the upper layer starts installing App3.
[0206] (3) Optimize App2 during the fourth time period t4 after the installation of App1 is completed.
[0207] For example, add dex2oat2 corresponding to App2 to the waiting queue and execute it in the fourth time period t4.
[0208] Specifically, the dex2oat2 task queue management thread (i.e., the first thread) retrieves the dex2oat2 from the queue, PMS calls the installd interface to execute it, and installd internally starts the dex2oat thread (i.e., the third thread) to execute the dex2oat2.
[0209] (4) During the fifth time period t5 after the upper layer of App1 is installed, the upper layer installs App4. When the duration of the second time period t2 is greater than the sum of the durations of the first time period t1 and the third time period t3, the start time of copying and scanning the fourth application package (i.e. the start time of t5) is later than or equal to the start time of optimizing the second application (i.e. the time of t4).
[0210] In this scenario, when the duration of the second time period t2 is greater than the sum of the durations of the first time period t1 and the third time period t3, it means that the underlying optimization task of App1 takes a long time. If left uncontrolled, multiple dex2oat tasks may accumulate in the underlying dex2oat task queue. In this case, PMS does not send a broadcast to the application installer indicating that App3 is installed, but waits for the underlying dex2oat1 to complete. Simultaneously with the completion of the underlying dex2oat1, dex2oat2 begins execution. At this time, dex2oat3 corresponding to App3 is added to the dex2oat waiting queue, so dex2oat3 is waiting to be executed in the dex2oat task queue. Then, PMS sends a message to the application installer indicating that App3 is installed, and the upper layer continues to install App4. At this point, the start time of optimizing App2 is equal to the start time of copying and scanning App4, meaning that the upper layer installing App4 and the lower layer executing dex2oat2 are happening simultaneously.
[0211] It should be understood that the installation process for subsequent applications can refer to the above process, and will not be repeated here.
[0212] It should be understood that the above process is illustrated using the example of one dex2oat task backlog in the dex2oat task queue, but the embodiments of this application are not limited to this. In the embodiments of this application, the number of dex2oat tasks backlog in the dex2oat task queue can also be two, three or more.
[0213] Based on the above technical solution, when installing applications in batches, if the execution process of dex2oat for a certain application takes a long time, this solution can avoid excessive dex2oat tasks accumulating in the dex2oat task queue.
[0214] Figure 10 This is a schematic flowchart of a method for installing an application provided in an embodiment of this application. The method may include steps 401 to 408.
[0215] 401, the user installed the application.
[0216] 402, Copy APK file.
[0217] 403, Scanning APK files.
[0218] It should be understood that steps 401 to 403 above can be referred to as described above, and will not be repeated for the sake of brevity.
[0219] 404, submitted dex2oat job.
[0220] PMS calls the installd interface to perform dexopt optimization, while installd internally calls the dex2oat thread to perform the dex2oat optimization process.
[0221] 405, Parallelize dex2oat worker tasks.
[0222] As mentioned above, the application installation method in this application embodiment allows for parallel processing of the upper-layer App installation and the lower-layer dex2oat task execution, thereby accelerating the application installation speed.
[0223] 406. If the dex2oat worker task waiting queue is not empty, then the blocking waiting queue will be cleared.
[0224] It should be understood that the dex2oat job waiting queue represents a queue of dex2oat jobs waiting to be executed, in addition to the currently executing dex2oat job.
[0225] During the application installation process, when the upper-layer app installation and the lower-layer dex2oat job tasks are processed in parallel, if the current dex2oat job task waiting queue is not empty, it means that the current dex2oat job task has not yet been completed. At this time, PMS will block and wait for the dex2oat job task to be completed before notifying the application installer that the application installation is complete.
[0226] For example, refer to Figure 9 In case (b), when the upper layer installs App3, and PMS submits dex2oat3, dex2oat1 has not yet finished executing. At this time, dex2oat2 is still waiting to be executed in the dex2oat task queue. Therefore, PMS does not send a message that App3 has been installed to the application installer, but instead blocks and waits for dex2oat1 to finish executing. After dex2oat1 finishes executing, dex2oat2 begins to execute, and the waiting queue is empty at this time.
[0227] 407. If the dex2oat job waiting queue is empty, submit the dex2oat job.
[0228] If the dex2oat job queue is empty, it means that there are no dex2oat jobs waiting to be executed in the dex2oat job queue. At this time, you can submit the dex2oat job for the application to the dex2oat job queue, that is, add the dex2oat job corresponding to the application to the dex2oat job waiting queue.
[0229] In one example, in step 406, the dex2oat job waiting queue is not empty. After the PMS blocking waiting queue is cleared, the PMS submits the application's dex2oat job to the job queue. For example, see reference... Figure 9 In (b), after dex2oat1 finishes execution, dex2oat2 begins execution. At this time, the dex2oat waiting queue is empty, so PMS sends a broadcast to the application installer that App3 has been installed. At the same time, dex2oat3 corresponding to App3 is added to the dex2oat waiting queue to wait for execution.
[0230] In another example, App3 is installed on the upper layer, and dex2oat2 is being executed on the lower layer. At this time, there are no dex2oat tasks waiting to be executed in the dex2oat work queue. In this case, dex2oat3 is added to the dex2oat work task queue to wait for execution.
[0231] 408, Application installation complete.
[0232] After submitting the dex2oat job for the currently installed app to the dex2oat job queue, PMS sends a broadcast to the app installer indicating that the app installation is complete.
[0233] It should be understood that at this time, although the PMS sends a broadcast to the application installer that the App installation is complete, the corresponding dex2oat job for the App is still running in the background or waiting to be executed.
[0234] Based on the above technical solution, this solution can avoid excessive backlog of dex2oat tasks in the dex2oat task queue when installing applications in batches.
[0235] During batch application installation, the application's dex2oat task is executed on the local system of the electronic device. Since this dex2oat execution process is computationally intensive, it consumes a significant amount of power, causing the electronic device's temperature to rise rapidly, potentially affecting its stability. Therefore, this application provides a temperature control strategy to mitigate these issues.
[0236] Figure 11 This is a timing flowchart illustrating a method for implementing a temperature control strategy during application installation, as provided in an embodiment of this application. Figure 11As shown, after the upper layer of the electronic device finishes installing App1, the lower layer starts executing dex2oat1. At the same time, the upper layer starts installing App2. When preparing to submit dex2oat2, i.e. at time T1, the temperature of the electronic device is monitored. This temperature can be the overall temperature of the electronic device or the temperature of the central processing unit (CPU) of the electronic device.
[0237] For example, a temperature threshold range can be preset. When the temperature is greater than the first threshold, the temperature of the electronic device is considered abnormal. When the temperature is less than or equal to the first threshold, the temperature of the electronic device is considered normal. For example, the first threshold can be any value between 35 degrees and 40 degrees.
[0238] If an abnormal temperature is detected in the electronic device at time T1, the first execution duration (i.e., the fourth time period) is determined. This first execution duration represents the duration for which the electronic device continuously executes the dex2oat task. This first execution duration can be used to determine if the dex2oat task has been running for an extended period. If the dex2oat task has been running for an extended period, the PMS will not send a broadcast indicating that App2 is installed. Instead, it will trigger a stop to the dex2oat task, i.e., suspend the dex2oat task queue management thread, allowing it to rest for a first preset duration. This means that the scheduling of the dex2oat task is paused for the first preset duration. In other words, after this first preset duration, App3 will be copied and scanned again. It is important to note that the execution of the current dex2oat task is not immediately stopped; rather, the stop is triggered only after App2's dex2oat2 execution is complete. Figure 11 At time T2, since the scanning and dex2oat optimization processes of the App are part of the installation process, we should try to keep them separate to avoid instability issues.
[0239] Optionally, when an abnormal temperature is detected in the electronic device at time T1, the dex2oat task can be stopped. Even if the dex2oat task queue management thread is paused for a first preset duration, the dex2oat task will be stopped only after the dex2oat2 of App2 has finished executing.
[0240] It should be understood that temperature monitoring in the embodiments of this application can be achieved by a temperature sensor or by other sensors with temperature monitoring functions, and the embodiments of this application do not specifically limit this.
[0241] It should be understood that in the embodiments of this application, the execution time of the current dex2oat optimization process can be statistically analyzed to determine whether it has been running for a long time. For example, if the execution time of the current dex2oat optimization process is greater than a preset value, it can be considered that it has been running for a long time. The process of determining whether the current dex2oat optimization process has been running for a long time will be described below in conjunction with specific embodiments, which will not be detailed here.
[0242] At time T2, the dex2oat task queue management thread is stopped, causing it to rest for a period of time until time T3. This rest interval can be a preset duration, such as 5s or 10s or other values.
[0243] At time T3, the dex2oat task has been paused for a period of time. PMS sends a broadcast to the application installer that the installation of App2 has ended and begins installing App3.
[0244] At time T4, the upper layer finishes installing App3, and the lower layer begins executing dex2oat3.
[0245] It can be seen that from the start of the dex2oat task stopping at time T2 to the start of dex2oat3 at time T4, the actual rest time of the dex2oat task is from T2 to T4, which can effectively reduce the overheating problem that occurs in a short period of time during the batch installation of applications on electronic devices.
[0246] It should be understood that the installation of more applications can refer to the above T1 to T4 times, and for the sake of simplicity, it will not be repeated.
[0247] The following is combined Figure 12 This application describes a method for calculating the execution time of dex2oat tasks in its embodiments.
[0248] Figure 12 This is a flowchart illustrating the process of calculating the working time of a dex2oat task, as provided in an embodiment of this application. Figure 12 As shown, the method may include steps 501 to 509.
[0249] Step 501: The user installs the application.
[0250] Step 502: Submit the dex2oat job.
[0251] Step 503: The dex2oat task begins execution, and time T1 is recorded.
[0252] Step 504: The dex2oat task is completed, and the time T2 is recorded.
[0253] Step 505: Record the execution time of dex2oat: dT = T2 - T1.
[0254] Step 506: Calculate the time interval between the current dex2oat task and the previous dex2oat task: AT = T1 - LT2.
[0255] Where AT represents the time interval between the current dex2oat task and the previous dex2oat task, and LT2 represents the time when the previous dex2oat task was completed.
[0256] Step 507: If AT ≤ MIN_INTER, then the working time WT of dex2oat is the sum of the working time of this dex2oat and the working time of the previous dex2oat.
[0257] Where WT represents the working time of dex2oat, and MIN_INTER represents the minimum time interval. It should be understood that the minimum time interval can be a preset value, for example, the minimum time interval can be 20s or 30s or other values.
[0258] If the time interval AT between the current dex2oat task and the previous dex2oat task is less than or equal to the set minimum time interval MIN_INTER for dex2oat, then the dex2oat working time is accumulated.
[0259] For example, such as Figure 11 As shown, during the fifth time period t5 before copying and scanning the first application App1, the underlying optimization dex2oat0 for the fourth application App0 is executed. If at time T1, the interval between the fifth time period t5 during which dex2oat0 is executed and the second time period during which dex2oat1 is executed is less than or equal to the minimum time interval (i.e., the third preset duration), then the working time WT of dex2oat (i.e. the fourth time period) is the sum of the durations of the fifth time period t5 and the second time period t2.
[0260] Step 508: If AT > MIN_INTER, then the working time of dex2oat is WT = dT.
[0261] If the time interval AT between the current dex2oat task and the previous dex2oat task is greater than the set minimum time interval MIN_INTER for dex2oat, then the execution time dT of the current dex2oat task will be used as the working time of dex2oat.
[0262] For example, such as Figure 11At time T1, if the interval between the fifth time period t5 and the second time period t2 is greater than the third preset duration, then the working time WT (fourth time period) of dex2oat is the execution time of dex2oat1, i.e., the first time period t1.
[0263] Step 509, LT2=T2.
[0264] When the next dex2oat job begins, the completion time of the current dex2oat job is used as LT2.
[0265] It should be understood that the above steps can be used to calculate the working time of the next one or more dex2oat jobs, and will not be repeated for the sake of brevity.
[0266] The following is combined Figure 13 This application introduces a method for optimizing and controlling the temperature control strategy according to embodiments of the present application.
[0267] Figure 13 This is a schematic diagram of an optimized control process for a temperature control strategy provided in an embodiment of this application. For example... Figure 13 As shown, the method may include steps 601 to 606.
[0268] Step 601, Install App2.
[0269] It should be understood that before step 601, App1 has already been installed at the upper layer. In this step, the installation of App2 at the upper layer and the execution of the dex2oat task at the lower layer are carried out in parallel.
[0270] Step 602: Submit the dex2oat job.
[0271] Step 603: The system reads the temperature information Temp based on the temperature monitoring results.
[0272] The system can monitor the temperature of electronic devices using temperature sensors. This temperature can be the overall temperature of the electronic device or the temperature of the CPU.
[0273] Step 604: Based on the temperature monitoring results in step 603, if the temperature of the electronic device Temp > MIN_TEMP and the dex2oat working time WT > MAX_WT, then trigger the dex2oat task to pause.
[0274] Here, MIN_TEMP represents the threshold temperature, which is the critical temperature used to determine whether the temperature is abnormal when the electronic device is installed and applied. MAX_WT represents the maximum operating time. The values of MIN_TEMP and MAX_WT can be preset by the system. As mentioned above, MIN_TEMP can be any value between 35 and 40 degrees Celsius, and MAX_WT can be any value between 20 and 30 seconds.
[0275] It should be understood that the WT in the embodiments of this application can be... Figure 10 The method for obtaining the working time of dex2oat tasks in the database.
[0276] In step 604, although the dex2oat job is triggered to stop, in order to avoid stability issues during application installation, the currently executing dex2oat job is not stopped immediately. As mentioned above, the dex2oat job is stopped only after App2's dex2oat2 has finished executing.
[0277] Step 605, dex2oat2 execution complete.
[0278] After dex2oat2 is completed, the dex2oat task will pause for a period of time to avoid instability issues caused by excessively high temperatures in electronic devices.
[0279] Step 606: WT is cleared.
[0280] Specifically, when the dex2oat task is stopped, the dex2oat working time WT is set to zero to facilitate the statistics of the dex2oat working time in the next cycle.
[0281] Based on the above technical methods, when installing applications in batches, the dex2oat task execution process will consume a lot of power. The temperature control strategy optimization method in this application embodiment can avoid the problem of insufficient stability of electronic devices due to excessive temperature.
[0282] Figure 14 This is an exemplary flowchart of a method for installing an application provided in an embodiment of this application. Figure 14 As shown, the method may include steps 710 to 740.
[0283] 710, The electronic device detected that the user triggered an operation to install an application.
[0284] For example, a user may download and install multiple apps at once from an app store, or a user may use an electronic device to clone and restore multiple apps, or clone multiple apps from one device to another.
[0285] 720, in response to this operation, copy and scan the first application package, which is the application package corresponding to the first application.
[0286] In this process, the electronic device responds to the user's operation by copying and scanning the first application package, which means that the first application is installed on the upper layer of the electronic device.
[0287] 730, within the first time period after copying and scanning the first application package, copying and scanning the second application package, which is the application package corresponding to the second application; The first time period can begin immediately after the electronic device scans and copies the first application package, or it can begin after a certain interval following the scanning and copying of the first application package by the electronic device.
[0288] 740, Optimization of the first application is performed during a second time period following the copying and scanning of the first application package; wherein the first time period and the second time period at least partially overlap.
[0289] Optionally, the first time period and the second time period start at the same time, that is, the upper-layer installation of the second application and the lower-layer optimization of the first application are performed simultaneously.
[0290] Optionally, the start times of the first time period and the second time period are different. For example, the start time of the first time period is later than the start time of the second time period. In this case, the installation of the first application and the second application on the upper layer of the electronic device will be spaced out for a period of time, which helps to reduce the overheating phenomenon of the electronic device.
[0291] The above embodiments illustrate the installation of two applications on an electronic device, but this should not limit the scope of this application. It should be understood that the installation process for more applications can refer to the above process.
[0292] The application installation method based on the embodiments of this application performs the upper-layer installation process and the lower-layer optimization process in parallel, which helps to speed up the installation of multiple applications on electronic devices, thereby improving the user experience.
[0293] It is understood that, in order to achieve the above-mentioned functions, electronic devices include hardware and / or software modules that perform the respective functions. Based on the algorithmic steps of the examples described in the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed by hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in conjunction with the embodiments, but such implementation should not be considered beyond the scope of this application.
[0294] This embodiment can divide the electronic device into functional modules according to the above method example. For example, each function can be divided into its own functional modules, or two or more functions can be integrated into one processing module. The integrated modules can be implemented in hardware. It should be noted that the module division in this embodiment is illustrative and only represents one logical functional division. In actual implementation, there may be other division methods.
[0295] This embodiment also provides a computer-readable storage medium storing computer instructions. When the computer instructions are executed on an electronic device, the electronic device performs the aforementioned method steps to implement the application installation method in the above embodiment.
[0296] This embodiment also provides a computer program product that, when run on a computer, causes the computer to perform the aforementioned steps to implement the application installation method described in the above embodiment.
[0297] In addition, embodiments of this application also provide an apparatus, which may specifically be a chip, component, or module. The apparatus may include a connected processor and a memory; wherein the memory is used to store computer execution instructions, and when the apparatus is running, the processor may execute the computer execution instructions stored in the memory to cause the chip to execute the application installation method in the above-described method embodiments.
[0298] In this embodiment, the electronic device, computer-readable storage medium, computer program product or chip are all used to execute the corresponding methods provided above. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects in the corresponding methods provided above, and will not be repeated here.
[0299] Through the above description of the embodiments, those skilled in the art will understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0300] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another apparatus, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0301] The units described as separate components may or may not be physically separate. A component shown as a unit can be one or more physical units; that is, it can be located in one place or distributed in multiple different locations. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0302] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0303] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, in essence, or the parts that contribute to the prior art, or all or part of the technical solutions, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0304] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for installing an application, characterized in that, The method is applied to an electronic device, and the method includes: The user was detected to have triggered the installation of a first application and a second application. In response to the operation, the first application package is copied and scanned, the first application package being the application package corresponding to the first application; During the first time period after copying and scanning the first application package, copying and scanning the second application package, wherein the second application package is the application package corresponding to the second application; During a second time period following the copying and scanning of the first application package, optimization of the first application is performed.
2. The method according to claim 1, characterized in that, The method further includes: The system detected that the user triggered the installation of third-party and fourth-party applications. During a third time period following the copying and scanning of the first application package, a third application package is copied and scanned, wherein the third application package is the application package corresponding to the third application; wherein... When the duration of the second time period is greater than the sum of the durations of the first time period and the third time period, the start time of copying and scanning the fourth application package is later than or equal to the start time of performing optimization on the second application.
3. The method according to claim 1, characterized in that, The method further includes: The user was detected to have initiated the installation of a third-party application. When the copying and scanning of the second application package is complete, the temperature of the central processing unit (CPU) of the electronic device is detected; The temperature is determined to be greater than or equal to a preset value; When the optimization of the second application ends, pause for the first preset duration; After the first preset time period, the third application package is copied and scanned, the third application package being the application package corresponding to the third application.
4. The method according to claim 3, characterized in that, Before optimizing the first application, optimizing the fourth application is performed, wherein determining that the temperature is greater than or equal to a preset value includes: The temperature is determined to be greater than or equal to a preset value and the duration of the fourth time period is greater than or equal to the second preset duration; Wherein, the fourth time period is the same as the second time period; or, When the time interval between the second time period and the fifth time period is less than or equal to the third preset duration, the fourth time period is the sum of the second time period and the fifth time period, and the fifth time period is the time period during which the electronic device performs optimization of the fourth application.
5. The method according to any one of claims 1-4, characterized in that, The optimization of the first application includes: The first optimization task is added to the first task queue, and the first optimization task is used to optimize the first application. Start the first thread, which is used to retrieve the first optimized task from the first task queue; The first interface is invoked, which is used to start the second thread, and the second thread is used to execute the first optimization task.
6. An electronic device, characterized in that, include: One or more processors; One or more memory units; The one or more memories store one or more computer programs, the one or more computer programs including instructions that, when executed by the one or more processors, cause the electronic device to perform the following steps: The user was detected to have triggered the installation of a first application and a second application. In response to the operation, the first application package is copied and scanned, the first application package being the application package corresponding to the first application; During the first time period after copying and scanning the first application package, copying and scanning the second application package, wherein the second application package is the application package corresponding to the second application; During a second time period following the copying and scanning of the first application package, optimization of the first application is performed.
7. The electronic device according to claim 6, characterized in that, When the instruction is executed by the one or more processors, the electronic device performs the following steps: The system detected that the user triggered the installation of third-party and fourth-party applications. During a third time period following the copying and scanning of the first application package, a third application package is copied and scanned, wherein the third application package is the application package corresponding to the third application; wherein... When the duration of the second time period is greater than the sum of the durations of the first time period and the third time period, the start time of copying and scanning the fourth application package is later than or equal to the start time of performing optimization on the second application.
8. The electronic device according to claim 6, characterized in that, When the instruction is executed by the one or more processors, the electronic device performs the following steps: The user was detected to have initiated the installation of a third-party application. When the copying and scanning of the second application package is complete, the temperature of the CPU of the electronic device is detected; The temperature is determined to be greater than or equal to a preset value; When the optimization of the second application ends, pause for the first preset duration; After the first preset time period, the third application package is copied and scanned, the third application package being the application package corresponding to the third application.
9. The electronic device according to claim 8, characterized in that, Before optimizing the first application, the electronic device optimizes the fourth application, specifically for: The temperature is determined to be greater than or equal to a preset value and the duration of the fourth time period is greater than or equal to the second preset duration; Wherein, the fourth time period is the same as the second time period; or, When the time interval between the second time period and the fifth time period is less than or equal to the third preset duration, the fourth time period is the sum of the second time period and the fifth time period, and the fifth time period is the time period during which the electronic device performs optimization of the fourth application.
10. The electronic device according to any one of claims 6-9, characterized in that, The electronic device is specifically used for: The first optimization task is added to the first task queue, and the first optimization task is used to optimize the first application. Start the first thread, which is used to retrieve the first optimized task from the first task queue; The first interface is invoked, which is used to start the second thread, and the second thread is used to execute the first optimization task.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that, when executed on an electronic device, cause the electronic device to perform the method of installing an application as described in any one of claims 1 to 5.
12. A computer program product, characterized in that, When the computer program product is run on a computer, the computer performs the method of installing the application as described in any one of claims 1 to 5.