Method and system for linking life cycle of main screen and sub-screen in dual-screen application

CN123030265APending Publication Date: 2026-11-03SHENZHEN XINZHILIAN SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611539264.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-30
Publication Date
2026-11-03

AI Technical Summary

Technical Problem

In the existing multi-display implementation of Android systems, the active pages on the two displays of the same device are independent of each other, and the page lifecycles are not aware of each other. The main screen display page cannot know the foreground state of the secondary screen operation page, which leads to the problem that the main screen display page may remain or cannot be restored when the secondary screen operation page is exited.

Method used

The system maintains the reference count of the secondary screen's foreground page and the liveness flag of the main screen within the application process. It manages the lifecycle of the secondary screen's operation page through a unified page base class. After the main screen's display page starts, a polling monitoring task is initiated. Combined with a zero-count confirmation window and a startup grace period, the system ensures the synchronized display of the main screen and secondary screen pages.

Benefits of technology

It enables synchronized display of the main screen and secondary screen on the same device, avoids the main screen being accidentally killed during the switching of the secondary screen, solves the problem of residual display on the main screen after exiting the secondary screen, and improves the user experience of the device.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123030265A_ABST
    Figure CN123030265A_ABST
Patent Text Reader

Abstract

The application relates to the technical field of multi-display application management, and provides a main screen and auxiliary screen life cycle linkage method and system in a dual-screen application. A reference count of a front page of the auxiliary screen and a survival flag of the main screen are maintained in an application process; an operation page of the auxiliary screen inherits a unified page base class; the reference count is increased by 1 when the page enters a front stage, and the reference count is decreased by 1 when the page leaves the front stage; a watchdog polling task is started by a display page of the main screen; the reference count is read according to a preset period; the exit judgment is not executed within a grace period started by the main screen; when the reference count is greater than 0 after the grace period ends, the main screen is kept; when the reference count is equal to 0 and still reaches a zero count confirmation window without being restored, the main screen is closed and the survival flag of the main screen is updated; the survival flag of the main screen is detected every time the home page of the auxiliary screen enters the front stage; and when the main screen is closed, the main screen is restarted according to a main screen display identifier. The application realizes that the auxiliary screen and the main screen appear synchronously when the auxiliary screen is opened, the main screen is kept when the page is switched, the main screen is closed when the auxiliary screen exits, and the main screen is automatically restored when the auxiliary screen enters again.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of multi-display application management, and in particular to a main screen and a secondary screen life cycle linkage method and system in a dual-screen application. BACKGROUND

[0002] With the development of multi-display Android devices, dual-screen smart photo frames, dual-screen tablets, and vehicle-mounted dual screens, etc. are increasingly popular. Such devices are configured with a horizontal large screen and a vertical small screen on the same device, the horizontal large screen displays photos, videos, and generation processes, etc., and the vertical small screen displays content selection, parameter adjustment, and operation confirmation, and the two screens run a main screen display page and a secondary screen operation page respectively.

[0003] In the existing multi-display implementation of the Android system, the active pages on the two screens of the same device are independent of each other, the page life cycles are not aware of each other, and the main screen display page cannot know the foreground state of the secondary screen operation page. In actual use, there are problems such as the secondary screen operation page being exited while the main screen display page is still displayed, the main screen display page being unable to recover when the secondary screen enters the application again, and the contents on the two screens of the same device being difficult to keep synchronized.

[0004] An existing linkage method relies on a secondary screen page destruction callback to send a broadcast to notify the main screen to exit, but in some systems, the secondary screen application exits by actually performing a page migration to the background operation, the active page is only migrated to the background and not destroyed, the destruction callback is not triggered, the broadcast cannot be sent, and the main screen display page cannot perceive the exit event.

[0005] Another existing linkage method uses a transient Boolean flag to record whether the secondary screen page is in the foreground. On the one hand, in the cold start or secondary screen page migration process, the destruction of the old page instance is later than the recovery of the new page instance, the Boolean flag is reset incorrectly, and there is a start race; on the other hand, when the secondary screen switches from the first page to the second page, the first page's leaving foreground callback sets the Boolean flag to false, and the detection logic on the main screen side mistakenly judges that the secondary screen has exited and closes the main screen display page, causing a false kill during page switching.

[0006] Therefore, there is an urgent need for a method to solve at least one of the above problems. SUMMARY

[0007] The present application provides a main screen and a secondary screen life cycle linkage method and system in a dual-screen application, aiming to solve the problem that in the existing multi-display implementation of the Android system, the active pages on the two screens of the same device are independent of each other, the page life cycles are not aware of each other, and the main screen display page cannot know the foreground state of the secondary screen operation page.

[0008] In a first aspect, embodiments of this application provide a method for linking the lifecycles of the main screen and the secondary screen in a dual-screen application, applied to a digital photo frame. The digital photo frame is configured with two displays, a main screen and a secondary screen. Within the same application process of the digital photo frame, a main screen display page and a secondary screen operation page run, including: Within the application process, maintain the reference count of the secondary screen foreground page and the liveness flag of the main screen. The secondary screen operation page inherits the unified page base class. When any secondary screen operation page enters the foreground, the unified page base class increments the reference count of the secondary screen foreground page by 1. When any secondary screen operation page leaves the foreground, the unified page base class decrements the reference count of the secondary screen foreground page by 1. After the main screen display page starts, a polling monitoring task is initiated. The polling monitoring task reads the reference count of the secondary screen foreground page according to a preset polling cycle. During the startup grace period after the main screen display page enters the foreground, the polling monitoring task does not perform an exit judgment. After the startup grace period ends, when the reference count of the secondary screen foreground page is greater than zero, the polling monitoring task keeps the main screen display page running. When the reference count of the secondary screen foreground page is equal to zero, the polling monitoring task starts a zero count confirmation timer. Only when the duration of the secondary screen foreground page reference count being equal to zero reaches the zero count confirmation window and has not yet recovered to a value greater than zero, the main screen display page is closed and the main screen survival flag is updated to the closed state. Each time the secondary screen homepage operation page enters the foreground, it reads the main screen's survival flag. When the main screen's survival flag indicates that the main screen display page has been closed, it restarts the main screen display page on the main screen according to the main screen display indicator and updates the main screen's survival flag to a survival status, so that the main screen display page and the secondary screen operation page of the same digital photo frame are displayed synchronously.

[0009] In some embodiments, maintaining the reference count of the secondary screen foreground page and the survival flag of the main screen within the application process, with the secondary screen operation pages inheriting a unified page base class, includes: creating two shared state variables, the secondary screen foreground page reference count and the main screen survival flag, in the application process-level global state object; the initial value of the secondary screen foreground page reference count is 0, and the initial value of the main screen survival flag is an uncreated state; encapsulating the entry and exit callback interfaces in the unified page base class; all secondary screen operation pages inheriting from the unified page base class and reusing the entry and exit callback interfaces; and performing read and write operations on the secondary screen foreground page reference count through atomic counting operations or synchronization locks to ensure that the value of the secondary screen foreground page reference count remains accurate when callbacks from multiple secondary screen operation pages are triggered concurrently.

[0010] In some embodiments, the step of incrementing the reference count of the secondary screen's foreground page by 1 when any secondary screen operation page enters the foreground and decrementing the reference count by 1 when any secondary screen operation page leaves the foreground includes: when the entry callback is triggered, the unified page base class first determines whether the page instance identifier of the corresponding secondary screen operation page has been recorded in the foreground page instance collection. If the page instance identifier is not recorded, it adds the page instance identifier to the foreground page instance collection and increments the secondary screen's foreground page reference count by 1; when the exit callback is triggered, the unified page base class removes the corresponding page instance identifier from the foreground page instance collection. If the removal is successful, the secondary screen's foreground page reference count is decremented by 1; if the removal fails, the secondary screen's foreground page reference count remains unchanged; and a lower limit protection is applied to the secondary screen's foreground page reference count to ensure that the value of the secondary screen's foreground page reference count is not less than 0.

[0011] In some embodiments, after the main screen display page starts, a polling monitoring task is initiated. The polling monitoring task reads the reference count of the secondary screen foreground page according to a preset polling period, including: when the main screen display page is created, the polling monitoring task is initiated through a timed task handle; the polling monitoring task runs periodically according to a preset polling period of 1 second; each time the polling monitoring task runs, it reads the current value of the secondary screen foreground page reference count and the main screen liveness flag from the application process-level global state object; when the main screen display page is closed, the polling monitoring task is deregistered and removed, causing the polling monitoring task to stop reading the secondary screen foreground page reference count.

[0012] In some embodiments, the step of not performing an exit judgment during the startup grace period after the main screen display page enters the foreground includes: starting a grace timer each time the main screen display page enters the foreground, with a startup grace period of 3 seconds; during the startup grace period, the polling monitoring task reads the reference count of the secondary screen foreground page and only records the value, without starting a zero-count confirmation timer or closing the main screen display page; after the grace timer reaches the startup grace period, the polling monitoring task enters a normal judgment state and performs the operation of maintaining the main screen display page or starting a zero-count confirmation timer according to the value of the secondary screen foreground page reference count; the grace timer is restarted when the main screen display page cold starts or restarts.

[0013] In some embodiments, after the startup grace period ends, when the reference count of the secondary screen foreground page is greater than zero, the polling monitoring task maintains the main screen display page; when the reference count of the secondary screen foreground page is equal to zero, the polling monitoring task starts a zero-count confirmation timer. Only when the duration of the secondary screen foreground page reference count being equal to zero reaches the zero-count confirmation window and has not yet recovered to a value greater than zero, the main screen display page is closed and the main screen survival flag is updated to the closed state. This includes: after the startup grace period ends, each time the polling monitoring task reads that the reference count of the secondary screen foreground page is greater than zero, the ongoing zero-count confirmation timer is canceled. The system will reset the zero count duration to zero while keeping the main screen display page running. When the polling monitoring task reads that the reference count of the secondary screen foreground page is equal to zero, it will record the start time of the zero count and start the zero count confirmation timer, with the zero count confirmation window lasting for 2 seconds. If the reference count of the secondary screen foreground page recovers to be greater than zero during the zero count confirmation timer, the zero count confirmation timer will be canceled and the zero count duration will be reset to zero. If the zero count duration reaches the zero count confirmation window and the reference count of the secondary screen foreground page is still equal to zero, the main screen display page will be closed, the polling monitoring task will be stopped, and the main screen survival flag will be updated to the closed state.

[0014] In some embodiments, the secondary screen homepage operation page reads the main screen survival flag each time it enters the foreground. When the main screen survival flag indicates that the main screen display page is closed, the main screen display page is restarted on the main screen according to the main screen display identifier. This includes: each time the secondary screen homepage operation page enters the foreground, it reads the main screen survival flag from the application process-level global state object; when the main screen survival flag is in a closed state or not created state, it constructs the page startup parameters of the main screen display page, carrying the main screen display identifier in the page startup parameters; it requests the multi-display management module to create and display the main screen display page on the main screen corresponding to the main screen display identifier through the page startup parameters; after the main screen display page is successfully created, it starts a polling monitoring task; when the actual display position of the main screen display page does not match the main screen display identifier, it corrects the display position of the main screen display page according to the main screen display identifier.

[0015] In some embodiments, updating the main screen survival flag to a live state, so that the main screen display page and the secondary screen operation page of the same digital photo frame are presented synchronously, includes: updating the main screen survival flag to a live state when the main screen display page is created and enters the foreground, and updating the main screen survival flag to a closed state when the main screen display page is closed; when the secondary screen operation page is launched for the first time and the main screen survival flag is not created, creating the main screen display page on the main screen according to the main screen display identifier at the same time as creating the secondary screen operation page, so that the main screen display page and the secondary screen operation page are presented synchronously on the two displays of the same digital photo frame; the polling monitoring task continues to run while the main screen survival flag is in a live state.

[0016] In some embodiments, the method further includes: recording the switching interval duration from a value greater than zero to zero and then back to a value greater than zero when the secondary screen operation page switches internally each time; taking the maximum value of the historical switching interval duration and adding a preset margin; dynamically updating the duration of the zero-count confirmation window; recording the startup time from initiating startup to entering the foreground when the main screen display page cold starts or restarts each time; taking the average value of the historical startup time and adding a preset margin; dynamically updating the startup grace period duration; and dynamically adjusting the preset polling cycle according to the change in the secondary screen foreground page reference count read by the polling monitoring task in two adjacent reads; the polling monitoring task enumerates the number of secondary screen operation pages currently actually in the foreground once every preset verification cycle; comparing the enumerated actual foreground page number with the secondary screen foreground page reference count; when the actual foreground page number is inconsistent with the secondary screen foreground page reference count, reconstructing the secondary screen foreground page reference count and the foreground page instance set according to the actual foreground page number.

[0017] Secondly, this application provides a system for linking the lifecycles of the main screen and the secondary screen in a dual-screen application, the system comprising: The counting increment / decrement unit is used to maintain the reference count of the secondary screen foreground page and the liveness flag of the main screen within the application process. The secondary screen operation page inherits the unified page base class. When any secondary screen operation page enters the foreground, the unified page base class increments the reference count of the secondary screen foreground page by 1. When any secondary screen operation page leaves the foreground, the unified page base class decrements the reference count of the secondary screen foreground page by 1. The task initiation unit is used to start the polling monitoring task after the main screen display page starts. The polling monitoring task reads the reference count of the secondary screen foreground page according to a preset polling cycle. During the start-up grace period after the main screen display page enters the foreground, the polling monitoring task does not perform an exit judgment. After the start-up grace period ends, when the reference count of the secondary screen foreground page is greater than zero, the polling monitoring task keeps the main screen display page. When the reference count of the secondary screen foreground page is equal to zero, the polling monitoring task starts a zero-count confirmation timer. Only when the duration of the secondary screen foreground page reference count being equal to zero reaches the zero-count confirmation window and has not yet recovered to a value greater than zero, the main screen display page is closed and the main screen survival flag is updated to the closed state. The liveness flag unit is used to read the liveness flag of the main screen every time the secondary screen homepage operation page enters the foreground. When the liveness flag of the main screen indicates that the main screen display page has been closed, the main screen display page is restarted on the main screen according to the main screen display indicator, and the liveness flag of the main screen is updated to live status, so that the main screen display page and the secondary screen operation page of the same digital photo frame are displayed synchronously.

[0018] The method provided in this application has the following beneficial effects: 1. A process-level secondary screen foreground page reference count is adopted to replace the instantaneous Boolean flag, refining the secondary screen foreground state from "whether there is a foreground page" to "the number of foreground pages". When switching between multiple pages within the secondary screen, the count first decreases and then increases. The count state is consistent with the actual foreground situation of the secondary screen page stack, and is naturally compatible with multiple page stacks on the secondary screen of the same device.

[0019] 2. Set a zero-count confirmation window. The main screen will not be closed immediately after the reference count reaches zero. It will only be closed if the zero count state continues to exceed the confirmation window and has not recovered. This tolerates the brief intervals of page switching within the secondary screen and avoids the main screen being mistakenly killed during the page switching process of the secondary screen on the same device.

[0020] 3. Set a grace period for main screen startup. During the grace period after the main screen page enters the foreground, the watchdog will not make an exit judgment. This covers the timing when the main screen recovers before the secondary screen during a cold start and the secondary screen's reference count has not yet been established, thus eliminating startup race conditions during cold starts and page migrations within the same application process.

[0021] 4. Maintain a process-level main screen liveness flag, which is re-detected each time the secondary screen homepage enters the foreground. When the main screen is closed, the main screen display page is automatically restarted on the main screen according to the main screen display flag, ensuring that the main screen will always appear synchronously when the secondary screen returns to the foreground on the same device, thus solving the problem that the main screen cannot be restored when entering the application again.

[0022] 5. Reference counting, liveness flag, and watchdog are all maintained within the same application process on the same dual-screen Android device. They do not rely on cross-device communication, cross-process communication, or system destruction broadcasts. Even in system scenarios where the secondary screen page is only moved to the background and not destroyed, it can still correctly detect exit. The implementation is simple, has good compatibility, and leaves no residue on the main screen after the secondary screen is exited.

[0023] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description

[0024] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0025] Figure 1 This is a schematic flowchart illustrating the steps of a method for linking the lifecycles of the main screen and the secondary screen in a dual-screen application, provided in an embodiment of this application. Figure 2 This is a schematic block diagram of the structure of a digital photo frame provided in one embodiment of this application; Figure 3This is a schematic diagram of a scenario illustrating a method for linking the lifecycles of the main screen and the secondary screen in a dual-screen application, provided in an embodiment of this application. Figure 4 This is a schematic diagram of a scenario illustrating another method for linking the lifecycles of the main screen and the secondary screen in a dual-screen application, provided in an embodiment of this application. Figure 5 This is a schematic diagram of a scenario illustrating another method for linking the lifecycles of the main screen and the secondary screen in a dual-screen application, provided in an embodiment of this application. Figure 6 This is a schematic block diagram of the structure of a system for linking the lifecycles of the main screen and the secondary screen in a dual-screen application, provided in one embodiment of this application. Figure 7 This is a schematic block diagram of another digital photo frame provided in an embodiment of this application.

[0026] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Detailed Implementation

[0027] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0028] The flowchart shown in the attached diagram is for illustrative purposes only and does not necessarily include all content and operations / steps, nor does it necessarily have to be performed in the order described. For example, some operations / steps can be broken down, combined, or partially merged, so the actual execution order may change depending on the actual situation.

[0029] It should be understood that, in order to clearly describe the technical solutions of the embodiments of the present invention, the terms "first" and "second" are used in the embodiments of the present invention to distinguish identical or similar items with essentially the same function and effect. Those skilled in the art will understand that the terms "first" and "second" do not limit the quantity or execution order, and the terms "first" and "second" are not necessarily different.

[0030] It should be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of the application. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.

[0031] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.

[0032] With the development of multi-display Android devices, products such as dual-screen smart photo frames, dual-screen tablets, and in-vehicle dual-screen displays, which combine two screens on a single device, are becoming increasingly popular. These devices feature a large horizontal screen and a small vertical screen on the same body. The large horizontal screen displays photos, videos, and the creation process, while the small vertical screen handles content selection, parameter adjustment, and operation confirmation. The main screen displays the page, while the secondary screen operates on the other.

[0033] In existing Android multi-display implementations, active pages on the two displays of the same device are independent of each other, with no awareness of each other's page lifecycles. The main screen display cannot know the foreground state of the secondary screen's operation page. In actual use, there are issues such as the secondary screen's operation page exiting while the main screen's display page remains displayed, and the main screen's display page failing to resume when the secondary screen re-enters the application. It is difficult to keep the content on the two displays of the same device synchronized.

[0034] One existing linkage method relies on the secondary screen page destruction callback to send a broadcast notification to the main screen to exit. However, in some systems, when the secondary screen application exits, the actual operation is to move the page to the background. The activity page is only moved to the background and not destroyed. As a result, the destruction callback is not triggered, the broadcast cannot be sent, and the main screen display page cannot perceive the exit event.

[0035] Another existing linkage method uses an instantaneous Boolean flag to record whether the secondary screen page is in the foreground. On the one hand, during cold start or secondary screen page migration, the destruction of the old page instance is later than the restoration of the new page instance, and the Boolean flag is incorrectly reset, resulting in a startup race condition. On the other hand, when switching from the first page to the second page within the secondary screen, the callback of the first page leaving the foreground sets the Boolean flag to false. Based on this, the detection logic on the main screen side mistakenly judges that the secondary screen has exited and closes the main screen display page, causing false kills during the page switching process.

[0036] Therefore, a method is urgently needed to solve at least one of the above problems.

[0037] Please refer to Figures 1 to 5 This application provides a method for linking the lifecycles of the main screen and the secondary screen in a dual-screen application, applicable to, for example... Figure 2The digital photo frame shown has two displays: a main screen and a secondary screen. The main screen displays the main content, while the secondary screen displays the secondary content. This method can also be applied to multi-display devices with two screens on the same device, such as dual-screen tablets, in-vehicle dual-screen terminals, and dual-screen POS terminals. The method is executed by the digital photo frame's processor, which calls a computer program stored in memory to implement each step. It should be noted that all information involved in the method provided in this application is extracted with the authorization of the relevant user and in accordance with relevant regulations, and will not infringe on user privacy.

[0038] Please refer to Figure 1 , Figure 1 This application provides a schematic flowchart of a method for linking the lifecycles of the main screen and the secondary screen in a dual-screen application, which includes steps S101 to S103.

[0039] Please refer to Figure 2 , Figure 2 This is a schematic block diagram illustrating the structure of a digital photo frame according to an embodiment of this application. The digital photo frame has two displays on the same body: a main screen and a secondary screen. The main screen is a large, horizontal screen used to display photos, videos, and content creation processes in full screen. The secondary screen is a small, vertical screen used to display operation pages such as content selection, parameter adjustment, and notification confirmation. The main screen and secondary screen are managed by the same application process, which runs the main screen display page and one or more secondary screen operation pages within the application process.

[0040] Please refer to Figures 3 to 5 , Figure 3 , Figure 4 and Figure 5 These are schematic diagrams illustrating scenarios of the lifecycle linkage method between the main screen and the secondary screen in a dual-screen application provided in this application embodiment. Figure 3 This demonstrates a dual-screen synchronous presentation scenario where the secondary screen's homepage operation page is in the foreground, and the main screen displays photos in full screen. Figure 4 This demonstrates a page switching scenario where the main screen displays the page while a notification page pops up inside the secondary screen's operation page. Figure 5 This demonstrates a scenario where a user selects calendar content on the secondary screen, and the main screen displays the calendar details page in tandem.

[0041] The provided method for linking the lifecycles of the main screen and the secondary screen in a dual-screen application includes steps S101 to S103. Details are as follows: Step S101 includes: maintaining the reference count of the secondary screen foreground page and the liveness flag of the main screen within the application process; the secondary screen operation page inherits the unified page base class; when any secondary screen operation page enters the foreground, the unified page base class increments the reference count of the secondary screen foreground page by 1; when any secondary screen operation page leaves the foreground, the unified page base class decrements the reference count of the secondary screen foreground page by 1.

[0042] Specifically, step S101 is the process-level shared state establishment and secondary screen foreground page counting phase. Two shared state variables are created in the application process-level global state object (such as the application instance object or its managed singleton state container): the secondary screen foreground page reference count and the main screen liveness flag. The secondary screen foreground page reference count represents the number of secondary screen operation pages actually in the foreground at the current moment, with an initial value of 0; the main screen liveness flag represents the lifecycle state of the main screen display page, with an initial value of uncreated, updated to liveness after the main screen display page is created and enters the foreground, and updated to closed after the main screen display page is closed.

[0043] All secondary screen operation pages inherit from a unified page base class. This base class encapsulates foreground and foreground entry callback interfaces, and incorporates reference counting logic within these interfaces. Each secondary screen operation page does not need to implement its own linkage code. When any secondary screen operation page enters the foreground (when the foreground entry callback is triggered), the unified page base class increments the foreground page reference count by 1; when any secondary screen operation page leaves the foreground (when the foreground exit callback is triggered), the unified page base class decrements the foreground page reference count by 1. When switching from the first page to the second page within a secondary screen, the first page leaving the foreground decrements the count, and the second page entering the foreground increments it. Outside of the switching interval, the count remains greater than 0. This upgrades the foreground state of the secondary screen from a single boolean judgment of "whether there is a foreground" to a count judgment of "the number of foreground pages," naturally compatible with multi-page stacks and page switching within the secondary screen. The reading and writing of the count are protected by atomic counting operations or synchronization locks, ensuring accurate counting when multiple page objects concurrently call back.

[0044] Step S102. After the main screen display page starts, the polling monitoring task is started. The polling monitoring task reads the reference count of the secondary screen foreground page according to the preset polling cycle. During the start-up grace period after the main screen display page enters the foreground, the polling monitoring task does not perform the exit judgment. After the start-up grace period ends, when the reference count of the secondary screen foreground page is greater than zero, the polling monitoring task keeps the main screen display page. When the reference count of the secondary screen foreground page is equal to zero, the polling monitoring task starts the zero count confirmation timer. Only when the duration of the secondary screen foreground page reference count being equal to zero reaches the zero count confirmation window and has not yet recovered to be greater than zero, the main screen display page is closed and the main screen survival flag is updated to the closed state.

[0045] Specifically, step S102 is the main screen side polling monitoring, start race condition shielding, and zero-count delay confirmation stage. When the main screen display page is created, a polling monitoring task (i.e., the main screen watchdog) is started. The polling monitoring task periodically reads the reference count of the secondary screen foreground page according to a preset polling cycle of 1 second. Each time the main screen display page enters the foreground, a grace period timer is started simultaneously, with a grace period duration of 3 seconds. The grace period is used to cover the timing window during cold starts or secondary screen page migration where "the destruction of the old page instance is later than the restoration of the new page instance". During the grace period, the polling monitoring task only reads and records the count value, does not start the zero-count confirmation timer, and does not close the main screen display page, thereby avoiding false kills caused by startup race conditions.

[0046] After the grace period ends, the polling monitoring task enters normal judgment state: when the count is greater than zero, it indicates that there is still an operation page in the foreground on the secondary screen (including the situation where the new page has been restored during the internal page switching process of the secondary screen), the ongoing zero count confirmation timer is canceled and the main screen display page is maintained; when the count is equal to zero, the main screen is not immediately closed, but the zero count start time is recorded and the zero count confirmation timer is started. The zero count confirmation window lasts for 2 seconds to cover the brief interval when the old page has left and the new page has not yet been restored during the internal page switching of the secondary screen. If the count recovers to a greater than zero during the confirmation timer, the timer is canceled and the zero count duration is cleared; only when the zero count duration reaches 2 seconds and the count is still zero is it determined that the secondary screen has indeed exited, the main screen display page is closed, the polling monitoring task is stopped, and the main screen survival flag is updated to the closed state. For systems where the page is moved to the background without triggering a destruction callback when the secondary screen exits, the count decreases normally with the callback of leaving the foreground, and the main screen can still perceive the exit through the confirmation window, without relying on the destruction callback and broadcast.

[0047] Step S103. Each time the secondary screen homepage operation page enters the foreground, it reads the main screen survival flag. When the main screen survival flag indicates that the main screen display page has been closed, it restarts the main screen display page on the main screen according to the main screen display indicator and updates the main screen survival flag to the survival status, so that the main screen display page and the secondary screen operation page of the same digital photo frame are displayed synchronously.

[0048] Specifically, step S103 is the automatic recovery phase of the main screen when the secondary screen re-enters the application. The secondary screen homepage operation page is the entry page for the secondary screen application. Every time it enters the foreground (including the first launch of the application, the secondary screen application switching back to the foreground from the background, and the user returning to the homepage from a secondary page), it reads the main screen survival flag from the application process-level global state object. When the main screen survival flag is in a closed state or not created state, the secondary screen homepage operation page constructs the page launch parameters for the main screen display page, carrying the main screen display identifier (the monitor number corresponding to the main screen) in the launch parameters. It requests the multi-display management module to create and display the main screen display page on the display screen corresponding to the main screen display identifier through the page launch parameters. After the main screen display page is successfully created and enters the foreground, the polling monitoring task is started, and the main screen survival flag is updated to a live state. Thus, the main screen will always appear synchronously every time the secondary screen returns to the foreground, solving the problem that the main screen cannot be restored when the secondary screen re-enters the application. When the secondary screen operation page is launched for the first time and the main screen survival flag is not created state, the main screen display page is created at the same time as the secondary screen operation page is created, according to the main screen display identifier, realizing the first linkage between the two screens.

[0049] In some embodiments, maintaining the reference count of the secondary screen foreground page and the survival flag of the main screen within the application process, with the secondary screen operation pages inheriting a unified page base class, includes: creating two shared state variables, the secondary screen foreground page reference count and the main screen survival flag, in the application process-level global state object; the initial value of the secondary screen foreground page reference count is 0, and the initial value of the main screen survival flag is an uncreated state; encapsulating the entry and exit callback interfaces in the unified page base class; all secondary screen operation pages inheriting from the unified page base class and reusing the entry and exit callback interfaces; and performing read and write operations on the secondary screen foreground page reference count through atomic counting operations or synchronization locks to ensure that the value of the secondary screen foreground page reference count remains accurate when callbacks from multiple secondary screen operation pages are triggered concurrently.

[0050] Specifically, upon application startup, shared state initialization is completed in the application process-level global state object: an integer reference count for the secondary screen foreground page is created and set to 0; a main screen survival flag is created and set to an uncreated state. The main screen survival flag uses an enumeration to retrieve values, including three states: uncreated, alive, and closed, making it distinguishable between the two scenarios: "the main screen was never created" and "the main screen was created and then closed." The global state object persists with the application process. The main screen display page and all secondary screen operation pages read and write this object through a unified state access interface, without relying on direct references between pages.

[0051] The unified page base class inherits from the system activity page base class. The unified page base class overrides and encapsulates the foreground entry callback interface and the foreground exit callback interface. In addition to calling the count maintenance logic, the interface reserves hooks for subclass business initialization and business release in the form of template methods. All secondary screen operation pages, such as the secondary screen homepage operation page, content selection page, parameter adjustment page, and notification confirmation page, inherit the unified page base class and reuse the callback interface. When adding a new secondary screen page, you only need to inherit the base class and do not need to write the linkage code again, ensuring that the count maintenance logic is consistent across all pages.

[0052] Read and write operations on the reference count of the secondary screen foreground page are performed through atomic counting operations or synchronization locks: atomic increment and atomic decrement methods provided by atomic integer types are used, or an in-process synchronization lock is applied outside the increment and decrement code segment. This ensures that when multiple secondary screen operation pages enter the foreground and leave the foreground are triggered concurrently due to rapid page switching in the system, the increment and decrement operations of the count take effect serially, preventing count loss or negative counts caused by concurrent increment and decrement.

[0053] In some embodiments, the step of incrementing the reference count of the secondary screen's foreground page by 1 when any secondary screen operation page enters the foreground and decrementing the reference count by 1 when any secondary screen operation page leaves the foreground includes: when the entry callback is triggered, the unified page base class first determines whether the page instance identifier of the corresponding secondary screen operation page has been recorded in the foreground page instance collection. If the page instance identifier is not recorded, it adds the page instance identifier to the foreground page instance collection and increments the secondary screen's foreground page reference count by 1; when the exit callback is triggered, the unified page base class removes the corresponding page instance identifier from the foreground page instance collection. If the removal is successful, the secondary screen's foreground page reference count is decremented by 1; if the removal fails, the secondary screen's foreground page reference count remains unchanged; and a lower limit protection is applied to the secondary screen's foreground page reference count to ensure that the value of the secondary screen's foreground page reference count is not less than 0.

[0054] Specifically, to prevent the system from repeatedly triggering the same page instance's foreground entry callback, which could cause an inflated reference count, an additional foreground page instance collection is maintained in the global state object. This collection records the identifiers (unique numbers) of page instances currently included in the reference count. When the unified page base class's foreground entry callback is triggered, it first retrieves the current page instance identifier and checks if it is already recorded in the foreground page instance collection: if not, it adds the page instance identifier to the collection and increments the secondary screen's foreground page reference count by 1; if it is already recorded, it is considered a duplicate callback and is no longer counted repeatedly.

[0055] When the unified page base class is triggered by the foreground departure callback, it attempts to remove the corresponding page instance identifier from the foreground page instance collection. If the deletion is successful (the identifier already existed in the collection), the foreground page reference count on the secondary screen is decremented by 1. If the deletion fails (the identifier does not exist in the collection, indicating that the instance was never counted or has been removed by other processes), the count remains unchanged to avoid duplicate deductions during a single departure. After each decrement, a lower limit protection is implemented. When the count calculation result is less than 0, it is forcibly set to 0, ensuring that the foreground page reference count on the secondary screen is never less than 0. Through "instance collection deduplication and lower limit protection," the reference count strictly corresponds one-to-one with the actual foreground page instances. Even under complex timing sequences such as switching from the first page to the second page within the secondary screen, pop-up page overlay and closure, and rapid page back-and-forth switching, the count can still accurately reflect the number of foreground pages.

[0056] In some embodiments, after the main screen display page starts, a polling monitoring task is initiated. The polling monitoring task reads the reference count of the secondary screen foreground page according to a preset polling period, including: when the main screen display page is created, the polling monitoring task is initiated through a timed task handle; the polling monitoring task runs periodically according to a preset polling period of 1 second; each time the polling monitoring task runs, it reads the current value of the secondary screen foreground page reference count and the main screen liveness flag from the application process-level global state object; when the main screen display page is closed, the polling monitoring task is deregistered and removed, causing the polling monitoring task to stop reading the secondary screen foreground page reference count.

[0057] Specifically, when the main screen display page is created, a polling monitoring task is registered with the application process's scheduled task handler via a scheduled task handle. The polling monitoring task runs periodically at a preset polling cycle of 1 second, that is, the monitoring process is triggered once per second. Each time the polling monitoring task runs, it reads the current value of the secondary screen's foreground page reference count and the main screen's liveness flag from the application process-level global state object, and executes the judgment logic according to the grace period state and confirmation window state described in step S102. By using polling reading instead of direct cross-page calls, the main screen display page does not depend on whether the callback of any secondary screen page is reliably triggered. Even when the secondary screen only executes the callback of moving the page to the background and destroying it without triggering, the main screen can still perceive the secondary screen's status through the count value.

[0058] When the main screen display page is closed (including active closure after zero count confirmation, overall application exit, and system resource reclamation), the polling monitoring task is deregistered and removed via the scheduled task handle, stopping periodic callbacks. This prevents memory leaks caused by the scheduled task still holding page object references after the main screen display page is destroyed, and also avoids invalid polling consuming processor resources. When the main screen display page is restarted, a new polling monitoring task is re-registered. The scheduled task handle is bound to the main screen display page instance; when the page is rebuilt, the old handle is deregistered before registering the new handle to prevent multiple polling tasks from coexisting and causing duplicate judgments.

[0059] In some embodiments, the step of not performing an exit judgment during the startup grace period after the main screen display page enters the foreground includes: starting a grace timer each time the main screen display page enters the foreground, with a startup grace period of 3 seconds; during the startup grace period, the polling monitoring task reads the reference count of the secondary screen foreground page and only records the value, without starting a zero-count confirmation timer or closing the main screen display page; after the grace timer reaches the startup grace period, the polling monitoring task enters a normal judgment state and performs the operation of maintaining the main screen display page or starting a zero-count confirmation timer according to the value of the secondary screen foreground page reference count; the grace timer is restarted when the main screen display page cold starts or restarts.

[0060] Specifically, each time the main screen page enters the foreground, the entry time is recorded and a grace period timer is started. The grace period duration is 3 seconds, which is longer than the maximum time interval during cold starts and secondary screen page migrations where "the old page instance leaves the foreground and the new page instance has not yet recovered." The grace period timer can be implemented by an independent delay task, with a grace period end flag set after the delay expires; alternatively, it can be determined in a polling monitoring task based on the difference between the current time and the entry time.

[0061] During the grace period, the polling monitoring task only writes the value and the time of reading the reference count of the secondary screen's foreground page to the runtime log each time, without starting a zero-count confirmation timer or performing any operation to close the main screen display page; even if the count is briefly zero during this period (the main screen recovers before the secondary screen, or the secondary screen page has not yet completed the foreground switch), the main screen display page remains displayed. After the grace timer reaches 3 seconds, the polling monitoring task enters the normal judgment state and executes according to the rule of maintaining a count greater than zero and starting the confirmation timer when the count equals zero. When the main screen display page is cold-started, restarted after process reconstruction, or restarted from the secondary screen's homepage, the grace timer is restarted and the grace end flag is reset to ensure that each main screen creation obtains a complete startup protection window.

[0062] In some embodiments, after the startup grace period ends, when the reference count of the secondary screen foreground page is greater than zero, the polling monitoring task maintains the main screen display page; when the reference count of the secondary screen foreground page is equal to zero, the polling monitoring task starts a zero-count confirmation timer. Only when the duration of the secondary screen foreground page reference count being equal to zero reaches the zero-count confirmation window and has not yet recovered to a value greater than zero, the main screen display page is closed and the main screen survival flag is updated to the closed state. This includes: after the startup grace period ends, each time the polling monitoring task reads that the reference count of the secondary screen foreground page is greater than zero, the ongoing zero-count confirmation timer is canceled. The system will reset the zero count duration to zero while keeping the main screen display page running. When the polling monitoring task reads that the reference count of the secondary screen foreground page is equal to zero, it will record the start time of the zero count and start the zero count confirmation timer, with the zero count confirmation window lasting for 2 seconds. If the reference count of the secondary screen foreground page recovers to be greater than zero during the zero count confirmation timer, the zero count confirmation timer will be canceled and the zero count duration will be reset to zero. If the zero count duration reaches the zero count confirmation window and the reference count of the secondary screen foreground page is still equal to zero, the main screen display page will be closed, the polling monitoring task will be stopped, and the main screen survival flag will be updated to the closed state.

[0063] Specifically, after the grace period ends, the polling monitoring task maintains the zero-count start time and zero-count confirmation timer status. Each time the polling reads that the reference count of the secondary screen's foreground page is greater than zero, if there was a previously ongoing zero-count confirmation timer, the timer is canceled and the duration of the zero count is cleared. At the same time, the main screen display page continues to run, and the secondary screen page with a count greater than zero indicates that the normal foreground or internal page switching of the secondary screen has been completed.

[0064] When the polling monitoring task reads a count of zero, if the confirmation timer has not yet started, the current time is recorded as the start time of the zero count, and a zero count confirmation timer is started. The duration of the zero count confirmation window is 2 seconds, which is longer than the maximum switching gap when switching between adjacent pages within the secondary screen ("the old page has left, and the new page has not resumed"), and shorter than the residual delay of the main screen that the user can perceive. In each subsequent polling cycle, the count continues to be read: if the count recovers to a greater than zero during the confirmation timer, it is determined to be a page switching gap rather than an exit, the confirmation timer is canceled, and the duration of the zero count is reset to zero. The main screen display page remains unchanged throughout, thereby eliminating false alarms when switching from the first page to the second page within the secondary screen.

[0065] When the zero count lasts for 2 seconds and the count is still zero, it is determined that the secondary screen operation page has been truly exited (including the user exiting the secondary screen application or the secondary screen application being moved to the background by the system and no page is in the foreground). The polling monitoring task calls the main screen display page's closing interface to close the main screen display page, stops and cancels the polling monitoring task through the timed task handle, and updates the main screen's survival flag to the closed state, so that the main screen can be restored when the secondary screen homepage enters the foreground again.

[0066] In some embodiments, the secondary screen homepage operation page reads the main screen survival flag each time it enters the foreground. When the main screen survival flag indicates that the main screen display page is closed, the main screen display page is restarted on the main screen according to the main screen display identifier. This includes: each time the secondary screen homepage operation page enters the foreground, it reads the main screen survival flag from the application process-level global state object; when the main screen survival flag is in a closed state or not created state, it constructs the page startup parameters of the main screen display page, carrying the main screen display identifier in the page startup parameters; it requests the multi-display management module to create and display the main screen display page on the main screen corresponding to the main screen display identifier through the page startup parameters; after the main screen display page is successfully created, it starts a polling monitoring task; when the actual display position of the main screen display page does not match the main screen display identifier, it corrects the display position of the main screen display page according to the main screen display identifier.

[0067] Specifically, the secondary screen homepage operation page adds main screen liveness check logic to the foreground callback: each time it enters the foreground, it reads the main screen liveness flag from the application process-level global state object. If the main screen liveness flag is alive, the main screen is not recreated to avoid multiple main screen display page instances; if the main screen liveness flag is closed (the main screen was closed due to the secondary screen exit) or not created (the application is launching for the first time), the page launch parameters for the main screen display page are constructed, carrying the main screen display identifier in the launch parameters. The main screen display identifier is the monitor number assigned by the system to the landscape large screen.

[0068] The secondary screen's homepage operation page initiates a page creation request to the system's multi-display management module via page startup parameters, requesting the creation and display of the main screen display page on the display screen corresponding to the main screen display identifier. The multi-display management module delivers the main screen display page to the landscape-oriented main screen according to the monitor number. After the main screen display page is successfully created and enters the foreground, it starts a polling monitoring task and initiates a grace period timer. If the system incorrectly creates the main screen display page on the secondary screen or another screen due to the default monitor policy (the actual display position does not match the main screen display identifier), the main screen display page reads its own monitor number after creation and compares it with the main screen display identifier. If they do not match, it re-requests creation with the main screen display identifier until the display position is correct, ensuring that the main screen display page is always presented on the landscape-oriented main screen.

[0069] In some embodiments, updating the main screen survival flag to a live state, so that the main screen display page and the secondary screen operation page of the same digital photo frame are presented synchronously, includes: updating the main screen survival flag to a live state when the main screen display page is created and enters the foreground, and updating the main screen survival flag to a closed state when the main screen display page is closed; when the secondary screen operation page is launched for the first time and the main screen survival flag is not created, creating the main screen display page on the main screen according to the main screen display identifier at the same time as creating the secondary screen operation page, so that the main screen display page and the secondary screen operation page are presented synchronously on the two displays of the same digital photo frame; the polling monitoring task continues to run while the main screen survival flag is in a live state.

[0070] Specifically, the state transition rules for the main screen's liveness flag are as follows: when the application process starts, the main screen's liveness flag is in an uncreated state; it is updated to a live state when the main screen display page is created and enters the foreground; it is updated to a closed state when the main screen display page is closed after zero count confirmation or abnormally destroyed; and it is updated to a live state again after the main screen display page is recreated and enters the foreground. These three states fully cover the main screen's lifecycle. The secondary screen homepage is only created when the flag is in an uncreated or closed state, and remains in its current state when the flag is live, thus avoiding duplicate creation.

[0071] When the secondary screen's operation page is launched for the first time and the primary screen's survival indicator is in an uncreated state, the secondary screen's homepage, while completing its own page creation, requests the multi-display management module to create the primary screen display page on the primary screen according to the primary screen's display indicator. The pages on both displays are created sequentially and presented synchronously within the same launch process: the landscape-oriented large screen enters the photo or content generation process display page, while the portrait-oriented small screen enters the content selection and operation homepage. The polling monitoring task runs continuously while the primary screen's survival indicator is in an active state, and is simultaneously deregistered when the primary screen is closed, ensuring strict alignment between the monitoring cycle and the primary screen's lifecycle.

[0072] In some embodiments, the method further includes: recording the switching interval duration from a value greater than zero to zero and then back to a value greater than zero when the secondary screen operation page switches internally each time; taking the maximum value of the historical switching interval duration and adding a preset margin; dynamically updating the duration of the zero-count confirmation window; recording the startup time from initiating startup to entering the foreground when the main screen display page cold starts or restarts each time; taking the average value of the historical startup time and adding a preset margin; dynamically updating the startup grace period duration; and dynamically adjusting the preset polling cycle according to the change in the secondary screen foreground page reference count read by the polling monitoring task in two adjacent reads; the polling monitoring task enumerates the number of secondary screen operation pages currently actually in the foreground once every preset verification cycle; comparing the enumerated actual foreground page number with the secondary screen foreground page reference count; when the actual foreground page number is inconsistent with the secondary screen foreground page reference count, reconstructing the secondary screen foreground page reference count and the foreground page instance set according to the actual foreground page number.

[0073] Specifically, the adaptive update method for the zero-count confirmation window is as follows: The system records the time interval during each internal page switch in the secondary screen, from when the reference count of the foreground page on the secondary screen changes from greater than zero to equal to zero and then back to greater than zero (i.e., the time difference between the old page leaving the foreground and the new page entering the foreground), forming a sample sequence of switch interval durations. The system takes the maximum value of the historical switch interval durations and adds a preset margin (e.g., 20% of the maximum interval duration as a margin), dynamically updating the duration of the zero-count confirmation window to ensure that the confirmation window is always greater than the actual page switch interval, while avoiding a fixed window length that would cause slow response when exiting the main screen. The weaker the device performance and the more complex the page, the longer the measured switch interval, and the wider the confirmation window will automatically become.

[0074] The adaptive update method for the startup grace period is as follows: record the startup time from initiating the startup request to the page entering the foreground during each cold start or restart of the main screen display page, take the average of the historical startup time and add a preset margin as the startup grace period length to ensure that the grace period covers the vast majority of startup sequences; at the same time, dynamically adjust the preset polling cycle according to the change in the secondary screen foreground page reference count read by the polling monitoring task in two adjacent reads: when the count is stable for a long time, appropriately extend the polling cycle to reduce processor overhead, and shorten the polling cycle to improve response speed when the count changes frequently (users frequently switch pages), and adjust the polling cycle between the preset minimum value and the preset maximum value.

[0075] The consistency verification method for counting is as follows: Every time the polling monitoring task completes a preset verification cycle (e.g., every 30 polling cycles), it enumerates the number of secondary screen operation pages that are currently in the foreground and belong to this application through the system page management interface. The enumerated number of actual foreground pages is compared with the secondary screen foreground page reference count. If the two are consistent, the status quo is maintained. If they are inconsistent (in extreme cases, the system callback is lost or the page is abnormally reclaimed by the system), the enumeration result is used as the standard. The secondary screen foreground page reference count is reconstructed according to the actual number of foreground pages, and the foreground page instance set is reconstructed with the foreground page instance list. This allows the shared state to automatically recover from the anomaly and ensures that the counting is accurate under long-term operation.

[0076] In some embodiments, please refer to Figure 2 The digital photo frame features a main screen in landscape mode and a secondary screen in portrait mode, both managed by the same application process. Within this application process, the main screen displays the page, the secondary screen's homepage operation page, and several secondary screen operation pages run. The application process-level global state object maintains a reference count for the secondary screen's foreground pages, a collection of foreground page instances, and a main screen liveness flag. All secondary screen operation pages inherit from a unified page base class that encapsulates foreground and foreground callback interfaces. When the main screen displays the page, a polling monitoring task with a 1-second cycle is initiated. Each time the main screen displays the page enters the foreground, a 3-second grace period is set. Once the secondary screen's foreground page reference count reaches zero, a 2-second zero-count confirmation window is displayed.

[0077] Please refer to Figure 3 In a dual-screen synchronous display scenario, the user launches the application on the secondary screen, and the secondary screen's homepage operation page enters the foreground. Upon entering the foreground, a callback checks if the page instance identifier is recorded in the foreground page instance set. If so, the identifier is added to the set, and the secondary screen's foreground page reference count changes from 0 to 1. Simultaneously, the secondary screen's homepage reads the main screen's liveness flag. If the flag is in an uncreated state, page launch parameters carrying the main screen's display identifier are constructed, requesting the multi-display management module to create the main screen display page on the landscape-oriented large screen. After the main screen display page is created and enters the foreground, the main screen's liveness flag is updated to live status. The main screen displays the photo content in full screen, while the secondary screen displays homepage content such as the clock, weather, and calendar cards. The main screen display page and the secondary screen's homepage operation page are presented synchronously on both displays. During the 3-second grace period after the main screen starts, the polling monitoring task does not execute the exit judgment, shielding the count fluctuations caused by the cold start sequence.

[0078] Please refer to Figure 4In scenarios involving switching within the secondary screen, a notification confirmation page (e.g., a content transfer notification offering "Remind Me Later" and "View Details") pops up on the secondary screen's homepage. When the homepage leaves the foreground, a callback decrements the secondary screen's foreground reference count by 1. When the notification confirmation page enters the foreground, a callback increments the count by 1. Between these callbacks, the count may briefly drop to 0. When the polling monitoring task detects a count of 0, it starts a zero-count confirmation timer. Within a 2-second confirmation window, the count recovers to a value greater than 0 as the notification confirmation page enters the foreground. The polling monitoring task then cancels the confirmation timer and resets the zero-count duration. The main screen displays the photo in full screen, preventing false alarms. When the user closes the notification confirmation page and returns to the homepage, the count undergoes the same decrement and increment process, and the main screen remains displayed. Switching between any pages within the secondary screen, such as from the content selection page to the parameter adjustment page, or from the parameter adjustment page to the operation confirmation page, is handled in the same manner.

[0079] Please refer to Figure 5 In scenarios where secondary screen operations and main screen content are linked, when a user selects a date or schedule on a calendar card on the secondary screen, the secondary screen sends a content display event to the main screen display page within the same application process. The main screen display page then switches from displaying photos to displaying the corresponding date's calendar month view and schedule details, while the secondary screen keeps the calendar operation card in the foreground. In this scenario, the secondary screen always has an operation page in the foreground, the secondary screen's foreground page reference count is consistently greater than 0, the polling monitoring task keeps the main screen display page running, and the main screen display content updates in sync with the secondary screen operations.

[0080] In the secondary screen exit scenario, when the user exits the secondary screen application or the secondary screen application is moved to the background by the system's execution page, all secondary screen operation pages leave the foreground, and the secondary screen foreground page reference count drops to 0. Since the secondary screen page may only be moved to the background and not destroyed, the destruction callback is not triggered and the exit broadcast is not sent, but the leave foreground callback has been executed normally. After the polling monitoring task reads that the count is 0, it starts the zero count confirmation timer. If the count does not recover to a value greater than 0 within 2 seconds of the confirmation window, the polling monitoring task closes the main screen display page, logs out of itself, and updates the main screen survival flag to the closed state, and the main screen no longer leaves any display.

[0081] When the user re-enters the secondary screen, they either reopen the secondary screen application or switch it back to the foreground. The secondary screen's homepage then enters the foreground and reads the main screen's survival flag. If the flag is closed, the main screen is recreated on the landscape screen according to the main screen's display indicator. Once the main screen enters the foreground, a polling monitoring task is initiated, and the main screen's survival flag is updated to show a live status. Both screens are then restored and presented synchronously. Through the combination of process-level reference counting, a startup grace period, a zero-count confirmation window, and a re-check of the main screen's survival flag, the digital photo frame achieves "synchronous appearance of the main screen when the secondary screen is opened, the main screen remaining in the foreground (including internal page switching), the main screen exiting when the secondary screen exits, and automatic restoration when the secondary screen re-enters the main screen," without relying on destruction callbacks or broadcasts. Cold start race conditions and page switching false kills are eliminated.

[0082] In some embodiments, the method further includes a cross-process counting synchronization process when the main screen display page and the secondary screen operation page belong to different processes: when the main screen display page runs in an independent display process, an inter-process state synchronization channel is established between the application main process and the display process. The application main process uniformly maintains the reference count of the secondary screen foreground page and the main screen liveness flag. The count changes and flag changes are synchronized to the display process in real time through the inter-process state synchronization channel. The polling monitoring task of the display process performs an exit determination based on the synchronized count.

[0083] Specifically, on some devices, the main screen display page runs in an independent display process (e.g., a display process specifically for handling photo and video rendering), while the secondary screen operation page runs in the application's main process. These two processes cannot directly share the reference count in memory. In some embodiments, the application's main process acts as the sole maintainer of the reference count, storing the increment and decrement results of the unified page base class's count in the main process's global state object. An inter-process state synchronization channel is established between the main process and the display process (e.g., a binding service, message bus, or inter-process state sharing component). Every change in the secondary screen's foreground page reference count, every migration of the main screen's liveness flag, and the zero-count confirmation timer are pushed to the display process in real-time via messages. The display process caches the most recent synchronization state, which is then read by a polling monitoring task.

[0084] When the inter-process channel is disconnected, the presentation process maintains the main screen display according to the last synchronization state before the disconnection and requests the main process to resend the full state. After reconnection, the local cache is corrected based on the full state of the main process to avoid main screen flickering or accidental closure caused by channel jitter. When the main process exits, it sends an exit message to the presentation process, which then closes the main screen display page accordingly. Cross-process synchronization makes the process-level reference counting scheme applicable in multi-process dual-screen architectures as well, and the counting maintenance logic still exists only in a unified page base class.

[0085] In some embodiments, the method further includes a linkage state recovery process after the application process is reclaimed by the system: the reference count of the secondary screen foreground page, the set of foreground page instances and the main screen survival flag are written to persistent storage according to a preset persistence period. After the application process is rebuilt, the persistent state is read and the shared state is restored in combination with the current actual foreground page enumeration result, so that the dual-screen linkage relationship is automatically rebuilt after the process is abnormally rebuilt.

[0086] Specifically, when dual-screen devices are experiencing memory shortages, the system may reclaim application processes. After the process is rebuilt, the reference count and the main screen's liveness flag in memory are lost. If this is not addressed, issues may arise such as the secondary screen page recovering but the main screen not appearing, or the main screen being recreated. In some embodiments, the application process writes the secondary screen's foreground page reference count, the set of foreground page instances (represented by page type identifiers), and the main screen's liveness flag to persistent storage at a preset persistence period (such as after each count change or every few polling cycles). The written content also includes a timestamp.

[0087] After the application process is rebuilt, the secondary screen homepage operation page first reads the persistent state, and then enumerates the actual display states of the secondary screen page and the main screen page that are currently in the foreground through the system page management interface. The persistent state is corrected based on the enumeration results: if the secondary screen page is in the foreground but the main screen does not exist, the main screen display page is recreated according to the main screen display identifier; if both the main screen and the secondary screen are in the foreground, the flag is set to live and the polling monitoring task is resumed; if no page is in the foreground on the secondary screen, the main screen remains closed. After the state is restored, the old persistent state is cleared or marked to prevent expired states from being reused, ensuring that the dual-screen linkage relationship can still be automatically rebuilt in abnormal scenarios such as process kill and restart or system upgrade and restart.

[0088] In some embodiments, the method further includes a group counting extension process for three or more displays or external displays: maintaining an independent foreground page reference count and display screen liveness flag for each operable display screen according to the display screen number; the maintenance and closing of the main screen display page is determined by the group count of its associated operable screen; and dynamically creating or deregistering the corresponding group when an external display screen is connected or disconnected.

[0089] Specifically, when a device is configured with three or more displays (such as a large landscape screen, a small portrait screen, and a top information screen), or supports connecting external displays via an external interface, a single global counter cannot distinguish the foreground state of each screen. In some embodiments, the unified page base class, in addition to maintaining the page instance identifier when a page enters or leaves the foreground, also records the display screen number where the page is located; the global state object maintains an independent foreground page reference count, a foreground page instance set, and a display screen liveness flag for each operable display screen according to the display screen number, and a pre-established association relationship between the display page and the operable screen (e.g., the landscape main screen is associated with the portrait operable screen, and the top information screen is associated with another operable screen).

[0090] The polling monitoring task reads the counts of the corresponding operation screen groups according to their associations and performs a keep-or-close decision. When an operation screen exits, only the display page associated with it is closed, without affecting other screen groups. When an external display screen is connected, the system calls back to notify the application. The application dynamically creates a counting group according to the external screen number and creates a corresponding display page on that screen. When the external display screen is unplugged, the corresponding group is deregistered and the page is released. Group counting allows the process-level reference counting scheme to naturally extend from dual-screen to multi-screen and hot-swappable scenarios, with each screen working together without interference.

[0091] In some embodiments, the method further includes a low-power monitoring process that combines polling with lifecycle event-driven processes: when the count change event of the secondary screen page entering or leaving the foreground is triggered, the main screen side is actively notified to refresh the judgment result; when there is no count change and the user does not operate, the polling frequency is reduced or polling is paused; and fixed-cycle polling is resumed in the zero-count confirmation window, thereby reducing processor usage and power consumption while ensuring the real-time nature of the exit judgment.

[0092] Specifically, a fixed 1-second polling cycle continuously wakes up the processor and increases power consumption when the secondary screen remains in the foreground for extended periods and the count remains constant. In some embodiments, a hybrid monitoring approach of "event-driven as the primary method and low-frequency polling as a fallback" is adopted: When the count of the unified page base class changes (increments or decrements), in addition to updating the global state, it sends a count change event to the main screen. Upon receiving the event, the main screen polling monitoring task immediately performs a judgment and resets the zero-count confirmation timer, allowing critical timing events such as page switching and exiting to respond without waiting for the next polling cycle. When no count change event is received and the user does not operate, the polling monitoring task enters a low-frequency mode, extending the polling cycle from 1 second to several seconds or pausing polling, retaining only the broadcast of system foreground state changes as the wake-up source.

[0093] When the count reaches 0, the fixed-cycle polling is immediately resumed to accurately time the zero-count confirmation window, ensuring the 2-second accuracy of the exit judgment; the fixed-cycle timing is also maintained during the start-up grace period. For constantly powered display devices such as digital photo frames, in scenarios where photos are displayed for extended periods and the secondary screen is unattended, hybrid monitoring significantly reduces the number of processor wake-ups and overall standby power consumption, while the real-time response to exit and page-switching scenarios remains unaffected.

[0094] In some embodiments, the method further includes a count rebinding process during display mode switching and page migration: when the device switches between independent dual display mode and mirror mode, or when the secondary screen operation page migrates between displays, the exit determination is paused, the foreground page instance set is re-established according to the page that is actually in the foreground on each display after the switch and the reference count is reset, and the polling determination is resumed after the switch is completed.

[0095] Specifically, dual-screen devices support independent dual-display mode (two screens displaying different pages) and mirror mode (two screens displaying the same content). When switching modes or when a user drags a page from one display to another, the page goes through a process of leaving the original display and then resuming on the new display. During this process, the triggering order of the foreground callback and the foreground callback may be interleaved, which can easily cause momentary counting errors. In some embodiments, when the system detects a display mode switch or cross-screen page migration, it sends a migration start event to the global state object. After the polling monitoring task receives the event, it enters a migration protection state: in the migration protection state, the exit judgment and zero count confirmation timing are paused, and the main screen shutdown operation outside the grace period is blocked.

[0096] After the migration is complete, the global state object enumerates the application pages that are actually in the foreground on each display screen after the switch through the system page management interface. It then re-establishes the foreground page instance set according to the page instance identifier and the display screen number, resets the foreground page reference count on the secondary screen to the actual number of foreground pages, and restarts the main screen startup grace period timer. After the enumeration is complete and the grace period ends, normal polling and judgment resume. Therefore, system-level reconstruction processes such as display mode switching and cross-screen drag migration will not cause the main screen to be accidentally closed or the dual-screen state to be disordered.

[0097] In some embodiments, the method further includes a synchronization process for the linkage status of the secondary screen operation content and the main screen display content: In addition to the counting maintenance of the unified page base class, the secondary screen operation page sends a content identifier and display instruction to the main screen display page through the content event channel in the application process. The main screen display page switches the display content according to the content identifier, and restores the display content before closing according to the current page state of the secondary screen when the main screen is closed and recreated.

[0098] Specifically, dual-screen interaction includes not only page lifecycle linkage but also the linkage between operation content and displayed content. In some embodiments, when the user selects a photo, selects a calendar date, adjusts display parameters, or confirms the generation task, the secondary screen operation page sends a content event to the main screen display page through the content event channel within the application process. The content event carries a content identifier, content type, and display parameters. The main screen display page switches the full-screen display content according to the content identifier (e.g., switching from a photo in the photo list to a full-screen display of that photo, switching from a clock card to the calendar details of the corresponding date, or displaying the content generation process screen). Figure 5 The diagram shows the correspondence between the secondary screen calendar operations and the main screen calendar details.

[0099] When the main screen is closed due to the secondary screen exiting, the global state object records the last displayed content identifier before closure. When the secondary screen re-enters and the main screen is recreated, the main screen reads this content identifier and restores the displayed content before closure (users can also set it to restore the default homepage content), ensuring that the display context is not lost when the main screen resumes. Content events are only handled when the secondary screen's foreground page reference count is greater than 0 and the main screen's liveness flag is active. When the secondary screen has no foreground page, the main screen does not respond to display commands from unknown sources, ensuring consistency between content linkage and lifecycle linkage states.

[0100] 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.

[0101] Please see Figure 6 As shown, Figure 6 This is a schematic diagram of the structure of the main screen and secondary screen lifecycle linkage system 200 in a dual-screen application provided in this application embodiment. This main screen and secondary screen lifecycle linkage system 200 is used to execute the steps of the main screen and secondary screen lifecycle linkage method shown in the above embodiments. The main screen and secondary screen lifecycle linkage system 200 can be a single server or a server cluster, or it can be a terminal, such as a handheld terminal, laptop computer, wearable device, or robot.

[0102] like Figure 6 As shown, the main screen and secondary screen lifecycle linkage system 200 in a dual-screen application includes: The counting unit 201 is used to maintain the reference count of the secondary screen foreground page and the liveness flag of the main screen within the application process. The secondary screen operation page inherits the unified page base class. When any secondary screen operation page enters the foreground, the unified page base class increments the reference count of the secondary screen foreground page by 1. When any secondary screen operation page leaves the foreground, the unified page base class decrements the reference count of the secondary screen foreground page by 1. Task initiation unit 202 is used to initiate a polling monitoring task after the main screen display page starts. The polling monitoring task reads the reference count of the secondary screen foreground page according to a preset polling cycle. During the start-up grace period after the main screen display page enters the foreground, the polling monitoring task does not perform an exit judgment. After the start-up grace period ends, when the reference count of the secondary screen foreground page is greater than zero, the polling monitoring task keeps the main screen display page. When the reference count of the secondary screen foreground page is equal to zero, the polling monitoring task starts a zero-count confirmation timer. Only when the duration of the secondary screen foreground page reference count being equal to zero reaches the zero-count confirmation window and has not yet recovered to a value greater than zero, the main screen display page is closed and the main screen survival flag is updated to the closed state. The liveness flag unit 203 is used to read the liveness flag of the main screen each time the secondary screen homepage operation page enters the foreground. When the liveness flag of the main screen indicates that the main screen display page has been closed, the main screen display page is restarted on the main screen according to the main screen display indicator, and the liveness flag of the main screen is updated to live status, so that the main screen display page and the secondary screen operation page of the same digital photo frame are presented synchronously.

[0103] In some embodiments, maintaining the reference count of the secondary screen foreground page and the survival flag of the main screen within the application process, with the secondary screen operation pages inheriting a unified page base class, includes: creating two shared state variables, the secondary screen foreground page reference count and the main screen survival flag, in the application process-level global state object; the initial value of the secondary screen foreground page reference count is 0, and the initial value of the main screen survival flag is an uncreated state; encapsulating the entry and exit callback interfaces in the unified page base class; all secondary screen operation pages inheriting from the unified page base class and reusing the entry and exit callback interfaces; and performing read and write operations on the secondary screen foreground page reference count through atomic counting operations or synchronization locks to ensure that the value of the secondary screen foreground page reference count remains accurate when callbacks from multiple secondary screen operation pages are triggered concurrently.

[0104] In some embodiments, the step of incrementing the reference count of the secondary screen's foreground page by 1 when any secondary screen operation page enters the foreground and decrementing the reference count by 1 when any secondary screen operation page leaves the foreground includes: when the entry callback is triggered, the unified page base class first determines whether the page instance identifier of the corresponding secondary screen operation page has been recorded in the foreground page instance collection. If the page instance identifier is not recorded, it adds the page instance identifier to the foreground page instance collection and increments the secondary screen's foreground page reference count by 1; when the exit callback is triggered, the unified page base class removes the corresponding page instance identifier from the foreground page instance collection. If the removal is successful, the secondary screen's foreground page reference count is decremented by 1; if the removal fails, the secondary screen's foreground page reference count remains unchanged; and a lower limit protection is applied to the secondary screen's foreground page reference count to ensure that the value of the secondary screen's foreground page reference count is not less than 0.

[0105] In some embodiments, after the main screen display page starts, a polling monitoring task is initiated. The polling monitoring task reads the reference count of the secondary screen foreground page according to a preset polling period, including: when the main screen display page is created, the polling monitoring task is initiated through a timed task handle; the polling monitoring task runs periodically according to a preset polling period of 1 second; each time the polling monitoring task runs, it reads the current value of the secondary screen foreground page reference count and the main screen liveness flag from the application process-level global state object; when the main screen display page is closed, the polling monitoring task is deregistered and removed, causing the polling monitoring task to stop reading the secondary screen foreground page reference count.

[0106] In some embodiments, the step of not performing an exit judgment during the startup grace period after the main screen display page enters the foreground includes: starting a grace timer each time the main screen display page enters the foreground, with a startup grace period of 3 seconds; during the startup grace period, the polling monitoring task reads the reference count of the secondary screen foreground page and only records the value, without starting a zero-count confirmation timer or closing the main screen display page; after the grace timer reaches the startup grace period, the polling monitoring task enters a normal judgment state and performs the operation of maintaining the main screen display page or starting a zero-count confirmation timer according to the value of the secondary screen foreground page reference count; the grace timer is restarted when the main screen display page cold starts or restarts.

[0107] In some embodiments, after the startup grace period ends, when the reference count of the secondary screen foreground page is greater than zero, the polling monitoring task maintains the main screen display page; when the reference count of the secondary screen foreground page is equal to zero, the polling monitoring task starts a zero-count confirmation timer. Only when the duration of the secondary screen foreground page reference count being equal to zero reaches the zero-count confirmation window and has not yet recovered to a value greater than zero, the main screen display page is closed and the main screen survival flag is updated to the closed state. This includes: after the startup grace period ends, each time the polling monitoring task reads that the reference count of the secondary screen foreground page is greater than zero, the ongoing zero-count confirmation timer is canceled. The system will reset the zero count duration to zero while keeping the main screen display page running. When the polling monitoring task reads that the reference count of the secondary screen foreground page is equal to zero, it will record the start time of the zero count and start the zero count confirmation timer, with the zero count confirmation window lasting for 2 seconds. If the reference count of the secondary screen foreground page recovers to be greater than zero during the zero count confirmation timer, the zero count confirmation timer will be canceled and the zero count duration will be reset to zero. If the zero count duration reaches the zero count confirmation window and the reference count of the secondary screen foreground page is still equal to zero, the main screen display page will be closed, the polling monitoring task will be stopped, and the main screen survival flag will be updated to the closed state.

[0108] In some embodiments, the secondary screen homepage operation page reads the main screen survival flag each time it enters the foreground. When the main screen survival flag indicates that the main screen display page is closed, the main screen display page is restarted on the main screen according to the main screen display identifier. This includes: each time the secondary screen homepage operation page enters the foreground, it reads the main screen survival flag from the application process-level global state object; when the main screen survival flag is in a closed state or not created state, it constructs the page startup parameters of the main screen display page, carrying the main screen display identifier in the page startup parameters; it requests the multi-display management module to create and display the main screen display page on the main screen corresponding to the main screen display identifier through the page startup parameters; after the main screen display page is successfully created, it starts a polling monitoring task; when the actual display position of the main screen display page does not match the main screen display identifier, it corrects the display position of the main screen display page according to the main screen display identifier.

[0109] In some embodiments, updating the main screen survival flag to a live state, so that the main screen display page and the secondary screen operation page of the same digital photo frame are presented synchronously, includes: updating the main screen survival flag to a live state when the main screen display page is created and enters the foreground, and updating the main screen survival flag to a closed state when the main screen display page is closed; when the secondary screen operation page is launched for the first time and the main screen survival flag is not created, creating the main screen display page on the main screen according to the main screen display identifier at the same time as creating the secondary screen operation page, so that the main screen display page and the secondary screen operation page are presented synchronously on the two displays of the same digital photo frame; the polling monitoring task continues to run while the main screen survival flag is in a live state.

[0110] In some embodiments, the method further includes: recording the switching interval duration from a value greater than zero to zero and then back to a value greater than zero when the secondary screen operation page switches internally each time; taking the maximum value of the historical switching interval duration and adding a preset margin; dynamically updating the duration of the zero-count confirmation window; recording the startup time from initiating startup to entering the foreground when the main screen display page cold starts or restarts each time; taking the average value of the historical startup time and adding a preset margin; dynamically updating the startup grace period duration; and dynamically adjusting the preset polling cycle according to the change in the secondary screen foreground page reference count read by the polling monitoring task in two adjacent reads; the polling monitoring task enumerates the number of secondary screen operation pages currently actually in the foreground once every preset verification cycle; comparing the enumerated actual foreground page number with the secondary screen foreground page reference count; when the actual foreground page number is inconsistent with the secondary screen foreground page reference count, reconstructing the secondary screen foreground page reference count and the foreground page instance set according to the actual foreground page number.

[0111] It should be noted that, for the sake of convenience and brevity, the specific working process of the main screen and secondary screen lifecycle linkage system and each module in the dual-screen application described above can be referred to the corresponding content in the various embodiments of the main screen and secondary screen lifecycle linkage method in the dual-screen application described above, and will not be repeated here.

[0112] The aforementioned method for linking the lifecycles of the main screen and the secondary screen in a dual-screen application can be implemented as a computer program, which can, for example... Figure 6 It runs on the system shown.

[0113] Please see Figure 7 , Figure 7 This is a schematic block diagram of the structure of a digital photo frame provided in an embodiment of this application. The digital photo frame includes a processor, a memory, and a network interface connected via a device bus, wherein the memory may include a storage medium and internal memory.

[0114] The storage medium can store operating devices and computer programs. These computer programs include program instructions that, when executed, cause the processor to perform any method for linking the lifecycles of the primary and secondary screens in a dual-screen application.

[0115] The processor provides computing and control capabilities to support the operation of the entire digital photo frame.

[0116] Internal memory provides an environment for the execution of computer programs in non-volatile storage media. When the computer program is executed by the processor, it enables the processor to execute any method of linking the lifecycles of the main screen and the secondary screen in a dual-screen application.

[0117] This network interface is used for network communication, such as sending assigned tasks. Those skilled in the art will understand that... Figure 7 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the terminal to which the present application is applied. A specific digital photo frame may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0118] It should be understood that the processor can be a Central Processing Unit (CPU), but it can also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among these, a general-purpose processor can be a microprocessor or any conventional processor.

[0119] In one embodiment, the processor is configured to run a computer program stored in memory to perform the following steps: Within the application process, maintain the reference count of the secondary screen foreground page and the liveness flag of the main screen. The secondary screen operation page inherits the unified page base class. When any secondary screen operation page enters the foreground, the unified page base class increments the reference count of the secondary screen foreground page by 1. When any secondary screen operation page leaves the foreground, the unified page base class decrements the reference count of the secondary screen foreground page by 1. After the main screen display page starts, a polling monitoring task is initiated. The polling monitoring task reads the reference count of the secondary screen foreground page according to a preset polling cycle. During the startup grace period after the main screen display page enters the foreground, the polling monitoring task does not perform an exit judgment. After the startup grace period ends, when the reference count of the secondary screen foreground page is greater than zero, the polling monitoring task keeps the main screen display page running. When the reference count of the secondary screen foreground page is equal to zero, the polling monitoring task starts a zero count confirmation timer. Only when the duration of the secondary screen foreground page reference count being equal to zero reaches the zero count confirmation window and has not yet recovered to a value greater than zero, the main screen display page is closed and the main screen survival flag is updated to the closed state. Each time the secondary screen homepage operation page enters the foreground, it reads the main screen's survival flag. When the main screen's survival flag indicates that the main screen display page has been closed, it restarts the main screen display page on the main screen according to the main screen display indicator and updates the main screen's survival flag to a survival status, so that the main screen display page and the secondary screen operation page of the same digital photo frame are displayed synchronously.

[0120] In some embodiments, maintaining the reference count of the secondary screen foreground page and the survival flag of the main screen within the application process, with the secondary screen operation pages inheriting a unified page base class, includes: creating two shared state variables, the secondary screen foreground page reference count and the main screen survival flag, in the application process-level global state object; the initial value of the secondary screen foreground page reference count is 0, and the initial value of the main screen survival flag is an uncreated state; encapsulating the entry and exit callback interfaces in the unified page base class; all secondary screen operation pages inheriting from the unified page base class and reusing the entry and exit callback interfaces; and performing read and write operations on the secondary screen foreground page reference count through atomic counting operations or synchronization locks to ensure that the value of the secondary screen foreground page reference count remains accurate when callbacks from multiple secondary screen operation pages are triggered concurrently.

[0121] In some embodiments, the step of incrementing the reference count of the secondary screen's foreground page by 1 when any secondary screen operation page enters the foreground and decrementing the reference count by 1 when any secondary screen operation page leaves the foreground includes: when the entry callback is triggered, the unified page base class first determines whether the page instance identifier of the corresponding secondary screen operation page has been recorded in the foreground page instance collection. If the page instance identifier is not recorded, it adds the page instance identifier to the foreground page instance collection and increments the secondary screen's foreground page reference count by 1; when the exit callback is triggered, the unified page base class removes the corresponding page instance identifier from the foreground page instance collection. If the removal is successful, the secondary screen's foreground page reference count is decremented by 1; if the removal fails, the secondary screen's foreground page reference count remains unchanged; and a lower limit protection is applied to the secondary screen's foreground page reference count to ensure that the value of the secondary screen's foreground page reference count is not less than 0.

[0122] In some embodiments, after the main screen display page starts, a polling monitoring task is initiated. The polling monitoring task reads the reference count of the secondary screen foreground page according to a preset polling period, including: when the main screen display page is created, the polling monitoring task is initiated through a timed task handle; the polling monitoring task runs periodically according to a preset polling period of 1 second; each time the polling monitoring task runs, it reads the current value of the secondary screen foreground page reference count and the main screen liveness flag from the application process-level global state object; when the main screen display page is closed, the polling monitoring task is deregistered and removed, causing the polling monitoring task to stop reading the secondary screen foreground page reference count.

[0123] In some embodiments, the step of not performing an exit judgment during the startup grace period after the main screen display page enters the foreground includes: starting a grace timer each time the main screen display page enters the foreground, with a startup grace period of 3 seconds; during the startup grace period, the polling monitoring task reads the reference count of the secondary screen foreground page and only records the value, without starting a zero-count confirmation timer or closing the main screen display page; after the grace timer reaches the startup grace period, the polling monitoring task enters a normal judgment state and performs the operation of maintaining the main screen display page or starting a zero-count confirmation timer according to the value of the secondary screen foreground page reference count; the grace timer is restarted when the main screen display page cold starts or restarts.

[0124] In some embodiments, after the startup grace period ends, when the reference count of the secondary screen foreground page is greater than zero, the polling monitoring task maintains the main screen display page; when the reference count of the secondary screen foreground page is equal to zero, the polling monitoring task starts a zero-count confirmation timer. Only when the duration of the secondary screen foreground page reference count being equal to zero reaches the zero-count confirmation window and has not yet recovered to a value greater than zero, the main screen display page is closed and the main screen survival flag is updated to the closed state. This includes: after the startup grace period ends, each time the polling monitoring task reads that the reference count of the secondary screen foreground page is greater than zero, the ongoing zero-count confirmation timer is canceled. The system will reset the zero count duration to zero while keeping the main screen display page running. When the polling monitoring task reads that the reference count of the secondary screen foreground page is equal to zero, it will record the start time of the zero count and start the zero count confirmation timer, with the zero count confirmation window lasting for 2 seconds. If the reference count of the secondary screen foreground page recovers to be greater than zero during the zero count confirmation timer, the zero count confirmation timer will be canceled and the zero count duration will be reset to zero. If the zero count duration reaches the zero count confirmation window and the reference count of the secondary screen foreground page is still equal to zero, the main screen display page will be closed, the polling monitoring task will be stopped, and the main screen survival flag will be updated to the closed state.

[0125] In some embodiments, the secondary screen homepage operation page reads the main screen survival flag each time it enters the foreground. When the main screen survival flag indicates that the main screen display page is closed, the main screen display page is restarted on the main screen according to the main screen display identifier. This includes: each time the secondary screen homepage operation page enters the foreground, it reads the main screen survival flag from the application process-level global state object; when the main screen survival flag is in a closed state or not created state, it constructs the page startup parameters of the main screen display page, carrying the main screen display identifier in the page startup parameters; it requests the multi-display management module to create and display the main screen display page on the main screen corresponding to the main screen display identifier through the page startup parameters; after the main screen display page is successfully created, it starts a polling monitoring task; when the actual display position of the main screen display page does not match the main screen display identifier, it corrects the display position of the main screen display page according to the main screen display identifier.

[0126] In some embodiments, updating the main screen survival flag to a live state, so that the main screen display page and the secondary screen operation page of the same digital photo frame are presented synchronously, includes: updating the main screen survival flag to a live state when the main screen display page is created and enters the foreground, and updating the main screen survival flag to a closed state when the main screen display page is closed; when the secondary screen operation page is launched for the first time and the main screen survival flag is not created, creating the main screen display page on the main screen according to the main screen display identifier at the same time as creating the secondary screen operation page, so that the main screen display page and the secondary screen operation page are presented synchronously on the two displays of the same digital photo frame; the polling monitoring task continues to run while the main screen survival flag is in a live state.

[0127] In some embodiments, the method further includes: recording the switching interval duration from a value greater than zero to zero and then back to a value greater than zero when the secondary screen operation page switches internally each time; taking the maximum value of the historical switching interval duration and adding a preset margin; dynamically updating the duration of the zero-count confirmation window; recording the startup time from initiating startup to entering the foreground when the main screen display page cold starts or restarts each time; taking the average value of the historical startup time and adding a preset margin; dynamically updating the startup grace period duration; and dynamically adjusting the preset polling cycle according to the change in the secondary screen foreground page reference count read by the polling monitoring task in two adjacent reads; the polling monitoring task enumerates the number of secondary screen operation pages currently actually in the foreground once every preset verification cycle; comparing the enumerated actual foreground page number with the secondary screen foreground page reference count; when the actual foreground page number is inconsistent with the secondary screen foreground page reference count, reconstructing the secondary screen foreground page reference count and the foreground page instance set according to the actual foreground page number.

[0128] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, causes the processor to implement the steps of the method for linking the lifecycles of the main screen and the secondary screen in a dual-screen application as provided in any embodiment of this application.

[0129] The computer-readable storage medium can be the internal storage unit of the digital photo frame described in the foregoing embodiments, such as the hard drive or memory of the digital photo frame. Alternatively, the computer-readable storage medium can be an external storage device of the digital photo frame, such as a plug-in hard drive, Smart Media Card (SMC), Secure Digital (SD) card, or Flash Card equipped on the digital photo frame.

[0130] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered 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 linking the lifecycles of the main screen and the secondary screen in a dual-screen application, applied to a digital photo frame, wherein the digital photo frame is configured with two displays, a main screen and a secondary screen, and the main screen display page and the secondary screen operation page run in the same application process of the digital photo frame, characterized in that, include: Maintain a reference count for the foreground page of the secondary screen and a liveness flag for the main screen within the application process; the operation pages of the secondary screen inherit from a unified page base class. When any secondary screen operation page enters the foreground, the unified page base class increments the reference count of the secondary screen foreground page by 1; when any secondary screen operation page leaves the foreground, the unified page base class decrements the reference count of the secondary screen foreground page by 1. After the main screen display page starts, a polling monitoring task is initiated. The polling monitoring task reads the reference count of the secondary screen foreground page according to a preset polling cycle. During the startup grace period after the main screen display page enters the foreground, the polling monitoring task does not perform an exit judgment. After the startup grace period ends, when the reference count of the secondary screen foreground page is greater than zero, the polling monitoring task keeps the main screen display page running. When the reference count of the secondary screen foreground page is equal to zero, the polling monitoring task starts a zero count confirmation timer. Only when the duration of the secondary screen foreground page reference count being equal to zero reaches the zero count confirmation window and has not yet recovered to a value greater than zero, the main screen display page is closed and the main screen survival flag is updated to the closed state. Each time the secondary screen homepage operation page enters the foreground, it reads the main screen's survival flag. When the main screen's survival flag indicates that the main screen display page has been closed, it restarts the main screen display page on the main screen according to the main screen display indicator and updates the main screen's survival flag to a survival status, so that the main screen display page and the secondary screen operation page of the same digital photo frame are displayed synchronously.

2. The method according to claim 1, characterized in that, The process of maintaining a reference count for the secondary screen's foreground page and a liveness flag for the main screen within the application process, with the secondary screen's operation pages inheriting a unified page base class, includes: In the application process-level global state object, create two shared state variables: the reference count of the secondary screen foreground page and the survival flag of the main screen. The initial value of the reference count of the secondary screen foreground page is 0, and the initial value of the survival flag of the main screen is not created. The unified page base class encapsulates the foreground entry callback interface and the foreground exit callback interface. All secondary screen operation pages inherit from the unified page base class and reuse the foreground entry callback interface and the foreground exit callback interface. Read and write operations on the reference count of the secondary screen foreground page are performed through atomic counting operations or synchronous locks to ensure that the reference count of the secondary screen foreground page remains accurate when the callbacks of multiple secondary screen operation pages are triggered concurrently.

3. The method according to claim 1, characterized in that, When any secondary screen operation page enters the foreground, the unified page base class increments the reference count of the secondary screen foreground page by 1; when any secondary screen operation page leaves the foreground, the unified page base class decrements the reference count of the secondary screen foreground page by 1, including: When the unified page base class is triggered upon entering the foreground callback, it first checks whether the page instance identifier of the corresponding secondary screen operation page has been recorded in the foreground page instance collection. If the page instance identifier has not been recorded, it adds the page instance identifier to the foreground page instance collection and increments the reference count of the secondary screen foreground page by 1. When the callback for leaving the foreground is triggered, the unified page base class removes the corresponding page instance identifier from the foreground page instance collection. If the deletion is successful, the reference count of the secondary screen foreground page is decremented by 1; if the deletion fails, the reference count of the secondary screen foreground page remains unchanged. A lower limit protection is implemented for the reference count of the secondary screen foreground page to ensure that the value of the reference count of the secondary screen foreground page is not less than 0.

4. The method according to claim 1, characterized in that, After the main screen display page starts, a polling monitoring task is initiated. The polling monitoring task reads the reference count of the secondary screen's foreground page according to a preset polling cycle, including: When the main screen display page is created, a polling monitoring task is started through a timed task handle. The polling monitoring task runs periodically according to a preset polling cycle of 1 second. Each time the polling monitoring task runs, it reads the current value of the reference count of the secondary screen foreground page and the main screen liveness flag from the application process-level global state object. When the main screen display page is closed, the polling monitoring task is logged out and removed, causing the polling monitoring task to stop reading the reference count of the secondary screen foreground page.

5. The method according to claim 1, characterized in that, During the grace period after the main screen display page enters the foreground, the polling monitoring task will not execute the exit judgment, including: Each time the main screen display page enters the foreground, a grace period timer is started, with a grace period duration of 3 seconds. During the grace period, the polling monitoring task reads the reference count of the secondary screen foreground page and only records the value, without starting the zero-count confirmation timer or closing the main screen display page. After the grace period is reached, the polling monitoring task enters the normal judgment state and performs the operation of maintaining the main screen display page or starting the zero count confirmation timer according to the value of the reference count of the secondary screen front-end page; the grace period timer is restarted when the main screen display page cold starts or restarts.

6. The method according to claim 1, characterized in that, After the grace period ends, when the reference count of the secondary screen's foreground page is greater than zero, the polling monitoring task keeps the main screen displaying the page. When the reference count of the secondary screen's foreground page is equal to zero, the polling monitoring task starts a zero-count confirmation timer. Only when the duration of the secondary screen's foreground page's reference count being equal to zero reaches the zero-count confirmation window and has not yet recovered to a greater than zero, the main screen displaying the page is closed and the main screen's liveness flag is updated to the closed state, including: After the grace period ends, whenever the polling monitoring task reads a reference count greater than zero for the secondary screen's foreground page, it cancels the ongoing zero-count confirmation timer and resets the duration of the zero count to zero, while keeping the main screen display page running. When the polling monitoring task reads that the reference count of the secondary screen's foreground page is equal to zero, it records the start time of the zero count and starts the zero count confirmation timer. The duration of the zero count confirmation window is 2 seconds. When the reference count of the secondary screen's foreground page recovers to be greater than zero during the zero count confirmation timer, the zero count confirmation timer is canceled and the zero count duration is cleared. When the zero count duration reaches the zero count confirmation window and the reference count of the secondary screen's foreground page is still equal to zero, the main screen display page is closed, the polling monitoring task is stopped, and the main screen's survival flag is updated to the closed state.

7. The method according to claim 1, characterized in that, Each time the secondary screen homepage operation page enters the foreground, it reads the main screen's liveness flag. When the main screen's liveness flag indicates that the main screen display page has been closed, it restarts the main screen display page on the main screen according to the main screen display indicator, including: Each time the secondary screen homepage operation page enters the foreground, it reads the main screen survival flag from the application process-level global state object. When the main screen survival flag is in a closed state or not created state, it constructs the page startup parameters of the main screen display page, and carries the main screen display identifier in the page startup parameters. The page startup parameters request the multi-display management module to create and display the main screen display page on the main screen corresponding to the main screen display identifier. After the main screen display page is successfully created, the polling monitoring task is started. If the actual display position of the main screen display page does not match the main screen display identifier, the display position of the main screen display page is corrected according to the main screen display identifier.

8. The method according to claim 1, characterized in that, The step of updating the main screen's survival flag to a survival status, so that the main screen display page and the secondary screen operation page of the same digital photo frame are displayed synchronously, includes: When the main screen display page is created and enters the foreground, the main screen survival flag is updated to live status; when the main screen display page is closed, the main screen survival flag is updated to closed status. When the secondary screen operation page is launched for the first time and the main screen's survival flag is in an uncreated state, the main screen display page is created on the main screen at the same time as the secondary screen operation page is created, so that the main screen display page and the secondary screen operation page are displayed synchronously on the two displays of the same digital photo frame; the polling monitoring task continues to run while the main screen's survival flag is in a alive state.

9. The method according to claim 1, characterized in that, The method further includes: Record the duration of the transition between when the reference count of the foreground page on the secondary screen changes from greater than zero to equal to zero and then back to greater than zero during each internal switching of the secondary screen operation page. Take the maximum value of the historical transition interval duration and add a preset margin to dynamically update the duration of the zero count confirmation window. Record the startup time from initiation to entering the foreground each time the main screen display page is cold-started or restarted. Take the average of the historical startup time and add a preset margin. Dynamically update the startup grace period and dynamically adjust the preset polling cycle according to the change in the secondary screen foreground page reference count read in two consecutive polling monitoring tasks. The polling monitoring task enumerates the number of secondary screen operation pages that are currently in the foreground every preset verification period. It compares the enumerated number of actual foreground pages with the reference count of the secondary screen foreground pages. When the actual number of foreground pages is inconsistent with the reference count of the secondary screen foreground pages, it reconstructs the secondary screen foreground page reference count and the set of foreground page instances according to the actual number of foreground pages.

10. A system for linking the lifecycles of the main screen and the secondary screen in a dual-screen application, used to implement the method as described in any one of claims 1-9, characterized in that, This is applied to digital photo frames, which are equipped with two displays: a main screen and a secondary screen. Within the same application process of the digital photo frame, both the main screen display page and the secondary screen operation page run, including: The counting increment / decrement unit is used to maintain the reference count of the secondary screen foreground page and the liveness flag of the main screen within the application process. The secondary screen operation page inherits the unified page base class. When any secondary screen operation page enters the foreground, the unified page base class increments the reference count of the secondary screen foreground page by 1. When any secondary screen operation page leaves the foreground, the unified page base class decrements the reference count of the secondary screen foreground page by 1. The task initiation unit is used to start the polling monitoring task after the main screen display page starts. The polling monitoring task reads the reference count of the secondary screen foreground page according to a preset polling cycle. During the start-up grace period after the main screen display page enters the foreground, the polling monitoring task does not perform an exit judgment. After the start-up grace period ends, when the reference count of the secondary screen foreground page is greater than zero, the polling monitoring task keeps the main screen display page. When the reference count of the secondary screen foreground page is equal to zero, the polling monitoring task starts a zero-count confirmation timer. Only when the duration of the secondary screen foreground page reference count being equal to zero reaches the zero-count confirmation window and has not yet recovered to a value greater than zero, the main screen display page is closed and the main screen survival flag is updated to the closed state. The liveness flag unit is used to read the liveness flag of the main screen every time the secondary screen homepage operation page enters the foreground. When the liveness flag of the main screen indicates that the main screen display page has been closed, the main screen display page is restarted on the main screen according to the main screen display indicator, and the liveness flag of the main screen is updated to live status, so that the main screen display page and the secondary screen operation page of the same digital photo frame are displayed synchronously.