Patent Description:
This disclosure relates to the field of terminal technologies, and in particular, the invention relates to a method, a device, a computer storage medium and a computer program for measuring a height on a plane.

Many wearable devices such as various sports watch products have an "altimeter" function, in other words, current altitudes of the devices can be displayed on the devices. As shown in <FIG>, a smart watch has an "altimeter" function, and displays a current altitude <NUM> meters of the smart watch.

Generally, the wearable devices implement the "altimeter" function by using barometric pressure sensors. Atmospheric pressure changes with an altitude. A barometric formula describes how atmospheric pressure changes with an altitude. The wearable device may calculate a current altitude based on a barometric pressure value measured by the barometric pressure sensor and the barometric formula.

However, in some cases, barometric pressure of an environment in which the wearable device is located is not atmospheric pressure. For example, when a user takes a plane with a wearable device, because pressure is boosted in a cabin of the plane, a barometric pressure value measured by a barometric pressure sensor is not an atmospheric pressure value corresponding to a current altitude. A height value calculated by the wearable device based on the barometric pressure value measured by the barometric pressure sensor and the barometric formula is not a true altitude of the wearable device. In other words, in this case, the data of the barometric pressure sensor of the wearable device is untrustworthy, and an "altimeter" function of the wearable device fails. For example, when a user takes a plane with a smart watch, the plane has flown nearly <NUM> thousand meters high, while an altitude displayed on the smart watch is only approximately <NUM> meters. <CIT> relates to a method and system for high precision altitude measurement over hostile terrain. <CIT> relates to a fitness monitoring device with altimeter. <CIT> relates to an altitude information acquiring device and system.

The object of the present invention is to provide a method, a device, a computer storage medium and a computer program for measuring a height on a plane and a device, so that an electronic device such as a wearable device can display an accurate altitude when data of a barometric pressure sensor is untrustworthy in a case in which a user takes a plane or in another case. This object is solved by the attached independent claims and further embodiments and improvements of the invention are listed in the attached dependent claims.

According to a first aspect according to the invention, an embodiment of this application provides a method for measuring a height in a cabin of a plane, as defined in claim <NUM>.

In the method, the electronic device switches based on a condition such as an environment in which the electronic device is located, a detection manner of obtaining an altitude. In this case, when a detection manner is invalid, the electronic device switches to another detection manner, so that the electronic device displays an accurate altitude.

In the invention, the first switching condition includes: the data obtained by the electronic device in the first detection manner is invalid. In other words, when the first detection manner is invalid, the altitude obtained in the first detection manner is inaccurate, and the electronic device switches from displaying the altitude obtained in the first detection manner to displaying the altitude obtained in the second detection manner, to display an accurate altitude.

In the invention, if the electronic device determines that a value by which an altitude value of the electronic device increases within first preset duration is greater than a preset first height threshold indicating that the pressure in the cabin of the plane has been boosted, the electronic device determines that the data obtained in the first detection manner is invalid.

In this manner, if the electronic device determines that the value by which the altitude value of the electronic device increases within the first preset duration is greater than the preset first height threshold, the electronic device may determine that a plane that a user takes with the electronic device takes off. After the plane takes off, pressure is boosted in a cabin of the plane, and in this case, the data obtained in the first detection manner is invalid.

In a possible design, if the electronic device determines, when displaying the altitude obtained in the second detection manner, that a second switching condition is met, the electronic device displays the altitude obtained in the first detection manner.

In the method, the electronic device may switch, based on the condition such as the environment in which the electronic device is located, back to displaying the altitude obtained in the first detection manner.

In a possible design, the second switching condition includes: the data obtained by the electronic device in the first detection manner becomes valid again. In other words, when the first detection manner becomes valid again, the altitude obtained in the first detection manner is accurate, and the electronic device switches from displaying the altitude obtained in the second detection manner to displaying the altitude obtained in the first detection manner. In some scenarios, for example, if the altitude obtained in the first detection manner is more accurate, switching, by the electronic device in a timely manner, back to displaying the altitude obtained in the first detection manner can enable an altitude value displayed by the electronic device to be more accurate. For example, if the second detection manner is relatively power-consuming, switching, by the electronic device in a timely manner, back to displaying the altitude obtained in the first detection manner can reduce power consumption.

In a possible design, if the electronic device determines that an absolute value of a difference between the altitude obtained in the first detection manner and the altitude obtained in the second detection manner is less than a preset threshold, it indicates that the altitude obtained in the first detection manner is accurate, and the electronic device may determine that the data obtained in the first detection manner becomes valid again.

In a possible design, if the electronic device determines that a value by which the altitude value of the electronic device decreases within second preset duration is greater than a preset second height threshold, it indicates that the plane that the user takes with the electronic device lands, and the electronic device may determine that the data obtained in the first detection manner becomes valid again.

In a possible design, the second switching condition includes: the electronic device detects an operation of disabling the second detection manner by the user. If the user disables the second detection manner, the electronic device cannot obtain the altitude in the second detection manner, and the electronic device switches from displaying the altitude obtained in the second detection manner to displaying the altitude obtained in the first detection manner.

In the invention, the first detection manner is detecting the altitude of the electronic device by using a barometric pressure sensor, and in a possible design, the second detection manner is receiving altitude data in data of a GNSS and obtaining the altitude of the electronic device.

In a possible design, before displaying the altitude obtained in the second detection manner, the electronic device enables a GNSS function of the electronic device. The electronic device can receive the altitude data in the data of the GNSS only when the GNSS function is enabled, to obtain the altitude of the electronic device and display the altitude.

In a possible design, the electronic device periodically enables the GNSS function of the electronic device based on a preset first time interval. Because power consumption of the GNSS function is relatively large, periodically enabling the GNSS function based on the time interval can reduce power consumption compared with a case in which the GNSS function is always enabled.

According to a second aspect according to the invention, an embodiment of this application provides an electronic device. The electronic device implements the method for measuring a height on a plane according to the first aspect. The electronic device may implement the foregoing method by using software or hardware or by using hardware executing corresponding software.

The electronic device includes a display, a processor, and a memory. The display and the processor are configured to support the electronic device in performing a corresponding function in the method in the first aspect. The memory is configured to be coupled to the processor, and store program instructions and data that are necessary for the electronic device. In addition, the electronic device may further include a communications interface, configured to support communication between the electronic device and another electronic device. The communications interface may be a transceiver or a transceiver circuit.

In a possible design not claimed, the electronic device may include a processing module, a display module, a first detection module, and a second detection module. The display module is configured to display an altitude obtained by the first detection module, and is further configured to display an altitude obtained by the second detection module. The processing module is configured to: determine whether a first switching condition is met; and if it is determined that the first switching condition is met, determine that the display module is to display the altitude obtained by the second detection module.

In the invention the first switching condition includes: the data obtained by the first detection module is invalid.

In the invention, the data obtained by the first detection module is invalid includes: the processing module determines that a value by which an altitude value of the electronic device increases within first preset duration is greater than a preset first height threshold indicating tha the pressure in the cabin of the plane has been boosted.

In a possible design, the processing module is further configured to: determine whether a second switching condition is met; and if it is determined that the second switching condition is met, determine that the display module is to display the altitude obtained by the first detection module.

In a possible design, the second switching condition includes: the data obtained by the first detection module becomes valid again.

In a possible design, that the data obtained by the first detection module becomes valid again includes: the processing module determines that an absolute value of a difference between the altitude obtained by the first detection module and the altitude obtained by the second detection module is less than a preset threshold.

In a possible design, that the data obtained by the first detection module becomes valid again includes: the processing module determines that a value by which the altitude value of the electronic device decreases within second preset duration is greater than a preset second height threshold.

In a possible design, the second switching condition includes: the processing module determines that an operation of disabling the second detection module by a user is detected.

In the invention, the first detection module is a barometric pressure sensor, and in a possible design, the second detection module is a GNSS module.

In a possible design, the processing module is further configured to determine to enable a GNSS function of the GNSS module.

In a possible design, the processing module is further configured to determine that the GNSS module is to periodically enable the GNSS function based on a preset first time interval.

According to a third aspect according to the invention, an embodiment of this application provides a computer storage medium. The computer storage medium includes computer instructions, and when the computer instructions run on an electronic device, the electronic device performs the method for measuring a height on a plane according to the first aspect and the possible design manners of the first aspect.

According to a fourth aspect according to the invention, an embodiment of this application provides a computer program product. When the computer program product runs on a computer, the computer performs the method for measuring a height on a plane according to the first aspect and the possible design manners of the first aspect.

The electronic device in the second aspect, the computer storage medium in the third aspect, and the computer program product in the fourth aspect are all configured to perform the corresponding method provided above. Therefore, for beneficial effects that can be achieved by the electronic device, the computer storage medium, and the computer program product, refer to beneficial effects of a corresponding solution in the corresponding method provided above.

The method for measuring a height on a plane provided in the embodiments of this application may be applied to an electronic device with an "altimeter" function. The electronic device may be a wearable device (for example, a smart watch, a smart band, smart glasses, or a smart helmet), a portable computer (for example, a mobile phone), a notebook computer, a tablet computer, an augmented reality (augmented reality, AR)/a virtual reality (virtual reality, VR) device, or the like. A specific form of the electronic device is not specially limited in the embodiments of this application.

<FIG> is a schematic diagram of a structure of an electronic device <NUM> according to an embodiment of this application. The electronic device <NUM> may include a processor <NUM>, a memory <NUM>, a display <NUM>, a power module <NUM>, a sensor module <NUM>, a positioning module <NUM>, and the like. The sensor module <NUM> may include a barometric pressure sensor 150A, a touch sensor 150B, and the like.

It may be understood that the structure shown in this embodiment of the present invention does not constitute a specific limitation on the electronic device <NUM>. In other embodiments of this application, the electronic device <NUM> may include more or fewer components than those shown in the figure, combine some components, split some components, or have different component arrangements. The components shown in the figure may be implemented by hardware, software, or a combination of software and hardware.

The processor <NUM> may include one or more processors. For example, the processor <NUM> may include an application processor, a controller, a digital signal processor (digital signal processor, DSP), or the like. Different processors may be independent components, or may be integrated into one or more processors.

The controller may be a nerve center and a command center of the electronic device <NUM>. The controller may generate an operation control signal based on an instruction operation code and a time sequence signal, to complete control of instruction fetching and instruction execution.

An operating system of the electronic device <NUM> may be installed on the application processor, to manage hardware and software resources of the electronic device <NUM>, for example, manage and configure memory, prioritize supply and demand of system resources, control input and output devices, operate a network, manage a file system, and manage a driver. The operating system may also be configured to provide an operating interface for a user to interact with the system. Various types of software, such as a driver and an application (application, App), may be installed in the operating system.

The memory <NUM> is configured to store instructions and data. In some embodiments, the memory <NUM> is a cache memory. The memory may store instructions or data used or cyclically used by the processor <NUM>. If the processor <NUM> needs to use the instructions or the data again, the processor <NUM> may directly invoke the instructions or the data from the memory <NUM>. This avoids repeated access, reduces a waiting time of the processor <NUM>, and improves system efficiency.

In some embodiments, the memory <NUM> may alternatively be disposed in the processor <NUM>. In other words, the processor <NUM> includes the memory <NUM>. This is not limited in this embodiment of this application.

The display <NUM> is configured to display an image, a video, and the like. The display <NUM> includes a display panel. The display panel may be a liquid crystal display (liquid crystal display, LCD), an organic light-emitting diode (organic light-emitting diode, OLED), an active-matrix organic light-emitting diode (active-matrix organic light emitting diode, AMOLED), a flexible light-emitting diode (flex light-emitting diode, FLED), a mini-LED, a micro-LED, a micro-OLED, quantum dot light emitting diodes (quantum dot light emitting diodes, QLED), or the like. In some embodiments, the electronic device <NUM> may include one or N displays <NUM>, where N is a positive integer greater than <NUM>.

The power module <NUM> may be configured to supply power to each component included in the electronic device <NUM>. In some embodiments, the power module <NUM> may be a battery, for example, a rechargeable battery.

The barometric pressure sensor 150A is configured to measure barometric pressure. In this embodiment of this application, the electronic device <NUM> calculates an altitude by using the barometric pressure value measured by the barometric pressure sensor 150A. In an example, the electronic device <NUM> calculates the altitude based on the barometric pressure value measured by the barometric pressure sensor 150A and a barometric formula. The barometric formula is a formula that describes how barometric pressure changes with a height. For a specific method for calculating the height based on the barometric pressure value and the barometric formula, refer to descriptions in the conventional technology. Details are not described in this embodiment of this application.

The touch sensor 150B is also referred to as a "touch panel". The touch sensor 150B may be disposed in the display <NUM>. The touch sensor 150B and the display <NUM> constitute a touchscreen. The touch sensor 150B is configured to detect a touch operation performed on or near the touch sensor 150B. The touch sensor may transfer the detected touch operation to the application processor, to determine a type of a touch event. The display <NUM> may provide a visual output related to the touch operation. In some other embodiments, the touch sensor 150B may alternatively be disposed on a surface of the electronic device <NUM> at a location different from that of the display <NUM>.

The positioning module <NUM> is configured to position the electronic device <NUM>. In this embodiment of this application, the positioning module <NUM> may receive data of a global navigation satellite system (global navigation satellite system, GNSS). The data of the GNSS includes a longitude, a latitude, an altitude, and the like. The electronic device <NUM> may obtain the altitude of the electronic device <NUM> by using altitude data of the GNSS. The GNSS may include a global positioning system (global positioning system, GPS), a global navigation satellite system (global navigation satellite system, GLONASS), a BeiDou navigation satellite system (beidou navigation satellite system, BDS), a quasi-zenith satellite system (quasi-zenith satellite system, QZSS), a Galileo satellite navigation system (galileo satellite navigation system, GSNS), and/or a satellite based augmentation system (satellite based augmentation systems, SBAS).

The method for measuring a height on a plane provided in the embodiments of this application may be applied to the electronic device <NUM>. The electronic device <NUM> has an "altimeter" function, and can display a current altitude of the electronic device <NUM> on the display <NUM>. The electronic device <NUM> may obtain the altitude of the electronic device <NUM> by using the barometric pressure value measured by the barometric pressure sensor 150A; or the electronic device <NUM> may obtain the altitude of the electronic device <NUM> by using the altitude data received by the positioning module <NUM>. Generally, because the altitude obtained by using the barometric pressure value measured by the barometric pressure sensor is more accurate than the altitude obtained by receiving the data of the GNSS by the electronic device, a height value displayed on the display <NUM> is the altitude obtained by using the barometric pressure sensor 150A. When the electronic device <NUM> determines that the altitude data obtained by using the barometric pressure sensor 150A is untrustworthy, the display <NUM> displays the altitude received by the positioning module <NUM>. In this way, the electronic device <NUM> can also display an accurate altitude when the data of the barometric pressure sensor is untrustworthy in a case in which a user takes a plane or in another case. Certainly, a function of displaying the current altitude on the display <NUM> by the electronic device <NUM> may be another name, and the electronic device <NUM> does not display a word "Altimeter" on the display <NUM>. For example, "Altitude: XX meters" is displayed on the display <NUM> of the electronic device <NUM>.

In some embodiments, the barometric pressure sensor and/or the positioning module of the electronic device <NUM> may not be disposed on the electronic device <NUM>, in other words, the electronic device <NUM> may obtain the current altitude by using a barometric pressure sensor and/or a positioning module of another device (an electronic device <NUM>) connected to the electronic device <NUM>, and display the current altitude on the electronic device <NUM>.

In an example, as shown in <FIG>, an electronic device <NUM> and an electronic device <NUM> are wirelessly connected. The electronic device <NUM> includes a processor <NUM>, a memory <NUM>, a display <NUM>, a power module <NUM>, a sensor module <NUM>, and the like. The electronic device <NUM> includes a positioning module <NUM>, and the positioning module <NUM> may receive data of a GNSS. The electronic device <NUM> may obtain an altitude of the electronic device <NUM> by using a barometric pressure value measured by a barometric pressure sensor 150A of the sensor module <NUM>; or may receive altitude data of the positioning module <NUM> of the electronic device <NUM>, and obtain an altitude of the electronic device <NUM>, in other words, obtain an altitude of the electronic device <NUM>.

In another example, as shown in <FIG>, an electronic device <NUM> and an electronic device <NUM> are wirelessly connected. The electronic device <NUM> includes a processor <NUM>, a memory <NUM>, a display <NUM>, a power module <NUM>, a positioning module <NUM>, and the like. The electronic device <NUM> includes a sensor module <NUM>, and the sensor module <NUM> includes a barometric pressure sensor 220A, configured to measure barometric pressure. The electronic device <NUM> may obtain an altitude of the electronic device <NUM> by using altitude data received by the positioning module <NUM>; or may receive barometric pressure value data of the barometric pressure sensor 220A of the sensor module <NUM> of the electronic device <NUM>, and obtain an altitude of the electronic device <NUM> based on the received barometric pressure value data, in other words, obtain an altitude of the electronic device <NUM>.

In still another example, as shown in <FIG>, an electronic device <NUM> and an electronic device <NUM> are wirelessly connected. The electronic device <NUM> includes a processor <NUM>, a memory <NUM>, a display <NUM>, a power module <NUM>, and the like. The electronic device <NUM> includes a positioning module <NUM>, a sensor module <NUM>, and the like, and the sensor module <NUM> includes a barometric pressure sensor 220A. The positioning module <NUM> may receive data of a GNSS. The barometric pressure sensor 220A is configured to measure barometric pressure. The electronic device <NUM> may receive barometric pressure value data of the barometric pressure sensor 220A of the sensor module <NUM> of the electronic device <NUM>, and obtain an altitude of the electronic device <NUM> based on the received barometric pressure value data, in other words, obtain an altitude of the electronic device <NUM>; or may receive altitude data of the positioning module <NUM> of the electronic device <NUM>, and obtain an altitude of the electronic device <NUM>, in other words, obtain an altitude of the electronic device <NUM>.

For example, the electronic device <NUM> is a smart watch, and the electronic device <NUM> is a mobile phone; or the electronic device <NUM> is a mobile phone, and the electronic device <NUM> is a smart watch.

With reference to the accompanying drawings, the following describes in detail the method for measuring a height on a plane provided in the embodiments of this application.

The embodiments of this application are descried by using an example in which the electronic device <NUM> is a smart watch and the smart watch includes a structure shown in <FIG>. It may be understood that the method for measuring a height on a plane provided in the embodiments of this application is also applicable to the electronic device <NUM> in <FIG>, or <FIG>.

As shown in <FIG>, a method for measuring a height on a plane provided in an embodiment of this application may include the following steps.

S301: An electronic device displays an altitude obtained in a first detection manner.

The first detection manner is a default altitude detection manner of the electronic device. The first detection manner is a manner of detecting an altitude by using a barometric pressure sensor. The electronic device obtains a current altitude based on a barometric pressure value measured by the barometric pressure sensor.

For example, when a user does not take a plane, the electronic device displays the current altitude obtained based on the barometric pressure value measured by the barometric pressure sensor. For example, the electronic device displays an interface shown in <FIG>, and a value of the current altitude is <NUM> meters.

S302: The electronic device determines whether a first switching condition is met; and if the electronic device determines that the first switching condition is met, the electronic device performs S303 that the electronic device displays an altitude obtained in a second detection manner; or if the electronic device determines that the first switching condition is not met, the electronic device performs S301 that the electronic device displays the altitude obtained in the first detection manner.

The first switching condition is that the data of the barometric pressure sensor is invalid.

For example, the user takes a plane with the electronic device, and the plane takes off. After the plane takes off, pressure is boosted in a cabin of the plane, and the barometric pressure value detected by the barometric pressure sensor of the electronic device is inconsistent with an atmospheric pressure value corresponding to the altitude of the electronic device, in other words, the data of the barometric pressure sensor is invalid.

If the electronic device detects that a first preset condition is met, the electronic device determines that the data of the barometric pressure sensor is invalid.

The first preset condition is that a value by which the altitude value of the electronic device increases within a first preset duration is greater than a preset first height threshold. For example, the first preset duration is <NUM> seconds, and the first height threshold is <NUM> meters. The altitude of the electronic device is obtained in the first detection manner.

If the electronic device detects that the value by which the altitude value of the electronic device increases within the first preset duration is greater than the preset first height threshold, the electronic device determines that the plane takes off, because after the plane takes off, pressure is boosted in the cabin of the plane, and the barometric pressure value detected by the barometric pressure sensor of the electronic device is inconsistent with the atmospheric pressure value corresponding to the altitude of the electronic device, in other words, the data of the barometric pressure sensor of the electronic device is invalid.

S303: The electronic device displays the altitude obtained in the second detection manner.

The second detection manner is a detection manner different from the first detection manner. For example, the second detection manner is a manner of detecting an altitude by using a GNSS. The electronic device receives altitude data in data of the GNSS, to obtain the current altitude.

For example, after the plane takes off, a smart watch displays the altitude data in the received data of the GNSS. As shown in <FIG>, the smart watch displays a current altitude <NUM> meters.

A GNSS function of the electronic device has an enabled state and a disabled state. In the enabled state, the electronic device may receive the data of the GNSS, and in the disabled state, the electronic device does not receive the data of the GNSS.

In some embodiments, if the electronic device determines, after determining that the data of the barometric pressure sensor is invalid, that the GNSS function of the electronic device is in the enabled state, the electronic device may directly display the altitude in the received data of the GNSS.

Before the plane takes off, the user may enable the GNSS function in some scenarios. For example, the GNSS is a GPS. If the electronic device determines, after determining that the data of the barometric pressure sensor is invalid, that a GPS function of the electronic device is in the enabled state, the electronic device may directly display height data in received data of the GPS.

In an implementation, the electronic device may enable the GPS function by enabling some modes such as a sports mode. For example, if the electronic device determines that the user has enabled an outdoor sports mode, the electronic device enables the GPS function. The user may enable the outdoor sports mode by enabling a sports mode of the electronic device. The sports mode of the electronic device may include walking, outdoor running, indoor running, riding, indoor cycling, mountain climbing, and the like. In an implementation, the outdoor sports mode includes walking, outdoor running, riding, and mountain climbing in the sports mode. It should be noted that the sports mode of the electronic device may have another name. For example, in some electronic devices, enabling the sports mode is referred to as enabling one "single motion". This is not limited in this embodiment of this application.

If the electronic device determines that the electronic device receives an operation of enabling the sports mode such as walking, outdoor running, riding, or mountain climbing by the user, in other words, the user has enabled the outdoor sports mode, the electronic device enables the GPS function.

In an example, the user may enable the sports mode on the smart watch. In another example, the user may enable the sports mode on a mobile phone on which a smart watch management APP is installed.

For example, as shown in <FIG>, the user may set each setting item of the smart watch in an interface <NUM> of the smart watch. The interface <NUM> includes an "Exercise" option <NUM>, a "Settings" option <NUM>, a "Battery" option <NUM>, and a "Phone" option <NUM>. The "Exercise" option <NUM> is used to set a sports mode, and different sports modes may be used to detect different sports types. The "Settings" option <NUM> is used to set various common options and applications of the smart watch, for example, may include setting a watch face style, a font size, and a volume. The "Battery" option <NUM> is used to set and view a battery, for example, set the battery to a power saving mode and view remaining battery power. The "Phone" option <NUM> is used to set a phone application, for example, set a call volume. The smart watch may receive a tap operation performed by the user on the "Exercise" option <NUM>, and the smart watch displays an exercise interface <NUM> in response to the tap operation performed by the user on the "Exercise" option <NUM>. The exercise interface <NUM> includes a "Walk" option <NUM>, a "Run outdoors" option <NUM>, and a "Run indoors" option <NUM>. The user may enable a walking mode by tapping the "Walk" option <NUM>, enable an outdoor running mode by tapping the "Run outdoors" option <NUM>, and enable an indoor running mode by tapping the "Run indoors" option <NUM>. For example, the smart watch may receive a tap operation performed by the user on the "Run outdoors" option <NUM>, and the smart watch enables the outdoor running mode in response to the tap operation performed by the user on the "Run outdoors" option <NUM>.

It may be understood that options included in the foregoing interfaces are described merely as examples. For example, the interface <NUM> may further include a "Timer" option and a "Music" option, and the exercise interface <NUM> may further include a "Ride" option, a "Cycle indoors" option, and a "Climb a mountain" option. Details are not described in this embodiment of this application. The user may trigger the smart watch to display another option in the interface by using a preset gesture. For example, the preset gesture may be that a finger slides up or a finger slides down.

In another implementation, the sports mode may further include taking a plane. If the electronic device determines that the user has enabled "Take a plane" in the sports mode, in other words, determines that the electronic device receives an operation of enabling "Take a plane" in the sports mode, the electronic device enables the GPS function.

For example, as shown in <FIG>, the smart watch receives, in an interface <NUM>, a tap operation performed by the user on an "Exercise" option <NUM>, and the smart watch displays an exercise interface <NUM> in response to the tap operation performed by the user on the "Exercise" option <NUM>. The exercise interface <NUM> includes a "Take a plane" option <NUM>, and the user may enable a "Take a plane" mode by tapping the "Take a plane" option <NUM>. The smart watch may receive a tap operation performed by the user on the "Take a plane" option <NUM>, and the smart watch enables the "Take a plane" mode in response to the tap operation performed by the user on the "Take a plane" option <NUM>.

In another example, the user may set an option of the GNSS function of the smart watch or the mobile phone, to enable or disable the GNSS function. Taking the mobile phone as an example, the user may set an option of a positioning function on the mobile phone, to enable or disable the positioning function (that is, enable or disable the GPS).

For example, as shown in <FIG>, the mobile phone may receive a first gesture of the user on a desktop, and display a pull-down menu <NUM>. For example, the first gesture may be that a single finger slides down from the top of a screen. The pull-down menu <NUM> includes options such as a WLAN option, a Bluetooth option, a vibrate option, a location option <NUM>, and a wireless projection option. The user may enable or disable a corresponding function by tapping an option. The location option <NUM> is used to control a positioning function of the mobile phone to be enabled or disabled. For example, when the positioning function of the mobile phone is disabled, if the mobile phone receives a tap operation performed by the user on the location option <NUM>, the mobile phone enables the positioning function; or when the positioning function of the mobile phone is enabled, if the mobile phone receives a tap operation performed by the user on the location option <NUM>, the mobile phone disables the positioning function. For a function of another option in the pull-down menu <NUM>, refer to function descriptions in the conventional technology. This is not limited in this embodiment of this application, and details are not described herein.

In some embodiments, if the electronic device determines, after determining that the data of the barometric pressure sensor is invalid, that the GNSS function of the electronic device is in the disabled state, the electronic device enables the GNSS function of the electronic device, and displays the altitude in the received data of the GNSS.

In an implementation, the electronic device periodically enables the GNSS function based on a preset first time interval. In each period, the GNSS function is disabled after the enabled state of the GNSS function lasts for preset duration. For example, the preset first time interval may be <NUM> minutes, and the preset duration is <NUM> seconds. For example, the GNSS is a GPS. The electronic device enables a GPS function every <NUM> minutes to receive an altitude in data of the GPS. The electronic device disables the GPS function after the GPS function has been enabled for <NUM> seconds. Within the first time interval before the GPS function is enabled next time, the electronic device displays an altitude in data of the GPS that is received this time. Compared with a case in which the GNSS function is always in the enabled state, intermittently enabling and disabling the GNSS function can reduce power consumption of the electronic device.

S304: The electronic device determines whether a second switching condition is met; and if the electronic device determines that the second switching condition is met, the electronic device performs S305 that the electronic device displays the altitude obtained in the first detection manner, or if the electronic device determines that the second switching condition is not met, the electronic device performs S303 that the electronic device displays the altitude obtained in the second detection manner.

In a scenario, when the plane that the user takes lands, pressure is no longer boosted in the cabin of the plane, and the electronic device detects that the data of the barometric pressure sensor becomes valid again, and in this case, the electronic device may stop displaying the altitude in the received data of the GNSS, and display the altitude obtained based on the barometric pressure value measured by the barometric pressure sensor. The second switching condition is that the electronic device determines that the data of the barometric pressure sensor is valid.

The electronic device may stop receiving the data of the GNSS. For example, the electronic device stops periodically enabling the GNSS function based on the preset first time interval.

After the plane lands, the barometric pressure value detected by the barometric pressure sensor of the electronic device is inconsistent with the atmospheric pressure value corresponding to the altitude of the electronic device, in other words, the data of the barometric pressure sensor is valid.

In an implementation, if the electronic device detects that a second preset condition is met, the electronic device determines that the data of the barometric pressure sensor is valid.

In a possible design, the second preset condition is that an absolute value of a difference between the altitude obtained by the electronic device based on the barometric pressure value measured by the barometric pressure sensor and the altitude in the received data of the GNSS is less than a preset threshold. For example, the preset threshold may be <NUM> meters.

For example, the electronic device periodically compares, based on a preset second time interval, the altitude obtained based on the barometric pressure value measured by the barometric pressure sensor and the altitude in the received data of the GNSS. If the electronic device determines, M (M><NUM>) consecutive times, that the absolute value of the difference between the altitude obtained based on the barometric pressure value measured by the barometric pressure sensor and the altitude in the received data of the GNSS is less than the preset threshold, the electronic device determines that the data of the barometric pressure sensor is valid.

In an example, the electronic device periodically enables the GNSS function based on the preset first time interval. Each time the electronic device enables the GNSS function and receives the data of the GNSS, the electronic device obtains the altitude based on the barometric pressure value measured by the barometric pressure sensor, and compares the altitude obtained based on the barometric pressure value measured by the barometric pressure sensor and the altitude in the received data of the GNSS. In this example, the second time interval is the same as the first time interval.

For example, the smart watch enables the GPS function for the first time, receives data of the GPS, determines that an altitude is <NUM> meters, obtains an altitude <NUM> meters based on a barometric pressure value measured by the barometric pressure sensor, and determines that a difference between the two altitudes is less than <NUM> meters. After <NUM> minutes, the smart watch enables the GPS function for the second time, receives data of the GPS, determines that an altitude is <NUM> meters, obtains an altitude <NUM> meters based on a barometric pressure value measured by the barometric pressure sensor, and determines that a difference between the two altitudes is less than <NUM> meters. After <NUM> minutes, the smart watch enables the GPS function for the third time, receives data of the GPS, determines that an altitude is <NUM> meters, obtains an altitude <NUM> meters based on a barometric pressure value measured by the barometric pressure sensor, and determines that a difference between the two altitudes is less than <NUM> meters. The smart watch determines, three consecutive times (M=<NUM>), that an absolute value of the difference between the altitude obtained based on the barometric pressure value measured by the barometric pressure sensor and the altitude in the received data of the GPS is less than the preset threshold (<NUM> meters), and in this case, determines that the data of the barometric pressure sensor is valid.

In another example, the GNSS function of the smart watch remains in the enabled state. For example, the user enables the "Take a plane" mode. The electronic device periodically compares, based on a preset second time interval, the altitude obtained based on the barometric pressure value measured by the barometric pressure sensor and the altitude in the received data of the GNSS. The second time interval may be the same as or different from the first time interval.

For example, the GPS function of the smart watch is in the enabled state, and the smart watch receives data of the GPS every <NUM> seconds. For the first time, the smart watch determines, based on received data of the GPS, that an altitude is <NUM> meters, obtains an altitude <NUM> meters based on a barometric pressure value measured by the barometric pressure sensor, and determines that a difference between the two altitudes is less than <NUM> meters. After <NUM> seconds, the smart watch determines, based on received data of the GPS, that an altitude is <NUM> meters, obtains an altitude <NUM> meters based on a barometric pressure value measured by the barometric pressure sensor, and determines that a difference between the two altitudes is less than <NUM> meters. After <NUM> seconds, the smart watch determines, based on received data of the GPS, that an altitude is <NUM> meters, obtains an altitude <NUM> meters based on a barometric pressure value measured by the barometric pressure sensor, and determines that a difference between the two altitudes is less than <NUM> meters. The smart watch determines, three consecutive times (M=<NUM>), that an absolute value of the difference between the altitude obtained based on the barometric pressure value measured by the barometric pressure sensor and the altitude in the received data of the GPS is less than the preset threshold (<NUM> meters), and in this case, determines that the data of the barometric pressure sensor is valid.

In another implementation, if the electronic device detects that a third preset condition is met, the electronic device determines that the data of the barometric pressure sensor is valid.

In a possible design, the third preset condition is that a value by which the altitude value of the electronic device decreases within second preset duration is greater than a preset second height threshold. For example, the second preset duration is <NUM> seconds, and the second height threshold is <NUM> meters. The altitude of the electronic device is obtained in the second detection manner. If the electronic device detects that the value by which the altitude value of the electronic device decreases within the second preset duration is greater than the preset second height threshold, the electronic device determines that the plane that the user takes lands, and in this case, the data of the barometric pressure sensor becomes valid again.

For example, the GNSS function of a smart watch remains in the enabled state, and the electronic device receives the altitude data in the data of the GNSS, to obtain the current altitude. If the electronic device determines that the value by which the altitude value of the electronic device decreases within the second preset duration is greater than the preset second height threshold, the electronic device determines that the data of the barometric pressure sensor is valid.

In a scenario, the user may disable the GNSS function in a flight process of the plane, and the electronic device stops receiving the data of the GNSS, stops displaying the altitude in the received data of the GNSS, and displays the altitude obtained based on the barometric pressure value measured by the barometric pressure sensor. The second switching condition is that the electronic device determines that the user has disabled the GNSS function.

For example, if the user disables the outdoor sports mode such as walking, outdoor running, riding, or mountain climbing on the smart watch in the flight process of the plane, the smart watch may disable the GNSS function. This scenario is particularly applicable to a case in which the user enables the GNSS function by enabling the outdoor sports mode.

For example, if the user disables the "Take a plane" mode on the smart watch in the flight process of the plane, the smart watch may also disable the GNSS function.

For example, if the user disables the positioning function of the mobile phone in the flight process of the plane, the GNSS function is disabled.

In a scenario, the user may disable the GNSS function in the flight process of the plane. If the electronic device determines that the data of the barometric pressure sensor is invalid in this case, the electronic device enables the GNSS function of the electronic device. For example, the electronic device periodically enables the GNSS function based on the preset first time interval. In this way, the electronic device can display the altitude in the received data of the GNSS.

Subsequently, when the plane that the user takes lands, pressure is no longer boosted in the cabin of the plane, and the electronic device detects that the data of the barometric pressure sensor becomes valid again, and in this case, the electronic device may stop displaying the altitude in the received data of the GNSS, and display the altitude obtained based on the barometric pressure value measured by the barometric pressure sensor. In addition, the electronic device stops receiving the data of the GNSS. For example, the electronic device stops periodically enabling the GNSS function based on the preset first time interval.

In this scenario, the second switching condition is that the electronic device determines that the data of the barometric pressure sensor is valid.

In an implementation, after determining, in S302, that the data of the barometric pressure sensor is invalid, the electronic device may record that the barometric pressure sensor is in an invalid state. Subsequently, if the electronic device detects that the data of the barometric pressure sensor becomes valid again, the electronic device records that the barometric pressure sensor is in a valid state. For example, the electronic device may record and update a state identifier of the barometric pressure sensor. The state identifier of the barometric pressure sensor is used to indicate a status of the barometric pressure sensor. If the state identifier of the barometric pressure sensor is <NUM>, it indicates that the data of the barometric pressure sensor is valid. If the state identifier of the barometric pressure sensor is <NUM>, it indicates that the data of the barometric pressure sensor is invalid.

In an example, the data of the barometric pressure sensor of the smart watch is valid, the smart watch displays the altitude obtained based on the barometric pressure value measured by the barometric pressure sensor, and the state identifier of the barometric pressure sensor is <NUM>. If the user enables the "Take a plane" mode on the smart watch, the GPS function is enabled. Subsequently, the user takes a plane with the smart watch, and the plane takes off. After the plane takes off, pressure is boosted in the cabin of the plane, and the data of the barometric pressure sensor is invalid. If the smart watch determines, after determining that the data of the barometric pressure sensor is invalid, that the GPS function is in the enabled state, the smart watch displays the altitude in the received data of the GPS. In addition, the state identifier of the barometric pressure sensor is updated to <NUM>, to indicate that the data of the barometric pressure sensor is invalid. If the user disables the "Take a plane" mode on the smart watch in the flight process of the plane, the GPS function is disabled. The smart watch detects that the GPS function is disabled, and determines that the data of the barometric pressure sensor is invalid (the state identifier of the barometric pressure sensor is <NUM>), and in this case, the smart watch periodically enables the GPS function based on the preset first time interval. In this way, the smart watch can display the altitude in the received data of the GPS. Subsequently, when the plane that the user takes lands, pressure is no longer boosted in the cabin of the plane, and the smart watch detects that the data of the barometric pressure sensor becomes valid again, the smart watch stops periodically enabling the GPS function based on the preset first time interval, and display the altitude obtained based on the barometric pressure value measured by the barometric pressure sensor.

S305: The electronic device displays the altitude obtained in the first detection manner.

For example, the electronic device displays the current altitude based on the barometric pressure value measured by the barometric pressure sensor.

For example, after the plane lands, the smart watch displays the altitude obtained based on the barometric pressure value measured by the barometric pressure sensor. As shown in <FIG>, the smart watch displays a current altitude <NUM> meters.

Optionally, the smart watch may display an altitude change curve in a period of time. For example, a curve <NUM> in <FIG> is an altitude change curve of the smart watch on the day.

According to the method for measuring a height on a plane provided in this embodiment of this application, generally, the height value displayed by the electronic device is the altitude obtained by using the barometric pressure sensor. When the user takes a plane with the electronic device, the electronic device determines that the data of the barometric pressure sensor is invalid, and the electronic device displays the altitude in the received data of the GNSS. In this way, the electronic device can also display an accurate altitude when the data of the barometric pressure sensor is untrustworthy in a case in which the user takes a plane or in another case.

After the plane that the user takes lands, the electronic device detects that the data of the barometric pressure sensor becomes valid again, and the electronic device displays the altitude obtained by using the barometric pressure sensor. The altitude obtained based on the barometric pressure value measured by the barometric pressure sensor is more accurate than the altitude obtained by receiving the data of the GNSS by the electronic device. In this way, the electronic device can display a more accurate altitude when the user does not take a plane. In addition, in this way, the electronic device may not enable the GNSS function when the user does not take a plane, so that power consumption of the electronic device is reduced.

It may be understood that the method for measuring a height on a plane provided in this embodiment of this application may be further applied to another scenario in which the user wears the electronic device on a transportation tool other than the plane and data of the barometric pressure sensor is invalid. Generally, the electronic device displays the altitude obtained by using the barometric pressure sensor. When determining that the data of the barometric pressure sensor is invalid, the electronic device displays the altitude in the received data of the GNSS. When detecting that the data of the barometric pressure sensor becomes valid again, the electronic device displays the altitude obtained by using the barometric pressure sensor. In this way, the electronic device can display an accurate altitude regardless of whether the data of the barometric pressure sensor is valid.

It can be understood that, to implement the foregoing functions, the electronic device includes a corresponding hardware structure and/or software module for performing each of the functions. A person skilled in the art should be easily aware that, in combination with the examples described in the embodiments disclosed in this specification, units, algorithms, and steps may be implemented by hardware or a combination of hardware and computer software in the embodiments of this application. Whether a function is performed by hardware or hardware driven by computer software depends on particular applications and design constraints of the technical solutions. A person skilled in the art may use different methods to implement the described functions for each particular application, but it should not be considered that the implementation goes beyond the scope of the embodiments of this application.

In the embodiments of this application, the electronic device may be divided into functional modules based on the foregoing method examples. For example, each functional module may be obtained through division based on each corresponding function, or two or more functions may be integrated into one processing module. The integrated module may be implemented in a form of hardware, or may be implemented in a form of a software function module. It should be noted that, in this embodiment of this application, division into the modules is an example, and is merely a logical function division. In an actual implementation, another division manner may be used.

<FIG> is a possible schematic diagram of a structure of the electronic device in the foregoing embodiments. The electronic device <NUM> includes a barometer <NUM>, a GNSS module <NUM>, a height measurement module <NUM>, and a GNSS control module <NUM>.

The barometer <NUM> is configured to detect a barometric pressure value. For example, the barometer <NUM> may be the barometric pressure sensor 150A in <FIG>.

The GNSS module <NUM> is configured to receive data of a GNSS. For example, the GNSS module <NUM> may be the positioning module <NUM> in <FIG>.

The height measurement module <NUM> is configured to calculate an altitude of the electronic device. The height measurement module <NUM> includes: a barometric pressure height submodule <NUM>, configured to calculate the altitude of the electronic device based on the barometric pressure value detected by the barometer <NUM>; a GNSS height submodule <NUM>, configured to obtain the altitude of the electronic device based on the data of the GNSS; a barometric pressure height validity determining submodule <NUM>, configured to determine whether the data of the barometer <NUM> is valid; and a height measurement submodule <NUM>, configured to obtain the altitude of the electronic device based on the data of the submodules in the height measurement module <NUM>, and further configured to interact with another module of the electronic device as an interface module of the height measurement module <NUM>.

The GNSS control module <NUM> is configured to control a GNSS function of the electronic device to be enabled or disabled. For example, the GNSS control module <NUM> may be configured to control, based on an operation of enabling or disabling a sports mode by a user, the GNSS function of the electronic device to be enabled or disabled. For example, if the GNSS control module <NUM> determines that an operation of enabling an outdoor sports mode such as walking, outdoor running, riding, or mountain climbing by the user is received, or determines that an operation of enabling a "Take a plane" mode in the sports mode by the user is received, the GNSS control module <NUM> controls the GNSS function of the electronic device to be enabled; or if the GNSS control module <NUM> determines that an operation of disabling an outdoor sports mode such as walking, outdoor running, riding, or mountain climbing by the user is received, or determines that an operation of disabling a "Take a plane" mode in the sports mode by the user is received, the GNSS control module <NUM> controls the GNSS function of the electronic device to be disabled. For example, the GNSS control module <NUM> may be further configured to control, based on an operation of enabling or disabling a positioning function by the user, the GNSS function of the electronic device to be enabled or disabled. Content of controlling the GNSS function to be enabled/disabled is described in detail in the foregoing embodiments, and is not described herein again.

For example, the height measurement module <NUM> and the GNSS control module <NUM> may be implemented by the processor <NUM> in <FIG>.

With reference to an interaction procedure between the modules of the electronic device <NUM>, the following describes in detail the method for measuring a height on a plane provided in the embodiments of this application.

Scenario <NUM>: A user enables a GNSS function of an electronic device before a plane takes off. Subsequently, the user takes a plane with the electronic device, and the plane takes off. After the plane takes off, pressure is boosted in a cabin of the plane, and data of a barometer of the electronic device is invalid.

This embodiment is described by using an example in which the user enables the GNSS function of the electronic device by enabling an outdoor sports mode or a "Take a plane" mode on the electronic device. Certainly, the user may alternatively enable the GNSS function in another manner before the plane takes off. For example, before the plane takes off, the user enables the GNSS function by enabling a positioning function of the electronic device. A specific manner in which the user enables the GNSS function does not affect a function of each module in this embodiment. Descriptions of functions of the modules and descriptions of an interaction procedure between the modules in this embodiment are also applicable to a scenario in which the user enables the GNSS function in another manner.

It should be noted that the sports mode in this embodiment is an outdoor sports mode such as walking, outdoor running, riding, or mountain climbing or a "Take a plane" mode. This is not specifically described in specific descriptions of the embodiments.

As shown in <FIG>, <FIG>, <FIG>, and <FIG>, a method for measuring a height on a plane provided in an embodiment of this application may include the following steps.

S801: A barometer periodically reports barometric pressure value data to a barometric pressure height submodule.

For example, the barometer periodically reports the detected barometric pressure value data to the barometric pressure height submodule based on a specified period (for example, <NUM> second).

S802: The barometric pressure height submodule receives the barometric pressure value data reported by the barometer.

The barometric pressure height submodule receives the barometric pressure value data reported by the barometer, and may calculate an altitude of an electronic device based on the barometric pressure value. The barometric pressure height submodule may send the altitude data of the electronic device to a height measurement submodule, and may also send the altitude data of the electronic device a barometric pressure height validity determining submodule.

S803: The barometric pressure height submodule periodically sends the altitude data of the electronic device to the height measurement submodule.

S804: The height measurement submodule receives the altitude data of the electronic device from the barometric pressure height submodule.

After the height measurement submodule receives the altitude data of the electronic device, the electronic device may display the altitude on a display. For example, when a user does not take a plane, the electronic device displays an interface shown in <FIG>, and an altitude value of the electronic device is <NUM> meters.

The height measurement submodule may further send, to the barometric pressure height validity determining submodule, the altitude data of the electronic device that is received from the barometric pressure height submodule.

S805: A GNSS control module receives an operation of enabling a sports mode on the electronic device by the user.

The GNSS control module receives the operation of enabling the sports mode on the electronic device by the user, and notifies, in response to the operation of enabling the sports mode on the electronic device by the user, a GNSS module to enable a GNSS function.

S806: The GNSS module enables the GNSS function.

The GNSS module may enable the GNSS function, and after receiving an operation of disabling the sports mode on the electronic device by the user, the GNSS control module notifies the GNSS module to disable the GNSS function.

When the GNSS function is enabled, the GNSS module may periodically (for example, a reporting period is <NUM> second) report received data of a GNSS to a GNSS height submodule.

The GNSS height submodule receives the data of the GNSS, and may obtain an altitude of the electronic device based on the data of the GNSS.

S807: The barometric pressure height validity determining submodule determines that the data of the barometer is invalid.

The barometric pressure height validity determining submodule periodically receives the altitude data of the electronic device that is sent by the height measurement submodule (the altitude data of the electronic device is received from the barometric pressure height submodule). If the barometric pressure height validity determining submodule determines, based on the altitude data of the electronic device that is received from the barometric pressure height submodule, that a first preset condition is met, the barometric pressure height validity determining submodule determines that the data of the barometer is invalid. For example, if the barometric pressure height validity determining submodule determines that the altitude data of the electronic device increases by <NUM> meters within <NUM> seconds, the barometric pressure height validity determining submodule determines that the data of the barometer is invalid.

For example, the user takes a plane with the electronic device, and the plane takes off. After the plane takes off, pressure is boosted in a cabin of the plane, and the data of the barometer is invalid.

S808: The barometric pressure height validity determining submodule notifies the height measurement submodule that the data of the barometer is invalid.

S809: The height measurement submodule receives the altitude of the electronic device from the GNSS height submodule.

If the height measurement submodule determines, after receiving a notification message that the data of the barometer is invalid, that the GNSS function of the electronic device is enabled, the height measurement submodule receives the altitude of the electronic device from the GNSS height submodule. In this way, the electronic device displays the altitude data in the received data of the GNSS.

For example, the electronic device displays an interface shown in <FIG>, and an altitude value of the electronic device is <NUM> meters.

The height measurement submodule may further send, to the barometric pressure height validity determining submodule, the altitude data of the electronic device that is received from the GNSS height submodule.

In a possible scenario, the plane that the user takes lands, pressure is no longer boosted in the cabin of the plane, and the data of the barometer becomes valid again. The method may further include the following steps.

S810: The barometric pressure height validity determining submodule determines that the data of the barometer is valid.

In an implementation, the barometric pressure height validity determining submodule compares the altitude data of the electronic device that is received from the barometric pressure height submodule and the altitude data of the electronic device that is received from the GNSS height submodule. If the barometric pressure height validity determining submodule determines that an absolute value of a difference between the altitude data of the electronic device that is received from the barometric pressure height submodule and the altitude data of the electronic device that is received from the GNSS height submodule is less than a preset threshold, the barometric pressure height validity determining submodule determines that the data of the barometer is valid.

S811: The barometric pressure height validity determining submodule notifies the height measurement submodule that the data of the barometer is valid.

S812: The height measurement submodule receives the altitude of the electronic device from the barometric pressure height submodule.

The height measurement submodule stops receiving the altitude of the electronic device from the GNSS height submodule, and receives the altitude of the electronic device from the barometric pressure height submodule again. In this way, the electronic device displays the altitude data of the electronic device that is received from the barometric pressure height submodule.

For example, after the plane lands, the electronic device displays an interface shown in <FIG>, and an altitude value of the electronic device is <NUM> meters.

In a possible scenario, the user may disable the GNSS function in a flight process of the plane. For example, if the user disables, on a smart watch, the sports mode on the electronic device in the flight process of the plane, disabling the GNSS function may be triggered. The method may further include the following steps.

S80a: The GNSS control module receives an operation of disabling the sports mode on the electronic device by the user.

The GNSS control module receives the operation of disabling the sports mode on the electronic device by the user, and the GNSS control module notifies, in response to the operation of disabling the sports mode on the electronic device by the user, the GNSS module to disable the GNSS function. The GNSS module stops periodically reporting the received data of the GNSS to the GNSS height submodule.

It may be understood that the height measurement submodule is an interface module between the height measurement module and another module, and the GNSS control module may notify, by using the height measurement submodule, the GNSS module to disable the GNSS function. In this case, the height measurement submodule may determine that the GNSS function is disabled.

S80b: The height measurement submodule receives the altitude of the electronic device from the barometric pressure height submodule.

According to the method for measuring a height on a plane provided in this embodiment of this application, generally, the height value displayed by the electronic device is the altitude obtained by using the barometric pressure sensor. The user may enable the GNSS function of the electronic device. When the user takes a plane with the electronic device, the electronic device determines that the data of the barometric pressure sensor is invalid, and the electronic device displays the altitude in the received data of the GNSS. In this way, the electronic device can also display an accurate altitude when the data of the barometric pressure sensor is untrustworthy in a case in which the user takes a plane or in another case.

After the plane that the user takes lands, the electronic device detects that the data of the barometric pressure sensor becomes valid again, and the electronic device displays the altitude obtained by using the barometric pressure sensor. The altitude obtained based on the barometric pressure value measured by the barometric pressure sensor is more accurate than the altitude obtained by receiving the data of the GNSS by the electronic device. In this way, the electronic device can display a more accurate altitude when the user does not take a plane.

If the user disables the GNSS function in the flight process of the plane, the electronic device displays the altitude obtained by using the barometric pressure sensor.

Scenario <NUM>: A user takes a plane with an electronic device, and the plane takes off. After the plane takes off, pressure is boosted in a cabin of the plane, and data of a barometer of the electronic device is invalid. The user does not enable a GNSS function of the electronic device.

As shown in <FIG> and <FIG>, a method for measuring a height on a plane provided in an embodiment of this application may include the following steps.

S901: A barometer periodically reports barometric pressure value data to a barometric pressure height submodule.

S902: The barometric pressure height submodule receives the barometric pressure value data reported by the barometer.

S903: The barometric pressure height submodule periodically sends altitude data of an electronic device to a height measurement submodule.

S904: The height measurement submodule receives the altitude data of the electronic device from the barometric pressure height submodule.

For detailed descriptions of S901 to S904, refer to S801 to S804.

S905: The barometric pressure height validity determining submodule determines that the data of the barometer is invalid.

For detailed descriptions of S905, refer to S807.

S906: The barometric pressure height validity determining submodule notifies the height measurement submodule that the data of the barometer is invalid.

For detailed descriptions of S906, refer to S808.

S907: The height measurement submodule notifies a GNSS height submodule to enable a GNSS function.

The height measurement submodule determines that the electronic device no longer displays the altitude data of the electronic device that is received from the barometric pressure height submodule, and notifies the GNSS height submodule to enable the GNSS function.

In an implementation, the height measurement submodule continues to receive the altitude data of the electronic device from the barometric pressure height submodule. In this case, the height measurement submodule may determine, based on the altitude data of the electronic device that is received from the barometric pressure height submodule, whether the data of the barometer becomes valid again.

S908: The GNSS height submodule notifies a GNSS module to enable the GNSS function.

The GNSS height submodule notifies the GNSS module to enable the GNSS function. After receiving the notification of enabling the GNSS function from the GNSS height submodule, the GNSS module enables the GNSS function, and receives data of a GNSS.

In an implementation, the GNSS height submodule periodically enables the GNSS function based on a preset first time interval. In each period, the GNSS function is disabled after an enabled state of the GNSS function lasts for preset duration. The GNSS module periodically enables the GNSS function based on the preset first time interval. In each period, after the data of the GNSS has been received for preset duration, the GNSS module stops receiving the data of the GNSS.

S909: The GNSS module periodically reports the data of the GNSS to the GNSS height submodule.

When the GNSS function is enabled, the GNSS module reports the data of the GNSS to the GNSS height submodule. The GNSS height submodule receives the data of the GNSS, and may obtain an altitude of the electronic device based on the data of the GNSS.

S910: The height measurement submodule receives the altitude of the electronic device from the GNSS height submodule.

The height measurement submodule receives the altitude of the electronic device from the GNSS height submodule. In this way, the electronic device displays the altitude data in the received data of the GNSS.

The height measurement submodule may further send, to the barometric pressure height validity determining submodule, the altitude of the electronic device that is received from the GNSS height submodule.

S911: The barometric pressure height validity determining submodule determines that the data of the barometer is valid.

For example, a plane that a user takes lands, pressure is no longer boosted in a cabin of the plane, the data of the barometer becomes valid again, and the barometric pressure height validity determining submodule determines that the data of the barometer is valid.

S912: The barometric pressure height validity determining submodule notifies the height measurement submodule that the data of the barometer is valid.

S913: The height measurement submodule receives the altitude of the electronic device from the barometric pressure height submodule.

The height measurement submodule stops receiving the altitude of the electronic device from the GNSS height submodule, and receives the altitude of the electronic device from the barometric pressure height submodule again. In this way, the electronic device displays the altitude data of the electronic device that is received from the barometric pressure height submodule. For example, after the plane lands, the electronic device displays an interface shown in <FIG>, and an altitude value of the electronic device is <NUM> meters.

S914: The height measurement submodule notifies the GNSS height submodule to disable the GNSS function.

The height measurement submodule determines that the electronic device no longer displays the altitude data of the electronic device that is received from the GNSS height submodule, and notifies the GNSS height submodule to disable the GNSS function.

S915: The GNSS height submodule notifies the GNSS module to disable the GNSS function.

The GNSS height submodule notifies the GNSS module to disable the GNSS function. After receiving the notification of disabling the GNSS function from the GNSS height submodule, the GNSS module disables the GNSS function, and no longer receives the data of the GNSS.

In an implementation, the GNSS height submodule determines to stop periodically enabling the GNSS function based on the preset first time interval. The GNSS height submodule notifies the GNSS module to stop periodically enabling the GNSS function based on the preset first time interval. After receiving the notification from the GNSS height submodule, the GNSS module stops periodically receiving the data of the GNSS based on the preset first time interval.

According to the method for measuring a height on a plane provided in this embodiment of this application, generally, the height value displayed by the electronic device is the altitude obtained by using the barometric pressure sensor. When the user takes a plane with the electronic device, the electronic device determines that the data of the barometric pressure sensor is invalid, and the electronic device may enable the GNSS function, and display the altitude in the received data of the GNSS. In this way, the electronic device can also display an accurate altitude when the data of the barometric pressure sensor is untrustworthy in a case in which the user takes a plane or in another case. In addition, the electronic device may periodically and intermittently enable the GNSS function, so that power consumption of the electronic device can be reduced.

When an integrated unit is used, <FIG> is a possible schematic diagram of a structure of the electronic device in the foregoing embodiments. The electronic device <NUM> includes a processing module <NUM>, a display module <NUM>, a barometric pressure module <NUM>, a positioning module <NUM>, and a storage module <NUM>.

The processing module <NUM> is configured to control and manage an action of the electronic device <NUM>. For example, the processing module <NUM> may be configured to perform the processing steps of S302 and S304 in <FIG> and/or another process of the technology described in this specification.

The display module <NUM> is configured to display an interface of the electronic device. For example, the display module <NUM> may be configured to display an altitude of the electronic device, and may be further configured to: display a setting interface for enabling and disabling a sports mode of the electronic device, and display a setting interface for enabling and disabling a positioning function. For example, the display module <NUM> may be configured to perform the processing steps of S301, S303, and S305 in <FIG> and/or another process of the technology described in this specification.

The barometric pressure module <NUM> is configured to detect barometric pressure of an environment in which the electronic device <NUM> is located.

The positioning module <NUM> is configured to position the electronic device <NUM>. For example, the positioning module <NUM> may be configured to receive data of a GNSS.

The storage module <NUM> is configured to store program code and data of the electronic device <NUM>. For example, the storage module <NUM> may be configured to store a state identifier of a barometric pressure sensor.

Certainly, units and modules in the electronic device <NUM> include but are not limited to the processing module <NUM>, the display module <NUM>, the barometric pressure module <NUM>, the positioning module <NUM>, and the storage module <NUM>. For example, the electronic device <NUM> may further include a power module.

The processing unit <NUM> may be a processor or a controller, for example, may be a central processing unit (central processing unit, CPU), a digital signal processor (digital signal processor, DSP), or an application-specific integrated circuit (application-specific integrated circuit, ASIC), a field programmable gate array (field programmable gate array, FPGA) or another programmable logic component, a transistor logic component, a hardware component, or any combination thereof. The processor may include an application processor and a baseband processor. The processing module may implement or execute various example logical blocks, modules, and circuits described with reference to content disclosed in this application. The processor may be a combination of processors implementing a computing function, for example, a combination of one or more microprocessors, or a combination of the DSP and a microprocessor. The display module <NUM> may be a display. The barometric pressure module <NUM> may be a barometric pressure sensor. The storage module <NUM> may be a memory.

For example, the processing module <NUM> is a processor (the processor <NUM> shown in <FIG>), the display module <NUM> is a display (the display <NUM> shown in <FIG>, where the display <NUM> may be a touchscreen, and a display panel and a touch panel may be integrated into the touchscreen), the barometric pressure module <NUM> is a barometric pressure sensor (the barometric pressure sensor 150A shown in <FIG>), the positioning module <NUM> may be the positioning module <NUM> shown in <FIG>, and the storage module <NUM> may be a memory (the memory <NUM> shown in <FIG>). The processor, the memory, and the like may be coupled together, for example, connected by using a bus.

An embodiment of this application further provides a computer storage medium. The computer storage medium stores computer program code, and when the processor executes the computer program code, the electronic device performs related method steps in <FIG> to implement the method in the foregoing embodiments.

An embodiment of this application further provides a computer program product. When the computer program product runs on a computer, the computer performs the related method steps in <FIG> to implement the method in the foregoing embodiment.

The electronic device <NUM>, the computer storage medium, and the computer program product provided in the embodiments of this application each are configured to perform the corresponding method provided above. Therefore, for beneficial effects that can be achieved by the electronic device <NUM>, the computer storage medium, and the computer program product, refer to the beneficial effects in the corresponding method provided above.

The foregoing descriptions about the implementations allow a person skilled in the art to clearly understand that, for the purpose of convenient and brief description, division into only the foregoing function modules is used as an example for description. In actual application, the foregoing functions can be allocated to different function modules for implementation as required. In other words, an inner structure of an apparatus is divided into different function modules to implement all or some of the functions described above.

In the several embodiments provided in this application, it should be understood that the disclosed apparatuses and methods may be implemented in other manners. For example, the described apparatus embodiments are merely examples. For example, division into the modules or units is merely logical function division, and may be other division in an actual implementation. For example, a plurality of units or components may be combined or may be integrated into another apparatus, or some features may be ignored or not performed. In addition, the displayed or discussed mutual couplings or direct couplings or communications connections may be implemented through some interfaces. The indirect couplings or communications connections between the apparatuses or units may be implemented in electronic, mechanical, or another form.

The units described as separate components may or may not be physically separate, and components displayed as units may be one or more physical units, that is, may be located in one place, or may be distributed on a plurality of different places. A part or all of the units may be selected based on actual requirements to achieve the objectives of the solutions of the embodiments.

When the integrated unit is implemented in a form of a software function unit and sold or used as an independent product, the integrated unit may be stored in a readable storage medium. Based on such an understanding, the technical solutions of the embodiments of this application essentially, or the part contributing to the conventional technology, or all or some of the technical solutions may be implemented in a form of a software product. The software product is stored in a storage medium and includes several instructions for instructing a device (which may be a single-chip microcomputer, a chip, or the like) or a processor (processor) to perform all or some of the steps of the methods in the embodiments of this application. The foregoing storage medium includes any medium that can store program code, for example, a USB flash drive, a removable hard disk, a ROM, a RAM, a magnetic disk, or an optical disc.

Claim 1:
A method for measuring a height in a cabin of a plane applied to an electronic device (<NUM>), such as a wearable device, wherein the electronic device comprises an altimeter function when the electronic device (<NUM>) is located in the cabin of the plane, comprising:
displaying (S301), by the electronic device (<NUM>), an altitude obtained in a first detection manner, wherein the first detection manner is a default altitude detection manner of the electronic device (<NUM>) and is a manner of detecting altitude using a barometric pressure sensor (150A) of the electronic device (<NUM>); and
if it is determined (S302) that a first switching condition is met, displaying (S303), by the electronic device (<NUM>), an altitude obtained in a second detection manner, different from the first detection manner,
wherein the first switching condition comprises: the data obtained by the electronic device in the first detection manner is determined as invalid, and wherein it is determined that the data obtained in the first detection manner is invalid when a value by which an altitude value of the electronic device increases within a
first preset duration is greater than a preset first height threshold indicating that the pressure in the cabin of the plane has been boosted.