A window direction setting method and an electronic device
By introducing orientation event listeners and motion sensors into electronic devices, the problem of inaccurate window rotation can be solved by listening to and controlling window rotation, improving rotation accuracy and user experience, while reducing power consumption.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HONOR DEVICE CO LTD
- Filing Date
- 2024-12-30
- Publication Date
- 2026-06-30
AI Technical Summary
In existing technologies, the window rotation of electronic devices is inaccurate when switching between portrait and landscape modes, resulting in a poor user experience, especially the abnormal window rotation of non-system applications.
By introducing orientation event listeners into electronic devices, changes in screen orientation are monitored and accurate rotation angles are sent to applications. Combined with motion sensors to detect rotation switching events, the rotation of windows of non-system applications can be controlled, avoiding the need to calculate rotation angles manually and thus reducing power consumption.
It improves the accuracy of window rotation, enhances the user experience, reduces power consumption, and ensures that the window display orientation of non-system applications is consistent with the device orientation.
Smart Images

Figure CN122308985A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of terminal technology, and in particular to a method for setting window orientation and an electronic device. Background Technology
[0002] Currently, many applications on mobile phones, tablets, and other electronic devices support rotating displays. Specifically, rotating displays include: when an electronic device switches from portrait to landscape mode, windows in the application interface can rotate from portrait to landscape mode; conversely, when an electronic device switches from landscape to portrait mode, windows in the application interface can rotate from landscape to portrait mode.
[0003] However, some applications do not rotate windows accurately. For example, a window may rotate even when the electronic device has not switched between portrait and landscape modes. Conversely, a window may not rotate even when the electronic device has switched between portrait and landscape modes. Summary of the Invention
[0004] This application provides a method for setting the window orientation and an electronic device, which can accurately rotate the window as the electronic device rotates, thereby improving the accuracy of the rotation display.
[0005] To achieve the above objectives, this application adopts the following technical solution:
[0006] Firstly, a method for setting window orientation is provided for use in electronic devices. The electronic device includes an orientation event listener (OrientationEventListener), and a first application is installed on the electronic device. The first application is not a system application, i.e., it is a non-system application.
[0007] Specifically, the method includes: after launching the first application, the orientation event listener receives a first registration request from the first application. The first registration request can request to listen for a rotation angle. After registering the listener, the orientation event listener can send the obtained rotation angle to the first application. In response to a change in the screen orientation of the electronic device, the orientation event listener sends a first angle (referred to as the fourth rotation angle below) to the first application. The first angle is any one of four target angles, each corresponding to a different screen orientation. For example, the target angles for portrait orientation, landscape orientation, reverse portrait orientation, and reverse landscape orientation are 0°, 90°, 180°, and 270°, respectively. Furthermore, the first angle is the target angle corresponding to the changed screen orientation. The first angle is used by the first application to set the display orientation of the first window, which is a window in the application interface of the first application. For example, the first application can call the `setRequestedOrientation` method to set the display orientation of the window.
[0008] In summary, by employing this application, the first angle returned by the orientation event listener to the first application is one of four target angles, and this first angle corresponds to the changed screen orientation. Thus, after obtaining the first angle, the first application can determine the screen orientation without further decision-making, which is beneficial for accurately setting the window's display orientation.
[0009] In addition, by adopting this application, the first application still registers a direction event listener without needing to be adjusted to adapt to this solution. This is so that the application side is unaware of the changes and can more accurately set the window's display direction without the application side being aware of the changes.
[0010] In one possible design approach of the first aspect, the electronic device also includes a motion sensor. The motion sensor is a virtual sensor that can be used to detect changes in screen orientation; after a screen orientation change, a rotation switching event is detected.
[0011] After the direction event listener receives the first registration request from the first application, the method further includes: the direction event listener registering a rotation switching service with the motion sensor. After registering the rotation switching service, the direction event listener can obtain rotation switching events detected by the motion sensor.
[0012] Furthermore, in response to a change in screen orientation, the orientation event listener sends a first angle to the first application, including: in response to the change in screen orientation, the orientation event listener receives a rotation switching event from a motion sensor, the rotation switching event indicating a switch to a first screen orientation, such as a portrait screen orientation, a landscape screen orientation, a reverse portrait screen orientation, or a reverse landscape screen orientation. Based on the rotation switching event, the orientation event listener sends a first angle to the first application, the first angle corresponding to the first screen orientation.
[0013] Using this design, the orientation event listener can directly obtain the corresponding first angle based on the rotation switching event detected by the motion sensor, thus obtaining a rotation angle that matches the screen orientation. This implementation eliminates the need for the orientation event listener to calculate the specific rotation angle itself, such as an angle between 0° and 360°. Furthermore, the method where the orientation event listener calculates the specific rotation angle itself is Google's native calculation method, which typically lacks filtering or other processing, resulting in lower accuracy. Therefore, this design method improves accuracy compared to Google's native calculation method.
[0014] In one possible design of the first aspect, the aforementioned orientation event listener registers a rotation switching service with the motion sensor, including: the application whitelist includes a first application, and the orientation event listener registers the rotation switching service with the motion sensor.
[0015] Using this design, the direction event listener can control which applications register for rotation switching services through an application whitelist, instead of registering rotation switching services for all applications. This allows the listener to acquire rotation switching events detected by the motion sensor from the first trusted non-system application on the whitelist.
[0016] In one possible design of the first aspect, after the orientation event listener registers the rotation switching service with the motion sensor, the method further includes: the orientation event listener receiving a first notification indicating that a first application should be frozen. In response to the first notification, the orientation event listener queries whether a registration for the rotation switching service exists. If a registration for the rotation switching service is found, the orientation event listener unregisters the rotation switching service from the motion sensor.
[0017] Using this design, after freezing the first application, the direction event listener can forcibly unregister the rotation switching service even if it is still registered. This way, even if some applications did not have the relevant specifications for unregistering installed when the application was frozen, the direction event sensor can still ensure unregistration.
[0018] Furthermore, the motion sensor has system (mainly referring to the AP subsystem) wake-up capability. That is, when the system is in sleep mode, the motion sensor can wake up the system after detecting a rotation switching event and report the rotation switching event to the corresponding module in the system, which will generate power consumption. Therefore, by adopting this design approach, using the orientation event sensor to ensure deregistration, we can avoid the motion sensor reporting rotation switching events and waking up the system, thus reducing power consumption.
[0019] In one possible design of the first aspect, a power-saving management application is also installed in the electronic device. A directional event listener receives a first notification, including: the directional event listener receiving a first notification from the power-saving management application; wherein the power-saving management module freezes the first application after detecting that the system hibernation conditions of the electronic device are met, and sends the first notification after freezing the first application.
[0020] Using this design, the power-saving management application can promptly notify the directional event listener after freezing the first application, allowing the directional event listener to unregister in a timely manner.
[0021] In one possible design of the first aspect, after the orientation event listener unregisters the rotation switching service from the motion sensor, the method further includes: the orientation event listener receiving a second notification instructing the unfreezing of the first application. In response to the second notification, the orientation event listener re-registers the rotation switching service with the motion sensor.
[0022] Using this design, after the first application is unfrozen, the direction event listener can resume registering the rotation switching service, thereby continuing to obtain rotation switching events detected by the motion sensor based on the registration of the rotation switching service.
[0023] In one possible design of the first aspect, the electronic device also includes a power-saving management application. The aforementioned directional event listener receives a second notification, comprising: the directional event listener receiving a second notification from the power-saving management application; wherein the power-saving management module unfreezes the first application after the electronic device is system-wake-up, and sends the second notification after unfreezing the first application.
[0024] Using this design, the power-saving management application can promptly notify the directional event listener after the first application is unfrozen, allowing the directional event listener to resume registration in a timely manner.
[0025] In one possible design approach of the first aspect, the aforementioned orientation event listener sends a first angle to the first application based on the rotation switching event, including: the orientation event listener converts the rotation switching event into the first angle. For example, this conversion is based on the correspondence between screen orientation and target angle. For instance, if the rotation switching event is event 1, indicating a switch to landscape mode, it can be converted into the target angle 90° corresponding to landscape mode. The orientation event listener, through the orientation event process, sends the first angle to the first application. The orientation event process can detect changes in the rotation angle, and whenever the rotation angle changes, the orientation event process can set the changed angle for the application, such as by calling the `setOrientation` method, so that the application can promptly obtain the new angle and use it to set the display orientation.
[0026] In one possible design of the first aspect, a second application, which is a non-system application, is also installed in the electronic device. The method further includes: after the second application is launched, a direction event listener receives a second registration request from the second application. The direction event listener calculates a second angle based on sensor data acquired by an accelerometer and / or gyroscope sensor, the second angle being any angle between 0° and 360°. The direction event listener sends the second angle to the second application, the second angle being used by the second application to set the display direction of a second window, which is a window within the application interface of the second application.
[0027] Using this design, for the second application, the orientation event listener can calculate and return the rotation angle between 0° and 360°. In other words, even if the rotation angle changes very slightly, such as from 50° to 51°, the orientation event listener will return the changed angle to the second application, rather than returning the angle based on the change in screen orientation. This results in two problems: firstly, the orientation event listener frequently returns the angle to the second application, leading to significant communication overhead; secondly, this angle is typically calculated by the orientation event listener using Google's native calculation method, which has low accuracy.
[0028] In one possible design approach of the first aspect, the second application is not included in the application whitelist, and the orientation event listener does not register rotation switching services with the motion sensor.
[0029] Using this design approach, for non-system applications not on the application whitelist, the direction event listener will not further register rotation switching services, but will calculate the rotation angle itself.
[0030] In one possible design of the first aspect, the electronic device also includes a third application (hereinafter referred to as the second non-system application), which is also a non-system application. The method further includes: after the third application is launched, the third application calculates the screen rotation angle based on sensor data collected by an accelerometer and / or gyroscope sensor, and uses this angle to set the display orientation of the window within the third application.
[0031] Using this design approach, even non-system applications can calculate the rotation angle and set the window's display orientation independently. These applications do not register orientation event listeners. Therefore, the solution provided in this application, which involves registering rotation switching services on top of registering orientation event listeners, will not affect these applications.
[0032] In a second aspect, an electronic device is provided, comprising a memory and one or more processors. The memory is coupled to the processors. The memory stores computer program code, which includes instructions. When the instructions are executed by the processor, the electronic device performs the method as described in any one of the first aspects above.
[0033] Thirdly, a computer-readable storage medium is provided that stores instructions which, when executed on an electronic device, cause the electronic device to perform any of the methods described in the first aspect.
[0034] Fourthly, a computer program product containing instructions is provided, which, when run on an electronic device, enables the electronic device to perform the method described in any one of the first aspects above.
[0035] Fifthly, embodiments of this application provide a chip, the chip including a processor, the processor being configured to invoke a computer program in memory to execute the method as described in the first aspect.
[0036] It is understood that the beneficial effects of the electronic device described in the second aspect, the computer-readable storage medium described in the third aspect, the computer program product described in the fourth aspect, and the chip described in the fifth aspect can be referred to the beneficial effects of the first aspect and any of its possible design embodiments, which will not be repeated here. Attached Figure Description
[0037] Figure 1 A schematic diagram illustrating a screen orientation provided in an embodiment of this application;
[0038] Figure 2 A schematic diagram illustrating the display orientation of a window according to an embodiment of this application;
[0039] Figure 3 A schematic diagram illustrating another window display orientation provided in an embodiment of this application;
[0040] Figure 4 A schematic diagram illustrating the enabling and disabling of screen rotation function provided in this application embodiment;
[0041] Figure 5A This is a schematic diagram illustrating a display orientation switching method provided in an embodiment of this application.
[0042] Figure 5B A schematic diagram illustrating a user-defined display orientation provided in an embodiment of this application;
[0043] Figure 6A A flowchart illustrating the control of window display direction as provided in an embodiment of this application;
[0044] Figure 6B A diagram showing the survey results of a screen rotation function switch provided in an embodiment of this application;
[0045] Figure 7 A model diagram for testing the display orientation of a window, provided in an embodiment of this application;
[0046] Figure 8A An illustration of an abnormal situation provided in an embodiment of this application;
[0047] Figure 8B An illustration showing another abnormal situation provided in the embodiments of this application;
[0048] Figure 9 A hardware structure diagram of a mobile phone provided in an embodiment of this application;
[0049] Figure 10 A software architecture diagram of a mobile phone provided in an embodiment of this application;
[0050] Figure 11 An interactive diagram illustrating the implementation of a window orientation setting method provided in an embodiment of this application;
[0051] Figure 12 The corresponding embodiment provided in this application Figure 11 Example diagram of implementation;
[0052] Figure 13 This application provides a schematic diagram of a scene specifying a display direction.
[0053] Figure 14 The following is an interactive diagram illustrating a scheme for reducing power consumption, as provided in this application embodiment. Detailed Implementation
[0054] The technical solutions of the embodiments of this application are described below with reference to the accompanying drawings. In the description of the embodiments of this application, the terminology used in the following embodiments is for the purpose of describing specific embodiments only and is not intended to limit the application. As used in the specification and appended claims of this application, the singular expressions "a," "the," "the," "the," and "this" are intended to also include expressions such as "one or more," unless the context clearly indicates otherwise. It should also be understood that in the following embodiments of this application, "at least one" and "one or more" refer to one or more (including two). The term "and / or" is used to describe the relationship between related objects, indicating that three relationships can exist; for example, A and / or B can represent: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship.
[0055] References to "one embodiment" or "some embodiments" in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized. The term "connection" includes direct connections and indirect connections, unless otherwise stated. "First" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated.
[0056] In the embodiments of this application, the words "exemplarily" or "for example" are used to indicate examples, illustrations, or explanations. Any embodiment or design described as "exemplarily" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design solutions. Specifically, the use of the words "exemplarily" or "for example" is intended to present the relevant concepts in a specific manner.
[0057] Before introducing the embodiments of this application, the main terms involved in the embodiments of this application will be briefly introduced below.
[0058] 1. Screen orientation.
[0059] Screen orientation refers to the actual orientation of the physical screen of an electronic device.
[0060] Screen orientation typically includes portrait orientation, landscape orientation, reverse portrait orientation, and reverse landscape orientation.
[0061] In this case, the portrait orientation is opposite to the reverse portrait orientation. See also Figure 1 State 101 is in portrait orientation, and state 102 is in reverse portrait orientation.
[0062] The landscape orientation is the opposite of the reverse landscape orientation. See also... Figure 1 State 103 is landscape orientation, and state 104 is reverse landscape orientation.
[0063] Normally, rotating an electronic device changes the orientation of its screen. See also... Figure 1In state 101, rotating the phone clockwise by approximately 90° will bring you to state 103. In state 103, rotating the phone clockwise by approximately 90° will bring you to state 102. In state 102, rotating the phone clockwise by approximately 90° will bring you to state 104. In state 104, rotating the phone clockwise by approximately 90° will return you to state 101. The same principle applies to counter-clockwise rotation, which will not be elaborated upon here.
[0064] Understandable. Figure 1 The orientations shown are only ideal states for the phone screen. For example, in the portrait orientation shown in state 101 and the portrait orientation shown in state 102, the long side of the screen is vertical and the short side is horizontal. Similarly, in the landscape orientation shown in state 103, the long side of the screen is horizontal and the short side is vertical. In actual implementation, in the portrait orientation and the reverse portrait orientation, the long side of the screen may have an angle with the direction of gravity, and is not perfectly perpendicular; similarly, the short side may also have an angle with the horizontal direction, and is not perfectly horizontal. Likewise, in the landscape orientation and the reverse landscape orientation, the short side of the screen may also have an angle with the direction of gravity, and is not perfectly vertical; similarly, the long side may also have an angle with the horizontal direction, and is not perfectly horizontal.
[0065] 2. Display orientation of windows / activities.
[0066] In the following text, the display orientation of a window / activity will be referred to as the window's display orientation.
[0067] The display orientation of a window refers to the orientation of the window on the screen. Window display orientations include portrait orientation (PORTRAIT), landscape orientation (LANDSCAPE), reverse portrait orientation (REVERSE_PORTRAIT), and reverse landscape orientation (REVERSE_LANDSCAPE).
[0068] It should be noted that, to distinguish between screen orientation and window display orientation, the screen orientations of portrait, landscape, reverse portrait, and reverse landscape can be referred to as portrait screen orientation, landscape screen orientation, reverse portrait screen orientation, and reverse landscape screen orientation, respectively. Similarly, the window display orientations of portrait, landscape, reverse portrait, and reverse landscape can be referred to as portrait display orientation, landscape display orientation, reverse portrait display orientation, and reverse landscape display orientation, respectively.
[0069] In both portrait and reverse portrait orientations, the window's width aligns with the shorter side of the screen, and its height aligns with the longer side. Furthermore, the portrait and reverse portrait orientations are opposite. When the window is in portrait orientation, rotating it approximately 180° will switch it to reverse portrait orientation. The same logic applies to switching from reverse portrait to portrait orientation, which will not be elaborated upon here.
[0070] The width of the window refers to the horizontal distance from the left edge to the right edge of the window, and the height of the window refers to the vertical distance from the top edge to the bottom edge of the window.
[0071] See Figure 2 The phone can display interface 201, which includes window 201-a, and window 201-a in interface 201 is displayed in portrait orientation. The phone can also display interface 202, which includes window 201-a, and window 201-a in interface 202 is displayed in reverse portrait orientation. The width w1 of window 201-a in both interfaces 201 and 202 is the same as the short side W of the screen, and the height h1 is the same as the long side H of the screen. Furthermore, window 201-a in portrait orientation in interface 201 can be rotated approximately 180° around the center of the screen to become window 201-a in reverse portrait orientation in interface 202.
[0072] In both landscape and reverse landscape orientations, the width of the window aligns with the long side of the screen, and the height aligns with the short side. Furthermore, landscape and reverse landscape orientations are opposite. When the window is in landscape orientation, rotating the electronic device approximately 180° will switch to reverse landscape orientation. The same principle applies to switching from reverse landscape to landscape orientation, which will not be elaborated upon here.
[0073] See Figure 3 The phone can display interface 301, which includes window 201-a, and the display orientation of window 201-a in interface 301 is landscape mode. The phone can also display interface 302, which includes window 201-a, and the display orientation of window 201-a in interface 302 is reversed landscape mode. The width w2 of window 201-a in both interfaces 301 and 302 is the same as the long side W of the screen, and the height h2 is the same as the long side H of the screen. Furthermore, window 201-a in landscape mode in interface 301 can be rotated approximately 180° around the center of the screen to become window 201-a in reverse landscape mode in interface 302.
[0074] 3. Screen rotation function.
[0075] Screen rotation is a function provided by electronic devices that allows windows on the screen to rotate as the screen orientation changes.
[0076] Electronic devices can display a primary toggle button for screen rotation in the settings app or control center. In response to a user's triggering of this primary toggle button, such as a click, the electronic device can turn screen rotation on or off. Alternatively, the electronic device can also turn screen rotation on or off in response to a user's primary gesture (such as a palm facing the screen and rotating clockwise or counter-clockwise) or primary voice command (such as "Turn screen rotation on" or "Turn screen rotation off").
[0077] Taking the display of the first power button in the control center of the mobile phone as an example, see... Figure 4 The phone can display interface 401. In response to the user swiping down from the top of interface 401, the phone can display interface 402. Interface 402 includes a control center 402-a. Control center 402-a includes toggle buttons for various control items, such as mobile data, WLAN, Bluetooth, sound, location information, screenshot, screen recording, wireless projection, and Do Not Disturb mode. It also includes a primary toggle button for screen rotation, such as auto-rotate 402-b. In response to the user clicking on auto-rotate 402-b in interface 402, the phone can display interface 403, where control center 402-a includes auto-rotate 402-b. Compared to auto-rotate 402-b in interface 402, the font and lines of auto-rotate 402-b in interface 403 are thicker, indicating that screen rotation is enabled. Conversely, in response to the user clicking on auto-rotate 402-b in interface 403, the phone can display interface 402. Compared to the auto-rotate 402-b in interface 403, the font and lines of the auto-rotate 402-b in interface 402 are not thickened, indicating that the screen rotation function is turned off.
[0078] When the screen rotation function is enabled, the electronic device can rotate the windows on the screen to match the screen orientation as the screen orientation changes.
[0079] See Figure 5AThe phone can display interface 501, with the screen orientation in portrait mode. Interface 501 includes a video playback window 501-a, also in portrait mode. Thus, from the user's perspective, the video playback window 501-a in interface 501 appears to be playing a video. If the user rotates the phone counter-clockwise as indicated by the arrow in the diagram, approximately 90°, the phone can display interface 502, with the screen orientation reversed to landscape mode. Interface 502 also includes a video playback window 501-a, again in landscape mode. Thus, from the user's perspective, as the screen orientation changes, the display orientation of the video playback window 501-a also changes, making the video playback window 501-a in interface 502 appear to be playing a video as well.
[0080] Furthermore, a window can support at least one display orientation. Typically, some windows support four orientations: portrait, landscape, reverse portrait, and reverse landscape. Some windows support three orientations: portrait, landscape, and reverse landscape. Some windows support two orientations: landscape and reverse landscape. Some windows only support portrait. Therefore, when screen rotation is enabled, the electronic device must consider the window's supported orientation when rotating the window as the screen orientation changes. For example, if a window does not support reverse portrait, the electronic device can maintain the window's orientation when the screen orientation changes to reverse portrait, thus preventing rotation to an unsupported reverse portrait orientation.
[0081] Additionally, users can manually switch the display orientation of windows by enabling or disabling screen rotation. In response to this manual switching, the electronic device can also rotate the windows on the screen, changing their display orientation. See also... Figure 5A and Figure 5B The video playback window 501-a in interface 501 includes a full-screen button 501-b. In response to the user's click on the full-screen button 501-b, the phone can display interface 511. The display orientation of the video playback window 501-a in interface 511 is a reverse landscape orientation, the same as the display orientation of the screen recognition playback window 501-a in interface 502. Since the phone is not rotated, the screen orientation corresponding to interface 511 remains portrait, the same as the screen orientation corresponding to interface 501.
[0082] The window orientation setting method provided in this application embodiment can be applied to scenarios where the display orientation of a window is controlled.
[0083] In some implementations, electronic devices can set the rotation strategy of windows in system applications based on rotation switching events. System applications refer to applications developed by the device's developer. For example, applications like the gallery, camera, calendar, and call apps on a mobile phone are system applications. Rotation switching events are used to indicate changes in screen orientation. For example, switching the screen orientation from portrait to landscape mode triggers event 0; switching from landscape to portrait mode triggers event 1, and so on.
[0084] The system application can register for rotation switching services provided by the motion sensor. It should be noted that the motion sensor is a virtual sensor. See also... Figure 6A Branch one describes the process of setting the display orientation of windows in a system application. Specifically, a motion sensor detects the rotation of an electronic device and generates a rotation switching event. The motion sensor then reports this event to the Motion Rotation Processor, such as the Motion Engine Service (described below). A routing switch module (such as MCUSwitch) can enable the Motion Rotation Processor to send the first rotation angle corresponding to the rotation switching event to the system application, such as based on the opening of a window in the foreground, including the system application. Finally, the system application sets the window's display orientation based on this first rotation angle.
[0085] Furthermore, electronic devices can monitor sensor data, such as rotation angles via orientation event listeners or data collected by accelerometers, and control the display orientation of windows in non-system applications based on the monitored data. Non-system applications refer to applications developed by developers other than the electronic device's manufacturer, such as WeChat. TM Taobao TM Tencent Video TM wait.
[0086] Some non-system applications (referred to as the first non-system application) can register orientation event listeners to detect rotation angles. See also Figure 6A Branch two involves the process of controlling the display orientation of windows in the first non-system application. Specifically, an accelerometer can collect acceleration data, and a gyroscope can collect angular velocity data. For ease of description, acceleration data and / or angular velocity data can be collectively referred to as sensor data. An orientation event listener can calculate a second rotation angle based on the sensor data. The routing switch module can enable the orientation event listener to send the second rotation angle to the first non-system application, such as when a window of a non-system application is open in the foreground. Finally, the first non-system application sets the display orientation of its window based on the second rotation angle.
[0087] See Figure 6A In branch three, some non-system applications (referred to as the second non-system application) can calculate the third rotation angle based on sensor data, such as acceleration data. Ultimately, the second non-system application sets the window's display orientation based on the third rotation angle.
[0088] However, regarding the adoption Figure 6A The electronic device implemented as shown collects source audio, including but not limited to the following, regarding the screen rotation function:
[0089] "This has happened twice. I didn't select screen rotation, and the portrait mode turned into the landscape mode."
[0090] "I've turned off automatic screen rotation, but it still spins randomly."
[0091] "The gravity sensor that automatically rotates often rotates in the opposite direction, and sometimes the experience is better than turning off the automatic rotation function."
[0092] "When watching the video in landscape mode, there is a bug that causes it to flip to the other side."
[0093] "After enabling smart screen rotation, when playing games or watching videos in landscape mode, the screen may rotate automatically, and it is very easy to trigger."
[0094] "Whether in image display or Toutiao" TM The automatic rotation of some videos often causes problems.
[0095] These user feedback reports clearly indicate that the screen rotation function has a poor user experience and may exhibit abnormal rotation issues.
[0096] Further, see Figure 6B The survey found that nearly 40% of users turned off the screen rotation function due to a poor user experience. This indicates that a large number of users are concerned about the abnormal rotation issues that occur with the screen rotation function.
[0097] In response to the abnormal rotation issue reported by users, the screen rotation function has been enabled, and the following steps have been taken: Figure 7 The dynamic tests shown include tests simulating walking and running scenarios, and tests simulating landscape video scenarios.
[0098] Among them, the test simulates walking and running scenarios: the phone is shaken in the vertical direction (i.e., the direction of gravity), such as within ±10° in the vertical direction, to simulate the user walking or running with the phone in their pocket, and to test the rotation of windows in various application interfaces.
[0099] Among them, the test of simulating landscape video scene: shake the phone horizontally, such as within a range of ±10° in the horizontal direction, to simulate the scene of playing video in landscape mode, and test the rotation of the video playback window when playing video in various applications.
[0100] Testing revealed that window rotation in the system application is quite accurate, as shown in the above... Figure 7 In the two scenarios shown in the test, no window rotation occurred. However, windows from non-system applications exhibited abnormal rotation issues, as described above. Figure 7 In the tests of the two scenarios shown, window rotation occurred.
[0101] See Figure 8A During the test simulating walking and running scenarios, when the phone rotated from the first posture to the second posture along the arrow direction, the screen orientation did not change, but the display orientation of window 501-a switched from the portrait display orientation to the reverse landscape display orientation, that is, the rotation was incorrect.
[0102] See Figure 8B During the test simulating a landscape video scene, when the phone rotated from the third posture to the fourth posture along the arrow direction, the screen orientation did not change, but the display orientation of window 501-a switched from the reverse landscape display orientation to the portrait display orientation, that is, the rotation was incorrect.
[0103] Based on the above problems, the window orientation setting method provided in this application embodiment can control the rotation of windows in non-system applications based on the rotation switching event of the electronic device.
[0104] Among them, based on the preceding text Figure 7 The test results show that the window rotation of the system application is accurate. Furthermore, based on the preceding text... Figure 6A The introduction states that the system application's window rotation is controlled based on rotation switching events. Therefore, by controlling the rotation of windows in non-system applications based on the electronic device's rotation switching events, the windows in non-system applications can also rotate accurately, thus ensuring that the display orientation of windows in non-system applications remains consistent with the device's orientation.
[0105] In other words, in this embodiment of the application, even for non-system applications, the rotation switching event detected by the motion sensor can be effectively used to control the window rotation without ignoring the rotation switching event.
[0106] Furthermore, for the first non-system application, window switching can be controlled based on rotation switching events. Based on the preceding text... Figure 6AAs described above, the second non-system application can calculate the rotation angle itself after acquiring sensor data. However, in practice, the second non-system application may use this sensor data for other purposes. Therefore, controlling window rotation only for the first non-system application can avoid affecting other functions in the second non-system application that require the aforementioned sensor data. The following text primarily focuses on controlling window switching based on rotation switching events for the first non-system application as an example.
[0107] For example, the electronic device in this application embodiment may be a mobile phone, tablet computer, desktop computer, laptop computer, handheld computer, notebook computer, ultra-mobile personal computer (UMPC), netbook, as well as cellular phone, personal digital assistant (PDA), artificial intelligence (AI) device, wearable device, in-vehicle device, smart home device and / or smart city device, etc., that has a display screen. This application embodiment does not impose any special limitations on the specific form of the electronic device.
[0108] The embodiments of this application will be mainly described using a mobile phone as an example.
[0109] See Figure 9 This is a hardware structure diagram of a mobile phone. For example... Figure 9 As shown, a mobile phone may include a processor 210, an external memory interface 220, an internal memory (RAM) 221, a universal serial bus (USB) interface 230, a charging management module 240, a power management module 241, a battery 242, an antenna 1, an antenna 2, a mobile communication module 250, a wireless communication module 260, an audio module 270, a speaker 270A, a receiver 270B, a microphone 270C, a headphone jack 270D, a sensor module 280, buttons 290, a motor 291, an indicator 292, a camera 293, a display screen 294, and a subscriber identification module (SIM) card interface 295, etc.
[0110] The sensor module 280 may further include accelerometers 280E, gyroscopes 280B, etc.
[0111] It is understood that the structure illustrated in this embodiment does not constitute a specific limitation on the mobile phone. In other embodiments, the mobile phone may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0112] The processor 210 may include one or more processing units, such as an application processor (AP), a modem, a central processing unit (CPU), a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), and / or a neural network processing unit (NPU).
[0113] Different processing units can be independent devices or integrated into one or more processors. For example, an AP can integrate a CPU, GPU, etc.
[0114] In some embodiments, the processor 210 can execute an image display method by running instructions stored in the internal memory 221.
[0115] In addition, one or more processing units in the aforementioned processor 210, as well as other components of the mobile phone (such as memory, input / output interfaces, etc.), can be integrated into the SoC.
[0116] The charging management module 240 receives charging input from the charger. The power management module 241 connects the battery 242, the charging management module 240, and the processor 210. The power management module 241 receives input from the battery 242 and / or the charging management module 240, providing power to the processor 210, internal memory 221, display screen 294, camera 293, and wireless communication module 260, etc. The power management module 241 can also monitor parameters such as battery capacity, battery cycle count, and battery health status.
[0117] The wireless communication function of a mobile phone can be implemented through antenna 1, antenna 2, mobile communication module 250, wireless communication module 260, modem processor, and baseband processor.
[0118] Mobile phones can achieve display functions through GPU, display screen 294, and application processor. The GPU is a microprocessor for image processing, connecting the display screen 294 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering.
[0119] Mobile phones can achieve camera functions through cameras 293, ISP, video codecs, GPU, display panels 294, application processors (AP), neural network processors (NPU), etc.
[0120] Mobile phones can perform audio functions, such as music playback and recording, through an audio module 270, a speaker 270A, a receiver 270B, a microphone 270C, a headphone jack 270D, and an application processor.
[0121] The gyroscope sensor 280B can be used to determine the phone's motion posture. In some embodiments, the gyroscope sensor 280B can determine the angular velocity of the phone around three axes. The gyroscope sensor 280B can be used for image stabilization. For example, when the shutter is pressed, the gyroscope sensor 280B detects the angle of the phone's shake, calculates the distance the lens module needs to compensate based on the angle, and controls the lens to move in the opposite direction to counteract the phone's shake, thus achieving image stabilization. The gyroscope sensor 280B can also be used in navigation and motion-sensing gaming scenarios.
[0122] The 280E accelerometer sensor can detect the magnitude of a mobile phone's acceleration in various directions (typically three axes). When the phone is stationary, it can detect the magnitude and direction of gravity. It can also be used to identify the device's posture, and is applicable to screen orientation switching, pedometers, and other applications.
[0123] In this embodiment, the mobile phone uses the aforementioned gyroscope sensor 280B and accelerometer sensor 280E, which can be used to determine the screen orientation and control the window rotation based on the screen orientation, so that the display orientation of the window matches the screen orientation.
[0124] Display screen 294 is used to display images, videos, etc. Display screen 294 includes a display panel. The display panel may be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a miniature LED, a microLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, a mobile phone may include one or more displays screens 294.
[0125] The software system of the aforementioned mobile phone can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application embodiment uses a layered architecture of Android. TM Taking a system as an example, this section illustrates the software structure of a mobile phone. A layered architecture divides the mobile phone's software system into several layers, each with a clear role and function, and the layers communicate with each other through software interfaces.
[0126] See Figure 10 The software architecture of a mobile phone can include an AP subsystem and a sensor management component (sensorhub) subsystem.
[0127] The AP subsystem includes an application layer, a framework layer, and a hardware abstraction layer (HAL). It should be noted that the AP subsystem may include more or fewer layers. For example, the AP subsystem may also include a kernel layer. As another example, the framework layer may further include an application framework layer (also known as a Java framework layer) and a native layer. This application does not specifically limit these aspects.
[0128] The application layer can include a series of application packages. For example, it can include application packages such as camera, calendar, WLAN, music, gallery, call, navigation, Bluetooth, and video, which are represented by APPs in the diagram.
[0129] The application layer may also include an orientation change process, an orientation event listener, and a motion engine service.
[0130] The orientation event listener can be used to calculate the rotation angle. For example, the orientation event listener can call the sensor event listener implementation (SensorEventListenerImpl) to calculate the rotation angle. The sensor event listener implementation can calculate the rotation angle based on data collected by accelerometers, gyroscopes, etc.
[0131] The orientation change process can be used to set the rotation angle for the application when the rotation angle changes.
[0132] Therefore, it's important to clarify that direction event listeners and direction change processes are capabilities provided by the application framework layer; however, these capabilities are invoked within the application layer. Figure 10 The direction event listener, direction change process, and setting request direction interface are implemented in the application framework layer.
[0133] The motion engine service manages the registration of rotation switching services. After each module (such as the application) registers its rotation switching service with the motion engine service, the motion engine service can distribute the received rotation switching services to the corresponding modules.
[0134] The application layer can also include a power-saving management module, such as a power-saving application. This module can be used for system (mainly referring to the AP subsystem) hibernation, application freezing, and other management functions to save battery power.
[0135] For example, the power-saving management module can detect whether the sleep conditions are met, and if so, control the AP subsystem to enter sleep mode. Sleep conditions include the current time being late at night and the phone being stationary for an extended period.
[0136] The application framework layer provides application programming interfaces (APIs) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.
[0137] The application framework layer can include an activity manager, a window manager, a sensor service, and so on.
[0138] The Activity Manager Service (AMS) provides the Activity Management Service. AMS can be used for starting, switching, and scheduling system components (such as activities, services, content providers, and broadcast receivers), as well as managing and scheduling application processes. For example, AMS can be used for activity lifecycle management and task stack management.
[0139] The window manager provides a window management service (WMS). WMS can be used for window management, window animation management, surface management, and as an intermediary for input systems. For example, WMS can manage the display and hiding of windows, determine window size and position, and manage window scaling and rotation.
[0140] Furthermore, the Activity Manager and Window Manager can include an Activity Client Controller and a Screen Rotation Module. The Activity Client Controller and the Screen Rotation Module can both be located within either the Activity Manager or the Window Manager.
[0141] The activity client controller can be used to manage all currently existing activities and / or windows, and determine the window to be rotated based on the settings parameters of the setting request direction interface called by the application. For example, if the mobile phone currently displays three windows, window A, window B, and window C, and the application calls the setting request direction interface to set the display direction of window A, the activity client controller can determine that window A is the window to be rotated based on this setting.
[0142] The screen rotation module can rotate the window to be rotated, so that the window is displayed in the orientation set by the application after rotation.
[0143] Sensor services can be used to report data collected by accelerometers, gyroscopes, and other sensors to upper layers (such as the application layer). For example, the sensor service reports data collected by various sensors to the application layer, which can then use the application to calculate rotation angles, thus enabling the application to perform the desired actions as described earlier. Figure 6A Control window rotation as shown in branch three.
[0144] The Hardware Abstraction Layer (HAL) encapsulates the underlying hardware drivers and provides a generic interface for calling the drivers to activate the corresponding hardware. The HAL may include sensor interfaces.
[0145] The sensor interface can be used to manage sensor registration. After a sensor is registered, the sensor interface can report the data collected by the sensor to the corresponding registered object, such as through a sensor service.
[0146] Furthermore, sensor interfaces may include accelerometer interfaces, gyroscope interfaces, motion sensor interfaces, etc. Accelerometer interfaces can be used to manage the registration of accelerometer sensors and report acceleration data to the corresponding registered objects. Gyroscope interface interfaces can be used to manage the registration of gyroscope sensors and report gyroscope data to the corresponding registered objects.
[0147] The sensor management component subsystem may include sensor drivers for driving sensors to operate. For example, sensor drivers may include accelerometer sensor drivers and gyroscope sensor drivers.
[0148] The accelerometer sensor driver can be used to operate the accelerometer sensor and report the acceleration data collected by the accelerometer sensor. Similarly, the gyroscope sensor driver can be used to operate the gyroscope sensor and report the angular velocity and direction data collected by the gyroscope sensor.
[0149] The sensor management component subsystem may also include motion sensors. These motion sensors integrate rotation switching detection algorithms to detect and report rotation switching events, such as through the motion engine service to applications that have registered for rotation switching services.
[0150] The window orientation setting method provided in this application embodiment can be executed in a mobile phone with the above-described hardware and software structure. For the first non-system application, the mobile phone can employ the following... Figure 11 The process replaces the previous one. Figure 6A The method shown in branch two controls the window's display orientation. Additionally, for system applications and secondary non-system applications, the phone can still use... Figure 6A The display direction of the window is controlled as shown in branches one and three, which will not be elaborated on here.
[0151] See Figure 11 Methods for setting the window orientation include:
[0152] S1101, First application starts.
[0153] The first application is the first non-system application.
[0154] For example, the first application can be launched in response to a user's click on the application icon of the first application on the desktop.
[0155] S1102, The first application registers a direction event listener through the direction change process.
[0156] After registering the listener, the first application can listen to the rotation angle calculated by the direction event listener and control the rotation of the window in the first application accordingly. See details in S1107-S1111 below.
[0157] Based on the preceding text Figure 6A As the description indicates, the first non-system application obtains the rotation angle by registering an orientation event listener to set the window's display orientation, while neither the system application nor the second non-system application needs to obtain the rotation angle by registering an orientation event listener. Therefore, if an application registers an orientation event listener, it indicates that the application is the first non-system application.
[0158] S1103, the direction event listener registers rotation switching services with the motion sensor through the motion engine service.
[0159] After registering the rotation switching service, the motion engine service can send feedback to the direction event listener on the rotation switching events detected by the motion sensor.
[0160] In some embodiments, when the first application registers the direction event listener in S1102, it may carry the application identifier of the first application, such as a process identifier (PID). Before S1103, the direction event listener can decide whether to register the rotation switching service based on the application identifier of the first application. For example, if the application identifier of the first application is in the application whitelist, the direction event listener can register the rotation switching service with the motion sensor. If the application identifier of the first application is not in the application whitelist, the direction event listener may not register the rotation switching service with the motion sensor. Thus, rotation switching events detected by the motion sensor can be obtained for trusted first non-system applications in the whitelist.
[0161] Additionally, for the first non-system application not on the application whitelist, if it's considered the second application, a direction event listener can also be registered. The direction event listener can detect that the second application is not on the application whitelist, thus avoiding further registration of the rotation switching service with the motion sensor. Subsequently, it can be done according to... Figure 6A In the second branch of the scheme, the direction event listener calculates the rotation angle based on sensor data and sends it to the second application, which then sets the display direction of the window.
[0162] S1104, Motion sensor detects rotation switching events.
[0163] Motion sensors can detect rotation switching events based on data collected by various physical sensors such as accelerometers and gyroscopes. For example, when the screen rotates from... Figure 1 After the state 101 changes to state 102, the rotation switching event can...
[0164] The rotation switching event can be used to indicate a change in screen orientation, including switching to portrait mode, reversing portrait mode, landscape mode, and reversing landscape mode. In short, when the motion sensor detects a rotation switching event, it indicates that the screen orientation has changed.
[0165] For example, the rotation switching events include event 0, event 1, event 2 and event 3, which sequentially indicate switching to portrait screen orientation, landscape screen orientation, reverse portrait screen orientation, and reverse landscape screen orientation.
[0166] S1105. After detecting a rotation switching event, the motion sensor reports the rotation switching event to the motion service engine.
[0167] S1106, The motion service engine returns a rotation switching event to the direction event listener.
[0168] In other words, the direction event listener receives rotation switching events, not specific angle values, as mentioned earlier. Figure 6A The second rotation angle shown in the middle branch two.
[0169] S1107, The direction event listener converts the rotation switching event into a fourth rotation angle.
[0170] The fourth rotation angle is the rotation angle corresponding to the screen direction to which the rotation switching event indicates.
[0171] Furthermore, the rotation angle corresponding to the screen orientation can be a specific angle within the angular range of the screen orientation, or a range encompassed by the angular range of the screen orientation. This application does not specifically limit this aspect in its embodiments.
[0172] Taking a landscape screen orientation as an example, with the angle range [80°, 100°] and the rotation switching event as event 1, indicating a switch to landscape orientation: the fourth rotation angle can be one of the angles in [80°, 100°], such as 90°. Alternatively, the fourth rotation angle can be a range within [80°, 100°], such as [85°, 95°], [85°, 92°], etc.
[0173] This article mainly uses the fourth rotation angle as a specific example for illustration.
[0174] The rotation switching event indicates a switch to a different screen orientation, and the orientation event listener can be converted to different fourth rotation angles.
[0175] For example, the rotation switching event is event 0, indicating a switch to portrait screen orientation, and the fourth rotation angle can be 0°.
[0176] For example, the rotation switching event is event 1, indicating a switch to landscape screen orientation, and the fourth rotation angle can be 90°.
[0177] For example, the rotation switching event is event 2, which indicates switching to the reverse portrait screen orientation, and the fourth rotation angle can be 180°.
[0178] For example, the rotation switching event is event 3, indicating switching to the reverse landscape screen orientation, and the fourth rotation angle can be 270°.
[0179] S1108, The direction change process detected a change in rotation angle.
[0180] It should be noted that the step of converting to obtain the fourth rotation angle in S1107 above can also be performed by the direction change process, and this application embodiment does not specifically limit this.
[0181] S1109, The direction change process sets the fourth rotation angle for the first application.
[0182] After each rotation angle change, the direction change process can be set as the first application registered for the rotation switching service.
[0183] For example, the orientation change process can call the setOrientation method to set a fourth rotation angle for the first application.
[0184] S1110, The first application sets the window's display orientation to the window manager / activity manager based on the fourth rotation angle.
[0185] Here, "window" refers to a window within the application interface of the first application. The application interface of the first application may include at least one window, and for each window, the first application can set the display direction based on the fourth rotation angle.
[0186] The fourth rotation angle corresponds to the screen orientation indicated by the rotation switching event. In other words, when the first application obtains the fourth rotation angle, it essentially obtains the screen orientation. By setting the window's display orientation based on the fourth rotation angle, the first application can achieve a display orientation setting based on the screen orientation, thus ensuring that the set display orientation matches the screen orientation.
[0187] For example, the first application can call the `setRequestedOrientation` method to set the window's display orientation to the window manager / activity manager. The display orientations that `setRequestedOrientation` can set include, but are not limited to, the following categories:
[0188] SCREEN_ORIENTATION_UNSPECIFIED: Default value, the system automatically selects the screen orientation based on the orientation sensor;
[0189] SCREEN_ORIENTATION_LANDSCAPE: Landscape display orientation;
[0190] SCREEN_ORIENTATION_PORTRAIT: Portrait display orientation;
[0191] SCREEN_ORIENTATION_USER: The user's current preferred orientation
[0192] SCREEN_ORIENTATION_SENSOR: Whether the screen rotation function is on or off, it is determined by the device's physical sensors. If the user rotates the device, the display orientation will switch between portrait and landscape.
[0193] SCREEN_ORIENTATION_NOSENSOR: Ignores physical sensors and will not switch display orientation as the user rotates the device;
[0194] SCREEN_ORIENTATION_SENSOR_LANDSCAPE: Whether the screen rotation function is on or off is determined by the device's physical sensors. If the user rotates the device, they can switch between landscape and reverse landscape orientations, but they will not switch to portrait or reverse portrait orientations.
[0195] SCREEN_ORIENTATION_SENSOR_PORTRAIT: Whether the screen rotation function is on or off is determined by the device's physical sensors. If the user rotates the device, they can switch between portrait and reverse portrait orientations, but they will not switch to landscape or reverse landscape orientations.
[0196] SCREEN_ORIENTATION_REVERSE_LANDSCAPE: Reverses the landscape orientation;
[0197] SCREEN_ORIENTATION_REVERSE_PORTRAIT: Reverses the portrait display orientation;
[0198] SCREEN_ORIENTATION_FULL_SENSOR: The display orientation is determined entirely by the physical sensor.
[0199] SCREEN_ORIENTATION_USER_LANDSCAPE: The user's preferred landscape orientation.
[0200] SCREEN_ORIENTATION_USER_PORTRAIT: The user's preferred portrait orientation.
[0201] SCREEN_ORIENTATION_FULL_USER: The display orientation is determined entirely by user settings.
[0202] It should be noted that the specific implementation of the first application setting the display orientation based on the rotation angle (such as the fourth rotation angle) is not the focus of this article; please refer to the relevant technical descriptions for details. In one specific implementation, the first application can, after obtaining the fourth rotation angle, further combine it with the window's supported display orientations to set the window's display orientation. For example, if the window supports portrait, landscape, and reverse landscape orientations, but not reverse portrait orientations, then even if the fourth rotation angle is 180°, the first application will not set the reverse portrait orientation to the window manager / activity manager.
[0203] S1111, Window Manager / Activity Manager: Rotate the window to achieve the set display orientation.
[0204] For example, if the current display orientation of the window is portrait mode and the first application is set to landscape mode, the window manager / activity manager can rotate the window 90° clockwise around the center of the screen to achieve the set display orientation.
[0205] It's understandable that after rotating the window, you can adjust its size and layout to fit the current screen orientation.
[0206] The above steps S1104-S1111 illustrate the specific implementation of rotating the window after detecting a rotation switching event. In practice, if multiple rotation switching events occur, S1104-S1111 can be executed repeatedly to rotate the window multiple times.
[0207] In addition, the phone can run multiple applications simultaneously in the foreground, thus displaying the application interfaces of multiple applications. Each of these non-system applications can be run as described above. Figure 11 Rotate the process control window.
[0208] Using the above Figure 11 In this process, the first application can obtain a fourth rotation angle that matches the screen orientation indicated by the rotation switching event, and control the window rotation based on the fourth rotation angle, so that the window's display orientation can match the screen orientation after the switch.
[0209] The embodiments of this application are combined here. Figure 12 Exemplary description Figure 11Implementation examples and the foregoing Figure 6A The difference between the two branches. Figure 12 The example uses a video playback application as an example:
[0210] See Figure 12 ,use Figure 11 In one embodiment, the rotation switching event detected by the motion sensor can be sent to an orientation event listener. The orientation event listener can convert the rotation switching event into a corresponding fourth rotation angle. Thus, the fourth rotation angle converted by the orientation event sensor matches the screen orientation. Corresponding to four screen orientations, there are four fourth rotation angles. Accordingly, the first application only needs to set the display orientation based on the screen orientation corresponding to the fourth rotation angle. And... Figure 6A In branch two, the direction event listener needs to be based on sensor data reported by the sensor service (such as...). Figure 12 (As shown by the dashed arrow in the image), the second rotation angle is calculated. This calculation method does not involve filtering or other processing, and the calculated second rotation angle is any angle value between 0° and 360°, which cannot accurately correspond to the four screen directions. Further decision-making is required, so the accuracy is low.
[0211] Typically, accelerometers and gyroscopes do not have system wake-up capabilities, while motion sensors do. Here, "system" primarily refers to the AP subsystem. System wake-up capability refers to the ability to wake the system from sleep mode.
[0212] The lack of system wake-up capability for accelerometers and gyroscopes means that when the system is in sleep mode, after the accelerometers and gyroscopes collect data, they cannot wake up the system. Therefore, when the system is awake, they cannot transmit the collected data to the corresponding modules in the system, such as to the sensor service.
[0213] The ability of a motion sensor to wake up the system means that when the system is in sleep mode, the motion sensor can wake up the system after detecting a rotation switching event, and then transmit the rotation switching event to the corresponding module in the system, such as the motion service engine, while the system is in a wake-up state.
[0214] In some embodiments, when the system is in sleep mode, the first application can unregister the rotation switching service. This way, when the system is in sleep mode, the motion sensor does not need to send rotation switching events to the motion engine service, and the system will not be woken up. This reduces the number of system wake-ups and saves power.
[0215] In other embodiments, when the system enters sleep mode, the mobile phone can cancel the registration of the first application for the rotation switching service through the power saving management module. This allows for the control of unregistering applications that did not cancel the rotation switching service during system sleep, thereby saving power.
[0216] See Figure 13 The mobile phone controls the first application to unregister and rotate to switch services through the power saving management module (taking the Power Saver app as an example). This includes:
[0217] S1301, Power Saving Management Module is frozen as the first application.
[0218] For example, when the system detects that it meets the hibernation conditions, such as when the screen has not been turned on for a long time, the power saving management module can freeze all applications running in the background, including the first application, and control the system to hibernate.
[0219] S1302, The power saving management module sends a first notification to the direction event listener, and the first notification indicates that the first application is frozen.
[0220] In this way, the power-saving management module can notify the direction event listener that the first application has been frozen.
[0221] S1303, The direction event listener detects whether the first application has registered a rotation switching service.
[0222] If a rotation switching service is detected to still be registered, it indicates that the first application did not unregister the rotation switching service while the system was in hibernation. The direction event listener can execute S1304 below to forcibly unregister the service.
[0223] If an unregistered rotation switching service is detected, it indicates that the first application has unregistered the rotation switching service while the system is in hibernation, and the direction event listener does not need to perform the unregistration.
[0224] S1304, The direction event listener cancels the registration of the first application for the rotation switching service with the motion engine service.
[0225] Furthermore, after deregistration, registration must be restored when the first application is unfrozen to avoid affecting the window rotation of the first application. Specifically, see S1305-S1307 below:
[0226] S1305, the first application to unfreeze the power saving management module.
[0227] For example, when the system is detected to meet the conditions for exiting hibernation, the power-saving management module can control the system to exit hibernation and unfreeze various applications, including the first application.
[0228] S1306, The power saving management module sends a second notification to the direction event listener, and the second notification indicates that the first application has been unfrozen.
[0229] In this way, the power-saving management module can notify the direction event listener that the first application has been unfrozen.
[0230] S1307. In response to the second notification, the direction event listener restores the first application's registration for the rotation switching service to the motion engine service.
[0231] In this way, after the first application is unfrozen, it is possible to continue to obtain rotation switching events detected by motion sensors based on the registration of rotation switching services.
[0232] Furthermore, when setting the display orientation of a window, one or more of the following basic strategies can be followed. For example, in S1110 above, the first application can combine these strategies to set the display orientation. As another example, in S1111 above, the window manager / activity manager can combine these strategies to control window rotation. It should be stated once again that the window orientation setting method provided in this application embodiment should follow the following basic strategies, but these strategies are not the core content of this application embodiment, and will not be elaborated upon further here.
[0233] Strategy 1: If screen rotation is disabled and the user has fixed the display orientation, then set the display orientation to the user's setting.
[0234] As discussed in section 3, "Screen Rotation Function," when the screen rotation function is disabled, the user can manually switch the window's display orientation, meaning the user has fixed the display orientation. In this case, as the screen orientation changes, the primary application can maintain the user's fixed display orientation, thus prioritizing the user's chosen display orientation.
[0235] Strategy 2: If the application interface of the first application is displayed on a non-default screen, then set it to the display orientation set by the user for that non-default screen, or the default display orientation in the non-default screen.
[0236] In a foldable phone (referred to as a foldable device), the foldable screen can be folded to form at least two sub-screens. Therefore, a foldable device has at least two screens.
[0237] Furthermore, mobile phones can also include screens other than flexible foldable screens, such as bi-fold (two-fold inward) folding devices, and may also include an outer screen. A bi-fold (two-fold inward) folding device refers to a device where, after the folding screen is folded, it can form two sub-screens with their front faces facing each other and invisible to the user. The outer screen is a screen located on the back of one of the sub-screens. Therefore, foldable screen devices can have even more screens.
[0238] In foldable screen devices, the default screen can be configured for various states, such as folded, semi-folded, and unfolded. For example, in a bi-fold inward-folding device, the folding screen is the default screen in the unfolded state, while the outer screen is a non-default screen. Acceleration and other data displayed on the non-default screen will be inaccurate. Therefore, if the application interface of the first application is displayed on the non-default screen, the window's display orientation can be set to the user-defined orientation when launching the first application on the non-default screen, or the default display orientation within the non-default screen.
[0239] Strategy 3: If the phone is in case mode, then set the display orientation to the one set in case mode.
[0240] The features offered by Case Mode include automatically turning off the screen when the phone is closed with a case (such as a phone case) and automatically turning on the screen when the case is opened. Typically, Case Mode is configured with a specific display orientation. That is, in Case Mode, the window's display orientation is fixed and will not change with the screen orientation. Therefore, while in Case Mode, you can set the window's display orientation to the orientation specified in Case Mode.
[0241] Strategy 4: If the phone is in multi-window mode and a specific display orientation is configured for each window, then set it to the specified display orientation configured for that window.
[0242] Multi-window mode refers to the display of multiple application windows on the screen, such as a floating video playback window or split-screen display. In some scenarios, a specific display orientation can be configured in multi-window mode.
[0243] Taking the floating video playback window with the specified display orientation as portrait mode as an example, see [link to example]. Figure 5A and Figure 14 The phone can display interface 501, which includes a video playback window 501-a. In response to a user swiping up from the bottom of interface 501, the phone can display interface 1401. Interface 1401 can include the corresponding desktop window and the video playback window 501-a. The video playback window 501-a in interface 1401 is displayed as a floating window, and its display orientation is portrait. When interface 1401 is displayed, if the user rotates the phone counterclockwise in the direction of the arrow in the diagram, interface 1402 is displayed. At this time, the screen orientation switches to landscape, but the display orientation of the video playback window 501-a in interface 1402 does not change, i.e., it maintains the specified portrait display orientation. Based on this, when the current window is in multi-window mode and the window is configured with a specified display orientation, the window's display orientation can be set to the specified display orientation in multi-window mode.
[0244] Strategy 5: If the window's display orientation is set to LOCKED, then set it to the locked display orientation.
[0245] Users or applications can set and lock the display orientation of a specific window. For example, in response to a user's setting... Figure 5A The click operation marked 502-b in interface 502 shows that the application can lock the current landscape display orientation of window 501-a. In this case, the window's display orientation is locked and cannot be changed. Based on this, when the window's display orientation is locked, the window's display orientation can be set to the locked orientation.
[0246] Strategy 6: If the window does not support rotation, set it to the window's default display orientation.
[0247] Some windows are not compatible with rotation and can only be displayed in the default orientation, such as portrait mode. Therefore, if a window does not support rotation, its display orientation can be set to its default orientation.
[0248] Strategy 7 enables screen rotation and sets the window's display orientation to USER, UNSPECIFIED, USER_LANDSCAPE, USER_PORTRAIT, or FULL_USER, allowing you to adjust the display orientation based on the screen orientation.
[0249] Strategy 8: If the window's display orientation is set to SENSOR, FULL_SENSOR, SENSOR_LANDSCAPE, or SENSOR_PORTRAIT, then the display orientation can be set according to the screen orientation, regardless of whether the screen rotation function is enabled or not.
[0250] Strategy nine disables screen rotation and sets the window's display orientation to NOSENSOR, LANDSCAPE, PORTRAIT, REVERSE_LANDSCAPE, or REVERSE_PORTRAIT, allowing the use of the display orientation requested by the application. This is one application scenario for the window orientation setting method provided in this application embodiment, where the application's requested display orientation can be the one set by the first application in this application embodiment based on the fourth rotation angle.
[0251] Alternatively, if none of the above strategies one through nine are satisfied, the display direction requested by the application can be used, such as the display direction set by the first application based on the fourth rotation angle.
[0252] This application also provides an electronic device, which may include a display screen, a memory, and one or more processors (such as a CPU, GPU, NPU, etc.). The display screen, memory, and processor are coupled. The memory is used to store computer program code, which includes computer instructions. When the processor executes the computer instructions, the electronic device can perform various functions or steps performed by the device in the above method embodiments.
[0253] This application also provides a chip system including at least one processor and at least one interface circuit. The processor and the interface circuit are interconnected via lines. For example, the interface circuit can be used to receive signals from other devices (e.g., the memory of an electronic device). As another example, the interface circuit can be used to send signals to other devices (e.g., the processor). Exemplarily, the interface circuit can read instructions stored in the memory and send the instructions to the processor. When the instructions are executed by the processor, the electronic device can perform the steps in the above embodiments. Of course, the chip system may also include other discrete devices, and this application does not specifically limit this.
[0254] This embodiment also provides a computer storage medium storing computer instructions. When the computer instructions are executed on an electronic device, the electronic device performs the aforementioned method steps to implement the image processing method described above.
[0255] This embodiment also provides a computer program product that, when run on a computer, causes the computer to perform the aforementioned steps to implement the image processing method described above.
[0256] In addition, embodiments of this application also provide an apparatus, which may specifically be a chip, component, or module. The apparatus may include a connected processor and a memory; wherein the memory is used to store computer execution instructions, and when the apparatus is running, the processor may execute the computer execution instructions stored in the memory to cause the chip to execute the image processing methods in the above-described method embodiments.
[0257] In this embodiment, the electronic device, computer storage medium, computer program product or chip are all used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can be referred to the beneficial effects of the corresponding method provided above, and will not be repeated here.
[0258] Through the above description of the embodiments, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0259] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0260] The unit described as a separate component may or may not be physically separate. The component shown as a unit can be one physical unit or multiple physical units, that is, it can be located in one place or distributed in multiple different places. Some or all of the units can be selected to achieve the purpose of the solution in this embodiment according to actual needs.
[0261] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0262] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, essentially or in other words, the parts that contribute to the prior art, or all or part of the technical solutions, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0263] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application and are not intended to limit it. Although this application has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of this application without departing from the spirit and scope of the technical solutions of this application.
Claims
1. A method for setting the orientation of a window, characterized in that, Applied to an electronic device, the electronic device including a direction event listener, the electronic device having a first application installed, the method includes: After the first application is launched, the direction event listener receives a first registration request from the first application; In response to a change in the screen orientation of the screen in the electronic device, the orientation event listener sends a first angle to the first application. The first angle is any one of four target angles and corresponds to the changed screen orientation. The first angle is used by the first application to set the display orientation of a first window, which is a window in the application interface of the first application.
2. The method according to claim 1, characterized in that, The electronic device also includes a motion sensor; After the direction event listener receives the first registration request from the first application, the direction further includes: The orientation event listener registers a rotation switching service with the motion sensor; In response to a change in the screen orientation, the orientation event listener sends a first angle to the first application, including: In response to a change in screen orientation, the orientation event listener receives a rotation switching event from the motion sensor, the rotation switching event indicating a switch to a first screen orientation; The orientation event listener sends the first angle to the first application based on the rotation switching event, and the first angle corresponds to the first screen orientation.
3. The method according to claim 2, characterized in that, The direction event listener registers rotation switching services with the motion sensor, including: The application whitelist includes the first application, and the direction event listener registers the rotation switching service with the motion sensor.
4. The method according to claim 2 or 3, characterized in that, After the orientation event listener registers the rotation switching service with the motion sensor, the method further includes: The directional event listener receives a first notification, which indicates that the first application should be frozen. In response to the first notification, the direction event listener queries whether there is a registration for the rotation switching service; If a registration for the rotation switching service is found, the direction event listener unregisters the rotation switching service from the motion sensor.
5. The method according to claim 4, characterized in that, The electronic device is also equipped with a power-saving management application; The direction event listener receives a first notification, including: The directional event listener receives the first notification from the power-saving management application; wherein, the power-saving management module freezes the first application after detecting that the system hibernation conditions of the electronic device are met, and sends the first notification after freezing the first application.
6. The method according to claim 4 or 5, characterized in that, After the direction event listener unregisters the rotation switching service from the motion sensor, the method further includes: The directional event listener receives a second notification, which instructs the first application to be unfrozen. In response to the second notification, the orientation event listener resumes registration of the rotation switching service with the motion sensor.
7. The method according to claim 6, characterized in that, The electronic device is also equipped with a power-saving management application; The direction event listener receives a second notification, including: The directional event listener receives the second notification from the power-saving management application; wherein, the power-saving management module unfreezes the first application after the electronic device is woken up by the system, and sends the second notification after unfreezing the first application.
8. The method according to any one of claims 2-7, characterized in that, The direction event listener sends the first angle to the first application based on the rotation switching event, including: The direction event listener converts the rotation switching event into the first angle; The direction event listener sends the first angle to the first application via the direction event process.
9. The method according to any one of claims 1-8, characterized in that, The electronic device also has a second application installed; The method further includes: After the second application is launched, the direction event listener receives a second registration request from the second application; The orientation event listener calculates a second angle based on sensor data collected by an accelerometer and / or a gyroscope sensor, where the second angle is any angle between 0° and 360°. The direction event listener sends the second angle to the second application. The second angle is used by the second application to set the display direction of the second window, which is a window in the application interface of the second application.
10. The method according to claim 9, characterized in that, The second application is not included in the application whitelist, and the direction event listener does not register rotation switching services with the motion sensor.
11. The method according to any one of claims 1-10, characterized in that, The electronic device also has a third application installed; The method further includes: After the third application is launched, the third application calculates the rotation angle of the screen based on sensor data collected by the accelerometer and / or gyroscope sensor, and uses this information to set the display orientation of the window in the third application.
12. The method according to any one of claims 1-11, characterized in that, The first application, the second application, and the third application are not system applications.
13. An electronic device, characterized in that, The electronic device includes: one or more processors; a memory; wherein the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code including computer instructions, and the one or more processors call the computer instructions to cause the electronic device to perform the method as described in any one of claims 1-12.
14. A computer program product containing instructions, characterized in that, When the computer program product is run on an electronic device, it causes the electronic device to perform the method as described in any one of claims 1-12.
15. A computer-readable storage medium comprising instructions, characterized in that, When the instructions are executed on an electronic device, the electronic device causes the electronic device to perform the method as described in any one of claims 1-12.