Data processing method, electronic device, storage medium and chip

The data processing method optimizes virtual gyroscope performance in electronic devices by adjusting acceleration sensor parameters for real-time data transmission and caching, addressing poor data processing capabilities and enhancing user experience.

CN118426873BActive Publication Date: 2024-12-13HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410845764.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-27
Publication Date
2024-12-13
Estimated Expiration
2044-06-27

AI Technical Summary

Technical Problem

The virtual gyroscope implemented by traditional algorithms in electronic devices suffers from poor data processing capabilities, leading to a poor user experience.

Method used

A data processing method that adjusts the parameter value of the acceleration sensor to either match or exceed the collected data volume, allowing real-time data transmission when subscribing to angular velocity data and caching data when unsubscribing, thereby improving timeliness and reducing energy consumption.

Benefits of technology

Enhances data processing performance by improving the timeliness of data transmission and reducing energy consumption, resulting in an improved user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118426873B_ABST
    Figure CN118426873B_ABST
Patent Text Reader

Abstract

The present application discloses a data processing method, an electronic device, a storage medium and a chip. The method is applied to an electronic device including an acceleration sensor, an acceleration sensor driver and a virtual gyroscope driver, wherein the acceleration sensor driver is used to report the acceleration data reported by the acceleration sensor to the virtual gyroscope driver, and the virtual gyroscope driver is used to generate angular velocity data based on the acceleration data, including: when a first application of the electronic device subscribes to the angular velocity data from the virtual gyroscope driver, the value of the first parameter is set to a first numerical value, the value of the first parameter represents the amount of acceleration data sent by the acceleration sensor to the acceleration sensor driver each time, and the first numerical value is the amount of acceleration data collected by the acceleration sensor each time; or when the first application cancels the subscription to the angular velocity data from the virtual gyroscope driver, the value of the first parameter is set to a second numerical value, and the second numerical value is greater than the first numerical value. The method can improve data processing performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and more specifically, to a data processing method, electronic device, storage medium and chip. Background Art

[0002] The virtual gyroscope in electronic devices is a virtual sensor that is fused by the acceleration (ACC) data and the magnetic (MAG) data through the attitude estimation algorithm. This virtual gyroscope implemented by the algorithm does not need to increase the hardware cost of the electronic device. Therefore, the virtual gyroscope is widely used in various application scenarios such as games, navigation, flight simulation and virtual reality of electronic devices. However, the virtual gyroscope implemented by the algorithm in traditional technology has the problem of poor data processing capability, resulting in poor user experience.

[0003] Therefore, how to improve data processing capabilities has become an urgent problem that needs to be solved. Summary of the invention

[0004] The present application provides a data processing method, an electronic device, a storage medium and a chip, which can improve data processing performance to improve user experience.

[0005] In a first aspect, a data processing method is provided, which is applied to an electronic device including an acceleration sensor, an acceleration sensor driver and a virtual gyroscope driver, wherein the acceleration sensor driver is used to report acceleration data reported by the acceleration sensor to the virtual gyroscope driver, and the virtual gyroscope driver is used to generate angular velocity data based on the acceleration data reported by the acceleration sensor driver. The method comprises: when a first application in the electronic device subscribes to angular velocity data from the virtual gyroscope driver, setting a parameter value of a first parameter of the acceleration sensor to a first value, wherein the parameter value of the first parameter represents the amount of acceleration data sent by the acceleration sensor to the acceleration sensor driver each time, and the first value is the amount of acceleration data collected by the acceleration sensor each time; or, when the first application cancels its subscription to angular velocity data from the virtual gyroscope driver, setting the parameter value of the first parameter to a second value, wherein the second value is greater than the first value.

[0006] The first application subscribes to the angular velocity data from the virtual gyroscope driver, that is, the first application needs to obtain the angular velocity data output by the virtual gyroscope. The first application unsubscribes from the angular velocity data from the virtual gyroscope driver, that is, the first application does not need to obtain the angular velocity data output by the virtual gyroscope.

[0007] The angular velocity data may refer to angle data including heading angle, pitch angle, and roll angle.

[0008] After the electronic device sets the parameter value of the first parameter of the acceleration sensor to the first value, the acceleration sensor directly reports the acceleration data with the first value collected to the acceleration sensor driver. Since the acceleration data amount collected by the acceleration sensor each time is also the first value, in this implementation method, it can be considered that the acceleration sensor can transmit the collected acceleration data with the first value in real time to the acceleration sensor driver.

[0009] In the above technical solution, when the first application of the electronic device subscribes to the angular velocity data of the virtual gyroscope driver of the electronic device, the electronic device sets the data volume of the acceleration data (i.e., the parameter value of the first parameter) sent by the acceleration sensor to the acceleration sensor driver each time to be the same as the data volume of the acceleration data collected by the acceleration sensor each time (i.e., the first value), that is, the acceleration sensor can report the collected acceleration data with the first value in real time to the acceleration sensor driver, which can improve the timeliness of the acceleration data transmission. Afterwards, when the acceleration sensor driver transmits the acceleration data reported by the acceleration sensor to the virtual gyroscope in real time, the virtual gyroscope can obtain the angular velocity data based on the acceleration data, thereby improving the timeliness of the angular velocity data of the virtual gyroscope to improve the user experience. In addition, when the first application unsubscribes from the angular velocity data to the virtual gyroscope, the electronic device sets the amount of acceleration data (i.e., the parameter value of the first parameter) that the acceleration sensor sends to the acceleration sensor driver each time to be greater than the amount of acceleration data (i.e., the first value) collected by the acceleration sensor each time, that is, the acceleration sensor will first cache the collected acceleration data whose amount is less than the second value, until the amount of acceleration data cached by the acceleration sensor is the second value, the acceleration sensor will report the acceleration data with the second value to the acceleration sensor driver, which can reduce the energy consumption of data transmission. In summary, the data processing method provided by the present application can improve data processing performance (the timeliness of data transmission or reduce the energy consumption of data transmission) to improve user experience.

[0010] In one possible implementation, when a first application in an electronic device drives a virtual gyroscope to subscribe to angular velocity data, a parameter value of a first parameter of an acceleration sensor is set to a first value, including: when the first application drives a virtual gyroscope to subscribe to angular velocity data, and when it is determined that the parameter value of the first parameter is not the first value, the parameter value of the first parameter is set to the first value.

[0011] For example, the first application in the above implementation is the application in the electronic device that drives and subscribes to angular velocity data for the first time to the virtual gyroscope, that is, before the first application drives and subscribes to angular velocity data to the virtual gyroscope, no other application in the electronic device drives and subscribes to angular velocity data to the virtual gyroscope.

[0012] For example, the first application in the above implementation is an application in the electronic device that is not the first time to subscribe to angular velocity data from the virtual gyroscope. In this implementation, before the first application subscribes to angular velocity data from the virtual gyroscope, other applications in the electronic device first subscribe to angular velocity data from the virtual gyroscope and then unsubscribe from the angular velocity data, so that the parameter value of the first parameter is not the first value.

[0013] In the above technical solution, the electronic device will set the parameter value of the first parameter to the first value only when the first application subscribes to the angular velocity data from the virtual gyroscope driver and determines that the first parameter is not the first value. In other words, the electronic device will not perform the operation of setting the parameter value of the first parameter to the first value only when the first application subscribes to the angular velocity data from the virtual gyroscope driver and determines that the first parameter is not the first value, thereby avoiding repeated execution of the operation of setting the value of the first parameter to the first value, which is beneficial to improving data processing performance and reducing energy consumption of the electronic device.

[0014] In another possible implementation, after setting the parameter value of the first parameter of the acceleration sensor to the first value, the method further includes: controlling the acceleration sensor to report the collected acceleration data whose data volume is the first value to the acceleration sensor driver.

[0015] In the above technical solution, after the first application subscribes to the angular velocity data from the virtual gyroscope driver, the electronic device first sets the value of the first parameter to the first value. Afterwards, the electronic device controls the acceleration sensor to report the collected acceleration data with the first value to the acceleration sensor driver, which can improve the timeliness of the acceleration data transmission. Afterwards, the acceleration sensor driver transmits the acceleration data reported by the acceleration sensor in real time to the virtual gyroscope, which can improve the timeliness of the angular velocity data generated by the virtual gyroscope to improve the user experience.

[0016] In another possible implementation, when a first application in an electronic device subscribes to angular velocity data from a virtual gyroscope driver, a parameter value of a first parameter of an acceleration sensor is set to a first value, including: obtaining a first registration subscription message, wherein the first registration subscription message is used to indicate that the first application subscribes to angular velocity data from a virtual gyroscope driver; and based on the first registration subscription message, setting the parameter value of the first parameter to the first value.

[0017] In the above technical solution, the electronic device can set the parameter of the first parameter of the acceleration sensor to the first value based on the first application driving the virtual gyroscope to subscribe to the subscription message of angular velocity data (ie, the first registration subscription message).

[0018] In another possible implementation, the electronic device also includes a sensor manager located at the application framework layer; and obtaining a first registration subscription message, including: the sensor manager receives the first registration subscription message sent by the first application; based on the first registration subscription message, setting the parameter value of the first parameter to the first numerical value, including: the sensor manager sends a first enable message to the virtual gyroscope driver based on the first registration subscription message; in response to receiving the first enable message, the virtual gyroscope driver sends a second enable message to the acceleration sensor driver; the acceleration sensor driver sets the parameter value of the first parameter to the first numerical value according to the second enable message.

[0019] Optionally, the electronic device in the above implementation also includes a sensor module located at the hardware abstraction layer, and the sensor manager sends a first enable message to the virtual gyroscope driver based on the first registration subscription message, including: the sensor manager sends the first enable message to the virtual gyroscope driver by calling the sensor module.

[0020] In another possible implementation, the electronic device also includes a magnetic sensor and a magnetic sensor driver; and the method also includes: in response to receiving a first enable message, the virtual gyroscope driver registers acceleration data with the acceleration sensor driver, and registers magnetic data with the magnetic sensor driver; after the virtual gyroscope driver registers acceleration data with the acceleration sensor driver, the virtual gyroscope driver receives first acceleration data with a first value obtained by the acceleration sensor driver from the acceleration sensor; after the virtual gyroscope driver registers magnetic data with the magnetic sensor driver, the virtual gyroscope driver receives first magnetic data with a first value obtained by the magnetic sensor driver from the magnetic sensor; the virtual gyroscope driver generates first angular velocity data based on the first acceleration data and the first magnetic data; the virtual gyroscope driver sends the first angular velocity data to the first application through the sensor manager.

[0021] It should be noted that after receiving the first enable message, the virtual gyroscope driver will automatically trigger the virtual gyroscope driver to perform the following three operations: sending a second enable message to the acceleration sensor driver, registering acceleration data to the acceleration sensor driver, and registering magnetic data to the magnetic sensor driver.

[0022] There is no particular limitation on the type of the magnetic sensor. For example, the magnetic sensor may be a geomagnetic sensor.

[0023] Optionally, the electronic device in the above implementation also includes a sensor module located at the hardware abstraction layer, and the virtual gyroscope driver sends the first angular velocity data to the first application through the sensor manager, including: the virtual gyroscope driver sends the first angular velocity data to the sensor manager by calling the sensor module.

[0024] In another possible implementation, when the first application cancels its subscription to angular velocity data from the virtual gyroscope driver, the parameter value of the first parameter is set to a second value, including: obtaining a first deregistration subscription message, wherein the first deregistration subscription message is used to indicate that the first application cancels its subscription to angular velocity data from the virtual gyroscope driver; and based on the first deregistration subscription message, setting the parameter value of the first parameter to the second value.

[0025] In the above technical solution, the electronic device can drive the virtual gyroscope to unsubscribe from the angular velocity data based on the first application (ie, the first unsubscribe message), and set the parameter of the first parameter of the acceleration sensor to the second value.

[0026] In another possible implementation, the electronic device also includes a sensor manager located at the application framework layer; and obtaining a first deregistration subscription message, including: the sensor manager receives the first deregistration subscription message sent by the first application; based on the first deregistration subscription message, setting the parameter value of the first parameter to a second value, including: the sensor manager sends a first disabling message to the virtual gyroscope driver based on the first deregistration subscription message; in response to receiving the first disabling message, the virtual gyroscope driver sends a second disabling message to the acceleration sensor driver; the acceleration sensor driver sets the parameter value of the first parameter to the second value according to the second disabling message.

[0027] In another possible implementation, the electronic device includes a first processor, the first processor is used to run a first application, an acceleration sensor driver, a magnetic sensor driver and a virtual gyroscope driver; or, the electronic device includes a first processor and a second processor, the first processor is used to run the first application, and the second processor is used to run the acceleration sensor driver, the magnetic sensor driver and the virtual gyroscope driver; or, the electronic device includes a first processor and a second processor, the first processor is used to run the first application, and the first processor is also used to run at least one of the acceleration sensor driver, the magnetic sensor driver and the virtual gyroscope driver, and the second processor is used to run a driver other than at least one of the acceleration sensor driver, the magnetic sensor driver and the virtual gyroscope driver.

[0028] When the first processor is used to run any one of an acceleration sensor driver, a magnetic sensor driver, or a virtual gyroscope driver, the any one of the drivers may be located in a kernel layer of the electronic device.

[0029] When the first processor is not used to execute the acceleration sensor driver, the magnetic sensor driver, and the virtual gyroscope driver, the kernel layer of the electronic device does not include these three drivers.

[0030] In another possible implementation, the first processor is an application processor, and the second processor is a system control processor, a sensor hub, an audio digital signal processor, or an enhanced digital signal processor.

[0031] In another possible implementation, after setting the parameter value of the first parameter to a second value, the method further includes: controlling the acceleration sensor to store the collected acceleration data in a cache of the acceleration sensor, wherein a cache capacity threshold of the cache is the second value.

[0032] The cache capacity threshold of the cache may be the maximum cache capacity of the cache, or the cache capacity threshold of the cache may be a predefined threshold that is smaller than the maximum cache capacity of the cache.

[0033] In the above technical solution, after the first application cancels the subscription to the angular velocity data of the virtual gyroscope driver and sets the value of the first parameter to the second value, the acceleration sensor caches the collected acceleration data whose amount is less than the second value, which can reduce the energy consumption of data transmission.

[0034] In another possible implementation, the first value is 1, and the second value is an integer in [2, 10].

[0035] In a second aspect, a data processing method is provided, which is applied to an electronic device including an acceleration sensor and an acceleration sensor driver, the method comprising: when a first application in the electronic device subscribes to acceleration data from the acceleration sensor, setting the parameter value of a first parameter of the acceleration sensor to a first value, wherein the parameter value of the first parameter represents the amount of acceleration data sent by the acceleration sensor to the acceleration sensor driver each time, and the first value is the amount of acceleration data collected by the acceleration sensor each time; or, when the first application cancels its subscription to acceleration data from the acceleration sensor, setting the parameter value of the first parameter to a second value, wherein the second value is greater than the first value.

[0036] In the above technical solution, when the first application subscribes to the acceleration data from the acceleration sensor, the electronic device sets the data volume of the acceleration data (i.e., the parameter value of the first parameter) sent by the acceleration sensor to the acceleration sensor driver each time to be equal to the data volume of the acceleration data collected by the acceleration sensor each time (i.e., the first value), that is, the acceleration sensor can report the collected acceleration data to the first application through the acceleration sensor driver in real time, which can improve the timeliness of acceleration data transmission to improve user experience. When the first application in the electronic device cancels the subscription to the acceleration data from the acceleration sensor, the electronic device sets the data volume of the acceleration data (i.e., the parameter value of the first parameter) sent by the acceleration sensor to the acceleration sensor driver each time to be greater than the data volume of the acceleration data collected by the acceleration sensor each time (i.e., the first value), and the acceleration sensor caches the collected acceleration data whose data volume is less than the second value, until the data volume of the acceleration data cached by the acceleration sensor is the second value, the acceleration sensor will transmit the acceleration data whose data volume is the second value to the first application through the acceleration sensor driver, which can reduce the energy consumption of data transmission. In summary, the data processing method provided in this application can improve data processing performance to enhance user experience.

[0037] In one possible implementation, when a first application in an electronic device subscribes to acceleration data from an acceleration sensor, a parameter value of a first parameter of the acceleration sensor is set to a first value, including: when the first application subscribes to acceleration data from the acceleration sensor and it is determined that the parameter value of the first parameter is not the first value, setting the parameter value of the first parameter to the first value.

[0038] For example, the first application in the above implementation is the application in the electronic device that subscribes to acceleration data from the acceleration sensor for the first time, that is, before the first application subscribes to acceleration data from the acceleration sensor, no other application in the electronic device subscribes to acceleration data from the acceleration sensor.

[0039] For example, the first application in the above implementation is not an application in the electronic device that subscribes to acceleration data from the acceleration sensor for the first time. In this implementation, before the first application subscribes to acceleration data from the acceleration sensor, other applications in the electronic device first subscribe to acceleration data from the acceleration sensor and then unsubscribe from the acceleration data, so that the parameter value of the first parameter is not the first value.

[0040] In the above technical solution, the electronic device will set the parameter value of the first parameter to the first value only when the first application subscribes to the acceleration data from the acceleration sensor and determines that the first parameter is not the first value. In other words, the electronic device will not perform the operation of setting the parameter value of the first parameter to the first value only when the first application subscribes to the acceleration data from the acceleration sensor and determines that the first parameter is not the first value, thereby avoiding repeated execution of the operation of setting the value of the first parameter to the first value, which is beneficial to improving data processing performance and reducing energy consumption of the electronic device.

[0041] In another possible implementation, after setting the parameter value of the first parameter of the acceleration sensor to the first value, the method further includes: controlling the acceleration sensor to report the collected acceleration data whose data volume is the first value to the acceleration sensor driver.

[0042] In the above technical solution, after the first application subscribes to the acceleration data from the acceleration sensor, the electronic device first sets the value of the first parameter to the first value. Afterwards, the electronic device controls the acceleration sensor to report the collected acceleration data with the first value to the acceleration sensor driver, which can improve the timeliness of the acceleration data transmission and improve the user experience.

[0043] In another possible implementation, when a first application in an electronic device subscribes to acceleration data from an acceleration sensor, a parameter value of a first parameter of the acceleration sensor is set to a first value, including obtaining a second registration subscription message, wherein the second registration subscription message is used to indicate that the first application subscribes to acceleration data from the acceleration sensor; based on the second registration subscription message, the parameter value of the first parameter is set to the first value.

[0044] In the above technical solution, the electronic device can subscribe to a subscription message (ie, a second registration subscription message) of acceleration data to the acceleration sensor based on the first application, and set a parameter of the first parameter of the acceleration sensor to a first value.

[0045] In another possible implementation, when the first application cancels its subscription to acceleration data from the acceleration sensor, the parameter value of the first parameter is set to a second value, including: obtaining a second deregistration subscription message, wherein the second deregistration subscription message is used to indicate that the first application cancels its subscription to acceleration data from the acceleration sensor; and based on the second deregistration subscription message, setting the parameter value of the first parameter to the second value.

[0046] In the above technical solution, the electronic device can set the parameter of the first parameter of the acceleration sensor to the second value based on the unsubscribe message (ie, the second unsubscribe message) of the first application to unsubscribe the acceleration data to the acceleration sensor.

[0047] In another possible implementation, the first value is 1, and the second value is an integer in [2, 10].

[0048] In a third aspect, a data processing device is provided, comprising a processing unit for executing any one of the data processing methods in the first aspect or the second aspect.

[0049] In a fourth aspect, an electronic device is provided, comprising a unit for executing any one of the methods in the first aspect or the second aspect. The electronic device may be a terminal device or a chip in the terminal device. The electronic device may include an input unit and a processing unit.

[0050] When the electronic device is a terminal device, the processing unit may be a processor, and the input unit may be a communication interface; the terminal device may also include a memory, which is used to store computer program code. When the processor executes the computer program code stored in the memory, the terminal device executes any one of the methods in the first aspect or the second aspect.

[0051] When the electronic device is a chip in a terminal device, the processing unit may be a processing unit inside the chip, and the input unit may be an output interface, a pin or a circuit, etc.; the chip may also include a memory, which may be a memory inside the chip (for example, a register, a cache, etc.) or a memory located outside the chip (for example, a read-only memory, a random access memory, etc.); the memory is used to store computer program code, and when the processor executes the computer program code stored in the memory, the chip executes any one of the methods in the first aspect or the second aspect.

[0052] In one possible implementation, a memory is used to store computer program code; a processor executes the computer program code stored in the memory, and when the computer program code stored in the memory is executed, the processor is used to execute any one of the methods in the first aspect or the second aspect.

[0053] In a fifth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program code. When the computer program code is executed by an electronic device, the electronic device executes any one of the data processing methods in the first aspect or the second aspect.

[0054] In a sixth aspect, a computer program product is provided, the computer program product comprising: a computer program code, when the computer program code is executed by an electronic device, the electronic device executes any one of the data processing methods in the first aspect or the second aspect.

[0055] It can be understood that the beneficial effects of the third to sixth aspects mentioned above can be found in the relevant descriptions in the first or second aspect mentioned above, and will not be repeated here.

[0056] It should be understood that the description of technical features, technical solutions, beneficial effects or similar language in this application does not imply that all features and advantages can be realized in any single embodiment. On the contrary, it is understood that the description of features or beneficial effects means that specific technical features, technical solutions or beneficial effects are included in at least one embodiment. Therefore, the description of technical features, technical solutions or beneficial effects in this specification does not necessarily refer to the same embodiment. Furthermore, the technical features, technical solutions and beneficial effects described in the present embodiment can also be combined in any appropriate manner. Those skilled in the art will understand that the embodiment can be realized without one or more specific technical features, technical solutions or beneficial effects of a specific embodiment. In other embodiments, additional technical features and beneficial effects can also be identified in specific embodiments that do not embody all embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] Figure 1 It is a schematic diagram of the hardware architecture of an electronic device 100 provided in an embodiment of the present application.

[0058] Figure 2 It is a schematic diagram of the software system of the electronic device 100 provided in an embodiment of the present application.

[0059] Figure 3 It is a schematic diagram of the operation of a processor in an electronic device 100 provided in an embodiment of the present application.

[0060] Figure 4 It is a schematic diagram of the operation of a processor in an electronic device 100 provided in an embodiment of the present application.

[0061] Figure 5 It is a schematic diagram of the operation of a processor in an electronic device 100 provided in an embodiment of the present application.

[0062] Figure 6 It is a schematic diagram of a data processing method provided in an embodiment of the present application.

[0063] Figure 7 It is a schematic diagram of a data processing method provided in an embodiment of the present application.

[0064] Figure 8 It is a schematic diagram of a data processing device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0065] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0066] The terms "first", "second", etc. in the specification, claims and drawings of this application are used to distinguish different objects, and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the definition of "first" or "second" features may explicitly or implicitly include one or more of the features.

[0067] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.

[0068] Gyroscope is one of the important sensors of electronic devices (such as mobile phones or tablets). The real-time angular velocity of electronic devices can be obtained through gyroscopes, so that various functions that rely on the movement changes of mobile terminals, such as virtual reality (VR) videos, games (such as shooting games and racing games), and navigation and positioning in electronic devices, can be realized. In some application scenarios, due to hardware limitations or other reasons, electronic devices may not be able to use physical gyroscopes. At this time, virtual gyroscopes can be used to simulate gyroscope data. Virtual gyroscopes are a virtual sensor that is fused by ACC data and MAG data through attitude estimation algorithms. Since the virtual gyroscopes implemented by algorithms do not require additional hardware costs, virtual gyroscopes are widely used in various application scenarios such as games, navigation, flight simulation, and virtual reality of electronic devices. For example, virtual gyroscopes can be used in parkour, action games and other scenarios in mobile games, allowing players to control the direction and movement of game characters through the attitude of the mobile phone. In navigation applications, virtual gyroscopes can achieve smooth compass rotation effects, and can realize functions such as real-time marking, path tracking, location tracking, and map navigation. In flight simulation scenarios, the virtual gyroscope can simulate real flight postures, allowing users to experience the joy of flying more realistically. In virtual reality scenarios, the virtual gyroscope can detect and dynamically present the device’s posture, allowing users to more realistically integrate into the virtual reality world.

[0069] At present, the data (i.e., angular velocity data) of the virtual gyroscope in the electronic device is obtained by the virtual gyroscope driver in the electronic device through the fusion of the ACC data and the MAG data through the attitude estimation algorithm. The geomagnetic sensor of the electronic device can transmit the collected MAG data to the virtual gyroscope in real time, that is, after the geomagnetic sensor collects a certain amount of MAG data, it directly transmits the collected MAG data of the certain amount of data to the virtual gyroscope driver through the geomagnetic sensor driver. In order to reduce the power consumption of the electronic device, the acceleration sensor of the electronic device is provided with a first in first out (FIFO) data buffer, that is, after the acceleration sensor collects the ACC data, it will first cache it in the FIFO buffer in the acceleration sensor. When the FIFO buffer is full or the data cached in the FIFO buffer reaches the threshold set by the software, the acceleration sensor will transmit all the ACC data cached in the FIFO buffer to the virtual gyroscope driver for processing, so as to achieve the purpose of reducing power consumption. Since the FIFO buffer is set in the acceleration sensor, the timeliness of the acceleration sensor transmitting the collected ACC data to the virtual gyroscope driver is low, which reduces the timeliness of the virtual gyroscope data. In summary, the traditional technology has the problem of poor data processing capability, resulting in poor user experience.

[0070] Therefore, in order to solve the above problems. The present application provides a data processing method, an electronic device, a storage medium and a chip. The data processing method provided by the present application is applied to an electronic device including an acceleration sensor, an acceleration sensor driver and a virtual gyroscope driver, wherein the acceleration sensor driver is used to report the acceleration data reported by the acceleration sensor to the virtual gyroscope driver, and the virtual gyroscope driver is used to generate angular velocity data based on the acceleration data, including: on the one hand, when the first application of the electronic device subscribes to the angular velocity data of the virtual gyroscope driver of the electronic device, the electronic device sets the acceleration sensor to send the acceleration data to the acceleration sensor driver each time (i.e., the parameter value of the first parameter) to be the same as the acceleration data collected by the acceleration sensor each time (i.e., the first value), that is, the acceleration sensor can report the collected acceleration data with the first value in real time to the acceleration sensor driver, which can improve the timeliness of the acceleration data transmission. Afterwards, when the acceleration sensor driver transmits the acceleration data reported from the acceleration sensor to the virtual gyroscope in real time, the virtual gyroscope can obtain angular velocity data based on the acceleration data, thereby improving the timeliness of the angular velocity data of the virtual gyroscope to improve the user experience. On the other hand, when the first application cancels the subscription of the angular velocity data to the virtual gyroscope, the electronic device sets the amount of acceleration data (i.e., the parameter value of the first parameter) sent by the acceleration sensor to the acceleration sensor driver each time to be greater than the amount of acceleration data (i.e., the first value) collected by the acceleration sensor each time, that is, the acceleration sensor will first cache the acceleration data with a data amount less than the second value, until the data amount of the acceleration data cached by the acceleration sensor is the second value, the acceleration sensor will report the acceleration data with a data amount of the second value to the acceleration sensor driver, which can reduce the energy consumption of data transmission. In summary, the data processing method provided by the present application can improve the data processing performance (the timeliness of data transmission or reduce the energy consumption of data transmission) to improve the user experience.

[0071] The data processing method provided in the embodiments of the present application can be applied to electronic devices. For example, the electronic device can be, but is not limited to, at least one of a smart phone, a tablet computer, a wearable device (e.g., a smart watch), a game console, an augmented reality (AR) / VR device, and an in-vehicle device.

[0072] Below, in conjunction with the accompanying drawings, the hardware structure, software structure of an electronic device applicable to the data processing method provided in an embodiment of the present application, and the operation of a processor in the electronic device are described in detail.

[0073] For example, Figure 11 is a schematic diagram of a hardware architecture of an electronic device 100 provided in an embodiment of the present application. The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a power management module 140, a communication management module 150, a display screen 160, a sensor module 170, and the like.

[0074] It is to be understood that the structure shown in the embodiment of the present application does not constitute a specific limitation on the hardware structure of the electronic device 100. In other embodiments, the electronic device 100 may include Figure 1 More or fewer components may be shown, or some components may be combined or separated, or the components may be arranged differently. Figure 1 The components shown may be implemented in hardware, software, or a combination of software and hardware.

[0075] The processor 110 can implement the functions of a processor in various possible implementations of the electronic device 100 .

[0076] In the embodiment of the present application, the processor 110 may include a first processor 111 ( Figure 1 Optionally, the processor 110 may further include a second processor 112 ( Figure 1 In some implementations, the processor 110 includes a first processor 111 and a second processor 112. The first processor 111 may be an application processor (AP), which is responsible for running applications in the electronic device 100. The second processor 112 may be a coprocessor or a low-power processor. For example, the second processor 112 may specifically be a system control processor (SCP), a sensor hub, an audio digital signal processor, or an advanced digital signal processor. In other implementations, the processor 110 includes a first processor 111, which has the capabilities of the first processor 111 and the capabilities of the second processor 112. The first processor 111 may be an AP.

[0077] Optionally, the processor 110 may also include other processing units, which may be but are not limited to at least one of the following processing units: a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and a neural-network processing unit (NPU). Among them, the controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction opcode and the timing signal to complete the control of fetching and executing instructions. It is understandable that the processing unit in the processor 110 may be an independent device or an integrated device.

[0078] In some implementations, the electronic device 100 where the processor 110 is located includes an accelerometer, an accelerometer driver, and a virtual gyroscope driver. The accelerometer driver is used to report the acceleration data reported by the accelerometer to the virtual gyroscope driver. The virtual gyroscope driver is used to generate angular velocity data based on the acceleration data reported by the accelerometer driver. The processor 110 is used to perform the following steps: when a first application in the electronic device subscribes to the angular velocity data to the virtual gyroscope driver, the parameter value of the first parameter of the accelerometer is set to a first value, wherein the parameter value of the first parameter represents the amount of acceleration data sent by the accelerometer to the accelerometer driver each time, and the first value is the amount of acceleration data collected by the accelerometer each time; or, when the first application cancels its subscription to the virtual gyroscope driver for angular velocity data, the parameter value of the first parameter is set to a second value, wherein the second value is greater than the first value.

[0079] The processor 110 may also be provided with a memory ( Figure 1 In some embodiments, the memory in the processor 110 is a cache memory. The memory can store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it can be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0080] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an I2C interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a GPIO interface, a subscriber identity module (SIM) interface, and / or a USB interface, etc.

[0081] In some embodiments, the processor 110 may be a system on chip (SOC), the first processor 111 and the second processor 112 are processors integrated on the SOC, and the first processor 111 and the second processor 112 work together to process sensor data.

[0082] The sensor module 170 includes a plurality of sensor hardware, which may include Figure 1 The acceleration sensor 171A and the geomagnetic sensor 171B are shown. The acceleration sensor 171A can detect the magnitude of the acceleration of the electronic device 100 in various directions (generally the x-axis, y-axis and z-axis). When the electronic device 100 is stationary, the magnitude and direction of gravity can be detected. The acceleration sensor 171A can also be used to identify the posture of the electronic device 100 as an input parameter for applications such as horizontal and vertical screen switching and pedometers. The geomagnetic sensor 171B is used to sense changes in the earth's magnetic field and output corresponding geomagnetic data, as well as to determine the orientation of the electronic device 100. Optionally, the sensor module 170 may also include other sensor hardware, which may be but is not limited to at least one of the following sensors: a gyroscope sensor, a temperature sensor, a humidity sensor, a pressure sensor, a barometric pressure sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor, etc.

[0083] The power management module 140 is used to supply power to the electronic device 100. The power management module 140 is connected to the processor 110. The power management module 140 receives input of an external power source and supplies power to the processor 110, the internal memory 121, the external memory, the display screen 160, the communication management module 150, and the like.

[0084] The communication management module 150 can provide a communication solution applied to the electronic device 100. Optionally, the communication management module 150 can be a wireless communication module, providing a wireless communication solution applied to the electronic device 100 including WLAN (such as WIFI), Bluetooth, global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared technology (IR), etc.

[0085] The communication management module 150 may be one or more devices integrating at least one communication processing module. The communication management module 150 receives electromagnetic waves via an antenna, modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110. The communication management module 150 may also receive a signal to be sent from the processor 110, modulate the frequency of the signal, amplify the signal, and convert it into electromagnetic waves for radiation via the antenna.

[0086] The electronic device 100 implements the display function through a GPU, a display screen 160, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 160 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.

[0087] The display screen 160 is used to display a map application interface, a VR video application interface, a game application interface, etc. The display screen 160 includes a display panel. In some embodiments, the electronic device 100 may include 1 or L display screens, where L is an integer greater than 1.

[0088] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function, such as storing music, video and other files in the external memory card.

[0089] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. For example, in an embodiment of the present application, the processor 110 can execute instructions stored in the internal memory 121, and the internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.

[0090] It should be understood that Figure 1 The connection relationship between the modules shown is only a schematic illustration and does not constitute a limitation on the connection relationship between the modules of the electronic device 100. Optionally, the modules of the electronic device 100 may also adopt a combination of multiple connection modes in the above embodiments.

[0091] The following describes the software system of the electronic device 100. The software system may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture or a cloud architecture. The embodiment of the present application takes the layered architecture as an example to exemplarily describe the software system of the electronic device 100.

[0092] For example, Figure 2 1 is a schematic diagram of a software system of an electronic device 100 provided in an embodiment of the present application. Figure 2 , the software system adopts a layered architecture. The layered architecture divides the software into several layers, each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided from top to bottom into an application layer 210, an application framework layer 220, an Android runtime (Android Runtime) and a core library layer 230, a hardware abstract layer (HAL) 240 and a kernel layer 250.

[0093] The application layer 210 may include a series of application packages. For example, the application package may include applications such as navigation, VR video, map, calendar, gallery, call, camera, Bluetooth, etc. Each application in the application layer 210 may generate application data, such as VR video for generating panoramic video data.

[0094] The application framework layer 220 provides an application programming interface (API) and a programming framework for the applications in the application layer 210. The application framework layer 220 includes some predefined functions.

[0095] The application framework layer 220 may include a sensor manager, an activity manager, an input manager, a resource manager, a notification manager, a view system, a content provider, and the like.

[0096] The sensor manager is a core component of the sensor framework of the Android system. The sensor manager is the entry point for applications (such as navigation applications, VR video applications, or map applications, etc.) to access sensor data. The sensor manager is responsible for managing all sensors on the electronic device 100 and providing an API for applications to access sensor data. In some implementations, the sensor manager can be understood as an independent thread.

[0097] Android Runtime includes core libraries and virtual machines. Android Runtime is responsible for scheduling and management of the Android system.

[0098] The core library consists of two parts: one part is the function that needs to be called by the programming language (such as Java), and the other part is the Android core library.

[0099] The application layer 210 and the application framework layer 220 run in a virtual machine. The virtual machine executes the programming files (such as java files) of the application layer 210 and the application framework layer 220 as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.

[0100] The core library layer 230 may include multiple functional modules, which may be, but are not limited to, a surface manager, a media framework, libc, and SQLite. The surface manager is used to manage the display subsystem and provides the fusion of two-dimensional (2D) and three-dimensional (3D) layers for multiple applications. The media framework supports playback and recording of a variety of commonly used audio and video formats, as well as static image files. Libc is a standard library of the C language. Libc is a bottom-level library in the system and is implemented through Linux system calls. For example, libc can be used to connect or disconnect camera services, set camera shooting parameters, start and stop preview, take pictures, etc.

[0101] The hardware abstraction layer (HAL) 240 is an interface layer between the operating system kernel and the upper layer software. The hardware abstraction layer 240 is used to abstract the hardware of the electronic device 100 and provide a consistent interface for the upper layer software of the electronic device 100. Figure 2 As shown, the hardware abstraction layer 240 includes a sensor module, which is also called a hardware abstraction layer module (i.e., sensorHAL) of the sensor. In some implementations, when the kernel layer 250 does not include the virtual gyroscope driver shown by the dotted line, and the angular velocity data generated by the virtual gyroscope driver is stored in the shared memory, the sensor module obtains the angular velocity data stored in the shared memory by calling the shared memory interface, and provides the angular velocity data to the upper interface, so that the application can obtain the angular velocity data. In other implementations, when the kernel layer 250 includes the virtual gyroscope driver shown by the dotted line, the sensor module obtains the angular velocity data transmitted by the virtual gyroscope driver by calling the virtual gyroscope driver interface, and provides the angular velocity data to the upper interface, so that the application can obtain the angular velocity data. Optionally, the hardware abstraction layer 240 may also include other modules, each of which implements an interface for a specific type of hardware component. For example, the other modules may be, but are not limited to, display modules, and the display module may provide an interface for accessing display hardware components.

[0102] The kernel layer 250 is the foundation of the Android operating system, and the final functions of the Android operating system are completed through the kernel layer. In some implementations, the kernel layer 250 may include various communication interfaces ( Figure 2 not shown) and Figure 2 The shared memory shown is used to cache data. In other implementations, the kernel layer 250 may also include Figure 2 At least one of the following sensor drivers shown by the dotted lines: virtual gyroscope driver, acceleration sensor driver, magnetic sensor driver. The magnetic sensor driver can be understood as a driver program of the magnetic sensor, and the magnetic sensor is not specifically limited. For example, the magnetic sensor can be, but is not limited to, a geomagnetic sensor. In this case, the magnetic sensor driver can be referred to as a geomagnetic sensor driver. Optionally, the kernel layer 250 can also include other drivers, such as, but not limited to, display drivers, camera drivers, and audio drivers.

[0103] It should be noted that the application provides Figure 2The software structure diagram of the electronic device 100 shown is only an example and does not limit the specific module division in different layers of the Android operating system. For details, please refer to the introduction of the Android operating system software structure in conventional technology. In addition, the data processing method provided in this application can also be implemented based on other operating systems (for example, IOS or Hongmeng, etc.), and this application will not cite examples one by one.

[0104] Combined with the above Figure 1 and Figure 2 The hardware structure and software structure of the electronic device to which the data processing method provided by this application is applicable are introduced. Figure 2 The software structure of the electronic device 100 shown can be run on the above Figure 1 The hardware structure of the electronic device 100 shown in FIG. Figure 1 The hardware structure of the electronic device 100 shown and the above Figure 2 The software structure of the electronic device 100 is shown, and the operation of the processor in the electronic device 100 is introduced (ie, Case 1 to Case 3 below).

[0105] Case 1: Figure 1 The processor 110 of the electronic device 100 shown includes a first processor 111 and a second processor 112 , wherein the first processor 111 is used to run applications, and the second processor 112 is used to run virtual gyroscope driving, acceleration sensor driving, and magnetic sensor driving.

[0106] In case one, the first processor 111 and the second processor 112 are two different processors.

[0107] For example, Figure 3 is a schematic diagram of the operation of a processor in an electronic device 100 provided in an embodiment of the present application. It should be noted that: Figure 3 Only the above Figure 1 Part of the hardware structure in Figure 1 The first processor 111 and the second processor 112 in. Figure 3 The kernel layer shown in the above Figure 2 The kernel layer 250 shown includes shared memory. It is understood that Figure 3 The first processor 111 and the second processor 112 shown can transmit data via a bus. Any two drivers in the second processor 112 are electrically connected, that is, the virtual gyroscope driver is electrically connected to the magnetic sensor driver, the virtual gyroscope driver is electrically connected to the acceleration sensor driver, and the acceleration sensor driver is electrically connected to the magnetic sensor driver.

[0108] The first processor 111 runs an application layer 210, an application framework layer 220, a hardware abstraction layer 240, and a kernel layer 250. The application layer 210 includes applications that need to subscribe to data of the virtual gyroscope, such as Figure 3 The navigation application, VR video application and map application shown. The application framework layer 220 includes a sensor manager. The hardware abstraction layer 240 includes a sensor module (i.e., sensorhal). The kernel layer 250 includes shared memory and various communication interfaces ( Figure 3 not shown in the figure).

[0109] A plurality of sensor drivers are running in the second processor 112 , and the plurality of sensor drivers include a virtual gyroscope driver, a magnetic sensor driver, and an acceleration sensor driver.

[0110] The hardware includes multiple sensor hardware, namely magnetic sensors and acceleration sensors.

[0111] For the interaction between the various software layers running in the first processor 111, the interaction between the various drivers running in the second processor 112, and the interaction between the first processor 111 and the second processor 112, please refer to Figure 3 The arrows shown will be combined with Figure 6 Middle Pair Figure 3 The interaction steps of each module shown are introduced in detail and will not be repeated here.

[0112] It should be understood that the above Figure 3 The architecture of the electronic device shown is for illustration only and does not constitute any limitation on the architecture of the electronic device to which the embodiments of the present application are applicable. For example, the application layer running in the first processor 111 may also include other applications, such as game applications, etc. For example, the second processor 112 may also run other drivers, such as gyroscope drivers, etc., but not limited to gyroscope drivers, etc.

[0113] Case 2: Figure 1 The processor 110 of the electronic device 100 shown includes a first processor 111 , wherein the first processor 111 is used to run applications, virtual gyroscope driving, acceleration sensor driving, and magnetic sensor driving.

[0114] For example, Figure 4 FIG. 1 is a schematic diagram of the operation of a processor in an electronic device 100 provided in an embodiment of the present application. Figure 4As shown, the application layer 210 run by the first processor 111 of the electronic device 100 includes multiple applications (i.e., navigation, VR video, and map), that is, the first processor 111 is used to run the multiple applications. The kernel layer 250 run by the first processor 111 of the electronic device 100 includes three drivers, namely, a virtual gyroscope driver, an acceleration sensor driver, and a magnetic sensor driver, that is, the first processor 111 is used to run these three drivers. Figure 4 The first processor 111 and the second processor 112 in the electronic device 100 shown can transmit data via a bus.

[0115] Understandably, Figure 4 Only the above Figure 1 Part of the hardware structure in Figure 1 The first processor 111 in the electronic device 100 is shown. It should also be understood that Figure 4 The kernel layer 250 running in the first processor 111 shown is the same as the above Figure 3 The kernel layer 250 of the first processor 111 shown is different, but Figure 4 The application layer 210, application framework layer 220, hardware abstraction layer 240 and hardware running in the first processor 111 are respectively similar to the above Figure 3 The application layer 210, application framework layer 220, hardware abstraction layer 240 running in the first processor 111 are the same as the hardware and are not described in detail here.

[0116] Case 3: Figure 1 The processor 110 of the electronic device 100 shown includes a first processor 111 and a second processor 112, wherein the first processor 111 is used to run applications and at least one of a virtual gyroscope drive, an acceleration sensor drive, and a magnetic sensor drive; and the second processor 112 is used to run drives among the virtual gyroscope drive, the acceleration sensor drive, and the magnetic sensor drive except the drive run by the first processor 111.

[0117] In case three, the first processor 111 and the second processor 112 are two different processors.

[0118] In an implementation of the third scenario, the first processor 111 is used to run applications and virtual gyroscope driving, and the second processor 112 is used to run acceleration sensor driving and magnetic sensor driving.

[0119] For example, Figure 5 FIG. 1 is a schematic diagram of the operation of a processor in an electronic device 100 provided in an embodiment of the present application. Figure 5As shown, the application layer 210 run by the first processor 111 in the electronic device 100 includes multiple applications (ie, navigation, VR video, and map), that is, the first processor 111 is used to run the multiple applications. Figure 5 The kernel layer 250 running on the first processor 111 of the electronic device 100 shown includes a virtual gyroscope driver, that is, the first processor 111 is also used to run the virtual gyroscope driver, and the virtual gyroscope driver is used to obtain acceleration data from the acceleration sensor driver in the second processor 112, and to obtain magnetic data from the magnetic sensor driver. The second processor 112 of the electronic device 100 runs an acceleration sensor driver and a magnetic sensor driver, the acceleration sensor driver is used to obtain acceleration data reported by the acceleration sensor from the acceleration sensor, and the magnetic sensor driver is used to obtain magnetic data reported by the magnetic sensor from the magnetic sensor.

[0120] Understandably, Figure 5 Only the above Figure 1 The partial hardware structure of the electronic device 100 shown is Figure 1 The first processor 111 and the second processor 112 in FIG. It should also be understood that Figure 5 The kernel layer 250 running in the first processor 111 shown is the same as the above Figure 3 The kernel layer 250 running on the first processor 111 is shown to be different. Figure 5 The application layer 210, application framework layer 220, hardware abstraction layer 240 and hardware running in the first processor 111 are respectively similar to the above Figure 3 The application layer 210, application framework layer 220, hardware abstraction layer 240 running in the first processor 111 are the same as the hardware and are not described in detail here.

[0121] In another implementation of situation three, the first processor 111 is used to run applications, virtual gyroscope drive and magnetic sensor drive, and the second processor 112 is used to run the acceleration sensor drive; or, the first processor 111 is used to run applications, virtual gyroscope drive and acceleration sensor drive, and the second processor 112 is used to run the magnetic sensor drive; or, the first processor 111 is used to run applications and acceleration sensor drive, and the second processor 112 is used to run virtual gyroscope drive and magnetic sensor drive; or, the first processor 111 is used to run applications and magnetic sensor drive, and the second processor 112 is used to run virtual gyroscope drive and acceleration sensor drive; or, the first processor 111 is used to run applications, acceleration sensor and magnetic sensor drive, and the second processor 112 is used to run virtual gyroscope drive.

[0122] It should be understood that the above Figure 3 , Figure 4and Figure 5 The operation of the processor in the electronic device 100 shown is for illustration only and does not constitute any limitation to the present application.

[0123] Next, combine Figure 6 and Figure 7 The data processing method provided in the embodiment of the present application is introduced in detail.

[0124] Figure 6 is a schematic diagram of a data processing method provided in an embodiment of the present application. It can be understood that, Figure 6 In the example, an electronic device A includes a map application, a VR video application, a sensor manager, a virtual gyroscope, an acceleration sensor driver, and a magnetic sensor driver, and the interaction steps between the multiple modules involved in the data processing method provided in the embodiment of the present application are introduced. Figure 6 The operation of the multiple modules shown in the processor of the electronic device A is not specifically limited. In some implementations, Figure 6 The multiple modules shown are modules executed by the same processor in the electronic device A. In this case, the same processor in the electronic device A may be the above-mentioned Figure 4 The first processor 111 in the electronic device 100 is shown. In some implementations, Figure 6 The modules shown are modules executed by multiple processors in the electronic device A. In this case, the multiple processors in the electronic device A may include the above-mentioned Figure 3 or Figure 5 The first processor 111 and the second processor 112 in the electronic device 100 are shown. It can be understood that the following Figure 6 The interaction process of multiple modules in the electronic device A not described in detail can be found in the above Figure 3 , Figure 4 or Figure 5 Related description in .

[0125] like Figure 6 As shown, the data processing method includes steps S601 to S617. Steps S601 to S617 are described in detail below.

[0126] Before electronic device A executes the data processing method provided in the embodiment of the present application, the watermark value of the FIFO buffer of the acceleration sensor of electronic device A is F / n, " / " represents a division sign, F represents the sampling rate of the acceleration sensor, n represents the settable property of the FIFO buffer of the acceleration sensor, and the value of n is usually associated with the sampling rate of the acceleration sensor. The value of n can be defined by each manufacturer of electronic device A, and there is no specific limitation on the value of n. It can be understood that when the watermark value of the FIFO buffer of the acceleration sensor is F / n, the acceleration sensor will report the ACC data with a data amount of F / n cached in the FIFO buffer to the acceleration sensor driver, and the watermark of the FIFO buffer can be less than or equal to the maximum cache capacity of the FIFO buffer. F / n is any integer in the range of [2,10], for example, F / n can be 2, 3, 4, 8 or 10, etc. It should be noted that the value of the water level of the FIFO buffer of the acceleration sensor of the electronic device represents the amount of ACC data transmitted by the acceleration sensor to the acceleration sensor driver at one time. That is to say, before executing the data processing method provided in the embodiment of the present application, the amount of ACC data transmitted by the acceleration sensor of the electronic device A to the acceleration sensor driver at one time is F / n (unit: frame).

[0127] In step S601, the VR video in electronic device A sends a registration message #1 to the sensor manager in electronic device A.

[0128] After VR video executes step S601, the sensor manager receives the registration message #1 sent by VR video. It can be understood that VR video is an application of the application layer of electronic device A, and the sensor manager is a module in the application framework layer of electronic device A.

[0129] Registration message #1 is used to indicate that the VR video requests to subscribe to the angular velocity data of the virtual gyroscope, and the content included in registration message #1 is not specifically limited. In some implementations, registration message #1 may include an identifier of a virtual gyroscope driver, and the identifier of the virtual gyroscope driver is used to indicate the virtual gyroscope driver. In some implementations, the virtual gyroscope driver is a driver program, and therefore, the identifier of the virtual gyroscope driver may be, but is not limited to, the identifier of the driver program.

[0130] Exemplarily, the registration message #1 may be expressed as register (virtual_gyro), where virtual_gyro indicates a virtual gyroscope driver.

[0131] The angular velocity data of the virtual gyroscope may refer to angular velocity data calculated based on the ACC data and the MAG data, and the angular velocity data refers to angle data including a heading angle, a pitch angle, and a roll angle.

[0132] It should be noted that, in the embodiment of the present application, before the VR video executes the above step S601, that is, before the VR video requests to subscribe to the data of the virtual gyroscope, no other application subscribes to the data of the virtual gyroscope. In other words, before the VR video executes the above step S601, the sensor manager does not receive a registration message sent by other applications for requesting to subscribe to the data of the virtual gyroscope. In other words, the VR video executes the above step S601, that is, the application in the electronic device A subscribes to the angular velocity data of the virtual gyroscope for the first time.

[0133] In step S602 , the sensor manager in electronic device A sends an enable message # 0 to the virtual gyroscope driver in electronic device A.

[0134] After the sensor manager executes the above step S602, the virtual gyroscope driver receives the enable message #0 sent by the sensor manager. After receiving the registration message #1, the sensor manager learns that the VR video needs to subscribe to the data of the virtual gyroscope. After that, the sensor manager sends the enable message #0 to the virtual gyroscope driver, and the enable message #0 is used to trigger the virtual gyroscope to automatically execute the following steps S603, S604 and S605.

[0135] In step S603 , the virtual gyroscope driver in electronic device A sends an enable message # 1 to the acceleration sensor driver in electronic device A.

[0136] After the virtual gyroscope driver executes the above step S603, the acceleration sensor driver accordingly receives the enable message #1 sent by the virtual gyroscope driver.

[0137] The enable message #1 may include the identifier of the virtual gyroscope driver, the identifier of the acceleration sensor and the control command #1, where the control command #1 is used to indicate that the value of the water level line of the FIFO buffer of the acceleration sensor is set to 1, that is, the control command #1 indicates that the amount of ACC data that needs to be controlled to be transmitted to the acceleration sensor driver at one time by the acceleration sensor is 1 frame of ACC data.

[0138] For example, enable message #1 may be a MESSAGEID_ENABLE message.

[0139] In step S604 , the virtual gyroscope driver in electronic device A sends an ACC registration message # 1 to the acceleration sensor driver in electronic device A.

[0140] The ACC registration message #1 is used to request to obtain acceleration data. For example, the ACC registration message #1 may be a sns_suid_lookup_add(acc) message.

[0141] After the virtual gyroscope driver sends the ACC registration message #1 to the acceleration sensor driver, a callback function will exist at the virtual gyroscope driver. After that, after the acceleration sensor driver obtains ACC data from the acceleration sensor, the virtual gyroscope driver can obtain the ACC data collected by the acceleration sensor from the acceleration sensor driver through the callback function.

[0142] In step S605 , the virtual gyroscope driver in electronic device A sends a MAG registration message # 1 to the magnetic sensor driver in electronic device A.

[0143] After the virtual gyroscope driver executes the above step S605, the magnetic sensor driver accordingly receives the MAG registration message #1 sent by the virtual gyroscope driver.

[0144] Exemplarily, the magnetic sensor may be a magnetic sensor, and the magnetic sensor driver may be a magnetic sensor driver.

[0145] The MAG registration message #1 is used to request to obtain MAG data. For example, the MAG registration message #1 may be a sns_suid_lookup_add(mag) message.

[0146] In the embodiment of the present application, the order in which electronic device A executes the above steps S604 and S605 is not specifically limited. For example, electronic device A may first execute step S604 and then execute step S605. For another example, electronic device A may first execute step S605 and then execute step S604.

[0147] The above steps S603 to S605 introduce the process of triggering the execution of the virtual gyroscope driver after the virtual gyroscope driver receives the enable message #0 sent by the sensor manager. Exemplarily, the pseudo code of the virtual gyroscope driver executing the above steps S603 to S605 is as follows:

[0148] If (get the application register) {

[0149] enable( ) {

[0150] Send the MESSAGEID_ENABLE message to the acceleration sensor driver;

[0151] Register ACC data to the acceleration sensor driver;

[0152] Register MAG data to the magnetic sensor driver;

[0153] }

[0154] notifyevent(){

[0155] Get ACC data from ACC and MAG data from MAG;

[0156] Call the attitude estimation algorithm to process the ACC data and MAG data to calculate the angular velocity;

[0157] }

[0158] }

[0159] In the above pseudo code, an example of register is registering message #1, an example of MESSAGEID_ENABLE is enabling message #1, and notifyevent() can be understood as a callback function.

[0160] In step S606 , the acceleration sensor driver in electronic device A sets the value of the water level of the FIFO buffer of the acceleration sensor in electronic device A to 1 according to the enable message 1 .

[0161] The acceleration sensor driver in electronic device A sets the value of the water level line of the FIFO buffer of the acceleration sensor in electronic device A to 1 according to the enable message 1. Exemplarily, the following steps may be included: the acceleration sensor driver sends a control command #1 to the acceleration sensor of electronic device A according to the enable message 1; the acceleration sensor sets the value of the water level line of the FIFO buffer of the acceleration sensor to 1 according to the control command #1.

[0162] Before electronic device A executes the above step S606, the acceleration sensor will collect ACC data with a data volume of (F / n) frames and send it to the acceleration sensor driver immediately, where F / n is any integer in [2,10]. Since the minimum unit of ACC data is one frame, that is, before electronic device A executes the above step S606, the acceleration sensor will cache the collected ACC data in the FIFO buffer first, and the acceleration sensor will not send the ACC data with a data volume of (F / n) frames to the acceleration sensor driver until the data volume of the ACC data cached in the FIFO buffer is (F / n) frames. After electronic device A executes the above step S606, the acceleration sensor will collect ACC data with a data volume of one frame and send it to the acceleration sensor driver immediately. Since the minimum unit of ACC data is one frame, after the electronic device executes the above step S606, the acceleration sensor can realize the purpose of transmitting ACC data to the acceleration sensor driver in real time, that is, the acceleration sensor will not cache the currently collected ACC data, so that the timeliness of ACC data transmission can be effectively improved, which is conducive to improving the timeliness of angular velocity data transmission generated by the virtual gyroscope driver.

[0163] Exemplarily, the pseudo code of the steps executed by the acceleration sensor driver may be as follows:

[0164] Func1(){normal data collection watermark=F / n;}

[0165] If (get MSGID_ENABLE message) {

[0166] watermark = 1;

[0167] }

[0168] If (get the registration message of virtual gyroscope driver) {

[0169] Send ACC data to the virtual gyroscope driver;

[0170] }

[0171] If (get MSGID_DISABLE message) {

[0172] watermark = F / n;

[0173] }

[0174] In the above pseudo code, an example of the MSGID_ENABLE message is the enable message 1. The watermark represents the water level of the FIFO buffer in the acceleration sensor, and an example of the MSGID_DISABLE message is the disable message 1 described below.

[0175] In step S607 , the acceleration sensor driver in electronic device A sends a frame of ACC data # 1 to the virtual gyroscope driver in electronic device A.

[0176] After the acceleration sensor driver executes the above step S607, correspondingly, the virtual gyroscope driver receives a frame of ACC data #1 sent by the acceleration sensor driver.

[0177] In the embodiment of the present application, the transmission form of the acceleration sensor driver sending a frame of ACC data #1 to the virtual gyroscope driver is not specifically limited. For example, the acceleration sensor driver can carry a frame of ACC data #1 in a data packet sent to the virtual gyroscope driver, so that the virtual gyroscope driver receives the frame of ACC data #1.

[0178] There is no specific limitation on whether the data packet carrying a frame of ACC data #1 includes other information. For example, the data packet carrying a frame of ACC data #1 may also include at least one of the following information: sensor type, sensor data accuracy, or sensor data timestamp.

[0179] In step S608 , the magnetic sensor driver in electronic device A sends a frame of ACC data # 1 to the virtual gyroscope driver in electronic device A.

[0180] After the magnetic sensor driver executes the above step S608, correspondingly, the virtual gyroscope driver receives a frame of MAG data #1 sent by the magnetic sensor driver.

[0181] In the embodiment of the present application, the sending form of the magnetic sensor driver sending a frame of MAG data #1 to the virtual gyroscope driver is not specifically limited. For example, the magnetic sensor driver can carry a frame of MAG data #1 in a data packet sent to the virtual gyroscope driver, so that the virtual gyroscope driver receives a frame of MAG data #1.

[0182] There is no specific limitation on whether a data packet carrying a frame of MAG data #1 includes other information. For example, a data packet carrying a frame of MAG data #1 may also include at least one of the following information: sensor type, sensor data accuracy, or sensor data timestamp.

[0183] In step S609, the virtual gyroscope driver in the electronic device A obtains a frame of angular velocity data #1 based on a frame of ACC data #1 and a frame of MAG data #1.

[0184] Angular velocity data #1 includes heading angle, pitch angle, and roll angle.

[0185] It can be understood that, when the VR video does not unsubscribe from the virtual gyroscope data, the virtual gyroscope driver can receive a frame of ACC data acquired in real time from the acceleration sensor by the acceleration sensor driver, and can receive a frame of MAG data acquired in real time from the magnetic sensor by the magnetic sensor driver, and calculate a frame of angular velocity data based on the frame of ACC data and the frame of MAG data acquired in real time.

[0186] The virtual gyroscope driver processes a frame of ACC data #1 and a frame of MAG data #1 based on the attitude estimation algorithm to obtain a frame of angular velocity data #1. The attitude estimation algorithm is not specifically limited, and an existing attitude estimation algorithm can be used, which will not be described in detail here.

[0187] Exemplarily, the virtual gyroscope driver processes a frame of ACC data #1 and a frame of MAG data #1 based on an attitude estimation algorithm to obtain a frame of angular velocity data #1, which may include the following steps: the virtual gyroscope driver performs data preprocessing on a frame of ACC data #1 and a frame of MAG data #1, respectively, to obtain a corrected frame of ACC data #1 and a corrected frame of MAG data #1; uses the corrected frame of ACC data #1 and the corrected frame of MAG data #1 to calculate the real-time attitude information of the carrier according to the dual-vector attitude determination principle; calculates the heading angle, roll angle and pitch angle according to the relationship between the attitude angle and the attitude matrix to obtain a frame of angular velocity data #1.

[0188] In the above implementation, the virtual gyroscope driver performs data preprocessing on a frame of ACC data #1, which may include: the virtual gyroscope driver passes a frame of ACC data #1 through a low-pass filter to remove noise, filter out high-frequency vibration information, and then passes a mean smoother to filter out the influence of harmful acceleration, so as to obtain a corrected frame of ACC data #1.

[0189] In the above implementation, the virtual gyroscope driver performs data preprocessing on a frame of MAG data #1, which may include: the virtual gyroscope driver removes noise from a frame of MAG data #1 through a low-pass filter, eliminates soft magnetic and hard magnetic interference through a correction module, and maps the magnetic data onto a standard sphere in space to obtain a corrected frame of MAG data #1.

[0190] In step S610 , the virtual gyroscope driver in electronic device A sends a frame of angular velocity data # 1 to the sensor manager in electronic device A.

[0191] The virtual gyroscope driver sends a frame of angular velocity data #1 to the sensor manager, so that the sensor manager receives the frame of angular velocity data #1. The data interaction process can be specifically referred to above. Figure 3 The relevant description in will not be repeated in detail here.

[0192] In step S611, the sensor manager in electronic device A sends a frame of angular velocity data #1 to the VR video in electronic device A.

[0193] Since the VR video requests the sensor manager to subscribe to the angular velocity data of the virtual gyroscope, after the sensor manager receives a frame of angular velocity data #1, the sensor manager can send the frame of angular velocity data #1 to the VR video.

[0194] It is understandable that when the sensor manager sends a frame of angular velocity data #1 to the VR video, the electronic device A may be in a screen-on state or a screen-off state, and this is not specifically limited in the embodiments of the present application.

[0195] It can be understood that after the sensor manager sends a frame of angular velocity data #1 to the VR video of electronic device A, if the VR video has not unsubscribed from the data of the virtual gyroscope, the sensor manager will receive the frame of angular velocity data sent by the virtual gyroscope driver in real time, and the sensor manager will send the acquired frame of angular velocity data to the VR video in real time.

[0196] It should be noted that the above steps S601 to S611 are the electronic device A performing the registration process (i.e. Figure 6 Optionally, after electronic device A executes steps S601 to S611, the map in electronic device A may also send registration message #2 to the sensor processor, and registration message #2 is used to request to subscribe to the data of the virtual gyroscope. In this implementation, electronic device A may also execute Figure 6 Steps S612 and S613 shown in registration process 2.

[0197] In step S612, the map in electronic device A sends a registration message #2 to the sensor manager in electronic device A.

[0198] After the map executes the above step S612, the sensor manager receives the registration message #2 sent by the map. It can be understood that the map is an application of the application layer of the electronic device A.

[0199] The registration message #2 is used to indicate that the map requests to subscribe to the angular velocity data of the virtual gyroscope, and the registration message #2 may include a virtual gyroscope driver identifier. Exemplarily, the registration message #2 is a register (virtual_gyro) message, and virtual_gyro indicates a virtual gyroscope driver.

[0200] In step S613, the sensor manager in electronic device A sends a frame of angular velocity data #2 to the map in electronic device A.

[0201] After electronic device A executes the above steps S601 to S612, the VR video has successfully subscribed to the data of the virtual gyroscope (i.e., angular velocity data), that is, the VR video can obtain a frame of angular velocity data (e.g., a frame of angular velocity data #1) from the virtual gyroscope driver in real time by the sensor manager. Since the VR video does not send a request to cancel the subscription to the virtual gyroscope data to the sensor manager, the sensor manager can obtain a frame of angular velocity data at the current moment from the virtual gyroscope driver in real time. Afterwards, after the sensor manager receives a request from other applications (i.e., a map) to subscribe to the data of the virtual gyroscope, the sensor manager can directly send the obtained frame of angular velocity data at the current moment to the map. In other words, in this scenario, after the map sends registration message #2 to the sensor manager, there is no need to execute related processes similar to the above steps S602 to S606.

[0202] A frame of angular velocity data #1 may be angular velocity data obtained by a frame of ACC data and a frame of MAG data obtained by the virtual gyroscope drive at moment 1 obtained by the sensor manager, and a frame of angular velocity data #2 may be angular velocity data obtained by a frame of ACC data and a frame of MAG data obtained by the virtual gyroscope drive at moment 2 obtained by the sensor manager, wherein moment 1 is a moment before moment 2, and a frame of angular velocity data #2 and a frame of angular velocity data #1 are angular velocity data sent by the sensor manager at different moments, and a frame of angular velocity data #2 is different from a frame of angular velocity data #1.

[0203] In the embodiment of the present application, when the application (such as VR video) in the electronic device A does not need to subscribe to the data of the virtual gyroscope, the electronic device A can also perform the following Figure 6 The deregistration process shown corresponds to steps S614 to S617.

[0204] In step S614, the VR video in electronic device A sends a deregistration message #1 to the sensor manager in electronic device A.

[0205] After the VR video executes the above step S601, the sensor manager receives the deregistration message #1 sent by the VR video accordingly.

[0206] The deregistration message #1 is used to request to unsubscribe from the virtual gyroscope data.

[0207] In step S615 , the sensor manager in electronic device A sends a disabling message # 0 to the virtual gyroscope driver in electronic device A.

[0208] The disabling message #0 is used to trigger the virtual gyroscope driver to automatically execute step S616 below.

[0209] The interaction process between the sensor manager and the virtual gyroscope driver may refer to the description of the interaction process between the sensor manager and the virtual gyroscope driver in the above step S602, which will not be described in detail here.

[0210] In step S616 , the virtual gyroscope driver in electronic device A sends a disabling message # 1 to the acceleration sensor driver in electronic device A.

[0211] After the virtual gyroscope driver executes the above step S616, correspondingly, the acceleration sensor driver receives the disabling message #1 sent by the virtual gyroscope driver.

[0212] The disabling message #1 may include the identifier of the virtual gyroscope drive, the identifier of the acceleration sensor and the control command #2, where the control command #2 is used to instruct to set the value of the water level of the FIFO buffer of the acceleration sensor to F / n.

[0213] For example, the disenable message #1 may be a MESSAGEID_DISENABLE message.

[0214] In step S617 , the acceleration sensor driver in electronic device A sets the value of the water level of the FIFO buffer of the acceleration sensor of electronic device A to F / n according to the disabling message 1 .

[0215] The acceleration sensor driver in electronic device A sets the value of the water level line of the FIFO buffer of the acceleration sensor of electronic device A to F / n according to the disabling message 1. Exemplarily, the following steps may be included: the acceleration sensor driver sends a control command #2 to the acceleration sensor of electronic device A according to the disabling message 1; the acceleration sensor sets the value of the water level line of the FIFO buffer of the acceleration sensor to F / n according to the control command #2.

[0216] After electronic device A executes the above step S617, the acceleration sensor collects (F / n) frames of ACC data and sends them to the acceleration sensor driver immediately, where F / n is an integer in the range of [2, 10]. For example, F / n can be 2, 3, 4 or 10.

[0217] The above steps S616 and S617 introduce the process of triggering the execution of the virtual gyroscope driver after the virtual gyroscope driver receives the disabling message #0 sent by the sensor manager. Exemplarily, the pseudo codes of the above steps S616 and S617 are as follows:

[0218] If (get the unregister of the application) {

[0219] disable( ) {

[0220] Send MSGID_DISABLE message to the acceleration sensor driver;

[0221] Unregister ACC data;

[0222] }

[0223] }

[0224] In the above pseudo code, an example of the above unregister is a deregistration message #1, an example of MESSAGEID_DISENABLE is a disabling message #1, and an example of disable ( ) is a disabling message #1.

[0225] It should be understood that the above Figure 6 The data processing method shown is for illustration only and does not constitute any limitation on the data processing method provided in the embodiment of the present application. For example, after electronic device A executes the above steps S601 to S611, the data processing flow can be directly terminated. For example, the above VR video can also be replaced by other applications that require data from a virtual gyroscope, for example, other applications can be, but are not limited to, game applications or navigation applications in electronic device A.

[0226] In an embodiment of the present application, when the VR video application of the electronic device subscribes to the angular velocity data from the virtual gyroscope driver of the electronic device, the electronic device sets the data volume of the ACC data sent by the acceleration sensor to the acceleration sensor driver each time (i.e., the value of the water level line of the FIFO buffer of the acceleration sensor) to be the same as the data volume of the ACC data collected by the acceleration sensor each time (i.e., 1 frame), that is, the acceleration sensor can report the collected data volume of 1 frame of ACC data to the acceleration sensor driver in real time, which can improve the timeliness of ACC data transmission. Afterwards, when the acceleration sensor driver transmits the ACC data reported by the acceleration sensor to the virtual gyroscope in real time, the virtual gyroscope can obtain the angular velocity data based on the ACC data, thereby improving the timeliness of the angular velocity data of the virtual gyroscope to improve the user experience. In addition, when the VR video application unsubscribes from the angular velocity data of the virtual gyroscope, the electronic device sets the amount of ACC data sent by the acceleration sensor to the acceleration sensor driver each time to be greater than the amount of ACC data collected by the acceleration sensor each time, that is, the acceleration sensor will first cache the collected ACC data with an amount less than (F / n) frames, until the amount of ACC data cached by the acceleration sensor is (F / n) frames, the acceleration sensor will report the ACC data with a data amount of (F / n) frames to the acceleration sensor driver, which can reduce the energy consumption of data transmission. Moreover, when the VR video application successfully subscribes to the angular velocity data driven by the virtual gyroscope, that is, when the value of the water level of the FIFO buffer of the acceleration sensor is set to 1, if the map application requests to subscribe to the angular velocity data driven by the virtual gyroscope again, there is no need to perform the operation of updating the value of the water level of the FIFO buffer again, simplifying the processing flow. In summary, the data processing method provided by the present application can improve the data processing performance (the timeliness of data transmission or reduce the energy consumption of data transmission) to improve the user experience.

[0227] Figure 7 is a schematic diagram of a data processing method provided in an embodiment of the present application. The data processing method provided in an embodiment of the present application can be executed by an electronic device. It is understood that the electronic device can be implemented as software, or a combination of software and hardware. Exemplarily, the electronic device in the embodiment of the present application can be, but is not limited to, Figure 3 , Figure 4 or Figure 5 The electronic device 100 is shown. Figure 7 As shown, the data processing method provided in the embodiment of the present application includes step S710 and step S720. Step S710 and step S720 are described in detail below.

[0228] In step S710, when the first application in the electronic device subscribes to angular velocity data to the virtual gyroscope driver, the parameter value of the first parameter of the acceleration sensor is set to a first numerical value, wherein the parameter value of the first parameter represents the amount of acceleration data sent by the acceleration sensor to the acceleration sensor driver each time, and the first numerical value is the amount of acceleration data collected by the acceleration sensor each time.

[0229] The electronic device in the embodiment of the present application includes an acceleration sensor, an acceleration sensor driver and a virtual gyroscope driver, wherein the acceleration sensor driver is used to report the acceleration data reported by the acceleration sensor to the virtual gyroscope driver, and the virtual gyroscope driver is used to generate angular velocity data based on the acceleration data reported by the acceleration sensor driver.

[0230] For example, the above Figure 6 The electronic device A in the data processing method provided is a specific example of the electronic device in the above step S710. Figure 6 The acceleration sensor in the above step S710 is a specific example of the acceleration sensor in the above step S710. Figure 6 The acceleration sensor driving in the above step S710 is a specific example of the acceleration sensor driving in the above step S710. Figure 6 The virtual gyroscope driving in the above step S710 is a specific example of the virtual gyroscope driving.

[0231] In the embodiment of the present application, the first application, each sensor and each driver in the electronic device are all running in the hardware processor of the electronic device, and there is no specific limitation on the running conditions of the first application, each sensor and each driver in the processor of the electronic device.

[0232] In some implementations, the electronic device includes a first processor, and the first processor is used to run a first application, an acceleration sensor driver, a magnetic sensor driver, and a virtual gyroscope driver.

[0233] The first application is an application in the application layer of the electronic device, and the first application is not specifically limited, that is, any application in the electronic device that needs to subscribe to the angular velocity data driven by the virtual gyroscope can be called the first application. For example, the first application can be, but is not limited to, maps, games, VR videos, and navigation. Optionally, the application layer of the electronic device may also include other applications other than the first application, which is not specifically limited in the embodiments of the present application. For example, other applications may be applications that need to subscribe to the angular velocity data driven by the virtual gyroscope, or may be applications that do not need to subscribe to the angular velocity data driven by the virtual gyroscope.

[0234] When the first processor runs the acceleration sensor driver, the magnetic sensor driver, and the virtual gyroscope driver, the acceleration sensor driver, the magnetic sensor driver, and the virtual gyroscope driver may be located in a kernel layer of the electronic device.

[0235] Exemplarily, the electronic device in the above implementation is Figure 4 In the electronic device 100 shown, the first processor is Figure 4 The first processor 111 is shown, and any one of the multiple applications (map, VR video and navigation) included in the application layer 210 run by the first processor 111 can be the above-mentioned first application, and the kernel layer 250 run by the first processor 111 includes an acceleration sensor driver, a magnetic sensor driver and a virtual gyroscope driver.

[0236] In some other implementations, the electronic device includes a first processor and a second processor, the first processor is used to run a first application, and the second processor is used to run an acceleration sensor driver, a magnetic sensor driver, and a virtual gyroscope driver.

[0237] The first application is an application in an application layer of the electronic device.

[0238] When the first processor does not execute the acceleration sensor driver, the magnetic sensor driver, and the virtual gyroscope driver, the kernel layer of the electronic device does not include these three drivers.

[0239] Exemplarily, the electronic device in the above implementation is Figure 3 In the electronic device 100 shown, the first processor is Figure 3 In the first processor 111 shown, any one of the multiple applications (map, VR video and navigation) included in the application layer 210 run by the first processor 111 can be the above-mentioned first application, and the kernel layer 250 run by the first processor 111 does not include the acceleration sensor driver, the magnetic sensor driver and the virtual gyroscope driver. The second processor 112 runs the acceleration sensor driver, the magnetic sensor driver and the virtual gyroscope driver of the electronic device.

[0240] In some other implementations, the electronic device includes a first processor and a second processor, the first processor is used to run a first application, and the first processor is also used to run at least one of an acceleration sensor driver, a magnetic sensor driver, and a virtual gyroscope driver, and the second processor is used to run drivers other than at least one of the acceleration sensor driver, the magnetic sensor driver, and the virtual gyroscope driver.

[0241] The first application is an application in the application layer of the electronic device. For an understanding of the first application, please refer to the description above, which will not be repeated here.

[0242] When the first processor is used to run at least one of an acceleration sensor driver, a magnetic sensor driver, and a virtual gyroscope driver, the kernel layer of the electronic device includes the at least one driver.

[0243] For example, the electronic device in the above implementation may be, but is not limited to, Figure 5 In the electronic device 100 shown, the first processor is Figure 5 In the first processor 111 shown, any one of the multiple applications (map, VR video and navigation) included in the application layer 210 run by the first processor 111 can be the first application in the above implementation, and the kernel layer 250 run by the first processor 111 includes a virtual gyroscope driver. The second processor 112 runs an acceleration sensor driver and a magnetic sensor driver.

[0244] The first processor and the second processor in the above implementations are not specifically limited. In some implementations, the first processor is an application processor, and the second processor is a system control processor, a sensor hub, an audio digital signal processor, or an enhanced digital signal processor.

[0245] A processor in an electronic device may be integrated with a first processor and a second processor. Exemplarily, the processor integrated with the first processor and the second processor may be, but is not limited to, a SOC.

[0246] The parameter value of the first parameter represents the amount of acceleration data sent by the acceleration sensor to the acceleration sensor driver each time. In some implementations, the parameter value of the first parameter is equal to the first value. In other implementations, the parameter value of the first parameter is equal to the second value. The second value is data greater than the first value, and the values ​​of the second value and the first value are not specifically limited. In some implementations, the amount of acceleration data collected by the acceleration sensor each time is 1 (unit: frame). In this scenario, the first value can be 1, and the second value can be an integer in [2,10]. For example, the second value can be, but is not limited to, 2, 3, 4, 5, or 10.

[0247] For example, the above Figure 6 The water level of the FIFO buffer in the data processing method provided can be a specific example of the first parameter mentioned above. Figure 6 The value of the water level of the FIFO buffer in the data processing method provided can be a specific example of the parameter value of the first parameter mentioned above. Figure 6 The value "F / n" in the data processing method provided can be a specific example of the second value mentioned above. Figure 6 The value "1" in the above-mentioned first value can be a specific example. For details not described in detail here, please refer to the above Figure 6Related description in .

[0248] In the embodiment of the present application, the method for implementing the electronic device to perform the above step S710 is not specifically limited.

[0249] In some implementations, the electronic device executes the above-mentioned step S710, that is, when a first application in the electronic device drives the virtual gyroscope to subscribe to angular velocity data, the parameter value of the first parameter of the acceleration sensor is set to the first value, including: when the first application drives the virtual gyroscope to subscribe to angular velocity data, and when it is determined that the parameter value of the first parameter is not the first value, the parameter value of the first parameter is set to the first value.

[0250] Optionally, the first application in the above implementation is the application in the electronic device that first subscribes to the angular velocity data from the virtual gyroscope drive, that is, before the first application subscribes to the angular velocity data from the virtual gyroscope drive, no other application in the electronic device subscribes to the angular velocity data from the virtual gyroscope drive. Figure 6 In the data processing method provided, the first application of the electronic device A may be the above Figure 6 VR video in.

[0251] Optionally, the first application in the above implementation is an application in the electronic device that is not the first time to subscribe to angular velocity data from the virtual gyroscope. In this scenario, before the first application subscribes to angular velocity data from the virtual gyroscope, other applications in the electronic device first subscribe to angular velocity data from the virtual gyroscope and then unsubscribe from the angular velocity data, so that the parameter value of the first parameter is not the first numerical value.

[0252] In the above implementation, the electronic device will set the parameter value of the first parameter to the first value only when the first application subscribes to the angular velocity data from the virtual gyroscope driver and determines that the first parameter is not the first value. In other words, the electronic device will not perform the operation of setting the parameter value of the first parameter to the first value only when the first application subscribes to the angular velocity data from the virtual gyroscope driver and determines that the first parameter is the first value, which can simplify the data processing process and reduce the energy consumption of the electronic device.

[0253] In some other implementations, the electronic device executes the above-mentioned step S710, that is, when a first application in the electronic device subscribes to angular velocity data from the virtual gyroscope driver, the parameter value of the first parameter of the acceleration sensor is set to the first numerical value, including: the electronic device obtains a first registration subscription message, wherein the first registration subscription message is used to indicate that the first application subscribes to angular velocity data from the virtual gyroscope driver; the electronic device sets the parameter value of the first parameter to the first numerical value based on the first registration subscription message.

[0254] The first registration subscription message is used to indicate that the first application subscribes to the angular velocity data from the virtual gyroscope driver. In some implementations, the first registration subscription message may include an identifier of the virtual gyroscope driver. Optionally, the first registration subscription message may also include other information, such as, but not limited to, an identifier of the first application.

[0255] For example, the above Figure 6 The registration message #1 or the registration message #2 in the provided data processing method is a specific example of the first registration subscription message mentioned above. For the contents not described in detail here, please refer to the above Figure 6 Related description in .

[0256] The electronic device sets the parameter value of the first parameter to the first value based on the first registration subscription message, that is, the electronic device sets the parameter value of the first parameter to the first value based on the data generated by the first registration subscription message.

[0257] In the above technical solution, the electronic device sends a subscription message (ie, a first registration subscription message) to the virtual gyroscope to subscribe to angular velocity data based on the first application, and sets the parameter of the first parameter to the first value.

[0258] Optionally, the electronic device in the above implementation also includes a sensor manager located at the application framework layer, and the first application is located at the application program layer of the electronic device; and the electronic device obtains a first registration subscription message, including: the sensor manager receives the first registration subscription message sent by the first application; the electronic device sets the parameter value of the first parameter to the first numerical value based on the first registration subscription message, including: the sensor manager sends a first enable message to the virtual gyroscope driver based on the first registration subscription message; in response to receiving the first enable message, the virtual gyroscope driver sends a second enable message to the acceleration sensor driver; the acceleration sensor driver sets the parameter value of the first parameter to the first numerical value according to the second enable message.

[0259] The first enable message is a message used to trigger the virtual gyroscope driver to perform a preset operation, that is, after the virtual gyroscope driver receives the first enable message, the electronic device will control the virtual gyroscope driver to automatically perform the preset operation, wherein the preset operation includes the virtual gyroscope driver sending the second enable message operation to the acceleration sensor driver, and the virtual gyroscope driver registering acceleration data to the acceleration sensor driver and the virtual gyroscope driver registering magnetic data to the magnetic sensor driver in the following text. It should be noted that only after the virtual gyroscope driver sends the second enable message to the acceleration sensor driver, the virtual gyroscope driver will register acceleration data to the acceleration sensor driver and register magnetic data to the magnetic sensor driver.

[0260] The second enable message is used to indicate that the parameter value of the first parameter is set to the first value. In some implementations, the second enable message may include an identifier of the virtual gyroscope drive, an identifier of the acceleration sensor, and a first control command, and the first control command is used to indicate that the parameter value of the first parameter is set to the first value.

[0261] For example, the above Figure 6 The sensor manager in the data processing method provided is a specific example of the above-mentioned sensor manager. Figure 6 The enabling message #1 in the data processing method provided is a specific example of the second enabling message mentioned above. Figure 6 The enabling message #0 in the above-mentioned first enabling message may be a specific example of the above-mentioned first enabling message. For the contents not described in detail here, please refer to the above Figure 6 Related description in .

[0262] Optionally, the electronic device also includes a sensor module located in the hardware abstraction layer. In the step in which the sensor manager sends a first enable message to the virtual gyroscope driver based on the first registration subscription message, exemplarily, it includes: the sensor manager sends the first enable message to the virtual gyroscope driver by calling the sensor module.

[0263] Optionally, the electronic device in the above implementation also includes a magnetic sensor and a magnetic sensor driver; and the method also includes: in response to receiving a first enable message, the virtual gyroscope driver registers acceleration data to the acceleration sensor driver, and registers magnetic data to the magnetic sensor driver; after the virtual gyroscope driver registers acceleration data to the acceleration sensor driver, the virtual gyroscope driver receives first acceleration data with a first value obtained by the acceleration sensor driver from the acceleration sensor; after the virtual gyroscope driver registers magnetic data to the magnetic sensor driver, the virtual gyroscope driver receives first magnetic data with a first value obtained by the magnetic sensor driver from the magnetic sensor; the virtual gyroscope driver generates first angular velocity data based on the first acceleration data and the first magnetic data; the virtual gyroscope driver sends the first angular velocity data to the first application through the sensor manager.

[0264] The first angular velocity data may refer to angle data including a heading angle, a pitch angle, and a roll angle.

[0265] There is no specific limitation on the type of the magnetic sensor. For example, the magnetic sensor may be a geomagnetic sensor. Based on this, the magnetic sensor drive may be referred to as a magnetic sensor drive.

[0266] In the embodiment of the present application, the method for implementing the virtual gyroscope driving to generate the first angular velocity data according to the first acceleration data and the first magnetic data is not specifically limited.

[0267] In some implementations, the virtual gyroscope driver processes the first acceleration data and the first magnetic data based on a posture estimation algorithm to generate the first angular velocity data. The posture estimation algorithm is not limited, and the posture estimation algorithm may be an existing posture estimation algorithm.

[0268] In other implementations, the virtual gyroscope driver generates first angular velocity data based on the first acceleration data and the first magnetic data, including: the virtual gyroscope driver performs correction processing on the first acceleration data to obtain the corrected first acceleration data; the virtual gyroscope driver performs correction processing on the first magnetic data to obtain the corrected first magnetic data; the virtual gyroscope driver processes the corrected first acceleration data and the corrected first magnetic data based on a posture estimation algorithm to generate the first angular velocity data.

[0269] For example, the above Figure 6 The magnetic sensor in the data processing method provided is a specific example of the above magnetic sensor. Figure 6 A frame of ACC data #1 in the above embodiment is a specific example of the first acceleration data in the above embodiment. Figure 6 A frame of MAG data #1 in the above implementation is a specific example of the first magnetic data in the above implementation. Figure 6 A frame of angular velocity data #1 in is a specific example of the first angular velocity data in the above implementation.

[0270] Optionally, the electronic device further includes a sensor module located at the hardware abstraction layer. In the step in which the virtual gyroscope driver sends the first angular velocity data to the first application through the sensor manager, exemplarily, it includes: the virtual gyroscope driver sends the first angular velocity data to the sensor manager by calling the sensor module.

[0271] In an embodiment of the present application, after the first application subscribes to angular velocity data from the virtual gyroscope and the electronic device sets the parameter value of the first parameter to a first numerical value, the electronic device may further perform the following steps: controlling the acceleration sensor to report the collected acceleration data having a first numerical value to the acceleration sensor driver.

[0272] In the above implementation, after the first application in the electronic device subscribes to the angular velocity data from the virtual gyroscope driver in the electronic device, the electronic device first sets the parameter value of the first parameter of the acceleration sensor to the first value. Afterwards, the electronic device controls the acceleration sensor to report the collected acceleration data with the first value to the acceleration sensor driver, which can improve the timeliness of the acceleration data transmission. Afterwards, the acceleration sensor driver transmits the acceleration data reported by the acceleration sensor in real time to the virtual gyroscope, which can improve the timeliness of the angular velocity data generated by the virtual gyroscope to improve the user experience.

[0273] In the above step S710, a first application in an electronic device subscribes to angular velocity data from a virtual gyroscope driver as an example. Optionally, after the electronic device executes the above step S710, if a second application in the electronic device subscribes to angular velocity data from a virtual gyroscope driver, since the parameter value of the current first parameter has been set to the first value, that is, in this scenario, the electronic device will no longer execute the relevant steps of setting the parameter value of the first parameter to the first value.

[0274] For example, the above Figure 6 The VR video in the data processing method provided is the first application in the above scenario. Figure 6 The map in the data processing method provided is the second application in the above scenario. For content not described in detail here, please refer to the above Figure 6 Related description in .

[0275] In step S720, when the first application drives the virtual gyroscope to unsubscribe from the angular velocity data, the electronic device sets the parameter value of the first parameter to a second value, wherein the second value is greater than the first value.

[0276] The electronic device executes the above step S720, that is, when the first application in the electronic device cancels the subscription of angular velocity data to the virtual gyroscope in the electronic device, the electronic device will set the data volume of the acceleration data sent by the acceleration sensor to the acceleration sensor driver each time (that is, the parameter value of the first parameter) to be greater than the data volume of the acceleration data collected by the acceleration sensor each time (that is, the first numerical value). In this scenario, the acceleration sensor will first cache the collected acceleration data whose data volume is less than the second numerical value, and only when the data volume of the acceleration data cached by the acceleration sensor is the second numerical value, the acceleration sensor will report the acceleration data whose data volume is the second numerical value to the acceleration sensor driver. In this way, the energy consumption of data transmission can be reduced.

[0277] In the embodiment of the present application, the method for implementing the electronic device to perform the above step S720 is not specifically limited.

[0278] In some implementations, the electronic device performs the above-mentioned step S720, i.e., when the first application cancels the subscription of angular velocity data to the virtual gyroscope driver, the parameter value of the first parameter is set to the second value, including: when the first application cancels the subscription of angular velocity data to the virtual gyroscope driver and determines that the parameter value of the first parameter is not the second value, the parameter value of the first parameter is set to the second value.

[0279] In some other implementations, the electronic device executes the above-mentioned step S720, that is, when the first application cancels the subscription of angular velocity data to the virtual gyroscope driver, the parameter value of the first parameter is set to a second value, including: the electronic device obtains a first deregistration subscription message, wherein the first deregistration subscription message is used to indicate that the first application cancels the subscription of angular velocity data to the virtual gyroscope driver; the electronic device sets the parameter value of the first parameter to the second value based on the first deregistration subscription message.

[0280] The first deregistration subscription message is used to indicate that the first application cancels the subscription of the angular velocity data from the virtual gyroscope driver, and the first deregistration subscription message may include the identifier of the virtual gyroscope driver.

[0281] For example, the above Figure 6 The deregistration message #1 in step S614 of the provided data processing method is a specific example of the first deregistration subscription message mentioned above. For contents not described in detail here, please refer to the relevant description in step S614 above.

[0282] Optionally, the electronic device in the above implementation also includes a sensor manager located at the application framework layer; and the electronic device obtains a first deregistration subscription message, including: the sensor manager receives the first deregistration subscription message sent by the first application; the electronic device sets the parameter value of the first parameter to a second value based on the first deregistration subscription message, including: the sensor manager sends a first dis-enable message to the virtual gyroscope driver based on the first deregistration subscription message; in response to receiving the first dis-enable message, the virtual gyroscope driver sends a second dis-enable message to the acceleration sensor driver; the acceleration sensor driver sets the parameter value of the first parameter to the second value according to the second dis-enable message.

[0283] The second disabling message may include an identifier of the virtual gyroscope drive, an identifier of the acceleration sensor, and a second control command, where the second control command is used to instruct to set the parameter value of the first parameter to a second value.

[0284] For example, the above Figure 6 The deregistration message #1 in the provided data processing method is a specific example of the first deregistration subscription message. Figure 6 The disabling message #0 in is a specific example of the first disabling message. Figure 6 The disabling message #1 in the above is a specific example of the second disabling message. For details not described in detail here, please refer to the above Figure 6 Related description in .

[0285] In an embodiment of the present application, after the first application in the electronic device cancels the subscription to angular velocity data from the virtual gyroscope in the electronic device and the electronic device sets the parameter value of the first parameter to a second value, the electronic device may further perform the following steps: the electronic device controls the acceleration sensor to store the collected acceleration data in a cache of the acceleration sensor, wherein the cache capacity threshold of the cache is the second value.

[0286] The cache capacity threshold of the cache may be the maximum cache capacity of the cache, or the cache capacity threshold of the cache may be a predefined threshold that is smaller than the maximum cache capacity of the cache.

[0287] There is no specific limitation on the type of the buffer of the acceleration sensor. For example, the buffer may be, but is not limited to, the buffer described above. Figure 6 FIFO buffer in the provided method.

[0288] In the above implementation, after the first application cancels the subscription to the angular velocity data of the virtual gyroscope driver and sets the value of the first parameter to the second value, the acceleration sensor caches the collected acceleration data whose amount of data is less than the second value, which can reduce the energy consumption of data transmission.

[0289] For example, the above Figure 6 The FIFO buffer of the acceleration sensor in step S606 in the provided data processing method is a specific example of the buffer of the acceleration sensor in the above implementation.

[0290] It should be noted that the above Figure 7 In the example of the first application subscribing to the angular velocity data of the virtual gyroscope, a method of setting the parameter value of the first parameter of the acceleration sensor is introduced. Optionally, in some other possible implementations, the above Figure 7The data processing method shown can also be replaced by the following steps: when the first application in the electronic device subscribes to acceleration data from the acceleration sensor, the parameter value of the first parameter of the acceleration sensor is set to a first value, wherein the parameter value of the first parameter represents the amount of acceleration data sent by the acceleration sensor to the acceleration sensor driver each time, and the first value is the amount of acceleration data collected by the acceleration sensor each time; or, when the first application cancels the subscription of acceleration data from the acceleration sensor, the parameter value of the first parameter is set to a second value, wherein the second value is greater than the first value. That is, in this implementation, the method of setting the parameter value of the first parameter is introduced by taking the first application subscribing to the acceleration data of the acceleration sensor as an example. It can be understood that the principle of setting the first parameter in the above two implementation methods is the same, that is, when the first application needs to subscribe to data, the electronic device sets the parameter value of the first parameter equal to the first value, and when the first application does not need to subscribe to data, the electronic device sets the parameter value of the first parameter equal to the second value.

[0291] It should be understood that the above Figure 7 The data processing method shown is for illustration only and does not constitute any limitation on the data processing method provided in the present application. For example, after electronic device A executes steps S601 to S617 above, other applications in the electronic device may also subscribe to angular velocity data from the virtual gyroscope. In this scenario, since the current parameter value of the first parameter is the second value, electronic device A will again execute similar steps described in steps S601 to S617 based on the subscription of other applications. The other applications and the first application are two different applications. For example, after electronic device A executes steps S601 to S617 above, the first application may also subscribe to angular velocity data from the virtual gyroscope. In this scenario, since the current parameter value of the first parameter is the second value, electronic device A will again execute similar steps described in steps S601 to S617 based on the subscription of the first application.

[0292] In an embodiment of the present application, when the first application of the electronic device subscribes to angular velocity data from the virtual gyroscope driver of the electronic device, the electronic device sets the amount of acceleration data (i.e., the parameter value of the first parameter) sent by the acceleration sensor to the acceleration sensor driver each time to be the same as the amount of acceleration data (i.e., the first value) collected by the acceleration sensor each time, that is, the acceleration sensor can report the collected acceleration data with the first value in real time to the acceleration sensor driver, which can improve the timeliness of acceleration data transmission. Afterwards, when the acceleration sensor driver transmits the acceleration data reported by the acceleration sensor to the virtual gyroscope in real time, the virtual gyroscope can obtain angular velocity data based on the acceleration data, thereby improving the timeliness of the angular velocity data of the virtual gyroscope to improve the user experience. In addition, when the first application unsubscribes from the angular velocity data to the virtual gyroscope, the electronic device sets the amount of acceleration data (i.e., the parameter value of the first parameter) that the acceleration sensor sends to the acceleration sensor driver each time to be greater than the amount of acceleration data (i.e., the first value) collected by the acceleration sensor each time, that is, the acceleration sensor will first cache the collected acceleration data whose amount is less than the second value, until the amount of acceleration data cached by the acceleration sensor is the second value, the acceleration sensor will report the acceleration data with the second value to the acceleration sensor driver, which can reduce the energy consumption of data transmission. In summary, the data processing method provided by the present application can improve data processing performance (the timeliness of data transmission or reduce the energy consumption of data transmission) to improve user experience.

[0293] The following will be combined Figure 7 It should be understood that the data processing device in the embodiment of the present application can execute various data processing methods in the aforementioned embodiment of the present application, that is, the specific working process of the following various products can refer to the corresponding process in the aforementioned method embodiment.

[0294] Figure 8 is a schematic diagram of a data processing device provided in an embodiment of the present application. For example, Figure 8 The data processing device 800 shown is applied to an electronic device including an acceleration sensor, an acceleration sensor driver and a virtual gyroscope driver. The acceleration sensor driver is used to report the acceleration data reported by the acceleration sensor to the virtual gyroscope driver. The virtual gyroscope driver is used to generate angular velocity data based on the acceleration data reported by the acceleration sensor driver. Figure 8 As shown, the data processing device 800 includes a processing unit 810 .

[0295] The processing unit 810 is used to: when a first application in the electronic device subscribes to angular velocity data from a virtual gyroscope driver, set the parameter value of a first parameter of the acceleration sensor to a first value, wherein the parameter value of the first parameter represents the amount of acceleration data sent by the acceleration sensor to the acceleration sensor driver each time, and the first value is the amount of acceleration data collected by the acceleration sensor each time; or, when the first application cancels its subscription to angular velocity data from the virtual gyroscope driver, set the parameter value of the first parameter to a second value, wherein the second value is greater than the first value.

[0296] In a possible implementation, the processing unit 810 is further configured to, when the first application drives the virtual gyroscope to subscribe to angular velocity data and determines that the parameter value of the first parameter is not the first value, perform the following operations: setting the parameter value of the first parameter to the first value.

[0297] In another possible implementation, the processing unit 810 is further configured to, after setting the parameter value of the first parameter of the acceleration sensor to the first value, perform the following operations: controlling the acceleration sensor to report the collected acceleration data having the first value to the acceleration sensor driver.

[0298] In another possible implementation, the processing unit 810 is further used to: obtain a first registration subscription message, wherein the first registration subscription message is used to indicate that the first application subscribes to angular velocity data to the virtual gyroscope driver; and based on the first registration subscription message, set the parameter value of the first parameter to a first value.

[0299] In another possible implementation, the processing unit 810 is further used to: obtain a first deregistration subscription message, wherein the first deregistration subscription message is used to indicate that the first application cancels the subscription of angular velocity data to the virtual gyroscope driver; and based on the first deregistration subscription message, set the parameter value of the first parameter to the second value.

[0300] In another possible implementation, the electronic device includes a first processor, the first processor is used to run the first application, the acceleration sensor driver, the magnetic sensor driver and the virtual gyroscope driver; or, the electronic device includes a first processor and a second processor, the first processor is used to run the first application, and the second processor is used to run the acceleration sensor driver, the magnetic sensor driver and the virtual gyroscope driver; or, the electronic device includes a first processor and a second processor, the first processor is used to run the first application, and the first processor is also used to run at least one of the acceleration sensor driver, the magnetic sensor driver and the virtual gyroscope driver, and the second processor is used to run a driver other than the acceleration sensor driver, the magnetic sensor driver and the virtual gyroscope driver.

[0301] In another possible implementation, the first processor is an application processor, and the second processor is a system control processor, a sensor hub, an audio digital signal processor, or an enhanced digital signal processor.

[0302] In another possible implementation, the processing unit 810 is further used to perform the following operations after setting the parameter value of the first parameter to a second value: controlling the acceleration sensor to store the collected acceleration data in a cache of the acceleration sensor, wherein a cache capacity threshold of the cache is the second value.

[0303] In another possible implementation, the first value is 1, and the second value is an integer in [2, 10].

[0304] Optional, above Figure 8 The data processing device shown is applied to an electronic device including an acceleration sensor and an acceleration sensor driver, and the processing unit 810 is used for: being applied to an electronic device including an acceleration sensor and an acceleration sensor driver, the method comprising: in a case where a first application in the electronic device subscribes to acceleration data from the acceleration sensor, setting the parameter value of a first parameter of the acceleration sensor to a first value, wherein the parameter value of the first parameter represents the amount of acceleration data sent by the acceleration sensor to the acceleration sensor driver each time, and the first value is the amount of acceleration data collected by the acceleration sensor each time; or, in a case where the first application cancels its subscription to acceleration data from the acceleration sensor, setting the parameter value of the first parameter to a second value, wherein the second value is greater than the first value.

[0305] In a possible implementation, the processing unit 810 is further configured to, when the first application subscribes to acceleration data from the acceleration sensor and determines that the parameter value of the first parameter is not the first value, perform the following operations: setting the parameter value of the first parameter to the first value.

[0306] In another possible implementation, the processing unit 810 is further configured to, after setting the parameter value of the first parameter of the acceleration sensor to the first value, perform the following operations: controlling the acceleration sensor to report the collected acceleration data having the first value to the acceleration sensor driver.

[0307] In another possible implementation, the processing unit 810 is further used to: obtain a second registration subscription message, wherein the second registration subscription message is used to indicate that the first application subscribes to acceleration data from the acceleration sensor; and based on the second registration subscription message, set the parameter value of the first parameter to the first value.

[0308] In another possible implementation, the processing unit 810 is further used to: obtain a second deregistration subscription message, wherein the second deregistration subscription message is used to indicate that the first application cancels the subscription of acceleration data from the acceleration sensor; and based on the second deregistration subscription message, set the parameter value of the first parameter to the second value.

[0309] In another possible implementation, the first value is 1, and the second value is an integer in [2, 10].

[0310] It should be noted that the above data processing device 800 is embodied in the form of a functional unit. The term "unit" here can be implemented in the form of software and / or hardware, and is not specifically limited to this.

[0311] For example, a "unit" may be a software program, a hardware circuit, or a combination of the two that implements the above functions. The hardware circuit may include an application specific integrated circuit (ASIC), an electronic circuit, a processor (such as a shared processor, a dedicated processor, or a group processor, etc.) and a memory for executing one or more software or firmware programs, a combined logic circuit, and / or other suitable components that support the described functions.

[0312] Therefore, the units of each example described in the embodiments of the present application can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present application.

[0313] The present application also provides a computer program product, which, when executed by an electronic device, implements the data processing method described in any method embodiment of the present application.

[0314] The computer program product may be stored in a memory, for example, a program, which is finally converted into an executable target file that can be executed by an electronic device after preprocessing, compiling, assembling and linking.

[0315] The present application also provides a chip, which is applied to an electronic device. The chip includes one or more processors, and the processor is used to call computer instructions so that the electronic device can implement the data processing method described in any method embodiment of the present application.

[0316] The present application also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a computer, the data processing method of any method embodiment of the present application is implemented. The computer program can be a high-level language program or an executable target program.

[0317] In this application, "at least one" means one or more, and "plurality" means two or more. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can mean: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.

[0318] It should be understood that in the various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0319] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0320] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0321] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic; for example, the division of the units is only a logical function division, and there may be other division methods in actual implementation; for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0322] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0323] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0324] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A data processing method, characterized in that: The method is applied to an electronic device including an acceleration sensor, an acceleration sensor driver, a virtual gyroscope driver, and a sensor manager located at an application framework layer, wherein the acceleration sensor driver is used to report acceleration data reported by the acceleration sensor to the virtual gyroscope driver, and the virtual gyroscope driver is used to generate angular velocity data based on the acceleration data reported by the acceleration sensor driver. The method includes: In a case where the first application in the electronic device subscribes to the angular velocity data from the virtual gyroscope driver, setting the parameter value of the first parameter of the acceleration sensor to a first value, wherein the parameter value of the first parameter represents the amount of acceleration data sent by the acceleration sensor to the acceleration sensor driver each time, and the first value is the amount of acceleration data collected by the acceleration sensor each time; Wherein, when the first application in the electronic device drives the virtual gyroscope to subscribe to angular velocity data, setting the parameter value of the first parameter of the acceleration sensor to a first value includes: The sensor manager receives a first registration subscription message sent by the first application, wherein the first registration subscription message is used to indicate that the first application subscribes to angular velocity data from the virtual gyroscope driver; The sensor manager sends a first enable message to the virtual gyroscope driver based on the first registration subscription message; In response to receiving the first enable message, the virtual gyroscope driver sends a second enable message to the acceleration sensor driver; The acceleration sensor driver sets the parameter value of the first parameter to the first value according to the second enable message; or, When the first application unsubscribes from the angular velocity data to the virtual gyroscope driver, setting the parameter value of the first parameter to a second value, wherein the second value is greater than the first value; Wherein, in a case where the first application unsubscribes from the angular velocity data to the virtual gyroscope driver, setting the parameter value of the first parameter to a second value includes: The sensor manager receives a first deregistration subscription message sent by the first application, wherein the first deregistration subscription message is used to indicate that the first application cancels the subscription of angular velocity data from the virtual gyroscope driver; The sensor manager sends a first disabling message to the virtual gyroscope driver based on the first deregistration subscription message; In response to receiving the first disabling message, the virtual gyroscope driver sends a second disabling message to the acceleration sensor driver; The acceleration sensor driver sets the parameter value of the first parameter to the second value according to the second disabling message.

2. The method according to claim 1, characterized in that In a case where a first application in the electronic device drives the virtual gyroscope to subscribe to angular velocity data, setting a parameter value of a first parameter of the acceleration sensor to a first value includes: When the first application drives the virtual gyroscope to subscribe to angular velocity data and it is determined that the parameter value of the first parameter is not the first value, the parameter value of the first parameter is set to the first value.

3. The method according to claim 1 or 2, characterized in that: After setting the parameter value of the first parameter of the acceleration sensor to the first value, the method further includes: The acceleration sensor is controlled to report the collected acceleration data whose data amount is the first value to the acceleration sensor driver.

4. The method according to claim 1 or 2, characterized in that: The electronic device further includes a magnetic sensor and a magnetic sensor driver; and the method further includes: In response to receiving the first enable message, the virtual gyroscope driver registers acceleration data with the acceleration sensor driver, and registers magnetic data with the magnetic sensor driver; After the virtual gyroscope driver registers the acceleration data with the acceleration sensor driver, the virtual gyroscope driver receives first acceleration data whose data amount is the first value and which is acquired by the acceleration sensor driver from the acceleration sensor; After the virtual gyroscope driver registers magnetic data with the magnetic sensor driver, the virtual gyroscope driver receives first magnetic data whose data amount is the first value obtained by the magnetic sensor driver from the magnetic sensor; The virtual gyroscope driver generates first angular velocity data according to the first acceleration data and the first magnetic data; The virtual gyroscope driver sends the first angular velocity data to the first application through the sensor manager.

5. The method according to claim 4, characterized in that The electronic device includes a first processor, and the first processor is used to run the first application, the acceleration sensor driver, the magnetic sensor driver, and the virtual gyroscope driver; or, The electronic device includes a first processor and a second processor, the first processor is used to run the first application, and the second processor is used to run the acceleration sensor driver, the magnetic sensor driver and the virtual gyroscope driver; or, The electronic device includes a first processor and a second processor, the first processor is used to run the first application, and the first processor is also used to run at least one of the acceleration sensor driver, the magnetic sensor driver and the virtual gyroscope driver, and the second processor is used to run drivers other than the acceleration sensor driver, the magnetic sensor driver and the virtual gyroscope driver.

6. The method according to claim 5, characterized in that The first processor is an application processor, and the second processor is a system control processor, a sensor hub, an audio digital signal processor, or an enhanced digital signal processor.

7. The method according to claim 1 or 2, characterized in that: After setting the parameter value of the first parameter to a second value, the method further includes: The acceleration sensor is controlled to store the collected acceleration data in a buffer of the acceleration sensor, wherein a buffer capacity threshold of the buffer is the second value.

8. The method according to claim 1 or 2, characterized in that: The first value is 1, and the second value is an integer in [2, 10].

9. An electronic device, characterized in that: It comprises one or more processors and one or more memories; wherein, the one or more memories are coupled to the one or more processors, and the one or more memories are used to store computer programs, so that when the one or more processors execute the computer programs, the electronic device executes the data processing method as described in any one of claims 1 to 8.

10. A chip, which is applied to electronic equipment, and includes one or more processors, characterized in that: The processor is used to call computer instructions so that the electronic device executes the data processing method according to any one of claims 1 to 8.

11. A computer-readable storage medium comprising a computer program, characterized in that: When the computer program is executed on an electronic device, the electronic device is enabled to execute the data processing method according to any one of claims 1 to 8.