Method of refreshing a user interface and electronic device
By caching user interface change requests from background applications and updating them when switching to the foreground application, the conflict problem of multiple applications concurrently accessing shared resources in IoT devices is resolved, improving the stability and efficiency of interface updates.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HUAWEI TECH CO LTD
- Filing Date
- 2021-07-09
- Publication Date
- 2026-04-24
AI Technical Summary
In IoT devices with screens, conflicts may occur when multiple applications run concurrently, especially when accessing shared resources at the same time, because the central processing unit does not support memory mapping of the memory management unit.
Cache user interface change requests from background applications and apply them to the user interface when the application switches to the foreground to avoid conflicts caused by concurrent access.
It effectively avoids conflicts caused by concurrent access from multiple applications, and improves the stability and efficiency of user interface updates.
Smart Images

Figure CN115599475B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of electronic technology, and more specifically, to a method and electronic device for refreshing a user interface. Background Technology
[0002] In some Internet of Things (IoT) devices with screens, due to design limitations of the central processing unit (CPU), the chip does not support memory mapping of the memory management unit (MMU), and only one process can run globally. If multiple applications are to be run simultaneously, they are usually run concurrently through multithreading or multitasking. In this case, the threads of these multiple applications may access the same shared resource at the same time, which will cause conflicts. Summary of the Invention
[0003] This application provides a method and electronic device for refreshing a user interface. This technical solution can cache user interface change requests from background applications and apply the user interface changes to the user interface when the background application becomes visible, thereby avoiding conflicts caused by concurrent access from multiple applications.
[0004] In a first aspect, a method for refreshing a user interface is provided. The method is applied to an electronic device and includes: the electronic device detecting a first user interface (UI) change request of a first application running in the background of the electronic device; the electronic device caching the first UI change request; and when the electronic device detects that the first application has switched to the foreground, updating the UI change corresponding to the first UI change request to the UI of the first application.
[0005] Based on the embodiments of this application, when the UI of a first application running in the background changes, the electronic device can detect the UI change request and cache it. When the first application switches to the foreground, the UI change is applied to the UI of the first application. This technical solution can avoid the conflict problem caused by concurrent access of multiple applications when the electronic device is running multiple applications at the same time.
[0006] In conjunction with the first aspect, in some implementations of the first aspect, the first UI change request is generated based on the first information of the first UI change, and the electronic device caches the first UI change request, including: the electronic device adds the first UI change request to the cached data structure.
[0007] The first piece of information may be the changed UI component, the properties of the UI component, and the values of the changed properties, etc. The properties of the UI component may include, but are not limited to, the component's length, width, color, and other characteristics or styles.
[0008] In this embodiment of the application, the data structure of the cache may include linked lists, queues, arrays, etc., and this embodiment of the application does not limit it.
[0009] Based on the embodiments of this application, UI change requests are cached in a cached data structure, so that UI changes in the background application are not executed immediately.
[0010] In conjunction with the first aspect, in some implementations of the first aspect, the method further includes: the electronic device detecting a second UI change request of the first application, wherein the second UI change request is generated based on second information of the second UI change; when the first UI component corresponding to the first UI change request is different from the second UI component corresponding to the second UI change request, or when the first UI component is the same as the second UI component but the attributes of the first UI component are different from the attributes of the second UI component, the electronic device adds the second UI change request to the cached data structure; when the electronic device detects that the first application has switched to the foreground, it updates the UI change corresponding to the second UI change request to the UI of the first application.
[0011] The second information may include the modified second UI component, the component's properties, and the values of the changed properties, etc. The properties of the UI component may include, but are not limited to, the component's length, width, color, and other characteristics or styles.
[0012] In this embodiment of the application, the UI component may include a native view UI component that can be drawn directly, or it may include a document object model (DOM) component structure in global wide area network (web) development, etc. This embodiment of the application does not limit it in this way.
[0013] Based on the embodiments of this application, when the UI component corresponding to the second UI change request is different from the UI component corresponding to the first UI change request, or when the component attributes are different, the first UI component can be added to a cached data structure. When the application switches from the background to the foreground, the second UI change is updated to the application's UI. This technical solution can cache different UI change requests in a data structure when multiple UI changes occur in the application, so that when the application switches to the foreground, the multiple UI changes are executed sequentially.
[0014] In conjunction with the first aspect, in some implementations of the first aspect, the method further includes: the electronic device detecting a third UI change request of the first application, wherein the third UI change request is generated based on third information of the third UI change; when the third UI component corresponding to the third UI change request is the same as the first UI component corresponding to the first UI change request and the attribute of the third UI component is the same as the attribute of the first UI component, the electronic device updates the value of the attribute of the first UI component in the cached data structure according to the value of the attribute of the third UI component.
[0015] This third piece of information may include the modified third UI component, the component's properties, and the values of the changed properties. The UI component's properties may include characteristics such as the component's length, width, color, or style.
[0016] For example, the attribute of the first UI component corresponding to the first UI change request is color, and the value of the attribute is a specific color, such as red. The third UI component corresponding to the third UI change request is the same as the first UI component, and the attribute of the third UI component is also color, such as yellow. Then the electronic device can update the value of the attribute of the first UI component corresponding to the first UI change request with the value of the attribute of the third UI component (yellow). That is, at this time, the value of the attribute of the cached first UI component is updated to yellow, so that the third UI change request does not need to be cached.
[0017] Based on the embodiments of this application, when the UI component corresponding to the third UI change request is the same as the UI component corresponding to the first UI change request and the components have the same attributes, the attribute value of the UI component corresponding to the third UI change request is updated with the attribute value of the UI component corresponding to the first UI change request. This avoids adding the third UI change request to the cached data structure, preventing the addition of new cache nodes and thus reducing the memory consumption of the electronic device.
[0018] In other embodiments, the electronic device may also cache the third UI change request.
[0019] In conjunction with the first aspect, in some implementations of the first aspect, updating the UI change corresponding to the first UI change request to the UI of the first application includes: the electronic device calling a system interface to update the UI change corresponding to the first UI change request to the UI component of the first application.
[0020] In conjunction with the first aspect, in some implementations of the first aspect, before the electronic device caches the first UI change request, the method further includes: the electronic device determining that the first UI change request needs to be cached.
[0021] Based on the embodiments of this application, before the electronic device caches the first UI change request, it can be determined in advance whether the first UI change request needs to be cached, thereby avoiding caching all UI change requests and saving the power consumption of the electronic device.
[0022] In other embodiments, the electronic device can determine whether the first UI change request needs to be cached. For some UI change requests, caching may not be required, and the UI can be directly updated to the application's UI.
[0023] In conjunction with the first aspect, in some implementations of the first aspect, the method further includes: when the electronic device determines that it does not need to cache the first UI change request, directly updating the UI change corresponding to the first UI change request to the UI of the first application.
[0024] In conjunction with the first aspect, in some implementations of the first aspect, the electronic device caching the first UI change request includes: the electronic device sending the first UI change request to a UI service thread; and the UI service thread caching the first UI change request.
[0025] In this embodiment of the application, the UI service thread can be used to manage UI changes for all applications. When there are multiple UI change requests, the UI service thread can cache the multiple UI changes in chronological order and execute them sequentially.
[0026] In other embodiments, the UI service thread can directly update the UI changes corresponding to the UI change request to the application's UI, which is not limited in this application embodiment.
[0027] In conjunction with the first aspect, in some implementations of the first aspect, updating the first UI change to the UI of the first application includes: the UI service thread updating the UI component corresponding to the first UI change request to the UI component of the first application.
[0028] Secondly, a method for refreshing a user interface is provided, the method being applied to an electronic device, the method comprising: the electronic device displaying a first interface, the first interface being a first user interface (UI) of a first application; the electronic device, in response to a first operation by a user, displaying the first interface and a second interface located above the first interface, wherein the second interface is a second UI of the second application; the electronic device, upon detecting a request to change the first UI of the first application, continuing to display the first interface and the second interface; and the electronic device, in response to a second operation by a user, displaying a third interface, wherein the third interface is the interface of the first application after the first UI has been changed.
[0029] Based on the embodiments of this application, when a first application running in the foreground of an electronic device is switched to the background, its first interface remains visible to the user. When the electronic device detects a UI change request from the first application, it can avoid immediately updating the UI of the first application. Instead, it can update the UI of the first application when the first application switches back to the foreground. This technical solution can avoid the conflict problem caused by concurrent access of multiple applications when the electronic device is running multiple applications simultaneously.
[0030] In conjunction with the second aspect, in some implementations of the second aspect, the second interface is semi-transparent; or, the second interface is not displayed in full screen.
[0031] Thirdly, 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 a method for refreshing a user interface as described in the first aspect and any possible implementation thereof to be performed.
[0032] In conjunction with the third aspect, in some implementations of the third aspect, the electronic device is an electronic device with a display screen that does not support memory management unit isolation.
[0033] In this embodiment of the application, memory management unit isolation refers to the ability of the memory management unit to divide and protect the actual physical memory, so that each software task can only access the memory space allocated to it.
[0034] For example, the electronic device can be a smartwatch, augmented reality (AR) glasses, a wristband, or other wearable devices, or other electronic devices with a display screen.
[0035] Fourthly, 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 a method for refreshing a user interface as described in the second aspect and any possible implementation thereof to be performed.
[0036] Fifthly, a chip is provided, characterized in that the chip includes a processor and a communication interface, the communication interface being used to receive a signal and transmit the signal to the processor, the processor processing the signal such that a method for refreshing a user interface as described in the first aspect and any possible implementation thereof is executed.
[0037] A sixth aspect provides a chip, characterized in that the chip includes a processor and a communication interface, the communication interface being used to receive a signal and transmit the signal to the processor, the processor processing the signal such that a method for refreshing a user interface as described in the second aspect and any possible implementation thereof is executed.
[0038] In a seventh aspect, a computer-readable storage medium is provided, wherein computer instructions are stored therein, which, when executed on a computer, cause a method for refreshing a user interface as described in the first aspect and any possible implementation thereof to be performed.
[0039] Eighthly, a computer-readable storage medium is provided, wherein computer instructions are stored therein, which, when executed on a computer, cause a method for refreshing a user interface as described in the second aspect and any possible implementation thereof to be performed.
[0040] A ninth aspect provides a computer program product including computer instructions that, when executed on an electronic device, cause a method for refreshing a user interface as described in the first aspect and any possible implementation thereof to be performed.
[0041] In a tenth aspect, a computer program product is provided, including computer instructions that, when executed on an electronic device, cause a method for refreshing a user interface as described in the second aspect and any possible implementation thereof to be performed. Attached Figure Description
[0042] Figure 1 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application.
[0043] Figure 2 This is a schematic diagram of the software structure of the electronic device provided in the embodiments of this application.
[0044] Figure 3 This is a schematic diagram of an electronic device launching multiple applications, provided in an embodiment of this application.
[0045] Figure 4 This is a schematic diagram of another electronic device that launches multiple applications, as provided in an embodiment of this application.
[0046] Figure 5 yes Figure 4 A schematic flowchart illustrating how an electronic device launches multiple applications.
[0047] Figure 6 This is a schematic diagram illustrating how a front-end application and a back-end application can jointly access shared resources, as provided in an embodiment of this application.
[0048] Figure 7 This is a schematic diagram illustrating the installation of a third-party application into an electronic device, as provided in an embodiment of this application.
[0049] Figure 8 This is a schematic diagram of a set of GUIs provided in the embodiments of this application.
[0050] Figure 9 This is a schematic framework diagram of a method for refreshing a user interface provided in an embodiment of this application.
[0051] Figure 10 This is a schematic flowchart illustrating a method for refreshing an interface provided in an embodiment of this application.
[0052] Figure 11 This is a schematic flowchart illustrating another method for refreshing an interface provided in an embodiment of this application.
[0053] Figure 12 This is a schematic flowchart illustrating a method for refreshing an interface provided in an embodiment of this application.
[0054] Figure 13 This is a schematic flowchart illustrating another method for refreshing an interface provided in an embodiment of this application. Detailed Implementation
[0055] The technical solutions in this application will now be described with reference to the accompanying drawings.
[0056] The electronic device in this application embodiment may refer to wearable devices, such as wristbands, sports watches, etc. The electronic device may also refer to other devices with a display screen, etc. The electronic device may also be a user device, remote terminal, mobile device, user terminal, terminal, handheld device with wireless communication function, terminal device in future 5G network, or terminal device in future evolved public land mobile network (PLMN), etc. This application embodiment does not limit this.
[0057] 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.
[0058] 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.
[0059] 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.
[0060] 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.
[0061] 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.
[0062] 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.
[0063] The I2C interface is a bidirectional synchronous serial bus that includes a serial data line (SDA) and a serial clock line (SCL).
[0064] 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 realize communication between the processor 110 and the audio module 170.
[0065] 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.
[0066] 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.
[0067] The MIPI interface can be used to connect the processor 110 to peripheral devices such as the display 194 and the camera 193.
[0068] The GPIO interface can be configured 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.
[0069] USB interface 130 is an interface that conforms to the USB standard specification, specifically it can be a Mini USB interface, Micro USB interface, USB Type C interface, etc. USB interface 130 can be used to connect a charger to charge electronic device 100, and it can also be used for data transfer between electronic device 100 and peripheral devices.
[0070] 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.
[0071] 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.
[0072] The power management module 141 is used to connect the battery 142, the charging management module 140, and the processor 110.
[0073] 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.
[0074] The mobile communication module 150 can provide wireless communication solutions, including 2G / 3G / 4G / 5G, for use on electronic devices 100.
[0075] 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.
[0076] The wireless communication module 160 can provide solutions for wireless communication applications on the electronic device 100, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR) technology, etc.
[0077] 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, so that electronic device 100 can communicate with networks and other devices through wireless communication technology.
[0078] 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.
[0079] Display screen 194 is used to display images, videos, etc. Display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), or a display panel made of materials selected from organic light-emitting diodes (OLEDs), active-matrix organic light-emitting diodes (AMOLEDs), flexible light-emitting diodes (FLEDs), Miniled, MicroLEDs, Micro-OLEDs, or quantum dot light-emitting diodes (QLEDs). In some embodiments, electronic device 100 may include one or N displays 194, where N is a positive integer greater than 1.
[0080] Electronic device 100 can perform shooting functions through ISP, camera 193, video codec, GPU, display 194 and application processor.
[0081] The ISP is used to process the data fed back by camera 193. Camera 193 is used to capture still images or videos.
[0082] A digital signal processor is used to process digital signals. In addition to processing digital image signals, it can also process other digital signals.
[0083] Video codecs are used to compress or decompress digital video. Electronic device 100 may support one or more video codecs.
[0084] The external storage interface 120 can be used to connect an external storage card, such as a Micro SD card, to expand the storage capacity of the electronic device 100.
[0085] 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.
[0086] 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.
[0087] The audio module 170 is used to convert digital audio information into analog audio signal output, and also to convert analog audio input into digital audio signal.
[0088] The loudspeaker 170A, also known as a "loudspeaker", is used to convert audio electrical signals into sound signals.
[0089] The receiver 170B, also known as the "earpiece", is used to convert audio electrical signals into sound signals.
[0090] The microphone 170C, also known as a "microphone" or "voice transducer," is used to convert sound signals into electrical signals.
[0091] The 170D headphone jack is used to connect wired headphones.
[0092] The pressure sensor 180A is used to sense pressure signals and can convert the pressure signals into electrical signals. In some embodiments, the pressure sensor 180A may be disposed on the display screen 194.
[0093] The gyroscope sensor 180B can be used to determine the motion attitude of the electronic device 100.
[0094] The barometric pressure sensor 180C is used to measure air pressure. In some embodiments, the electronic device 100 calculates altitude using the air pressure value measured by the barometric pressure sensor 180C to assist in positioning and navigation.
[0095] The accelerometer 180E can detect the magnitude of acceleration of electronic device 100 in various directions (generally three axes).
[0096] Distance sensor 180F is used to measure distance.
[0097] The fingerprint sensor 180H is used to collect fingerprints.
[0098] 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".
[0099] The bone conduction sensor 180M can acquire vibration signals. In some embodiments, the bone conduction sensor 180M can acquire vibration signals from vibrating bone fragments in the human vocal cords. The bone conduction sensor 180M can also contact the human pulse to receive blood pressure signals.
[0100] Button 190 includes the power button, volume buttons, etc.
[0101] Motor 191 can generate vibration alerts.
[0102] Indicator 192 can be an indicator light, used to indicate charging status, power changes, or to indicate messages, missed calls, notifications, etc.
[0103] The SIM card interface 195 is used to connect the SIM card.
[0104] 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.
[0105] 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.
[0106] 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.
[0107] 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.
[0108] like Figure 2 As shown, the application framework layer may include a window manager, content provider, view system, phone manager, resource manager, notification manager, etc.
[0109] 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.
[0110] 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.
[0111] 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.
[0112] The phone manager is used to provide communication functions for electronic device 100. For example, it manages call status (including connection and disconnection).
[0113] The file explorer provides applications with various resources, such as localized strings, icons, images, layout files, video files, and more.
[0114] 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.
[0115] The Android runtime consists of core libraries and a virtual machine. The Android runtime is responsible for scheduling and managing the Android system.
[0116] 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.
[0117] 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.
[0118] System libraries can include multiple functional modules. For example: surface manager, media libraries, 3D graphics processing libraries (e.g., OpenGL ES), 2D graphics engines (e.g., SGL), etc.
[0119] The Surface Manager is used to manage the display subsystem and provides the blending of 2D and 3D layers for multiple applications.
[0120] The media library supports playback and recording of various common audio and video formats, as well as still image files. It supports multiple audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG.
[0121] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0122] A 2D graphics engine is a graphics engine for 2D drawing.
[0123] The kernel layer is the layer between hardware and software. The kernel layer contains at least the display driver, camera driver, audio driver, and sensor driver.
[0124] Before introducing the technical solution of this application, let me first briefly introduce some technical terms that may be involved in the solution of this application.
[0125] A process is a running activity of a program on a certain set of data in a computer. It is the basic unit for system resource allocation and scheduling and is the foundation of the operating system structure.
[0126] A thread is the smallest unit of computation that an operating system can schedule. It is contained within a process and is the actual unit of operation within that process. A thread refers to a single, sequential flow of control within a process. Multiple threads can run concurrently within a process, each executing different tasks in parallel. Multiple threads within the same process will share all system resources of that process, such as virtual address space, file descriptors, and signal handling.
[0127] MMU isolation: The memory management unit can segment and protect the actual physical memory, so that each software task can only access the memory space allocated to it.
[0128] User interface (UI): This is the medium through which a system and a user interact and exchange information. It converts information from its internal form to a form that humans can understand. Currently, the most commonly used is the graphical user interface (GUI), which provides a direct and visual display and is easy to operate. It is also called the human-computer interface, or simply the interface.
[0129] Figure 3 This is a schematic diagram of an electronic device launching multiple applications, provided in an embodiment of this application.
[0130] See Figure 3 The chip of electronic device 1 supports MMU isolation, which means that every time the system starts an application (App), it will create an independent process for the App to run the App. As the smallest resource scheduling resource, the process can be isolated from other processes.
[0131] like Figure 3 As shown, when electronic device 1 launches App 1, a process 1 is created for App 1. This process 1 may include a UI thread 1, which is used to uniformly handle UI updates from App 1. This UI thread 1 can access the resources 1 allocated by the system for this process 1.
[0132] When the electronic device 1 launches App 2, it can create process 2 for App 2. Process 2 can include UI thread 2, which is used to uniformly handle UI updates by App 2. UI thread 2 can access resources 2 allocated by the system for process 2.
[0133] Resource 1 and Resource 2 are isolated from each other. Therefore, even if App1 and App2 run concurrently, they will access different resources.
[0134] However, not all electronic devices support MMU isolation. For example, some lightweight IoT devices do not have chips that support MMU isolation.
[0135] Figure 4 This is a schematic diagram of another electronic device that launches multiple applications, as provided in an embodiment of this application.
[0136] See Figure 4 The electronic device 2 does not support MMU isolation, meaning that the electronic device can only run one process globally, and each application is executed by a separate UI thread. In other words, when the system runs multiple applications at the same time, the UI threads corresponding to these multiple applications will share the resources allocated by the system to process 1.
[0137] like Figure 4 As shown, when the electronic device launches App1, it creates process1. Process1 may include UI thread1 of App1. UI thread1 is used to handle UI updates of App1. UI thread1 can access resources1 allocated by the system to process1.
[0138] When the electronic device launches App2, it continues to create UI thread 2 for App2 in process 1. UI thread 2 is used to handle UI updates by App2. UI thread 2 can also access resource 1.
[0139] Therefore, when App1 and App2 run concurrently, they may both call the same resource. For example, if UI thread 1 and UI thread 2 both call the same system function, an access conflict will occur, which will cause functional abnormalities.
[0140] The following is combined Figures 5-6 This section details the access conflict issue.
[0141] Figure 5 yes Figure 4 A schematic flowchart illustrating how an electronic device launches multiple applications. This scheme may include steps 101 to 113.
[0142] 101, System startup.
[0143] For example, a user presses and holds the power button on an electronic device to turn it on.
[0144] 102. Start the management module and create a system graphics display thread.
[0145] This thread is responsible for handling the system's graphical displays, such as boot animations and desktop displays.
[0146] 103. The graphics drawing module creates the system's graphics root node.
[0147] The system graph root node is the root container responsible for attaching the graph component trees of all applications. Each application's component tree can be a sub-component tree of this graph root node.
[0148] 104. The image rendering module renders the system graphics.
[0149] In this step, the rendering of system graphics by the image drawing module can be understood as the image drawing module traversing all sub-component trees starting from the system root node, drawing the components in the sub-component tree in sequence, and outputting them to a unified graphics buffer.
[0150] 105. Send the rendered system graphics to the screen for display.
[0151] In this step, the system interface can be called to send the rendered system graphics (i.e., the components in the graphics buffer) to the screen driver for output and display. At this time, the system desktop can be displayed on the screen of the electronic device.
[0152] It should be understood that steps 101 to 105 are optional steps. In some embodiments, the technical solution can be executed from an electronic device that is already in a power-on state, that is, it can be executed from step 106.
[0153] 106. Launch App1.
[0154] For example, a user can launch App1 by clicking its application icon on the desktop of their electronic device.
[0155] 107. Start the management module to create the main thread of App1.
[0156] 108. The startup management module sends the information of App1 to the application operation management module.
[0157] The information for App1 may include the App1's package name, user identification (UID), and other information.
[0158] 109. The application runtime management module loads and runs the code of App1.
[0159] 110. The application operation management module creates component tree 1 for App1.
[0160] 111. The application operation management module sets UI properties on component tree 1.
[0161] For example, you can set UI properties such as the length, width, color, and transparency of the display component.
[0162] 112. The application operation management module attaches the root node of the component tree to the system root node.
[0163] The application operation management module attaches the root node of component tree 1, which has UI attributes set, to the system root node so that the graphics drawing module can draw the UI of App1.
[0164] 113, UI has changed.
[0165] It should be understood that steps 106 to 113 above illustrate the process of launching App1. The launching of App2 can be referred to the above steps, and for the sake of brevity, it will not be repeated.
[0166] As can be seen from the above steps, each app has its own thread and component tree, and UI changes are all performed on its own main thread. Since a thread is the smallest unit of CPU execution scheduling, concurrent execution of the same function may occur during the execution of program code statements, which may lead to access conflicts and cause functional abnormalities.
[0167] For example, the caller will use the SetText(int fontsize, const char* text) interface in the UI function library to pass in the font size and text string to be set. Suppose that the SetText interface uses a global variable g_fontsize to record the size of the text to be displayed.
[0168] If UI thread 1 of App1 and UI thread 2 of App2 both call the SetText interface at the same time, an access conflict may occur, causing text distortion and other phenomena.
[0169] See Figure 6 , Figure 6 This is a schematic diagram illustrating how a front-end application and a back-end application can jointly access shared resources, as provided in an embodiment of this application.
[0170] App1 is the foreground application, while App2 and App3 are background applications. That is, the interface currently displayed on the electronic device is the display interface of App1. App2 and App3 run concurrently with App1, but their display interfaces are not visible to the user.
[0171] Among them, the component tree of App1 is component tree 1, the component tree of App2 is component tree 2, and the component tree of App3 is component tree 3.
[0172] For example, if node 1 of App1 calls SetText("AA", fontsize: 30) and node 2 of App2 calls SetText("AA", fontsize: 38), it can be seen that if both applications access the font library public resources at the same time, it may cause the text to be distorted.
[0173] In view of this, this application provides a method for refreshing the interface. This technical solution can cache UI change requests corresponding to UI changes that occur in background applications. When the background application is visible, the UI change is applied to the user interface, thereby avoiding conflicts caused by concurrent access from multiple applications.
[0174] Figure 7 This is a schematic diagram illustrating the installation of a third-party application into an electronic device, as provided in an embodiment of this application.
[0175] See Figure 7 Electronic device 200a can be a mobile phone, and electronic device 200b can be a wearable device, such as a sports watch. The sports watch can connect to the mobile phone via Bluetooth, wireless, or wired connections.
[0176] With the help of a mobile phone, sports watches can install third-party applications. For example, the mobile phone can download the installation package of a third-party application from an app store in the cloud and install it on the sports watch.
[0177] like Figure 7 As shown, the third-party application can be "Weather", "Music", App2, etc. When the application is installed on the sports watch, the user can display the application icons and application names of the installed applications on the display interface of the sports watch.
[0178] When a user taps the "Music" icon or text, the fitness watch can display the "Music" interface, making "Music" the foreground application. At this time, the fitness watch can still receive commands from the phone to launch other applications. For example, if the user launches App2 on their phone, the fitness watch will switch "Music" from the foreground to the background and display App2's interface in the foreground. Both "Music" and App2 are running. The foreground App2 can directly respond to user touch events and change its UI, while the background application "Music" may still trigger UI changes due to its own processing logic.
[0179] Figure 8This is a schematic diagram of a set of graphical user interfaces (GUIs) provided in the embodiments of this application. Among them, from Figure 8 (a) through (h) show the user's operation of the sports watch on the phone and the sports watch.
[0180] See Figure 8 In (a), the GUI is the display interface 310 of the sports watch 300b. This display interface 310 can include multiple applications installed on the sports watch, such as "Weather," "Music," and "App2." When the sports watch detects that the user clicks on the App2 application icon 311, the application name, or the area containing the application name, it can display... Figure 8 The GUI shown in (b) is shown in the image.
[0181] It should be understood that when a user swipes their finger up or down on the screen of the sports watch, other apps installed on the sports watch can be displayed in a scrolling manner.
[0182] See Figure 8 In (b), the GUI is the display interface 320 of App2. The display interface 320 may include images 321 and other graphics.
[0183] See Figure 8 In (c), the GUI is the display desktop 350 of the mobile phone 300a, which can include multiple applications installed on the mobile phone. When the mobile phone detects that the user clicks the Health & Fitness application icon 351, it can display as follows: Figure 8 The GUI shown in (d) is shown in the image.
[0184] See Figure 8 In section (d), this GUI is the primary display interface 360 for sports and health. This display interface 360 can include multiple function cards and multiple function controls, each function control corresponding to a display interface. When the phone detects that the user has clicked on function control 361, it can display something like... Figure 8 The GUI shown in (e) is shown in the image.
[0185] See Figure 8In section (e), the GUI refers to the display interface 370 corresponding to function control 361. This display interface 370 may include function cards 371, which may include the name of the currently connected sports watch, HUAWEIWATCH GT2 PRO, and its icon. The display interface 370 may also include other smart devices that have been connected to the phone, such as Huawei body fat scales and Huawei speakers. When the phone detects that the user has clicked on function card 371, it can display... Figure 8 The GUI shown in (f) is shown in the image.
[0186] See Figure 8 In section (f), the GUI refers to the display interface 380 corresponding to function card 371. This display interface 380 may include a status card 382 for the HUAWEI WATCH GT2 PRO, which may display the watch's connection status, battery level, etc. The display interface 380 may also include a watch face market where users can download and install watch faces. Furthermore, the display interface 380 may include applications such as "Weather," "Health Monitoring," "Heart Health Research Experience," and "App1." When the user clicks on the "App1" card 381, the watch can display... Figure 8 The GUI shown in (g) is shown in the image.
[0187] See Figure 8 In (g), the GUI is the display interface 330 of App1. The display interface 330 can be semi-transparent, that is, the display interface of App1 is displayed on the upper layer of the display interface 330, but the user can still see the display interface 320 of App2 in the background through the display interface.
[0188] When the sports watch detects a user swiping up or down on the screen (330), it can display a person's face. Figure 8 The GUI shown in (h) is shown in the image.
[0189] In some examples, the display interface 330 may not be semi-transparent; that is, only the display interface of App1 is displayed in the display interface 330, and the display interface of App2 running in the background is not visible to the user.
[0190] In other examples, the display interface 330 may also be in a non-full-screen state. For example, the display interface 330 may be displayed in half-screen mode, and the other half-screen may be used to display the display interface of the background application App2, etc.
[0191] See Figure 8In (h), the GUI is the display interface 340 of App2, and the color of the graphic 341 in the display interface 340 is the same as... Figure 8 The image 321 in (b) has changed compared to the previous one.
[0192] It should be understood that when App2 is running in the background, if a UI change occurs, the UI change will not be executed immediately. Instead, the UI change will only be displayed in the screen after App2 is switched to the foreground.
[0193] This technical solution can avoid access conflicts caused when foreground and background applications run concurrently and access the same resource.
[0194] Figure 9 This is a schematic framework diagram of a method for refreshing a user interface provided in an embodiment of this application. The components in the component tree in this embodiment can also be referred to as nodes.
[0195] See Figure 9 App1 is the foreground application on the electronic device, meaning it is the application currently displayed on the screen, and its UI is visible to the user. When component 1 in App1's component tree 1 changes, the change can be directly applied to component 1, meaning the UI change can be directly displayed on the electronic device's screen.
[0196] App2 is a background application on the electronic device, meaning that although App2 is running, its UI is not visible to the user. When component 2 in component tree 2 of App2 changes, the change is not applied directly to component 2. Instead, the UI change is cached. When App2 is brought to the foreground, before the electronic device renders the first frame of App2, the UI change is applied to component 2. In other words, when the electronic device displays the UI of App2, that UI is an interface that includes the aforementioned UI changes.
[0197] It should be understood that when multiple UI components in component tree 2 of App2 change, these multiple UI changes can be cached in sequence. When App2 is switched to the foreground display, before the electronic device draws the first frame of App2, these multiple UI changes are applied to the corresponding components in the component tree in sequence. That is, when the electronic device displays the UI of App2, the UI is an interface that includes the above multiple UI changes.
[0198] In this embodiment, the electronic device can generate a UI change request based on the details of the UI changes in the background application, and add the UI change request to a cached data structure, which can be an array, queue, linked list, etc. For example, if the data structure is a queue, the electronic device can add the UI change request to the cached queue. Alternatively, when there are multiple UI change requests, they can be added to the cached queue sequentially according to their chronological order.
[0199] It should be understood that UI change requests in this cache queue can be executed sequentially according to the first-in, first-out principle.
[0200] The details of the change may include, but are not limited to, the UI component corresponding to the UI change, the properties of the UI component, and the values of the properties after the change. The properties of the UI component may include, but are not limited to, the component's length, width, color, and other characteristics or styles.
[0201] In some embodiments, multiple UI changes are triggered sequentially in the background. The electronic device generates a UI change request for each of these UI changes. When the UI component attributes corresponding to the multiple UI change requests are the same, the UI change request corresponding to the later detected UI change can be cached, and the cached previous UI change request with the same attribute as the corresponding UI component can be deleted. For example, if the attribute of UI component 1 corresponding to UI change request 1 is color, such as red, and the attribute of UI component 1 corresponding to UI change request 2 is also color, such as yellow, and UI change request 1 comes first and UI change request 2 comes later, then the electronic device first caches UI change request 1. After UI change request 2 is generated, the cached UI change request 1 is deleted, and UI change request 2 is cached. This avoids adding extra cache nodes, reduces memory overhead, and eliminates unnecessary UI refresh overhead.
[0202] In other embodiments, multiple UI changes are triggered sequentially in the background. The electronic device generates a UI change request for each of these multiple UI changes. When the UI component corresponding to the multiple UI change requests has the same attribute, the attribute value of the UI component corresponding to the later UI change request can be used to update the cached attribute value of the UI component corresponding to the UI change request, thus eliminating the need to add new cache nodes. For example, if the cache queue caches UI change request 1, and the attribute of the corresponding UI component 1 is color, such as red, and then the cache queue receives UI change request 2, whose corresponding UI component 1 also has the same color attribute, such as yellow, then it is only necessary to change the color of the UI component 1 corresponding to the cached UI change request 1 to yellow, without caching UI change request 2. This avoids adding extra cache nodes, reduces memory overhead, and eliminates unnecessary UI refresh overhead.
[0203] Figure 10 This is a schematic flowchart illustrating a method for refreshing a user interface provided in an embodiment of this application. Figure 10 As shown, this method can be applied to electronic devices, and the method may include steps 501 to 514.
[0204] 501, a background application triggered a UI change.
[0205] It should be understood that this application runs in the background and can run concurrently with foreground applications. For example, when the application is in the background and receives distributed messages from the system, it can trigger UI changes.
[0206] In some embodiments, the distributed message may be communication information pushed by the mobile phone to the background application of the watch. For example, if a cycling navigation application is running on the watch, the application will continuously receive navigation direction prompts sent by the corresponding cycling navigation application on the mobile phone and display them on the watch's screen. When the cycling navigation application on the watch is switched to the background, although the UI information of the cycling navigation application is no longer displayed on the watch's screen, the application will still continuously receive messages sent by the mobile phone.
[0207] In other embodiments, an application is launched on the watch that changes its UI at regular intervals. However, if the user switches the application to the background during the interval, the UI change will still be triggered after the interval expires.
[0208] 502, the electronic device detected a UI change.
[0209] In some embodiments, step 502 can be performed by an application framework in the electronic device. The application framework can provide applications with an application programming interface (API) and a programming framework; for example, the application framework may include predefined functions. Applications can access the system capabilities of the electronic device by calling system APIs. When the application's UI changes, the application calls the corresponding API, thus the application framework can detect the UI change.
[0210] In some alternative embodiments, the electronic device may determine whether the UI change needs to be cached, a process that may include steps 503 to 505.
[0211] 503, the application framework queries the change management module to see if UI changes need to be cached.
[0212] The change management module is used to handle all caching actions and the application process for updating the cache.
[0213] 504. The change management module determines whether the UI change belongs to the backend.
[0214] When the change management module determines that the UI change belongs to the backend, step 505 can be executed; when the change management module determines that the UI change does not belong to the backend, that is, the UI change belongs to the frontend, step 514 can be executed.
[0215] 505. When the change management module determines that the UI change belongs to the backend, it returns a confirmation result of the required change to the application framework.
[0216] For example, when the change management module determines that the UI change belongs to the backend, it returns a "yes" confirmation result to the application framework.
[0217] It should be understood that in some embodiments, the electronic device may generate a UI change request based on the details of the UI change, without needing to determine whether the UI change needs to be cached.
[0218] For example, the process by which an electronic device generates a UI change request based on the details of the UI change may include steps 506 to 507.
[0219] 506, the application framework submits the UI change details to the change generation module.
[0220] For example, the application framework can submit the UI change details to the change generation module through the system interface.
[0221] The details of the UI change may include: the UI component that has changed, what attributes have been changed, and the changed values. These attributes may include, but are not limited to, the width and height of the component, color, transparency, etc.
[0222] For example, if the UI component originally corresponds to a function card in the interface with a yellow background, then the UI change detail could be to change the background color to red.
[0223] 507. The change generation module generates a UI change request based on the UI change details.
[0224] The change generation module generates a UI change request based on the UI change details. In other words, the change generation module sets the received UI change details into the data structure of the UI change request.
[0225] After an electronic device generates a UI change request, it can cache the UI change request. The process of caching the UI change request by the electronic device may include steps 508 to 509.
[0226] 508, the change generation module submits the UI change request to the change cache module.
[0227] For example, the change generation module submits the UI change request to the change cache module through the system interface.
[0228] 509, the change cache module adds the UI change request to the cache data structure.
[0229] The data structure of the cache can include, but is not limited to, linked lists, arrays, or queues.
[0230] For example, if the data structure of the cache adopts a queue structure, the change cache module adds the UI change request to the cache queue. When there are multiple UI change requests, the multiple UI change requests are added to the cache queue in sequence. The cache queue can adopt a first-in-first-out method, that is, the UI change request that enters the cache queue first is processed first.
[0231] It should be understood that when the application switches back to the foreground, the electronic device can update the UI changes corresponding to the UI change request to the application's UI. This process may include steps 510 to 513.
[0232] 510, the application is switched back to the foreground display.
[0233] For example, see Figure 8 As shown in (g) and (h), in response to the user's swipe gesture on the sports watch screen, the application App2 switches from the background to the foreground.
[0234] Alternatively, the application may be brought to the foreground from the background after the foreground application has exited.
[0235] 511, the application will notify the change management module that it has switched back to the foreground display status.
[0236] For example, the application switches the application back to the foreground display of the status notification change management module by calling the system interface.
[0237] 512. The change management module iterates through the cached UI change requests in the cache list to determine the UI change requests that need to be executed.
[0238] For example, if the cache list is a cache queue, the change management module will sequentially traverse the cached UI change requests in the cache queue to determine the UI change requests that need to be executed.
[0239] 513. Apply UI changes to UI components.
[0240] In this step, the UI change can be applied to the corresponding UI component by calling the corresponding system interface, so that the display interface of the corresponding UI component changes or partially changes.
[0241] It should be understood that when there are multiple UI changes, these changes can be applied to the corresponding UI components sequentially before the first frame of the application is drawn when it switches back to the foreground. In other words, the interface when the application switches back to the foreground is already the interface after multiple UI changes.
[0242] 514, Clear cache list.
[0243] Once the UI change requests cached in this cache list have been executed, the cache list will be cleared.
[0244] It should be understood that step 514 is an optional step.
[0245] It should also be understood that the above steps are merely illustrative, and the implementation order of the above steps is not limited in the embodiments of this application. In some embodiments, other modules in the electronic device may also be used to implement the above functions or steps, and the embodiments of this application are not limited in this regard.
[0246] Based on the embodiments of this application, UI change messages of background applications are cached in a list. When the application switches back to the foreground, the cached UI changes are applied to the UI components in sequence, thereby avoiding functional abnormalities that may be caused by multiple concurrently running applications.
[0247] Figure 11 This is a schematic flowchart illustrating another method for refreshing the user interface provided in an embodiment of this application. Figure 11As shown, the method may include steps 601 to 617.
[0248] 601, System startup error.
[0249] For example, a user can press and hold the power button on an electronic device to turn it on.
[0250] It should be understood that step 601 is an optional step, and in some embodiments, this technical solution can also be implemented in an electronic device that has already been powered on and started.
[0251] 602, Start the system UI service thread.
[0252] 603, Launch App1.
[0253] For example, a user can launch App1 by clicking its application icon on the desktop of their electronic device.
[0254] In some embodiments, step 602 may also be located after step 603. This application does not limit the execution order of steps 602 and 603.
[0255] 604, the startup management module started thread 1 of App1.
[0256] 605, Thread 1 loads and runs the code of App1.
[0257] 606, Thread 1 loads the user interface of App1.
[0258] 607, Thread 1 sets the properties of the UI components of App1.
[0259] For example, setting the properties of the corresponding UI components in the component tree.
[0260] Specifically, the UI service thread calls the system interface to apply the changes to the UI components.
[0261] 608, Launch App2.
[0262] For example, a user can launch App2 by clicking its application icon on the home screen of their electronic device. Alternatively, App2 can be launched from another electronic device, for example, see [link to relevant documentation]. Figure 8 In (f) and (g), the applications in the sports watch can be launched via the mobile phone.
[0263] 609, Startup management module starts thread 2 of App2.
[0264] 610, Thread 2 loads and runs the code for App2.
[0265] 611, Thread 2 loads the user interface of App2.
[0266] 612, Thread 2 sets the properties of the UI components of App2.
[0267] 613. When App1 makes its first UI change, thread 1 sends the UI change message to the UI service thread.
[0268] In other embodiments, when the UI service thread receives multiple UI change messages, it can put these multiple UI change messages into a queue and execute them sequentially.
[0269] 614, the UI service thread applies the first UI change to the UI component.
[0270] In some embodiments, the UI service thread applies the information of the first UI change to the corresponding UI component and attaches the component tree of App1 to the system root node of the electronic device. The graphics drawing module of the electronic device can traverse all the sub-component trees starting from the system root node, draw the components of the sub-component trees in turn, and send the drawn components to the screen driver for display, so that the changed UI of App2 can be displayed on the screen of the electronic device.
[0271] For example, the UI service thread can apply multiple UI changes to UI components sequentially based on the chronological order of the received UI changes.
[0272] 615. When the second UI of App2 changes, thread 2 sends the message of the second UI change to the UI service thread.
[0273] 616, the UI service thread applies the second UI change to the UI component.
[0274] Step 616 can be found in the description of step 614, and will not be repeated here for the sake of brevity.
[0275] It should be understood that when the UI service thread receives multiple UI change messages, it can execute the UI changes sequentially according to the time they are received. When multiple UI change messages are received at the same time, the UI change messages can be randomly added to the queue and then executed sequentially.
[0276] The above steps are merely illustrative, and the implementation order of the above steps is not limited in this application embodiment. In some embodiments, other modules in the electronic device may also be used to implement the above functions or steps, and this application embodiment is not limited in this regard.
[0277] Based on the embodiments of this application, a UI service thread can be introduced to uniformly manage UI changes of all applications. This UI service thread can execute all UI changes in sequence according to the order in which they are received, thereby avoiding the functional abnormalities that may be caused by multiple concurrently running applications undergoing UI changes at the same time.
[0278] Figure 12 This is a schematic flowchart illustrating a method for refreshing a user interface provided in an embodiment of this application. Figure 12 As shown, this method can be applied to electronic devices, and the method may include steps 710 to 730.
[0279] 710, the electronic device detects a first user interface (UI) change request from a first application, the first application running in the background of the electronic device.
[0280] In step 710, the first application runs in the background of the electronic device. When the first UI of the first application changes, the electronic device can detect the UI change request corresponding to the UI change.
[0281] 720, the electronic device caches the first UI change request.
[0282] In step 720, after the electronic device detects the first UI change request, it can cache the UI change request.
[0283] In some embodiments, the first UI change request is generated based on first information about the UI change, and the electronic device adds the first UI change request to a cached data structure.
[0284] The first piece of information may include the UI component corresponding to the first UI change request, as well as the component's attributes and their values. The cached data structure may be a linked list, a queue, or an array.
[0285] For example, if the property of UI component 1 is color, such as red, then the first information corresponding to the first UI change could be changing the color of the property of UI component 1 to yellow.
[0286] 730, when the electronic device detects that the first application has switched to the foreground, it updates the UI change corresponding to the first UI change request to the UI of the first application.
[0287] In step 730, the first application is switched from the background to the foreground. This can be achieved by the user closing the foreground application, making the first application the foreground, or by the user switching the original foreground application to the background, or by the user switching the first application to run in the foreground.
[0288] When the first application is switched to the foreground, the electronic device can update the UI changes corresponding to the UI change request to the UI of the first application before displaying the first frame of the first application, so that the user can directly see the updated UI of the first application.
[0289] Based on the embodiments of this application, when the UI of a first application running in the background changes, the electronic device can detect the UI change request and cache it instead of executing it immediately. When the first application switches to the foreground, the UI change is applied to the UI of the first application. This technical solution can avoid the conflict problem caused by concurrent access of multiple applications when the electronic device is running multiple applications at the same time.
[0290] Optionally, the method further includes: the electronic device detecting a second UI change request of the first application, wherein the second UI change request is generated based on second information of the second UI change; when the first UI component corresponding to the first UI change request is different from the second UI component corresponding to the second UI change request, or when the first UI component is the same as the second UI component but the attributes of the first UI component are different from the attributes of the second UI component, the electronic device adds the second UI change request to the cached data structure list; when the electronic device detects that the first application has switched to the foreground, it updates the UI change corresponding to the second UI change request to the UI of the first application.
[0291] The second information may include the UI component corresponding to the second UI change, as well as the component's properties and the values of those properties.
[0292] The UI component may include a local UI component that can be drawn directly, or it may include a Document Object Model (DOM) component structure in global wide area network (web) development, etc. This application embodiment does not limit this.
[0293] Based on the embodiments of this application, when the UI component corresponding to the second UI change request is different from the UI component corresponding to the first UI change request, or when the component attributes are different, the first UI component can be added to a cached data structure. When the application switches from the background to the foreground, the second UI change is updated to the application's UI. This technical solution can cache different UI change requests in a data structure when multiple UI changes occur in the application, so that when the application switches to the foreground, the multiple UI changes are executed sequentially.
[0294] Optionally, the method further includes: the electronic device detecting a third UI change request of the first application, wherein the third UI change request is generated based on third information of the third UI change; when the third UI component corresponding to the third UI change request is the same as the first UI component corresponding to the first UI change request, and the attribute of the third UI component is the same as the attribute of the first UI component, the electronic device updates the value of the attribute of the first UI component in the cached data structure according to the value of the attribute of the third UI component.
[0295] This third piece of information may include the modified third UI component, the component's properties, and the values of the changed properties. The UI component's properties may include characteristics such as the component's length, width, color, or style.
[0296] For example, the attribute of the first UI component corresponding to the first UI change request is color, and the value of the attribute is a specific color, such as red. The third UI component corresponding to the third UI change request is the same as the first UI component, and the attribute of the third UI component is also color, such as yellow. Then the electronic device can update the value of the attribute of the first UI component corresponding to the first UI change request with the value of the attribute of the third UI component (yellow). That is, at this time, the value of the attribute of the cached first UI component is updated to yellow, so that the third UI change request does not need to be cached.
[0297] Based on the embodiments of this application, when the UI component corresponding to the third UI change request is the same as the UI component corresponding to the first UI change request and the components have the same attributes, the attribute value of the UI component corresponding to the third UI change request is updated with the attribute value of the UI component corresponding to the first UI change request. This avoids adding the third UI change request to the cached data structure, preventing the addition of new cache nodes and thus reducing the memory consumption of the electronic device.
[0298] In some embodiments, the electronic device may also cache the third UI change request, that is, it is not necessary to update the value of the attribute of the UI component corresponding to the first UI change request with the value of the attribute of the UI component corresponding to the third UI change request. This application embodiment does not limit this.
[0299] Optionally, updating the UI change corresponding to the first UI change request to the UI of the first application includes: the electronic device calling a system interface to update the UI change corresponding to the first UI change request to the UI component of the first application.
[0300] Optionally, before the electronic device caches the first UI change request, the method further includes: the electronic device determining that the first UI change request needs to be cached.
[0301] Optionally, the method further includes: when the electronic device determines that it does not need to cache the first UI change request, directly updating the UI change corresponding to the first UI change request to the UI of the first application.
[0302] In some embodiments, when the first application is running in the foreground, the first UI change request generally does not need to be cached, and the UI change corresponding to the first UI change request can be directly updated to the UI of the first application.
[0303] In other embodiments, when the first application is running in the background, the UI changes corresponding to the first UI change request may not need to be cached, and the UI changes corresponding to the first UI change request can be directly updated to the UI of the first application.
[0304] Optionally, the electronic device caching the first UI change request includes: the electronic device sending the first UI change request to the UI service thread; and the UI service thread caching the first UI change request.
[0305] In this embodiment of the application, the UI service thread can be used to manage UI changes for all applications. When there are multiple UI change requests, the UI service thread can cache the multiple UI changes in chronological order and execute them sequentially.
[0306] For example, see Figure 11 This UI service thread can cache the received UI change requests from App1 and App2, and execute them sequentially.
[0307] In other embodiments, the UI service thread can directly update the UI changes to the application's UI, but this application does not limit this aspect.
[0308] Optionally, updating the UI change corresponding to the first UI change request to the UI of the first application includes: the UI service thread updating the component corresponding to the first UI change to the UI component of the first application.
[0309] Figure 13 This is a schematic flowchart illustrating another method for refreshing a user interface provided in this application. This method can be applied to electronic devices, such as… Figure 13 As shown, the method may include steps 810 to 840.
[0310] 810, the electronic device displays a first interface, which is the first user interface (UI) of the first application.
[0311] For example, such as Figure 8As shown in (b), the electronic device can be a smartwatch, the first application can be App2, and the first user interface can be the display interface 320 of App2.
[0312] 820, the electronic device responds to a first operation by the user by displaying a first interface and a second interface located above the first interface, wherein the second interface is a second UI of the second application.
[0313] For example, such as Figure 8 As shown in (f) and (g), the first operation can be the user clicking on card 381 of App1 on the mobile phone, and the second interface can be the display interface of App1.
[0314] 830, when the electronic device detects a first UI change request from the first application, it continues to display the first interface and the second interface.
[0315] For example, such as Figure 8 As shown in (g), when the electronic device detects the first UI change request of the background application App2, the smartwatch continues to display the interfaces of App2 and App1 without any changes.
[0316] Optionally, the second interface is semi-transparent; or, the second interface is not displayed in full screen.
[0317] When the second interface is semi-transparent or not displayed in full screen, the user can see the first interface below the second interface.
[0318] 840, the electronic device responds to the user's second operation by displaying a third interface, wherein the third interface is the interface of the first application after the first UI has been modified.
[0319] For example, such as Figure 8 As shown in (g) and (h), the second operation can be the user swiping up on the display interface of the smartwatch, and the third interface can be the display interface 340 of App2, which is the interface after the first UI change.
[0320] Based on the embodiments of this application, when a first application running in the foreground of an electronic device is switched to the background, its first interface remains visible to the user. When the electronic device detects a UI change request from the first application, it can avoid immediately updating the UI of the first application. Instead, it can update the UI of the first application when the first application switches back to the foreground. This technical solution can avoid the conflict problem caused by concurrent access of multiple applications when the electronic device is running multiple applications simultaneously.
[0321] This application also provides an electronic device, including 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 one or more processors, cause a method for refreshing the user interface as described in any of the possible implementations above to be executed.
[0322] Optionally, the electronic device is an electronic device with a display screen that does not support memory management unit isolation.
[0323] For example, the electronic device can be a wearable device such as a smartwatch, AR glasses, or a wristband, or other electronic devices with a display screen.
[0324] This application also provides a chip, which includes a processor and a communication interface. The communication interface is used to receive signals and transmit the signals to the processor. The processor processes the signals so that the method for refreshing the user interface as described in any of the possible implementations above is executed.
[0325] 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 method for refreshing the user interface in the above embodiment.
[0326] 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 method for refreshing the user interface in the above embodiment.
[0327] 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 window display method in the above method embodiments.
[0328] 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.
[0329] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software 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, but such implementation should not be considered beyond the scope of this application.
[0330] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0331] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of 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 system, or some features may be ignored or not executed. Furthermore, the 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.
[0332] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0333] In addition, 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.
[0334] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in 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.
[0335] 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 refreshing a user interface, characterized in that, The method is applied to an electronic device, and the method includes: The electronic device detects a UI change request from a first application, the first application running in the background of the electronic device, wherein the first application accesses the same shared resources as the foreground application of the electronic device when running in the background. The electronic device caches the first user interface (UI) change request. When the electronic device detects that the first application has switched to the foreground, it updates the UI change corresponding to the first user interface (UI) change request to the UI of the first application.
2. The method according to claim 1, characterized in that, The first user interface (UI) change request is generated based on first information about the first UI change. The electronic device caches the first user interface (UI) change request, including: The electronic device adds the first user interface (UI) change request to the cached data structure.
3. The method according to claim 1 or 2, characterized in that, The method further includes: The electronic device detects a second UI change request from the first application, wherein the second UI change request is generated based on second information about the second UI change; When the first UI component corresponding to the first UI change request is different from the second UI component corresponding to the second UI change request, or when the first UI component is the same as the second UI component but the attributes of the first UI component are different from the attributes of the second UI component, the electronic device adds the second UI change request to the cached data structure. When the electronic device detects that the first application has switched to the foreground, it updates the UI of the first application with the UI changes corresponding to the second UI change request.
4. The method according to claim 1 or 2, characterized in that, The method further includes: The electronic device detects a third UI change request from the first application, wherein the third UI change request is generated based on third information of the third UI change; When the third UI component corresponding to the third UI change request is the same as the first UI component corresponding to the first UI change request, and the attribute of the third UI component is the same as the attribute of the first UI component, the electronic device updates the attribute value of the first UI component in the cached data structure according to the attribute value of the third UI component.
5. The method according to claim 1, characterized in that, The electronic device caches the first user interface (UI) change request, including: The electronic device sends the first user interface (UI) change request to the UI service thread; The UI service thread caches the UI change request for the first user interface.
6. A method for refreshing a user interface, characterized in that, The method is applied to an electronic device, and the method includes: The electronic device displays a first interface, which is the first user interface (UI) of the first application. The electronic device responds to a user's first operation by displaying a first interface and a second interface located above the first interface, wherein the second interface is a second UI of a second application, and the first application and the second application access the same shared resource; When the electronic device detects a first UI change request from the first application, it continues to display the first interface and the second interface; The electronic device responds to a second user operation, which is a swipe operation, to display a third interface, wherein the third interface is the interface of the first application after the first UI has been modified.
7. The method according to claim 6, characterized in that, The second interface is semi-transparent; or, the second interface is not displayed in full screen.
8. An electronic device, characterized in that, include: 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 one or more processors, cause the method of refreshing the user interface as described in any one of claims 1-5 or 6-7 to be performed.
9. The electronic device according to claim 8, characterized in that, The electronic device is an electronic device with a display screen that does not support memory management unit isolation.
10. A chip, characterized in that, The chip includes a processor and a communication interface, the communication interface being used to receive signals and transmit the signals to the processor, the processor processing the signals such that the method for refreshing the user interface as described in any one of claims 1-5 or 6-7 is executed.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that, when executed on a computer, cause the method for refreshing the user interface as described in any one of claims 1-5 or 6-7 to be performed.
Citation Information
Patent Citations
Operating geographic location systems
CN103428362A