A method and electronic device for detecting screen orientation
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HONOR DEVICE CO LTD
- Filing Date
- 2024-12-31
- Publication Date
- 2026-06-30
AI Technical Summary
In existing technologies, the detection of switching between landscape and portrait orientations on electronic devices is inaccurate, resulting in the inability to provide accurately adapted services and affecting user experience.
By dynamically adjusting the angle threshold for detecting screen orientation, the angle threshold is dynamically adjusted after the electronic device has been in a stationary state for a continuous period of time exceeding a first duration. This avoids triggering screen orientation switching detection when the device is slightly rotated, thereby improving the accuracy of the detection results.
It improves the accuracy of screen orientation detection, reduces false detections caused by slight rotation, and enhances the user experience.
Smart Images

Figure CN122308692A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of terminal technology, and in particular to a method for detecting screen orientation and an electronic device. Background Technology
[0002] As the user rotates the electronic device, the screen orientation can switch between landscape and portrait modes. After this orientation change, the device can provide corresponding services to enhance the user experience. For example, after switching to landscape mode, the device can change the video playback window to a landscape display, making it easier to watch videos.
[0003] However, in existing technologies, electronic devices do not accurately detect the switching between landscape and portrait orientations, which can lead to inaccurate provision of adapted services and negatively impact the user experience. For example, if the electronic device detects a switch to landscape orientation when the screen is in portrait mode, it will switch the video playback window to landscape mode, thus affecting the user's video viewing experience. Summary of the Invention
[0004] This application provides a screen orientation detection method and electronic device, which can dynamically adjust the angle threshold for detecting screen orientation, accurately detect screen orientation changes, thereby facilitating the accurate provision of services that match the screen orientation and improving user experience.
[0005] To achieve the above objectives, this application adopts the following technical solution:
[0006] In a first aspect, this application provides a method for detecting screen orientation, applied to an electronic device, the electronic device including a screen.
[0007] Specifically, the method includes: when the screen orientation is a first orientation, if the corresponding angles of the screen (α0, β0, γ01, γ02 in the following text) meet a first angle threshold, a switch to a second orientation is detected. If the screen orientation switches back to the first orientation, and the electronic device remains stationary for a duration exceeding a first duration, a switch to the second orientation is detected if the corresponding angle of the screen meets a second angle threshold. Note that the first and second angle thresholds are different.
[0008] The first direction can be landscape, such as a forward landscape direction or a reverse landscape direction. Correspondingly, the second direction can be portrait, such as a forward portrait direction or a reverse portrait direction. The first angle threshold is the initial threshold used for switching from landscape to portrait, as shown in β and γ2 below. The second angle threshold is the threshold after adjusting the first angle threshold, as shown in β' and γ2' below.
[0009] Alternatively, the first direction can be a portrait orientation, such as a forward portrait orientation or a reverse portrait orientation. Correspondingly, the second direction can be a landscape orientation, such as a forward landscape orientation or a reverse landscape orientation. The first angle threshold is the initial threshold used for switching from portrait to landscape, as shown in α and γ1 below, and the second angle threshold is the threshold after adjusting the first angle threshold, as shown in α' and γ1' below.
[0010] In summary, by employing this application, the angle threshold used by the electronic device differs when the screen orientation is switched from the first orientation to the second orientation twice. That is, the angle threshold is dynamically changing, not fixed. Furthermore, when the electronic device remains stationary for a continuous period exceeding the first duration—meaning the device's posture has remained unchanged for some time—the device uses a dynamic angle threshold for detection. In this case, the device's posture remaining unchanged for a period likely indicates that the user is holding or leaning the device against an object while using it. In such situations, slight rotation of the electronic device is merely an unconscious action by the user, such as simply due to unstable hand grip, and the user does not intend to switch the screen orientation. Therefore, by using a dynamic angle threshold, the detection of a screen orientation switch can be avoided only after slight rotation of the electronic device, ensuring that a significant rotation of the device triggers the detection of a screen orientation switch. This improves the accuracy of the screen orientation detection results.
[0011] In one possible design of the first aspect, after the continuous duration of the electronic device being in a stationary state exceeds a first duration, before detecting that the screen orientation has switched to the second orientation after the angle corresponding to the screen meets a second angle threshold, the above method further includes: adjusting the first angle threshold to obtain the second angle threshold.
[0012] In other words, the angle threshold is adjusted only after the electronic device's posture has remained unchanged for a period of time. This allows for targeted adjustments to the angle threshold in cases where false detections may occur.
[0013] In one possible design of the first aspect, before detecting that the screen orientation has switched to the second orientation after the angle corresponding to the screen meets the second angle threshold, the above method further includes: determining that the difference between the angle corresponding to the screen and the first angle threshold when the screen is stationary is within the range of the difference.
[0014] If the difference between the screen's corresponding angle and the first angle threshold is within the specified range, it indicates that the screen's corresponding angle is close to the first angle threshold. In this case, even a slight rotation of the electronic device can easily trigger the first angle threshold. Therefore, using the first angle threshold is highly prone to false detection.
[0015] By adopting this design approach, when it is determined that using the first angle threshold is very likely to cause false detection, using the second angle threshold detection can more effectively avoid false detection.
[0016] In one possible design of the first aspect, after determining that the difference between the angle corresponding to the screen and the first angle threshold when the screen is stationary is within the range of the difference, the method further includes: after the difference between the angle corresponding to the screen and the first angle threshold is no longer within the range of the difference as the electronic device is rotated, when the angle corresponding to the screen satisfies the first angle threshold, detecting that the screen orientation has switched to the second orientation.
[0017] If, as the electronic device is rotated, the difference between the screen's corresponding angle and the first angle threshold is no longer within the specified range, it indicates that the screen's corresponding angle has deviated significantly from the first angle threshold. In this case, the electronic device needs to be rotated substantially to trigger the first angle threshold.
[0018] Using this design, if the electronic device is unlikely to trigger the first angle threshold, then the first angle threshold is used to detect screen orientation changes. This reduces the impact on the user experience.
[0019] In one possible design approach of the first aspect, after the difference between the angle corresponding to the screen and the first angle threshold is no longer within the range of the difference, and before the screen orientation is detected to switch to the second orientation after the angle corresponding to the screen satisfies the first angle threshold, the above method further includes: restoring from the second angle threshold to the first angle threshold.
[0020] By employing this design, the electronic device can continue to use the first angle threshold to detect screen orientation changes by restoring the first angle threshold.
[0021] In one possible design of the first aspect, when the screen orientation is switched back to the first orientation, the above method further includes: the continuous duration of the electronic device being in a stationary state exceeds the first duration, but the difference between the angle corresponding to the screen and the first angle threshold when in the stationary state is not within the range of the difference; when the angle corresponding to the screen meets the first angle threshold, the screen orientation is detected to be switched to the second orientation.
[0022] In other words, if the electronic device's posture remains unchanged for a period of time, but it is far from the first angle threshold, the electronic device will not trigger the first angle threshold when it is slightly rotated. Therefore, the first angle threshold will still be used to detect the change in screen orientation, reducing invalid adjustments.
[0023] In one possible design approach of the first aspect, when the screen orientation is a first orientation, when the angle corresponding to the screen meets a first angle threshold, the screen orientation is detected to switch to a second orientation, including: when the screen orientation is a first orientation, the continuous duration of the electronic device being in a stationary state does not exceed a first duration, and when the angle corresponding to the screen meets the first angle threshold, the screen orientation is detected to switch to a second orientation.
[0024] The condition where the continuous duration of the electronic device remaining stationary does not exceed the first duration includes situations where the electronic device is constantly in motion, or where the electronic device is stationary but for a short period. In such cases, triggering the angle threshold when the electronic device is slightly rotated is reasonable. Using this design approach, for this situation, the electronic device uses the first angle threshold to detect screen orientation changes, which improves the accuracy of the detection.
[0025] In one possible design of the first aspect, after detecting that the screen orientation has switched to the second orientation when the angle corresponding to the screen meets the second angle threshold, the above method further includes: restoring from the second angle threshold to the first angle threshold.
[0026] Using this design, the electronic device restores the first angle threshold each time it detects a change in screen orientation to the second orientation. This way, when switching back to the first orientation, the electronic device can use the first angle threshold as the initial angle threshold for detection, avoiding unreasonable angle thresholds caused by cumulative adjustments.
[0027] In one possible design approach of the first aspect, if the electronic device remains stationary for a continuous period exceeding a first duration, and the screen angle meets a second angle threshold, a switch to the second orientation is detected. This includes: after detecting that the continuous period of being stationary exceeds the first duration, the electronic device adjusts the first angle threshold to obtain the second angle threshold. In other words, the electronic device can adjust the angle threshold after detecting that its posture has not changed for a period of time. It should be noted that if the electronic device's posture does not change for a period of time, the screen angle will not change, therefore there is no need to detect whether the angle threshold has been triggered.
[0028] Subsequently, after the electronic device detects that the continuous duration of the stationary state has not exceeded the first duration, that is, when the electronic device may move, the angle of the screen will change. Accordingly, the electronic device needs to detect whether the angle threshold is triggered, that is, whether the angle of the screen meets the current second angle threshold. When the angle of the screen meets the second angle threshold, the screen direction is detected to switch to the second direction.
[0029] Using this design, if the electronic device's posture remains unchanged for a period of time, it adjusts the angle threshold. If the posture of the electronic device may change over a period of time, it detects whether the angle threshold has been triggered. In this way, the electronic device can take targeted actions for different situations, improving the rationality of detection.
[0030] In one possible design approach of the first aspect, the first orientation is landscape and the second orientation is portrait. The first angle threshold includes a first β (hereinafter referred to as β), and the second angle threshold includes a second β (hereinafter referred to as β'). β refers to the angle threshold between the vertical bisector of the screen and the vertical direction when switching from landscape to portrait orientation. Alternatively, the first angle threshold includes a first γ2 (hereinafter referred to as γ2), and the second angle threshold includes a second γ2 (hereinafter referred to as γ2'). γ2 refers to the angle threshold between the vertical bisector of the screen and the horizontal direction when switching from a landscape and horizontally positioned state to a portrait state.
[0031] In one possible design approach of the first aspect, the first orientation is portrait mode and the second orientation is landscape mode. The first angle threshold includes a first α (hereinafter referred to as α), and the second angle threshold includes a second α (hereinafter referred to as α'). α refers to the angle threshold between the vertical bisector of the screen and the horizontal direction when switching from a portrait orientation to a landscape orientation. Alternatively, the first angle threshold includes a first γ1 (hereinafter referred to as γ1), and the second angle threshold includes a second γ1 (hereinafter referred to as γ1'). γ1 refers to the angle threshold between the horizontal bisector of the screen and the horizontal direction when switching from a portrait and horizontally positioned state to a landscape orientation.
[0032] Secondly, 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 following steps: when the screen orientation is a first orientation, and the corresponding angle of the screen meets a first angle threshold, a switch to a second orientation is detected; when the screen orientation switches back to the first orientation, and the continuous duration of the electronic device being stationary exceeds a first duration, a switch to the second orientation is detected when the corresponding angle of the screen meets a second angle threshold; wherein the first angle threshold and the second angle threshold are different.
[0033] In one possible design approach of the second aspect, when the instruction is executed by the processor, the electronic device performs the following steps: adjusting the first angle threshold to obtain the second angle threshold.
[0034] In one possible design approach in the second aspect, when the instruction is executed by the processor, the electronic device performs the following steps: determining that the difference between the angle corresponding to the screen when in a stationary state and a first angle threshold is within the range of the difference.
[0035] In one possible design approach of the second aspect, when the instruction is executed by the processor, the electronic device performs the following steps: after the difference between the angle corresponding to the screen and the first angle threshold is no longer within the range as the electronic device is rotated, the screen orientation is detected to switch to the second orientation after the angle corresponding to the screen meets the first angle threshold.
[0036] In one possible design of the second aspect, when the instruction is executed by the processor, the electronic device performs the following steps: recovering from the second angle threshold to the first angle threshold.
[0037] In one possible design approach of the second aspect, when the instruction is executed by the processor, the electronic device performs the following steps: the continuous duration of the electronic device being in a stationary state exceeds a first duration, but the difference between the angle corresponding to the screen and the first angle threshold when in the stationary state is not within the range of the difference; when the angle corresponding to the screen meets the first angle threshold, the screen orientation is detected to switch to the second orientation.
[0038] In one possible design approach of the second aspect, when the instruction is executed by the processor, the electronic device performs the following steps: when the screen orientation is a first orientation, the duration of the continuous period during which the electronic device is in a stationary state does not exceed a first duration; when the angle corresponding to the screen meets a first angle threshold, the screen orientation is detected to switch to a second orientation.
[0039] In one possible design approach of the second aspect, when the instruction is executed by the processor, the electronic device performs the following steps: after the electronic device detects that the continuous duration of being in a stationary state exceeds a first duration, it adjusts the first angle threshold to obtain a second angle threshold; after the electronic device detects that the continuous duration of being in a stationary state does not exceed the first duration, it detects whether the angle corresponding to the screen meets the second angle threshold; when the angle corresponding to the screen meets the second angle threshold, it detects that the screen orientation has switched to the second orientation.
[0040] 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.
[0041] 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.
[0042] 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.
[0043] 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
[0044] Figure 1 A schematic diagram illustrating a screen orientation provided in an embodiment of this application;
[0045] Figure 2 A schematic diagram of a set of angle thresholds provided for embodiments of this application;
[0046] Figure 3 A schematic diagram of another set of angle thresholds provided for embodiments of this application;
[0047] Figure 4 A schematic diagram illustrating the enabling and disabling of screen rotation function provided in this application embodiment;
[0048] Figure 5 This is a schematic diagram illustrating a display orientation switching method provided in an embodiment of this application.
[0049] Figure 6 A diagram showing the survey results of a screen rotation function switch provided in an embodiment of this application;
[0050] Figure 7 A hardware structure diagram of a mobile phone provided in an embodiment of this application;
[0051] Figure 8 A software architecture diagram of a mobile phone provided in an embodiment of this application;
[0052] Figure 9 A flowchart illustrating a screen orientation detection method provided in an embodiment of this application;
[0053] Figure 10 A scene diagram illustrating the adjustment of an angle threshold provided in an embodiment of this application;
[0054] Figure 11 A scene diagram showing a scenario where the angle threshold is not adjusted, provided for an embodiment of this application;
[0055] Figure 12 Another scenario diagram for adjusting the angle threshold provided in this application embodiment;
[0056] Figure 13This is another scenario diagram for an embodiment of this application where the angle threshold is not adjusted. Detailed Implementation
[0057] 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.
[0058] 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.
[0059] 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.
[0060] Before introducing the embodiments of this application, the main terms involved in the embodiments of this application will be briefly introduced below.
[0061] 1. Screen orientation.
[0062] Screen orientation refers to the actual orientation of the physical screen of an electronic device.
[0063] Screen orientation typically includes portrait orientation, landscape orientation, reverse portrait orientation, and reverse landscape orientation. Specifically, portrait orientation is the opposite of reverse portrait orientation, and landscape orientation is the opposite of reverse landscape orientation.
[0064] See Figure 1 State 101 is the orientation for portrait mode, state 102 is the orientation for reverse portrait mode, state 103 is the orientation for landscape mode, and state 104 is the orientation for reverse landscape mode.
[0065] Normally, rotating an electronic device changes the orientation of its screen. For example, in... Figure 1 In state 101, rotating the phone clockwise by about 90° will bring you to state 103.
[0066] It should be noted that electronic devices can have multiple screens, each with its own orientation. For example, a bi-fold phone can include a folding screen and an outer screen, each with its own orientation.
[0067] 2. Angle threshold.
[0068] Angle thresholds are used by electronic devices to detect changes in screen orientation. Typically, angle thresholds include α, β, γ1, and γ2.
[0069] Here, α and γ1 are the angle thresholds for switching from portrait to landscape mode. That is, when the screen orientation of the electronic device is portrait, a switch to landscape mode is triggered when either angle threshold α or γ1 is met. Landscape mode refers to both forward and reverse landscape orientations, while portrait mode refers to both forward and reverse portrait orientations, and the same applies below.
[0070] For example, see Figure 2 α refers to the angle threshold between the vertical bisector of the screen and the horizontal direction when switching from portrait to landscape orientation. The vertical bisector of the screen is perpendicular to the shorter side of the screen. For example, when the screen is in portrait orientation... Figure 2 In state 201, the screen orientation is portrait. Then, rotate the phone in the direction shown by the arrow in the image until the screen is in portrait orientation. Figure 2 In state 202, the angle between the vertical bisector of the screen and the horizontal direction is exactly α, which satisfies the angle threshold α for switching to landscape mode.
[0071] See also Figure 2γ1 refers to the angle threshold between the screen's horizontal bisector and the horizontal direction when the screen switches from portrait to landscape mode. The horizontal bisector is perpendicular to the screen's long side. For example, when the screen is in portrait mode... Figure 2 When in the horizontal position shown in state 203, the screen orientation is portrait (e.g., playing a video in portrait mode). Then, rotate the phone in the direction indicated by the arrow in the diagram until the screen reaches the desired orientation. Figure 2 In state 204, the angle between the horizontal bisector of the screen and the horizontal direction is exactly γ1, which satisfies the angle threshold γ1 for switching to landscape mode.
[0072] Here, β and γ2 are the angle thresholds for switching from landscape to portrait mode. In other words, when the screen orientation of the electronic device is landscape, switching to portrait mode is triggered when either angle threshold β or γ2 is met.
[0073] Further, see Figure 3 β refers to the angle threshold between the screen's vertical bisector and the vertical direction when switching from landscape to portrait orientation. For example, when the screen is in landscape orientation... Figure 3 In state 301, the screen orientation is landscape. Then, rotate the phone in the direction shown by the arrow in the image until the screen is in landscape mode. Figure 3 In state 302, the angle between the vertical bisector of the screen and the vertical direction is exactly β, which satisfies the angle threshold β for switching to portrait mode.
[0074] See also Figure 3 γ2 refers to the angle threshold between the vertical bisector of the screen and the horizontal direction when the screen switches from a landscape to a portrait orientation. For example, when the screen is in a portrait orientation... Figure 3 When in the horizontal position shown in state 303, the screen orientation is landscape (e.g., playing a video in landscape mode). Then, rotate the phone in the direction shown by the arrow in the diagram until the screen reaches the desired orientation. Figure 3 In state 304, the angle between the vertical bisector of the screen and the horizontal direction is exactly γ2, which satisfies the angle threshold γ2 for switching to portrait mode.
[0075] Furthermore, each screen can have a corresponding angle threshold, which can be the same or different for different screens. Taking a bi-fold inward-folding phone as an example, the angle threshold of the folding screen is the same as that of the outer screen, which is α = 20°, β = 25°, γ1 = 45°, and γ2 = 35°.
[0076] 3. Screen rotation function.
[0077] Screen rotation is a function provided by electronic devices that allows windows on the screen to rotate as the screen orientation changes.
[0078] 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").
[0079] 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.
[0080] 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.
[0081] See Figure 5The phone can display interface 501, with the screen orientation being portrait. Interface 501 includes a video playback window 501-a, which is also displayed in portrait orientation. 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 being reversed to landscape orientation. Interface 502 also includes a video playback window 501-a, which is also displayed in reverse landscape orientation. 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.
[0082] When screen rotation is turned off, electronic devices can maintain the display orientation of windows on the screen regardless of screen orientation.
[0083] In addition, users can manually switch the window's display orientation whether the screen rotation function is enabled or disabled.
[0084] The state switching detection method provided in this application embodiment can be applied to scenarios involving screen orientation detection.
[0085] In some implementations, the aforementioned angle thresholds are fixed thresholds. For example, α = 20°, β = 25°, γ1 = 45°, γ2 = 35°. Or, for another example, α = 20°, β = 20°, γ1 = 45°, γ2 = 3°. The electronic device can always detect the screen orientation using a fixed threshold.
[0086] For example, when the screen of an electronic device is in portrait mode, the electronic device can detect that the screen orientation has been switched to landscape mode if the angle α0 ≤ α between the vertical bisector of the screen and the horizontal direction, or if the angle γ01 ≥ γ1 between the horizontal bisector of the screen and the horizontal direction.
[0087] For example, when the screen of an electronic device is in landscape mode, the electronic device can detect that the screen orientation has been switched to portrait mode if the angle β0 between the vertical bisector of the screen and the vertical direction is ≤β, or if the angle γ02 between the vertical bisector of the screen and the horizontal direction is ≥γ2.
[0088] Furthermore, electronic devices can also detect a switch to landscape mode by combining the direction of motion, such as the direction of acceleration, specifically by switching to a forward landscape orientation or a reverse landscape orientation, or by detecting a switch to portrait mode, specifically by switching to a forward portrait orientation or a reverse portrait orientation.
[0089] Subsequently, electronic devices can provide adapted services based on the detection results. For example, electronic devices can control the rotation of windows based on the detection results, so that the display orientation of the window matches the screen orientation.
[0090] However, for electronic devices that detect screen orientation based on a fixed threshold, the following sources of sound related to screen rotation functionality have been collected:
[0091] "This has happened twice. I didn't select screen rotation, and the portrait mode turned into the landscape mode."
[0092] "I've turned off automatic screen rotation, but it still spins randomly."
[0093] "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."
[0094] "When watching the video in landscape mode, there is a bug that causes it to flip to the other side."
[0095] "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."
[0096] "Whether in image display or Toutiao" TM The automatic rotation of some videos often causes problems.
[0097] These user feedback reports clearly show that electronic devices that detect screen orientation based on a fixed threshold will result in a poor user experience for screen rotation functions and cause abnormal rotation issues.
[0098] Further, see Figure 6 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 abnormal rotation issues that occur with the screen rotation function.
[0099] Regarding the abnormal rotation issue reported by users, we enabled the screen rotation function and tested it. The tests revealed that abnormal rotation is highly likely to occur in the following scenarios: when the user is holding the electronic device and is positioned near an angle threshold, such as near β and γ2 or near α and γ1. In this situation, a slight rotation of the electronic device might meet the switching condition, and the device would detect a change in screen orientation. However, this slight rotation might be an unconscious action by the user, who has no intention of changing the screen orientation. Detecting a screen orientation change in this case would clearly not meet the user's expectations, resulting in inaccurate detection results.
[0100] To address the aforementioned issues, this application provides a screen orientation detection method that dynamically adjusts an angle threshold when the electronic device remains stationary for a period of time, preventing the detection of screen orientation changes even with slight rotation of the electronic device. This improves the accuracy of the detection results.
[0101] 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.
[0102] The embodiments of this application will be mainly described using a mobile phone as an example.
[0103] See Figure 7 This is a hardware structure diagram of a mobile phone. For example... Figure 7 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.
[0104] The sensor module 280 may further include accelerometers 280E, gyroscopes 280B, etc.
[0105] 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.
[0106] 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).
[0107] Different processing units can be independent devices or integrated into one or more processors. For example, an AP can integrate a CPU, GPU, etc.
[0108] In some embodiments, the processor 210 can execute an image display method by running instructions stored in the internal memory 221.
[0109] 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.
[0110] 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.
[0111] 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.
[0112] 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.
[0113] Mobile phones can achieve camera functions through cameras 293, ISP, video codecs, GPU, display panels 294, application processors (AP), neural network processors (NPU), etc.
[0114] 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.
[0115] 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.
[0116] 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.
[0117] In some embodiments, 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.
[0118] 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.
[0119] 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.
[0120] See Figure 8 The software architecture of a mobile phone can include an AP subsystem and a sensor management component (sensorhub) subsystem.
[0121] The AP subsystem includes an application layer, an application framework layer, a native 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. This application does not specifically limit this.
[0122] 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.
[0123] The application layer may also include a Motion Engine Service. The Motion Engine Service manages the registration of rotation switching events. After each module (such as an application) registers its rotation switching event with the Motion Engine Service, the service can distribute the received rotation switching events to the corresponding module, such as one or more apps within an application, or the window manager / activity manager in the application framework layer.
[0124] For example, some applications can detect the screen orientation themselves and set the window display orientation based on the detected screen orientation. The motion engine service can distribute rotation switching events to these applications, so that these applications can directly obtain the screen orientation and use it to set the window display orientation without having to calculate it themselves.
[0125] The rotation switching event is used to indicate a change in screen orientation. Specifically, the rotation switching event can indicate switching to portrait orientation, landscape orientation, reverse portrait orientation, and reverse landscape orientation. For example, event 0 indicates switching to portrait orientation, event 1 indicates switching to landscape orientation, and so on.
[0126] 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.
[0127] The application framework layer may include an activity manager, a window manager, a sensor manager, an extended device manager, and so on.
[0128] 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.
[0129] 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.
[0130] In some embodiments, the activity manager / window manager can control window rotation based on the detected screen orientation, so that the window's display orientation is consistent with the screen orientation.
[0131] The sensor manager can be used for data interaction between the application layer and the underlying layer. For example, the sensor manager can transmit sensor data from the underlying layer to the application layer. As another example, the sensor manager can transmit registration requests from the application layer to the underlying layer to register sensors.
[0132] The extended device manager can be used for data interaction between the motion engine service and the underlying layer (such as motion sensors). For example, the extended device manager can transmit a registration request from the motion engine service to the underlying layer to register the motion sensor. As another example, the extended device manager can report data from the underlying layer, such as rotation switching events detected by the motion sensor, to the motion engine service.
[0133] The local layer provides various services to the upper layers (such as the application framework layer). The local layer may include sensor services (Se nsorService), extended device services (ExtDeviceService), etc.
[0134] Sensor services can be used to report data collected by sensors such as accelerometers and gyroscopes to the upper layer.
[0135] Extended device services can be used to report rotation switching events detected by motion sensors to the upper layer.
[0136] The Hardware Abstraction Layer (HAL) encapsulates the underlying hardware drivers and provides a generic interface for calling the drivers to the upper layers, enabling the upper layers to invoke the drivers and drive the corresponding hardware. The HAL can include interfaces for accelerometers, gyroscopes, and motion sensors, which are used by the upper layers to call the accelerometer driver, gyroscope driver, and motion sensor, respectively.
[0137] 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.
[0138] 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.
[0139] The sensor management component subsystem may also include a motion sensor. The motion sensor can be a virtual sensor. It integrates a rotation switching detection algorithm to detect and report rotation switching events. In other words, the phone can detect screen orientation using the motion sensor and report rotation switching events when the screen orientation changes.
[0140] The screen orientation detection method provided in this application embodiment can be executed in a mobile phone with the above-described hardware and software structure.
[0141] See Figure 9 The method for detecting screen orientation includes the following steps.
[0142] S901: The mobile phone acquires motion data from the device.
[0143] For example, motion data includes data collected by accelerometers, gyroscopes, and other sensors.
[0144] S902. The mobile phone detects whether the continuous duration of its stationary state has reached the first duration. If yes, proceed to S903; otherwise, proceed to S904.
[0145] A mobile phone can detect the current device status based on motion data, which includes both a moving state and a stationary state. For example, if the acceleration value collected by the accelerometer is 0 and the angular velocity value collected by the gyroscope sensor is 0, the mobile phone can detect that the device is stationary.
[0146] When a mobile phone detects that the current device state is stationary, it can further combine historical detection results to determine whether the continuous duration of the stationary state has reached a certain duration, such as 3 seconds, 5 seconds, etc.
[0147] In one specific implementation, the mobile phone can determine whether the duration of the stationary state has reached a first duration by combining the number of times it has been continuously detected as stationary.
[0148] For example, every second time interval, such as 100ms, the mobile phone acquires motion data and detects whether the continuous duration of being in a stationary state exceeds the first time interval, such as 3s. In the historical detection results, the most recent (first time interval / second time interval)-1 detection results all detect that the device is in a stationary state, and the current device state is also stationary. The mobile phone can detect that the duration of being in a stationary state has reached the first time interval.
[0149] In another specific implementation, the phone can record a timestamp after detecting a stationary state and clear the timestamp after detecting movement. Subsequently, after each time a stationary state is detected, the time difference between the current time and the earliest timestamp is calculated. If this time difference is greater than or equal to a first duration, then the duration of the detected stationary state has reached the first duration.
[0150] If the phone detects that it has been stationary for a certain period of time, it indicates that the phone's posture has not changed for some time. In this case, the phone can execute S903 to adjust the angle threshold, preventing the phone from reaching the angle threshold even with slight rotation.
[0151] For example, if a user holds or leans their phone against an object, keeping the phone stationary for a period of time, they would not want the window to rotate if the hand is unstable and the phone slides slightly while leaning against an object. Therefore, by adjusting the angle threshold, slight rotation can be avoided by reaching the angle threshold.
[0152] If the phone detects that it is in a running state, or that it has been stationary for less than the first duration, it indicates that the phone's posture has changed in the short term. In this case, the phone can execute S904 to further detect whether a screen orientation change has occurred.
[0153] S903, mobile phone angle adjustment threshold.
[0154] The phone can adjust the angle threshold based on the screen orientation when stationary, which refers to the previously detected screen orientation. The specific adjustment methods are shown in Case 1 and Case 2 below:
[0155] Scenario 1: When the screen is stationary, it is in landscape orientation. Landscape orientation includes both forward landscape orientation and reverse landscape orientation.
[0156] In some cases, there may be situations where the phone switches to portrait mode, including both forward and reverse portrait orientations. The phone can adjust β and γ2, for example, lowering β to β' and increasing γ2 to γ2'. After adjusting β and γ2, a significant rotation in landscape mode will trigger the switch to portrait mode.
[0157] See Figure 10 Before adjusting β, when the phone (represented by a solid rectangle in the diagram, and the same applies below) rotates at the first angle (e.g., β0-β) in the direction indicated by the arrow, the β threshold requirement for switching to portrait mode is met, i.e., the angle between the vertical bisector of the screen and the vertical direction (denoted as β0 in this article) ≤ β. After adjusting β to obtain β', the β' threshold requirement for switching to portrait mode is met only when the phone rotates at the second angle (e.g., β0-β') in the direction indicated by the arrow, i.e., β0 ≤ β'. The first angle is smaller than the second angle. It should be understood that the same principle applies before and after adjusting γ2, which will not be elaborated here.
[0158] Thus, in case one, after adjusting β and γ2, it can be avoided that after a period of stillness, a slight rotation will reach the angle threshold for switching to portrait mode.
[0159] This application does not limit the specific adjustment range of β and γ2. Specifically, the adjustment range of β and γ2 can be the same, such as 10°. Alternatively, the adjustment range of β and γ2 can be different, such as β being adjusted down by 5° and γ2 being adjusted up by 10°.
[0160] In some embodiments, when the phone is in its current stationary state, the phone adjusts β and / or γ2 if the first difference between β0 and β, and / or the second difference between the angle between the vertical bisector of the screen and the horizontal direction (denoted as γ0 in this document) and γ2, are within the range of these differences. The specific adjustment method is as follows:
[0161] Method 1: If both the first and second differences are within the range, such as within 5° or 10°, it indicates that the stationary state is close to the angle thresholds β and γ2 for switching to portrait mode. In this case, slightly rotating the phone will easily reach the angle thresholds β and γ2. Adjusting β and γ2 on the phone effectively reduces the possibility of false detection.
[0162] Method Two: If the first difference is within the range, but the second difference is not, it indicates that the stationary state is close to the angle threshold β for switching to portrait mode. In this case, even a slight rotation of the phone will easily reach the angle threshold β. The phone can then adjust β, effectively reducing the possibility of false detection.
[0163] Method 3: If the first difference is outside the range, but the second difference is within the range, it indicates that the stationary state is close to the angle threshold γ2 for switching to portrait mode. In this case, slightly rotating the phone will easily reach the angle threshold γ2. The phone can then adjust γ2, effectively reducing the possibility of false detection.
[0164] In addition, if neither the first nor the second difference is within the range of the difference, the phone may not need to adjust β and γ2.
[0165] If both the first and second differences are outside the range, it indicates that the stationary state is far from the angle thresholds β and γ2 for switching to portrait mode. In this case, a significant rotation of the phone is required to reach the angle thresholds β and γ2. For example, with a difference range of 10° and β = 25°, see [link to example]. Figure 11 When the phone is stationary, β0 is approximately 90°, and the first difference from β is 65°. If the difference exceeds 10°, a significant rotation is required to reach the threshold β. The same applies to γ2. In this case, the phone can avoid adjusting β and γ2, reducing unnecessary adjustments.
[0166] Furthermore, after adjusting β and / or γ2, the phone can detect changes in the first difference and the second difference. When the first difference is no longer within the difference range, the phone can revert to β. When the second difference is no longer within the difference range, the phone can revert to γ2.
[0167] Scenario 2: When the screen is stationary, it is in portrait orientation, which includes both forward portrait orientation and reverse portrait orientation.
[0168] In scenario two, there will be a switch to landscape mode, which includes both forward and reverse landscape orientations. The phone can adjust α and γ1, for example, lowering α to α' and increasing γ1 to γ1'. After adjusting α and γ1, a significant rotation in portrait mode will trigger the switch to landscape mode.
[0169] See Figure 12Before lowering α, when the phone rotates at a third angle (e.g., α0-α) in the direction indicated by the arrow, the α threshold requirement for switching to landscape mode is met, meaning the angle between the vertical bisector of the screen and the horizontal direction (denoted as α0 in this article) ≤ α. After lowering α to obtain α', the α' threshold requirement for switching to landscape mode is met only when the phone rotates at a fourth angle (e.g., α0-α') in the direction indicated by the arrow, i.e., α0 ≤ α'. The third angle is less than the fourth angle. It should be understood that the same principle applies before and after raising γ1, which will not be elaborated here.
[0170] Thus, in case two, after adjusting α and γ1, it can be avoided that after a period of stillness, a slight rotation will reach the angle threshold for switching to landscape mode.
[0171] This application does not limit the specific range of adjustment for α and γ1. The adjustment range of α and γ1 can be the same, such as 10°. Alternatively, the adjustment range of α and γ1 can be different, such as α being adjusted down by 5° and γ1 being adjusted up by 10°.
[0172] In some embodiments, when the phone is in its current stationary state, if the third difference between α0 and α, and / or the fourth difference between γ0 and γ1, are within the range of these differences, the phone adjusts α and / or γ1. The specific adjustment method is as follows:
[0173] Method 4: If both the third and fourth differences are within the range, such as within 5° or 10°, it indicates that the stationary state is close to the angle thresholds α and γ1 for switching to landscape mode. In this case, slightly rotating the phone will easily reach the angle thresholds α and γ1. The phone can then adjust α and γ1, effectively reducing the possibility of false detection.
[0174] Method 5: If the third difference is within the range, but the fourth difference is not, it indicates that the stationary state is close to the angle threshold α for switching to portrait mode. In this case, a slight rotation of the phone will easily reach the angle threshold α. The phone can then adjust α, effectively reducing the possibility of false detection.
[0175] Method Six: If the third difference is outside the range, but the fourth difference is within the range, it indicates that the stationary state is close to the angle threshold γ1 for switching to portrait mode. In this case, even a slight rotation of the phone will easily reach the angle threshold γ1. The phone can then adjust γ1, effectively reducing the possibility of false detection.
[0176] In addition, if the third and fourth differences are not within the range of differences, the phone does not need to adjust α and γ1.
[0177] If the third and fourth differences are both outside the range, it indicates that the stationary state is far from the angle thresholds α and γ1 for switching to landscape mode. In this case, the phone needs to be rotated significantly to reach the angle thresholds α and γ1. For example, with a difference range of 10° and α = 20°, see [link to example]. Figure 13 When the phone is stationary, α0 is approximately 90°, and the third difference from α is 70°. If the difference exceeds 10°, a significant rotation is required to reach the threshold α, and the same applies to γ1. In this case, the phone can avoid adjusting α and γ1, reducing unnecessary adjustments.
[0178] Furthermore, after adjusting α and γ1, the phone can detect changes in the third and fourth differences. When the third difference is no longer within the difference range, the phone can revert to α. When the fourth difference is no longer within the difference range, the phone can revert to γ1.
[0179] It should be noted that the above S903 only describes the specific implementation of the adjustment when the condition for adjusting the angle threshold is met only once. Furthermore, if the condition for adjusting the angle threshold is met multiple times between two screen orientation changes, the angle threshold can be adjusted in the following manner.
[0180] In one specific implementation, whenever the condition for adjusting the angle threshold is detected to be met, the phone adjusts the angle threshold based on the current angle threshold.
[0181] For example, if the phone's detection result for S902 is "yes," and the screen orientation is landscape and both the first difference (the difference from β or the adjusted β') and the second difference (the difference from γ2 or the adjusted γ2') are within the difference range, or if the screen orientation is portrait and both the third difference (the difference from α or the adjusted α') and the fourth difference (the difference from γ1 or the adjusted γ1') are within the difference range, then the angle threshold is adjusted. Taking β as an example, during the first adjustment, β can be reduced by 10° to obtain β'; during the second adjustment, β' can be reduced by 10° to obtain β'', and so on. It should be noted that if the screen orientation reverts to β and γ2, or to α and γ1, the adjustment is based on the reverted values.
[0182] In this way, the phone can further adjust the angle threshold each time it meets the conditions that are prone to false detection, thereby minimizing the possibility of false detection.
[0183] Furthermore, building upon the above implementation, the phone can also check whether the angle threshold to be adjusted is within a reasonable range before each adjustment. For example, it can check whether α' is greater than the first angle threshold, β' is greater than the second angle threshold, γ1' is less than the third angle threshold, and γ2' is less than the fourth angle threshold. Adjustment is only made if the angle threshold is detected to be within a reasonable range; otherwise, no adjustment is made. For instance, if α' is already very small and cannot meet the requirement of exceeding the first angle threshold, further adjustment is not advisable. In this way, the phone can ensure that the angle threshold is not adjusted to an unreasonable range, but rather fluctuates within a reasonable range, avoiding an angle threshold that is too small or too large and thus affecting the user experience.
[0184] In another specific implementation, the phone only adjusts the angle threshold once when the condition for adjusting the angle threshold is met and the threshold angle is the initial value. For example, it adjusts from β to β', from γ2 to γ2', from α to α', and from γ1 to γ1'.
[0185] For example, after a screen orientation change, the phone can initially meet the following first condition: if the detection result of S902 is yes, the screen orientation is landscape, and the first difference (the difference between β and β) is within the difference range, then β is adjusted once to obtain β'. Subsequently, if the first difference (the difference between β and β) is detected to be outside the difference range, the phone can revert to β. After this, when the above first condition is met again, β can be adjusted again to obtain β'. Conversely, if β is not reverted to β, no further adjustments will be made based on β'. The adjustment of γ2 follows the same principle and will not be elaborated here.
[0186] For example, after a screen orientation change, the phone can first meet the following second condition: if the detection result of S902 is yes, the screen orientation is portrait, and the third difference (the difference from α) is within the difference range, then α is adjusted once to obtain α'. Subsequently, if the third difference (the difference from α) is detected to be outside the difference range, the phone can revert to α. After this, when the above second condition is met again, α can be adjusted again to obtain α'. Conversely, if it has not reverted to α, no further adjustment will be made based on α'. The adjustment of γ1 is similar and will not be elaborated here.
[0187] In this way, the phone can ensure that the angle threshold is appropriately reduced based on the initial angle threshold, thus guaranteeing the user experience.
[0188] After adjusting the angle threshold via S903, the phone can continue to execute S901 and its subsequent steps.
[0189] S904. The phone checks whether the angle threshold is met. If yes, proceed to S905; otherwise, continue with S901 and subsequent steps.
[0190] The angle threshold can be an initial angle threshold, such as α, β, γ1, and γ2. Alternatively, the angle threshold can be a threshold adjusted by S903 as described above, such as β' and γ2', α' and γ1'.
[0191] For example, when the screen of an electronic device is in portrait mode, the angle thresholds include α0≤α' or γ01≥γ1'.
[0192] For example, when the screen of an electronic device is in landscape mode, the angle thresholds include β0≤β' or γ02≥γ2'.
[0193] If the angle threshold is met, it indicates that the screen orientation can be switched, and the phone executes S905 to obtain the detection result.
[0194] If the angle threshold is not met, it indicates that the screen orientation has not been switched, and the phone can continue to detect, such as continuing to execute S901 and its subsequent steps.
[0195] S905: The phone detected a change in screen orientation.
[0196] For example, the phone detects that the screen orientation has switched to portrait orientation, reverse portrait orientation, landscape orientation with reverse orientation, or reverse landscape orientation.
[0197] Furthermore, after detecting a change in screen orientation, the phone can restore the angle threshold, allowing it to adjust or detect based on the initial angle threshold after a screen orientation change, thus avoiding unreasonable angle thresholds caused by cumulative adjustments.
[0198] In one specific implementation, the motion sensor in the mobile phone can be used to perform the action. Figure 9 The process involves several steps to detect the screen orientation. Upon detecting a change in screen orientation, the motion sensor can notify modules registered for rotation switching services, such as via the motion sensor interface, extended device services, extended device management, and motion engine services, ultimately providing each module with real-time screen orientation information. This is especially beneficial for modules that previously had to calculate the screen orientation manually, such as applications, allowing them to quickly obtain an accurate orientation without calculation. This information can then be used to accurately set the display orientation of windows, etc.
[0199] use Figure 9This solution allows the phone to adjust its angle threshold, ensuring that slight rotation won't trigger the threshold if the phone remains stationary for a period of time. This improves the accuracy of screen orientation detection, facilitating the provision of adapted services based on accurate screen orientation and enhancing the user experience.
[0200] Therefore, it should be noted that the specific adjustment methods for each angle threshold, such as raising or lowering it, and whether the angle threshold is met, are all related to the definition of the angle threshold.
[0201] Optionally, γ1 can also refer to the angle threshold between the horizontal bisector of the screen and the vertical direction when switching from a portrait to a landscape orientation. In this case: adjusting γ1 can mean lowering γ1; and when γ01 ≤ γ1 (or γ1'), the angle threshold is satisfied. And / or, α can also refer to the angle threshold between the vertical bisector of the screen and the vertical direction when switching from a portrait to a landscape orientation. In this case: adjusting α can mean raising α; and when α0 ≥ α (or α'), the angle threshold is satisfied.
[0202] Optionally, γ2 can also refer to the angle threshold between the vertical bisector of the screen and the vertical direction when switching from a landscape to a portrait orientation. In this case: adjusting γ2 can mean lowering γ2; and when γ02 ≤ γ2 (or γ2'), the angle threshold is satisfied. And / or, β can also refer to the angle threshold between the vertical bisector of the screen and the vertical direction when switching from a landscape to a portrait orientation. In this case: adjusting β can mean raising β; and when β0 ≥ β (or β'), the angle threshold is satisfied.
[0203] The following are several complete examples to illustrate... Figure 9 The specific implementation of the scheme is shown below. In the example below, we assume the current screen orientation is landscape. It can be understood that the same logic applies to the current screen orientation being portrait; simply replace β and γ2 with α and γ1.
[0204] Example 1
[0205] The phone does not meet the conditions for adjusting the angle threshold. The phone can execute S901-S902, S904.
[0206] Specifically, S904 involves the phone detecting whether β and γ2 are satisfied. If β and γ2 are not satisfied, S901-S902 and S904 are executed repeatedly; if β and γ2 are satisfied, the phone executes S905, detecting that the screen orientation has switched to portrait mode.
[0207] Example 2
[0208] Between time t1 and time t2, the phone does not meet the conditions for adjusting the angle threshold. The execution logic during this process is the same as in Example 1, and will not be repeated here. Furthermore, since the angle threshold is not met between time t1 and time t2, S905 will never be executed.
[0209] Next, at time t3, the mobile phone meets the condition for adjusting the angle threshold, and the mobile phone can execute S901-S903. Specifically, S903 is: the mobile phone adjusts β and γ2 to obtain β' and γ2'.
[0210] Next, between time t4 and time t5, if the phone does not meet the conditions for adjusting the angle threshold, the phone can execute S901-S902 and S904. Specifically, S904 involves the phone checking whether β' and γ2' are satisfied. If β' and γ2' are not satisfied, S901-S902 and S904 are repeated; if β' and γ2' are satisfied, the phone executes S905, detecting that the screen orientation has switched to portrait mode.
[0211] Example 3
[0212] In Example 2, at time t6 after time t3, the mobile phone meets the condition for restoring the angle threshold. If the first difference and / or the second difference are not within the difference range, or the third difference and / or the fourth difference are not within the difference range, the mobile phone can restore β' and γ2' to β and γ2.
[0213] Next, between time t4 and time t5, if the phone does not meet the conditions for adjusting the angle threshold, the phone can execute S901-S902 and S904. Specifically, S904 involves the phone checking whether β and γ2 are satisfied. If β and γ2 are not satisfied, S901-S902 and S904 are repeated; if β and γ2 are satisfied, the phone executes S905, detecting that the screen orientation has switched to portrait mode.
[0214] Based on the examples above, it is clear that the angle threshold can change dynamically. A mobile phone may detect whether the screen orientation has changed based on the original angle threshold, such as β and γ2, or it may detect the change based on the adjusted angle threshold, such as β' and γ2'.
[0215] In addition, the above examples can be used in combination. In the case of multiple times switching between landscape and portrait modes, the phone may detect whether the screen orientation has changed based on different angle thresholds.
[0216] For example, if the phone does not adjust β and γ2 when the screen orientation is landscape (as in Example 1), or if it adjusts them and then reverts to β and γ2 (as in Example 3), the phone can detect whether the screen orientation has changed based on β and γ2. In another scenario where the screen orientation is landscape, if the phone adjusts β and γ2 (as in Example 2), the phone can detect whether the screen orientation has changed based on the adjusted β' and γ2'.
[0217] 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.
[0218] 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.
[0219] 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.
[0220] 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.
[0221] 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.
[0222] 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.
[0223] 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.
[0224] 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.
[0225] 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.
[0226] 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.
[0227] 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.
[0228] 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 detecting screen orientation, characterized in that, Applied to an electronic device, the electronic device including a screen, the method includes: When the screen orientation is a first orientation, and the angle corresponding to the screen meets a first angle threshold, the screen orientation is detected to switch to a second orientation. If the screen orientation is switched back to the first orientation and the electronic device remains stationary for a duration exceeding the first duration, and the screen orientation is switched to the second orientation when the corresponding angle meets the second angle threshold; The first angle threshold and the second angle threshold are different.
2. The method according to claim 1, characterized in that, After the electronic device has been stationary for a continuous period exceeding a first duration, and before the screen orientation is detected to have switched to the second orientation when the angle corresponding to the screen meets a second angle threshold, the method further includes: Adjust the first angle threshold to obtain the second angle threshold.
3. The method according to claim 1 or 2, characterized in that, Before detecting that the screen orientation has switched to the second orientation after the angle corresponding to the screen meets the second angle threshold, the method further includes: It is determined that the difference between the angle corresponding to the screen when it is stationary and the first angle threshold is within the range of the difference.
4. The method according to claim 3, characterized in that, After determining that the difference between the angle corresponding to the screen when in a stationary state and the first angle threshold is within the range of the difference, the method further includes: As the electronic device is rotated, after the difference between the angle corresponding to the screen and the first angle threshold is no longer within the range of the difference, when the angle corresponding to the screen meets the first angle threshold, the screen orientation is detected to switch to the second orientation.
5. The method according to claim 4, characterized in that, After the difference between the angle corresponding to the screen and the first angle threshold is not within the range of the difference, and before detecting that the screen orientation has switched to the second orientation after the angle corresponding to the screen meets the first angle threshold, the method further includes: Restore from the second angle threshold to the first angle threshold.
6. The method according to any one of claims 3-5, characterized in that, If the screen orientation is switched back to the first orientation, the method further includes: The electronic device remains stationary for a duration exceeding the first duration, but the difference between the angle corresponding to the screen and the first angle threshold is not within the range when it is stationary. When the angle corresponding to the screen meets the first angle threshold, the screen orientation is detected to switch to the second orientation.
7. The method according to any one of claims 1-6, characterized in that, When the screen orientation is a first orientation, and the angle corresponding to the screen meets a first angle threshold, detecting a switch of the screen orientation to a second orientation includes: When the screen orientation is the first orientation, and the duration of the continuous static state of the electronic device does not exceed the first duration, the screen orientation is detected to switch to the second orientation when the angle corresponding to the screen meets the first angle threshold.
8. The method according to any one of claims 1-7, characterized in that, After detecting that the screen orientation has switched to the second orientation when the angle corresponding to the screen meets the second angle threshold, the method further includes: Restore from the second angle threshold to the first angle threshold.
9. The method according to any one of claims 1-8, characterized in that, If the electronic device remains stationary for a continuous period exceeding a first duration, and the screen angle meets a second angle threshold, the detection of a screen orientation switch to the second orientation includes: After the electronic device detects that the continuous duration of being in a stationary state exceeds the first duration, it adjusts the first angle threshold to obtain the second angle threshold. After the electronic device detects that the continuous duration of being in a stationary state has not exceeded the first duration, it detects whether the angle corresponding to the screen meets the second angle threshold. When the angle corresponding to the screen meets the second angle threshold, it detects that the screen orientation has switched to the second orientation.
10. The method according to any one of claims 1-9, characterized in that, The first direction is landscape mode, and the second direction is portrait mode. Wherein, the first angle threshold includes a first β, and the second angle threshold includes a second β. β refers to the angle threshold between the vertical bisector of the screen and the vertical direction when switching to portrait mode in landscape mode. Alternatively, the first angle threshold includes a first γ2, and the second angle threshold includes a second γ2. γ2 refers to the angle threshold between the vertical bisector of the screen and the horizontal direction when the screen switches from a landscape and horizontally placed state to a portrait state.
11. The method according to any one of claims 1-9, characterized in that, The first direction is for portrait mode, and the second direction is for landscape mode. Wherein, the first angle threshold includes a first α, and the second angle threshold includes a second α. α refers to the angle threshold between the vertical bisector of the screen and the horizontal direction when switching to landscape mode in the case of a portrait screen. Alternatively, the first angle threshold includes a first γ1, and the second angle threshold includes a second γ1. γ1 refers to the angle threshold between the horizontal bisector of the screen and the horizontal direction when the screen is switched from a portrait and horizontally placed state to a landscape state.
12. 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-11.
13. 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-11.
14. 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-11.