Theme synchronous switching method, system and device and storage medium
By intercepting the vertical sync signal and synchronously triggering the application's rendering operation, the problem of inconsistent theme switching in the Android system was solved, achieving synchronized theme switching within the same vertical sync cycle, thus improving user experience and visual consistency.
Patent Information
- Application Number
- CN202511474300.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-15
- Publication Date
- 2026-02-24
AI Technical Summary
In Android systems, differences in the receiving and execution times of different applications when switching themes lead to inconsistent interfaces, affecting user experience.
By intercepting the vertical synchronization signal, the rendering operations of all applications are triggered synchronously, so that theme switching is completed within the same vertical synchronization cycle. Choreographer's state machine controls the drawing process, and the application state is accurately determined by ready or timeout signals to ensure that the signal is released when the synchronization conditions are met.
It achieves visual synchronization of global theme switching, eliminates the time difference between theme switching in different areas and applications, improves user experience, and provides zero-latency visual uniformity and a smooth switching process.
Smart Images

Figure CN121560426A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of interface display technology, and in particular to a method, system, device and storage medium for synchronous theme switching. Background Technology
[0002] In current Android operating systems, smooth rendering and display of the graphical user interface heavily relies on a precise timing control mechanism driven by hardware VSync (Vertical Sync) signals. At the heart of this mechanism is the Choreographer component, which coordinates the application layer's drawing work at fixed intervals of approximately 16ms (corresponding to one display cycle on a 60Hz refresh rate screen). Choreographer receives VSync pulses from the display subsystem and uses them to call back the application to perform a series of operations, including input processing, animation calculations, view traversal, and final drawing. This ensures that the application's rendered content remains synchronized with the screen's refresh cycle, thereby avoiding screen tearing and providing a smooth visual experience.
[0003] Therefore, when the Android system uses the Choreographer mechanism driven by the VSync signal, refreshing the screen every 16ms, if the system triggers a theme switch (such as switching between night and day modes), different applications will receive the theme change command at different times and execute it at different speeds. This results in UI components such as the status bar, navigation bar, and foreground applications updating the theme separately within different refresh cycles, creating a visually noticeable "step-by-step switching" phenomenon (for example, the status bar has switched to day mode while the media application still displays night mode, only switching to day mode after a while), severely impacting the consistency of the user experience. Summary of the Invention
[0004] This invention provides a method, system, device, and storage medium for theme synchronization switching, which solves the technical problem that existing 16ms application switching has reception time difference and execution time difference, resulting in inconsistent application theme switching, inconsistent application interface, and poor user experience.
[0005] To address the above technical problems, this invention provides a topic synchronization switching method, comprising the following steps: When a theme switching command is detected, the theme switching command is broadcast to one or more applications within the system; Signal interception is performed based on the aforementioned topic switching command, including intercepting the vertical synchronization signal; Obtain the preparation status of each application and determine whether the loading of the target theme resources is complete; When it is detected that the preparation status of all the applications meets the synchronization conditions, the vertical synchronization signal is released; In response to the vertical synchronization signal, all applications are synchronously triggered to perform rendering operations based on the theme switching command, so that the target theme interface after the switch is presented within the same vertical synchronization cycle.
[0006] This basic solution utilizes the intervention mechanism of the vertical synchronization signal (VSync signal) to synchronize the loading preparation of target theme resources by different applications by intercepting the vertical synchronization signal. This, in turn, synchronously triggers the rendering operations of all applications based on theme switching instructions, so that the target theme interface after the switch is presented within the same vertical synchronization cycle. This achieves global visual synchronization of theme switching within the existing Android rendering framework, eliminates the time difference between theme switching in different areas and applications, provides zero-latency perception, achieves visual uniformity, and significantly improves the user experience. Furthermore, by utilizing the existing VSync mechanism, no additional synchronization protocol is required, resulting in low system overhead.
[0007] In a further implementation, when a theme switching command is detected, the theme switching command is broadcast to one or more applications within the system, specifically: A theme switching instruction is generated based on the detected user operation; when the theme switching instruction is detected, a broadcast message is generated based on the theme switching instruction and broadcast to one or more applications in the system, prompting the applications to trigger resource loading and interface update preparation.
[0008] In a further implementation, signal interception is performed based on the topic switching command, specifically intercepting the vertical synchronization signal, including: Create a subclass of Choreographer and override its core doFrame() method; add a state machine to control the drawing process, the state machine including IDLE / PENDING and READY; When the topic switching instruction is received, the state machine is set to IDLE / PENDING, providing a blocking interface for delayed topic drawing, intercepting the vertical synchronization signal, and pausing Choreographer's frame drawing callback.
[0009] This solution rewrites the core `doFrame()` method of Choreographer, adding a state machine to control the rendering process. Based on the flags of the state machine, it controls the interception and release of the vertical synchronization signal, transforming the originally asynchronous and scattered application response process into a synchronous and centralized batch processing process. This fundamentally eliminates the visual asynchrony problem of theme switching caused by differences in processing speed between multiple applications, effectively improving the user experience. Based on the state machine, it has strong scalability and does not affect the normal response of input events and background services in the system. When the vertical synchronization signal is released, the rendering process resumes immediately. The hardware acceleration feature ensures an absolutely smooth switching process without any lag.
[0010] In a further implementation, obtaining the preparation status of each application and determining whether the loading of the target topic resources is complete includes: Modify the onThemeChanged() notification callback method of each application to send a ready signal after asynchronously loading resources in the onThemeChanged() notification callback method; and set a maximum waiting time, and send a timeout signal after the resource loading time exceeds the maximum waiting time; determine whether the loading of the target theme resources is complete based on the ready signal or the timeout signal.
[0011] This solution adaptively modifies the onThemeChanged() callback method for theme change notifications in applications. By sending ready or timeout signals, it actively receives status feedback from all applications, thereby accurately determining the global progress (how many applications are ready) and providing a basis for achieving precise synchronization. It also effectively prevents system failures caused by slow response or freezing of individual applications, ensuring the normal operation of the system.
[0012] In a further implementation, when it is identified that the preparation status of all the applications meets the synchronization conditions, the vertical synchronization signal is released, including: The system receives the readiness status of each application. When the ready signal or timeout signal of all applications is detected, it determines that the readiness status of all applications meets the synchronization condition, and then releases the vertical synchronization signal; otherwise, it maintains the interception state of the vertical synchronization signal.
[0013] Based on the different characteristics of resource loading by different applications, this solution actively obtains the ready signal or timeout signal of the application as a preparation mark, synchronizes all applications when the resource loading is completed, and releases the vertical synchronization signal, thereby realizing cross-process application synchronization in the Android system.
[0014] In a further implementation, in response to the vertical synchronization signal, all the applications are synchronously triggered to perform rendering operations based on the theme switching instruction, so that the target theme interface after the switch is presented within the same vertical synchronization cycle, including; In response to the vertical synchronization signal, all applications are synchronously triggered to perform rendering operations based on the theme switching instruction, and the backlog of drawing requests are processed at once. The corresponding theme interface is drawn according to the target theme resource. New frames of all applications are synthesized and displayed within the same vertical synchronization cycle, so that the target theme interface after switching is presented within the same vertical synchronization cycle.
[0015] This solution receives the released vertical synchronization signal, processes the backlog of drawing requests all at once, synthesizes new frames for all applications within the same vertical synchronization cycle, and displays them. This ensures that the target theme interface after switching is presented within the same vertical synchronization cycle. Synchronous switching of the theme interface is achieved through resource loading alignment and synchronous rendering, resulting in high screen display consistency and a good user experience.
[0016] This invention provides a topic synchronization switching system for executing a topic synchronization switching method as described above, comprising: The theme switching monitoring module is used to listen for whether a user's theme switching command has been received; The VSYNC control module is used to intercept or release the vertical synchronization signal. When the theme switching instruction is received, the vertical synchronization signal is intercepted, thereby causing Choreographer to pause the frame drawing callback; when it is recognized that the preparation status of all applications meets the synchronization conditions, the vertical synchronization signal is released. The resource readiness monitoring module is used to obtain the readiness status of each application and determine whether the loading of the target topic resources has been completed. The theme drawing module is used to respond to the vertical synchronization signal, synchronously trigger the rendering operation of all the applications based on the theme switching instruction, and draw the corresponding target theme interface according to the target theme resource; The display module is used to display the target theme interface.
[0017] This basic switching system uses various modules to implement each step of the switching method, providing a hardware foundation for the switching method and facilitating its implementation. The VSYNC control module takes over the scheduling of the VSync signal, ensuring that the theme switching action can be perfectly aligned with the device's refresh cycle, completing the theme switching synchronously, presenting a highly consistent visual style, and improving the quality of the screen switching.
[0018] The present invention provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it performs steps to implement the topic synchronization switching method described above.
[0019] This invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the topic synchronization switching method described above. The computer-readable storage medium may be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc. Attached Figure Description
[0020] Figure 1 This is a flowchart illustrating a topic synchronization switching method provided in an embodiment of the present invention; Figure 2 This is a system framework diagram of a topic synchronization switching system provided in an embodiment of the present invention. Detailed Implementation
[0021] The embodiments of the present invention are described in detail below with reference to the accompanying drawings. The embodiments are given for illustrative purposes only and should not be construed as limiting the present invention. The accompanying drawings are for reference and illustration only and do not constitute a limitation on the scope of patent protection of the present invention, because many changes can be made to the present invention without departing from the spirit and scope of the present invention.
[0022] Example 1 This invention provides a method for synchronous topic switching, such as... Figure 1 As shown, this embodiment includes the following steps: S1. When a theme switching command is detected, the theme switching command is broadcast to one or more applications within the system, specifically: A theme switching instruction is generated based on the detected user operation; when the theme switching instruction is detected, a broadcast message is generated based on the theme switching instruction and broadcast to one or more applications in the system, prompting the applications to trigger resource loading and interface update preparation.
[0023] S2. Based on the topic switching command, intercept the signal, specifically including: Create a subclass of Choreographer and override its core doFrame() method; add a state machine to control the drawing process, the state machine including IDLE / PENDING and READY; When the topic switching instruction is received, the state machine is set to IDLE / PENDING, providing a blocking interface for delayed topic drawing, intercepting the vertical synchronization signal, and pausing Choreographer's frame drawing callback.
[0024] VSYNC (Vertical Synchronization) is an important concept in computer graphics and display technology. It is a synchronization pulse signal emitted by a display device (such as a monitor or television) when it completes the refresh of a frame. This signal indicates that the display device has completed scanning all lines of the current frame and is ready to begin displaying the next frame.
[0025] During graphics rendering, the VSYNC signal is used by the operating system and the graphics processing unit (GPU) to synchronize graphics rendering with the actual physical refresh of the screen. Without synchronization, the GPU may start rendering the next frame while the monitor is still displaying the content of the previous frame. This can cause image tearing on the screen, where parts of the same frame and parts of the next frame appear on the screen at the same time, creating a visual discontinuity.
[0026] When VSYNC is enabled, the GPU will only begin rendering the next frame after receiving the VSYNC signal, and will submit the newly rendered frame content to the display buffer when the next VSYNC signal arrives. In this way, each frame rendered by the GPU is precisely aligned with the display's refresh cycle, thereby eliminating image tearing and improving visual quality.
[0027] This embodiment rewrites the core doFrame() method of Choreographer, adding a state machine to control the rendering process. Based on the flags of the state machine, it controls the interception and release of the vertical synchronization signal, transforming the originally asynchronous and scattered application response process into a synchronous and centralized batch processing process. This fundamentally eliminates the visual asynchrony problem of theme switching caused by differences in processing speed between multiple applications, effectively improving the user experience. Based on the state machine, it has strong scalability and does not affect the normal response of input events and background services in the system. When the vertical synchronization signal is released, the rendering process resumes immediately. The hardware acceleration feature ensures that the switching process is absolutely smooth and without any lag.
[0028] S3. Obtain the preparation status of each application and determine whether the loading of the target theme resources is complete, including: Modify the onThemeChanged() notification callback method of each application (i.e., the registered application) to send a ready signal after asynchronously loading resources in the onThemeChanged() notification callback method; and set a maximum waiting time, and send a timeout signal after the resource loading time exceeds the maximum waiting time; determine whether the loading of the target theme resources is complete based on the ready signal or the timeout signal. If yes, proceed to step S4; otherwise, repeat this step.
[0029] For example, setting a maximum wait time (such as 1000ms) can prevent system crashes caused by application errors, and a timeout signal can be sent after the timeout to force the release of the VSync signal.
[0030] This embodiment adaptively modifies the onThemeChanged() callback method for theme change notifications in the application. By sending ready or timeout signals, it actively receives status feedback from all applications, thereby accurately determining the global progress (how many applications are ready) and providing a basis for achieving precise synchronization. It also effectively prevents system failures caused by slow response or freezing of individual applications, ensuring the normal operation of the system.
[0031] S4. When it is detected that the preparation status of all the applications meets the synchronization conditions, release the vertical synchronization signal, including: The system receives the readiness status of each application. When the ready signal or timeout signal of all applications is detected, it determines that the readiness status of all applications meets the synchronization condition, and then releases the vertical synchronization signal; otherwise, it maintains the interception state of the vertical synchronization signal.
[0032] Based on the different characteristics of resource loading by different applications, this embodiment actively obtains the ready signal or timeout signal of the application as a preparation mark, synchronizes all applications when the resource loading is completed, and releases the vertical synchronization signal, thereby realizing cross-process application synchronization of the Android system.
[0033] S5. In response to the vertical synchronization signal, synchronously trigger the rendering operations of all the applications based on the theme switching instruction, so that the target theme interface after switching is presented within the same vertical synchronization cycle, including; In response to the vertical synchronization signal, all applications are synchronously triggered to perform rendering operations based on the theme switching instruction, and the backlog of drawing requests are processed at once. The corresponding theme interface is drawn according to the target theme resource. New frames of all applications are synthesized and displayed within the same vertical synchronization cycle, so that the target theme interface after switching is presented within the same vertical synchronization cycle.
[0034] This embodiment receives the released vertical synchronization signal, processes the backlog of drawing requests all at once, synthesizes new frames of all applications within the same vertical synchronization cycle, and displays them, so that the target theme interface after switching is presented within the same vertical synchronization cycle. Synchronous switching of the theme interface is achieved through resource loading alignment and synchronous rendering, resulting in high screen display consistency and a good user experience.
[0035] Example 2 This invention provides a topic synchronization switching system for executing a topic synchronization switching method as described in Embodiment 1 above, such as... Figure 2 As shown, it includes: Theme switching monitoring module 1 is used to monitor whether a user's theme switching command has been received; VSYNC control module 2 is used to intercept or release the vertical synchronization signal. When the theme switching instruction is received, the vertical synchronization signal is intercepted, thereby causing Choreographer to pause frame drawing callbacks; when it is recognized that the preparation status of all applications meets the synchronization conditions, the vertical synchronization signal is released. Resource readiness monitoring module 3 is used to obtain the readiness status of each application and determine whether the loading of the target topic resources has been completed. Theme drawing module 4 is used to respond to the vertical synchronization signal, synchronously trigger the rendering operation of all the applications based on the theme switching instruction, and draw the corresponding target theme interface according to the target theme resource; Display module 5 is used to display the target theme interface.
[0036] This basic switching system uses various modules to implement each step of the switching method, providing a hardware foundation for the switching method and facilitating its implementation. The VSYNC control module takes over the scheduling of the VSync signal, ensuring that the theme switching action can be perfectly aligned with the device's refresh cycle, completing the theme switching synchronously, presenting a highly consistent visual style, and improving the quality of the screen switching.
[0037] Example 3 This invention provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it performs steps to implement the topic synchronization switching method as described in Embodiment 1 above.
[0038] Example 4 This invention provides a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements the steps of the topic synchronization switching method described in Embodiment 1 above. The computer-readable storage medium may be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0039] This invention utilizes the intervention mechanism of the vertical synchronization signal (VSync signal) to synchronize the loading preparation of target theme resources by different applications by intercepting the vertical synchronization signal. This, in turn, synchronously triggers the rendering operations of all applications based on theme switching instructions, so that the target theme interface after the switch is presented within the same vertical synchronization cycle. This achieves global theme switching visual synchronization under the existing Android rendering framework, eliminates the time difference between theme switching in different regions and applications, provides zero-latency perception, achieves visual uniformity, and significantly improves the user experience. Furthermore, by utilizing the existing VSync mechanism, no additional synchronization protocol is required, resulting in low system overhead.
[0040] The above embodiments are preferred embodiments of the present invention, but the embodiments of the present invention are not limited to the above embodiments. Any changes, modifications, substitutions, combinations, or simplifications made without departing from the spirit and principle of the present invention shall be considered equivalent substitutions and shall be included within the protection scope of the present invention.
Claims
1. A method for synchronous theme switching, characterized in that, Including the following steps: When a theme switching command is detected, the theme switching command is broadcast to one or more applications within the system; Signal interception is performed based on the aforementioned topic switching command, including intercepting the vertical synchronization signal; Obtain the preparation status of each application and determine whether the loading of the target theme resources is complete; When it is detected that the preparation status of all the applications meets the synchronization conditions, the vertical synchronization signal is released; In response to the vertical synchronization signal, all applications are synchronously triggered to perform rendering operations based on the theme switching command, so that the target theme interface after the switch is presented within the same vertical synchronization cycle.
2. The topic synchronization switching method as described in claim 1, characterized in that, When a theme switching command is detected, the theme switching command is broadcast to one or more applications within the system, specifically: A theme switching instruction is generated based on the detected user operation; when the theme switching instruction is detected, a broadcast message is generated based on the theme switching instruction and broadcast to one or more applications in the system, prompting the applications to trigger resource loading and interface update preparation.
3. The topic synchronization switching method as described in claim 1, characterized in that, Signal interception based on the aforementioned topic switching command, specifically intercepting the vertical synchronization signal, includes: Create a subclass of Choreographer and override its core doFrame() method, and add a state machine to control the drawing process, the state machine including IDLE / PENDING and READY; When the topic switching instruction is received, the state machine is set to IDLE / PENDING, providing a blocking interface for delayed topic drawing, intercepting the vertical synchronization signal, and pausing Choreographer's frame drawing callback.
4. The topic synchronization switching method as described in claim 1, characterized in that, Obtaining the preparation status of each application and determining whether the loading of the target theme resources is complete includes: Modify the onThemeChanged() notification callback method of each application to send a ready signal after asynchronously loading resources in the onThemeChanged() notification callback method; and set a maximum waiting time, and send a timeout signal after the resource loading time exceeds the maximum waiting time; determine whether the loading of the target theme resources is complete based on the ready signal or the timeout signal.
5. The topic synchronization switching method as described in claim 4, characterized in that, When it is detected that the preparation status of all the applications meets the synchronization conditions, the vertical synchronization signal is released, including: The system receives the readiness status of each application. When the ready signal or timeout signal of all applications is detected, it determines that the readiness status of all applications meets the synchronization condition, and then releases the vertical synchronization signal; otherwise, it maintains the interception state of the vertical synchronization signal.
6. The topic synchronization switching method as described in claim 4, characterized in that, In response to the vertical synchronization signal, all applications are synchronously triggered to perform rendering operations based on the theme switching instruction, so that the target theme interface after the switch is presented within the same vertical synchronization cycle, including; In response to the vertical synchronization signal, all applications are synchronously triggered to perform rendering operations based on the theme switching instruction, and the backlog of drawing requests are processed at once. The corresponding theme interface is drawn according to the target theme resource. New frames of all applications are synthesized and displayed within the same vertical synchronization cycle, so that the target theme interface after switching is presented within the same vertical synchronization cycle.
7. A topic synchronization switching system, used to execute a topic synchronization switching method as described in any one of claims 1 to 6, characterized in that, include: The theme switching monitoring module is used to listen for whether a user's theme switching command has been received; The VSYNC control module is used to intercept or release the vertical synchronization signal. When the theme switching instruction is received, the vertical synchronization signal is intercepted, thereby causing Choreographer to pause the frame drawing callback; when it is recognized that the preparation status of all applications meets the synchronization conditions, the vertical synchronization signal is released. The resource readiness monitoring module is used to obtain the readiness status of each application and determine whether the loading of the target topic resources has been completed. The theme drawing module is used to respond to the vertical synchronization signal, synchronously trigger the rendering operation of all the applications based on the theme switching instruction, and draw the corresponding target theme interface according to the target theme resource; The display module is used to display the target theme interface.
8. A terminal device, characterized in that: It includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, it performs the steps of the topic synchronization switching method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the topic synchronization switching method as described in any one of claims 1 to 6.