Equipment control method and device, electronic equipment and computer program product

By combining the detection results of ultrasonic and infrared proximity sensors and attitude sensors, the problem of misjudgment in the recognition of external objects in touch screen electronic devices has been solved, achieving more accurate screen status control and improving the user experience.

CN122018841APending Publication Date: 2026-05-12CHENGDU OPPO TELECOMM TECH CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHENGDU OPPO TELECOMM TECH CORP LTD
Filing Date
2024-11-12
Publication Date
2026-05-12

AI Technical Summary

Technical Problem

In existing technologies, touch screen electronic devices may misjudge the distance between external objects and the device, resulting in inaccurate screen status control and affecting user experience.

Method used

By combining the detection results from ultrasonic sensors, infrared proximity sensors, and attitude sensors, the distance between external objects and the equipment is comprehensively identified, and the screen status is controlled based on the target detection results.

Benefits of technology

It improves the accuracy of screen status control, reduces the probability of accidental touches, and enhances the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122018841A_ABST
    Figure CN122018841A_ABST
Patent Text Reader

Abstract

The invention provides an equipment control method and device, electronic equipment and a computer program product, which can more accurately identify whether an external object is close to or far away from the electronic equipment, and effectively improve the control accuracy of the screen state of the electronic equipment. The method comprises the following steps: acquiring a first detection result determined by an ultrasonic sensor, acquiring a second detection result determined by an infrared proximity sensor, and acquiring attitude data acquired by an attitude sensor; based on at least one of the first detection result, the second detection result and the attitude data, a target detection result is obtained, and the target detection result is used for indicating whether an external object is close to or far away from the electronic equipment; according to the target detection result, the screen state of the electronic equipment is controlled, and the screen state comprises a screen-off state or a screen-on state.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of terminal equipment technology, and in particular to a device control method and apparatus, electronic equipment, and computer program product. Background Technology

[0002] With the development of science and technology, and the innovation of electronic device forms and functions, electronic devices have become more diverse and feature-rich. Currently, touchscreen electronic devices account for a very high proportion of the market and are increasingly favored by users.

[0003] When using touchscreen electronic devices, the device can control its screen state based on its distance from external objects. Therefore, accurately identifying the distance between external objects and the electronic device to accurately control its screen state has become a pressing problem to be solved. Summary of the Invention

[0004] This application provides a device control method and apparatus, an electronic device, and a computer program product, which can more accurately identify whether external objects are approaching or moving away from the electronic device, effectively improving the accuracy of controlling the screen status of the electronic device.

[0005] In a first aspect, a device control method is provided, applying an electronic device including an infrared proximity sensor, an ultrasonic sensor, and an attitude sensor. The method includes: acquiring a first detection result determined by the ultrasonic sensor, acquiring a second detection result determined by the infrared proximity sensor, and acquiring attitude data collected by the attitude sensor; obtaining a target detection result based on at least one of the first detection result, the second detection result, and the attitude data, the target detection result indicating whether an external object is approaching or moving away from the electronic device; and controlling the screen state of the electronic device according to the target detection result, the screen state including a screen-off state or a screen-on state.

[0006] In this application, an electronic device can obtain a target detection result based on at least one of a first detection result, a second detection result, and attitude data. This target detection result indicates whether an external object is approaching or moving away from the electronic device, and the screen state of the electronic device is controlled to be either off or on based on the target detection result. Specifically, the first detection result is determined by an ultrasonic sensor, the second detection result is determined by an infrared proximity sensor, and the attitude data is collected by an attitude sensor. This allows the electronic device to comprehensively analyze the first detection result from the infrared proximity sensor, the second detection result from the ultrasonic sensor, and the attitude data collected by the attitude sensor to more accurately identify whether an external object is approaching or moving away from the electronic device, thereby achieving precise control over the screen state of the electronic device.

[0007] Secondly, a device control apparatus is provided, applying an electronic device including an infrared proximity sensor, an ultrasonic sensor, and an attitude sensor. The device control apparatus includes an acquisition module and a processing module. The acquisition module is used to acquire a first detection result determined by the ultrasonic sensor, a second detection result determined by the infrared proximity sensor, and attitude data collected by the attitude sensor. The processing module is used to obtain a target detection result based on at least one of the first detection result, the second detection result, and the attitude data, the target detection result indicating whether an external object is approaching or moving away from the electronic device. Based on the target detection result, the processing module controls the screen state of the electronic device, the screen state including a screen-off state or a screen-on state.

[0008] Thirdly, an electronic device is provided, including a processor coupled to a memory for executing instructions in the memory to implement the method in any of the possible implementations of the first aspect described above. Optionally, the electronic device further includes a memory. Optionally, the electronic device further includes a communication interface, to which the processor is coupled.

[0009] Fourthly, a processor is provided, comprising: an input circuit, an output circuit, and a processing circuit. The processing circuit is used to receive signals through the input circuit and transmit signals through the output circuit, causing the processor to execute the method in any possible implementation of the first aspect described above.

[0010] In specific implementation, the processor can be a chip, the input circuit can be an input pin, the output circuit can be an output pin, and the processing circuit can be a transistor, gate circuit, flip-flop, and various logic circuits. The input signal received by the input circuit can be received and input by, for example, but not limited to, a receiver, and the signal output by the output circuit can be output to, for example, but not limited to, a transmitter and transmitted by the transmitter. Furthermore, the input circuit and the output circuit can be the same circuit, which is used as the input circuit and the output circuit at different times. This application does not limit the specific implementation of the processor and various circuits.

[0011] Fifthly, a processing apparatus is provided, including a processor and a memory. The processor is used to read instructions stored in the memory and to receive signals via a receiver and transmit signals via a transmitter to execute the method in any of the possible implementations of the first aspect described above.

[0012] Optionally, there may be one or more processors and one or more memories.

[0013] Alternatively, the memory can be integrated with the processor, or the memory can be set up separately from the processor.

[0014] In specific implementation, the memory can be a non-transitory memory, such as read-only memory (ROM), which can be integrated with the processor on the same chip or set on different chips. The embodiments of this application do not limit the type of memory or the way the memory and processor are set.

[0015] The processing device in the fifth aspect above can be a chip. The processor can be implemented in hardware or software. When implemented in hardware, the processor can be a logic circuit, integrated circuit, etc. When implemented in software, the processor can be a general-purpose processor that reads software code stored in memory. The memory can be integrated into the processor or located outside the processor and exist independently.

[0016] In a sixth aspect, a computer program product is provided, the computer program product comprising: a computer program (also referred to as code or instructions), which, when run, causes a computer to perform the method in any of the possible implementations of the first aspect described above.

[0017] In a seventh aspect, a computer-readable storage medium is provided that stores a computer program (also referred to as code or instructions) that, when executed on a computer, causes the computer to perform the methods in any of the possible implementations of the first aspect described above. Attached Figure Description

[0018] Figure 1 This is a schematic diagram of the system architecture of the electronic device provided in the embodiments of this application;

[0019] Figure 2 This is a schematic diagram of an electronic device provided in an embodiment of this application;

[0020] Figure 3 This is a schematic flowchart of a device control method provided in an embodiment of this application;

[0021] Figure 4 This is a schematic diagram of an infrared proximity detection method provided in an embodiment of this application;

[0022] Figure 5 This is a schematic flowchart illustrating a first specific example of the device control method provided in the embodiments of this application;

[0023] Figure 6 This is a schematic flowchart illustrating a second specific example of the device control method provided in the embodiments of this application;

[0024] Figure 7This is a schematic flowchart illustrating a third specific example of the device control method provided in the embodiments of this application;

[0025] Figure 8 This is a schematic diagram of an electronic device provided in an embodiment of this application;

[0026] Figure 9 This is a schematic flowchart illustrating a fourth specific example of the device control method provided in the embodiments of this application;

[0027] Figure 10 This is a schematic diagram of the electronic device software architecture provided in the embodiments of this application;

[0028] Figure 11 This is a schematic flowchart illustrating the fifth specific example of the device control method provided in the embodiments of this application;

[0029] Figure 12 This is a schematic block diagram of a device control apparatus provided in an embodiment of this application;

[0030] Figure 13 This is a schematic block diagram of an electronic device provided in an embodiment of this application. Detailed Implementation

[0031] The technical solutions in this application will now be described with reference to the accompanying drawings.

[0032] To facilitate a clear description of the technical solutions in the embodiments of this application, the terms "first" and "second" are used in the embodiments of this application to distinguish identical or similar items with essentially the same function and effect. Those skilled in the art will understand that the terms "first" and "second" do not limit the quantity or execution order, and the terms "first" and "second" are not necessarily different.

[0033] It should be noted that, in this application, the words "exemplarily" or "for example" are used to indicate examples, illustrations, or explanations. Any embodiment or design described as "exemplarily" or "for example" in this application should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of words such as "exemplarily" or "for example" is intended to present the relevant concepts in a specific manner.

[0034] Furthermore, "at least one" refers to one or more, while "more than one" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can mean: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, and c can mean: a, or b, or c, or a and b, or a and c, or b and c, or a, b, and c, where a, b, and c can be single or multiple.

[0035] To make the objectives and technical solutions of this application clearer and more intuitive, the device control method and apparatus, electronic equipment, and computer program products provided in the embodiments of this application will be described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit this application.

[0036] Currently, electronic devices can control their screen status based on the distance between external objects and the device. Therefore, accurately identifying the distance between external objects and electronic devices to precisely control their screen status has become a pressing problem to be solved.

[0037] For example, when an infrared proximity sensor detects an external object approaching or moving away from an electronic device and controls the screen state based on the detection result, an error in the detection result could lead to miscontrol of the screen state, affecting user experience. For instance, in call mode, even without an external object approaching or obstructing the electronic device, the infrared proximity sensor might mistakenly detect an object approaching, causing the screen to remain off, severely impacting normal user operation. Alternatively, when a black / dark object approaches or obstructs the electronic device (e.g., the user's hair obstructs the device while making a call), the detection result should indicate an object is approaching. However, due to the "black card effect," the infrared proximity sensor may fail to detect the object's proximity or mistakenly detect it moving away, preventing the screen from turning off properly and leading to malfunctions and accidental touches. The "black card effect" refers to the absorption of infrared light emitted by the proximity sensor by a black / dark object, preventing it from returning to the sensor and thus hindering proximity detection.

[0038] This application provides a device control method and apparatus, an electronic device, and a computer program product. The electronic device can obtain a target detection result based on at least one of a first detection result, a second detection result, and attitude data. The target detection result is used to indicate whether an external object is approaching or moving away from the electronic device, and the screen state of the electronic device is controlled to be either off or on based on the target detection result. The first detection result is determined by an ultrasonic sensor, the second detection result is determined by an infrared proximity sensor, and the attitude data is collected by an attitude sensor. This allows the electronic device to comprehensively analyze the first detection result from the infrared proximity sensor, the second detection result from the ultrasonic sensor, and the attitude data collected by the attitude sensor to more accurately identify whether an external object is approaching or moving away from the electronic device, and to achieve precise control of the screen state of the electronic device.

[0039] The electronic devices involved in the embodiments of this application may be mobile phones, watches, laptops, handheld computers, mobile internet devices (MIDs), personal computers (PCs), wearable devices, virtual reality (VR) devices, augmented reality (AR) devices, wireless terminals in self-driving vehicles, wireless terminals in smart grids, wireless terminals in transportation safety, wireless terminals in smart cities, wireless terminals in smart homes, personal digital assistants (PDAs), etc., but the embodiments of this application are not limited to these.

[0040] For example, Figure 1 This is a schematic diagram of the system architecture of an electronic device provided in an embodiment of this application.

[0041] like Figure 1 As shown, the electronic device includes a processor 110 and a display unit 170. The display unit 170 may include a display screen.

[0042] Optionally, the electronic device may also include a memory 130. The processor 110 and the memory 130 can communicate with each other via an internal connection to transfer data. The memory 130 stores computer programs, and the processor 110 retrieves and runs the computer programs from the memory 130. The processor 110 and the memory 130 can be combined into a single processing device, but more commonly they are independent components. The processor 110 executes the program code stored in the memory 130 to achieve the aforementioned functions. In specific implementations, the memory 130 can be integrated into the processor 110, or it can be independent of the processor 110.

[0043] In addition, to further enhance the functionality of the electronic device, it may also include one or more of an input unit 160, an audio circuit 180, and a sensor 101.

[0044] Optionally, the above-mentioned electronic device may also include a power supply 150 for providing power to various devices or circuits in the electronic device.

[0045] Understandable, Figure 1 The operation and / or function of each module in the illustrated electronic device are respectively for implementing the corresponding processes in the following method embodiments. For details, please refer to the descriptions in the following method embodiments; detailed descriptions are omitted here to avoid repetition.

[0046] Understandable, Figure 1 The processor 110 in the illustrated electronic device may include one or more processing units, such as an application processor (AP), 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 / or a neural network processing unit (NPU). These different processing units may be independent devices or integrated into one or more processors.

[0047] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0048] Understandable, Figure 1 The power supply 150 shown provides power to the processor 110, memory 130, display unit 170, input unit 160, etc. The display unit 170 displays images, videos, etc. The display unit 170 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a mini-LED, a micro-LED, a quantum dot light-emitting diode (QLED), etc. The memory 130 can be used to store computer executable program code, which includes instructions. The memory 130 can include a program storage area and a data storage area. The program storage area can store the operating system, at least one application program required for a function, etc. The data storage area can store data created during the use of the electronic device, etc. Furthermore, memory 130 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc. Processor 110 executes various functional applications and data processing of the electronic device by running instructions stored in memory 130 and / or instructions stored in memory configured within the processor. The electronic device may implement audio functions, such as music playback and recording, through audio circuitry 180 and application processors.

[0049] Figure 2 This is a schematic diagram of an electronic device 200 provided in an embodiment of this application. Figure 2As shown, the electronic device 200 includes multiple sensors, such as an infrared proximity sensor 201, an ultrasonic sensor 202, and an attitude sensor 203. The infrared proximity sensor 201 is a sensor that uses infrared light to detect the approach of an object; the ultrasonic sensor 202 is a sensor that uses ultrasonic signals to detect distance; and the attitude sensor 203 is a device capable of measuring the attitude of an object in space.

[0050] The following is combined Figure 2 and Figure 3 The device control method provided in this application is described.

[0051] Figure 3 This is a schematic flowchart of a device control method 300 provided in an embodiment of this application. Figure 3 As shown, the method 300 may include the following steps:

[0052] S301, acquire the first detection result determined by the ultrasonic sensor, acquire the second detection result determined by the infrared proximity sensor, and acquire the attitude data collected by the attitude sensor.

[0053] In some embodiments, the electronic device may, in response to a trigger operation, acquire a first detection result determined by the ultrasonic sensor and a second detection result determined by the infrared proximity sensor, and acquire attitude data collected by the attitude sensor.

[0054] In one possible scenario, the triggering operation could be an operation to turn on the electronic device. For example, a user could touch the power-on function component of the electronic device, so that the electronic device could respond to the touch operation of the power-on function button, obtain the above-mentioned detection results and posture data, and realize the detection of the distance between the electronic device and external objects, so as to control the screen state of the electronic device in a timely manner.

[0055] In another possible scenario, the trigger operation could also be the activation of the proximity detection function of the electronic device. For example, the user can touch the proximity detection function component of the electronic device, so that the electronic device can respond to the touch operation of the proximity detection function component, obtain the above detection results and posture data, and realize the detection of the distance between the electronic device and external objects, so as to control the screen state of the electronic device in a timely manner, meet the user's needs, and improve the user experience.

[0056] In other embodiments, the electronic device may also acquire a first detection result determined by the ultrasonic sensor and a second detection result determined by the infrared proximity sensor when it is determined to be in a preset mode, and acquire attitude data collected by the attitude sensor.

[0057] In one possible scenario, electronic devices can be categorized into sleep mode and non-sleep mode. In sleep mode, users are less likely to use electronic devices, such as during nighttime sleep when users rarely use them. In non-sleep mode, users are more likely to use electronic devices, such as during non-nighttime sleep when users use them for work or entertainment.

[0058] For example, if it is determined that the electronic device is in sleep mode, it can be inferred that the probability of the user using the electronic device is low, and the probability of accidental touch on the screen is also relatively low. Therefore, in a mode where the need for preventing accidental touches is not high, the operation of obtaining the detection results and posture data mentioned above can be omitted to reduce additional power consumption. Alternatively, if it is determined that the electronic device is in non-sleep mode, it can be inferred that the probability of the user using the electronic device is high, and the probability of accidental touch on the screen is also relatively high. Therefore, in a mode where the need for preventing accidental touches is high, the electronic device can be triggered to obtain the detection results and posture data mentioned above to determine the distance between external objects and the electronic device, control the screen state of the electronic device in a timely manner, reduce the probability of accidental touches, and improve the user experience.

[0059] In some embodiments, the electronic device may further include a call mode and a non-call mode. In call mode, the user typically uses the electronic device close to their head or ear. Conversely, in non-call mode, the user uses the electronic device away from their head or ear.

[0060] For example, when it is determined that the electronic device is in call mode, the probability of accidental touches on the screen is high because the user's head or ear is close to the device. Therefore, in modes where accidental touch prevention is crucial, the electronic device can be triggered to acquire the aforementioned detection results and posture data to determine the distance between external objects and the device, thereby controlling the screen state in a timely manner, reducing the probability of accidental touches, and improving the user experience. Alternatively, when it is determined that the electronic device is in non-call mode, the probability of accidental touches on the screen is relatively low because the user's head or ear is less likely to be in contact with the device. Therefore, in modes where accidental touch prevention is less critical, the operation of acquiring the aforementioned detection results and posture data can be omitted to reduce additional power consumption.

[0061] It should be understood that the preset modes shown above are merely exemplary. In addition, other specific modes may be used to trigger the above operations in different modes and realize device control in different modes. This application does not limit this.

[0062] Optionally, the electronic device can also acquire the aforementioned detection results and posture data upon receiving a preset instruction, and realize the detection of the distance between the electronic device and external objects, so as to control the screen status of the electronic device in a timely manner. The preset instruction can be a voice command for proximity detection, etc., and this application does not limit this to such cases.

[0063] In some embodiments, the electronic device can acquire in real time the first detection result determined by the ultrasonic sensor, the second detection result determined by the infrared proximity sensor, and the attitude data collected by the attitude sensor.

[0064] In other embodiments, the electronic device may also periodically acquire a first detection result determined by the ultrasonic sensor and a second detection result determined by the infrared proximity sensor, and acquire attitude data collected by the attitude sensor.

[0065] In some embodiments, the ultrasonic sensor 202 includes an ultrasonic transmitter and an ultrasonic receiver. The ultrasonic transmitter can be used to transmit ultrasonic signals, and the ultrasonic receiver can be used to receive reflected signals of the ultrasonic signals, so that the ultrasonic sensor 202 can determine a first detection result based on the transmission time between the ultrasonic signals and the reflected signals, for acquisition and application by an electronic device.

[0066] In one possible scenario, the first detection result includes distance information, which characterizes the distance between the external object and the electronic device. The smaller the distance information, the closer the external object is to the electronic device.

[0067] For example, different signal intensities of ultrasonic signals can correspond to different distances (such as a second correspondence). Therefore, the ultrasonic sensor can determine a first detection result including distance information based on the signal intensity of the ultrasonic signal received by the ultrasonic receiver and the aforementioned second correspondence, for acquisition and application by the electronic device. For instance, if the distance information is less than a first distance threshold, the first detection result indicates that an external object is approaching the electronic device; or, if the distance information is greater than or equal to a second distance threshold, the first detection result indicates that an external object is moving away from the electronic device, where the second distance threshold is greater than or equal to the first distance threshold.

[0068] In one possible scenario, the first detection result includes signal strength information of the ultrasonic signal, which can characterize the distance between the external object and the electronic device. The greater the signal strength of the ultrasonic signal, the closer the external object is to the electronic device.

[0069] For example, if the signal strength information of the ultrasonic signal is greater than a first ultrasonic signal threshold, the first detection result indicates that an external object is approaching the electronic device; or, if the signal strength information of the ultrasonic signal is less than or equal to a second ultrasonic signal threshold, the first detection result indicates that an external object is moving away from the electronic device, where the first ultrasonic signal threshold is greater than or equal to the second ultrasonic signal threshold.

[0070] Optionally, the first detection result may also include information about the distance between the external object and the electronic device. Such as "far away" or "near", or "1" (indicating far away) or "0" (indicating near), which can characterize whether the external object is far away from or near the electronic device, so that the electronic device can know the distance between the external object and the electronic device without any data processing when it receives the first detection result.

[0071] In some embodiments, the infrared proximity sensor 201 may include an infrared emitter and an infrared receiver. The infrared emitter emits an infrared light signal, and when the infrared light signal encounters an external object, a portion of the infrared light signal is reflected and received by the infrared receiver. The infrared proximity sensor 201 can determine the aforementioned second detection result from the received infrared light signal for acquisition and application by an electronic device.

[0072] Figure 4 This is a schematic diagram illustrating the proximity detection of an infrared proximity sensor provided in an embodiment of this application. Figure 4 As shown, the horizontal axis represents distance, which is the distance measured when the infrared proximity sensor detects an approaching external object. The vertical axis represents the infrared light intensity value (PS value), which characterizes the signal strength of the infrared light signal detected by the infrared proximity sensor after being reflected back from an external object. When there is no external object in front of the infrared proximity sensor, the PS value is low (e.g., close to 0), while when an external object approaches and blocks the infrared proximity sensor, the PS value is high (e.g., close to 2047).

[0073] In one possible scenario, the second detection result may include signal strength information of the infrared light signal, which can characterize the distance between the external object and the electronic device. The higher the signal strength of the infrared light signal, the closer the external object is to the electronic device.

[0074] like Figure 4As shown, a proximity threshold (such as a first infrared light signal threshold) and a distance threshold (such as a second infrared light signal threshold) are set. When the signal strength information of the infrared light signal is greater than the first infrared light signal threshold, the signal strength information of the infrared light signal can indicate that an external object is approaching the electronic device; or, when the signal strength information of the infrared light signal is less than or equal to the second infrared light signal threshold, the signal strength information of the infrared light signal can also indicate that an external object is moving away from the electronic device, wherein the first infrared light signal threshold is greater than or equal to the second infrared light signal threshold.

[0075] In another possible scenario, the second detection result includes distance information, which characterizes the distance between the external object and the electronic device. The smaller the distance, the closer the external object is to the electronic device.

[0076] like Figure 4 As shown, different signal intensities of infrared light signals can correspond to different distances (such as the first correspondence). Therefore, the infrared proximity sensor can determine a second detection result, including distance, based on the signal intensity of the infrared light signal received by the infrared receiver and the aforementioned first correspondence, for acquisition and application by electronic devices. For example, if the distance information is less than a third distance threshold, the second detection result indicates that an external object is approaching the electronic device; or, if the distance information is greater than or equal to a fourth distance threshold, the second detection result indicates that an external object is moving away from the electronic device, where the fourth distance threshold is greater than or equal to the third distance threshold.

[0077] It should be understood that during the actual proximity detection process of infrared proximity sensors, environmental factors in practical applications can also be considered, and adjustments can be made through corresponding designs and algorithms to improve the performance and reliability of infrared proximity sensors.

[0078] For example, such as Figure 4The terms "gray card," "black card," and "oil stain" shown refer to environmental factors encountered by infrared proximity sensors in practical applications. A gray card typically refers to an object with moderate reflectivity. Its role in infrared proximity sensors is to provide a baseline reflectivity for calibration. In other words, because the reflectivity of a gray card is neither particularly high nor particularly low, it serves as a reference point, helping the infrared proximity sensor maintain consistent performance in different environments. A black card refers to an object with very low reflectivity, such as black hair or a black surface. Since black objects absorb infrared light rather than reflect it, this can reduce the signal received by the infrared receiver of the proximity sensor, thus affecting its performance. Oil stains typically refer to grease accumulated on or near the surface of the infrared proximity sensor. This grease can interfere with the infrared light emitted by the sensor, leading to false alarms. For example, grease may absorb or scatter infrared light, causing the proximity sensor to perceive an approaching object, even when no object is actually present.

[0079] Optionally, the second detection result may also include information about the distance between the external object and the electronic device. For example, "far away" or "near," "1" (indicating far away) or "0" (indicating near) can indicate whether the external object is far away from or near the electronic device, so that the electronic device can know the distance between the external object and the electronic device without any data processing upon receiving the second detection result.

[0080] In some embodiments, the attitude sensor 203 includes an accelerometer and an angular velocity sensor, and the attitude data may include acceleration data and angular velocity data. That is, the accelerometer can collect acceleration data, and the angular velocity sensor can collect angular velocity data.

[0081] An angular velocity sensor can be designed based on the law of conservation of angular momentum, and determines the rotational state of an object by detecting the angular velocity generated when the object rotates around three axes.

[0082] Accelerometers can use the inertial force generated when a mass is affected by gravitational acceleration to determine the degree of tilt of an object.

[0083] S302, based on at least one of the first detection result, the second detection result, and the attitude data, a target detection result is obtained, which is used to indicate whether an external object is approaching or moving away from the electronic device.

[0084] In some embodiments, the external object may include at least one object other than the electronic device that can provide a touch response.

[0085] For example, the external object can be a user's hand, head, ear, or other body part.

[0086] Alternatively, the external object can also be other electronic devices used to perform touch operations (such as touch devices), such as styluses.

[0087] It should be understood that the external objects shown above are merely exemplary. In addition, other external objects may be determined according to the specific use scenario. For example, in the range measurement scenario, any external object that does not have a touch control effect may also be included. This application does not limit this.

[0088] In some embodiments, the electronic device may obtain a target detection result based on a first detection result, a second detection result, and attitude data, which is used to indicate whether an external object is approaching or moving away from the electronic device.

[0089] For example, when the electronic device is in call mode, if a first detection result indicates that an external object is approaching the electronic device, a second detection result indicates that an external object is approaching the electronic device, and the posture corresponding to the electronic device being in call mode (such as answering posture) is identified based on the posture data, a target detection result is obtained, and the target detection result is used to indicate that an external object is approaching the electronic device.

[0090] In some embodiments, the electronic device may also obtain a target detection result based on two of the first detection result, the second detection result, and the attitude data, which is used to indicate whether an external object is approaching or moving away from the electronic device.

[0091] For example, since both the first detection result and the second proximity detection are obtained by detecting the distance between the same electronic device and an external object, under normal circumstances, the two detection results are the same, such as both indicating that the external object is moving away from the electronic device or both indicating that the external object is approaching the electronic device. Therefore, this application can enable the first detection result and the second detection result to verify each other, so as to achieve efficient and accurate judgment of the distance between the electronic device and the external object. If the electronic device is in call mode, and it is determined that the first detection result indicates that the external object is approaching the electronic device and the second detection result indicates that the external object is approaching the electronic device, since both indicate that the external object is approaching the electronic device, it can be deduced that the probability of the two detection results being wrong is not high. Therefore, the target detection result can be determined efficiently and accurately as the external object approaching the electronic device, and the screen state of the electronic device can be controlled in a timely manner, such as putting the screen in a screen-off state, so as to reduce the probability of accidental touch on the display screen of the electronic device in the scenario where the external object is approaching the electronic device.

[0092] Similarly, if an electronic device is in call mode, and the first detection result indicates that an external object is approaching the device, and the posture data identifies the device as being in a call-answering posture, then the target detection result can be determined to be an external object approaching the device. The screen state of the device can then be controlled in a timely manner, such as turning off the screen, to reduce the probability of accidental touches on the device's display screen in scenarios where an external object is approaching. Alternatively, if the second detection result indicates that an external object is approaching the device, and the posture data identifies the device as being in a call-answering posture, then the target detection result can also be determined to be an external object approaching the device, and the screen state of the device can be controlled in a timely manner.

[0093] In some embodiments, the electronic device may also obtain a target detection result based on one of a first detection result, a second detection result, and attitude data, which is used to indicate whether an external object is approaching or moving away from the electronic device.

[0094] For example, when an electronic device is in call mode, the user's head or ear is usually close to the device, meaning there is a high probability that an external object is near the device. However, to accurately identify whether an external object is near the device, further verification can be performed using the first detection result in the current mode. If the first detection result indicates that an external object is near the device, it can be verified that the user's head or ear is near the device, thus confirming that the target detection result is that an external object is near the device.

[0095] For example, when an electronic device is in call mode, the user's head or ear is usually close to the device, meaning there is a high probability that an external object is near the device. However, to accurately identify whether an external object is near the device, further verification can be performed using a second detection result in the current mode. If the second detection result indicates that an external object is near the device, it can be verified that the user's head or ear is near the device, thus confirming that the target detection result is that an external object is near the device.

[0096] For example, when an electronic device is in call mode, the user's head or ear is usually close to the device, meaning there is a high probability that an external object is near the device. However, to accurately identify whether an external object is near the device, further verification can be performed using posture data in the current mode. For instance, by identifying the posture corresponding to the electronic device being in call mode (such as the answering posture) based on the posture data, it can be verified that the user's head or ear is close to the device, thus confirming that the target detection result is that an external object is near the device.

[0097] Similarly, the electronic device can also obtain a target detection result to indicate that an external object is moving away from the electronic device based on at least one of the first detection result, the second detection result, and the attitude data.

[0098] S303, based on the target detection result, control the screen state of the electronic device, which includes a screen off state or a screen on state.

[0099] In some embodiments, when the target detection result indicates that an external object is approaching the electronic device, the screen state of the electronic device can be controlled to be off; and / or, when the target detection result indicates that an external object is moving away from the electronic device, the screen state of the electronic device can be controlled to be on.

[0100] For example, when the external object is the user's head or ear, if the object is close to the electronic device, it can be inferred that the user is likely to want to listen to the audio on the device. Therefore, the screen of the electronic device can be kept off to prevent accidental touches from the screen while the user can listen to the audio. Alternatively, if the object is far from the electronic device, it can be inferred that the user is more likely to use the device but less likely to want to listen to the audio. In this case, the screen can be kept on to prevent the screen from being off and disrupting the user's continuity of use, thus affecting the user experience.

[0101] In another embodiment, when the target detection result indicates that an external object is approaching the electronic device, the screen state of the electronic device can also be controlled to be on; and / or, when the target detection result indicates that an external object is moving away from the electronic device, the screen state of the electronic device can also be controlled to be off.

[0102] For example, when the external object is a user's hand or a touch device (such as a stylus), if the external object is close to the electronic device, it can be inferred that the user is likely to want to perform touch operations on the electronic device to achieve the desired function. Therefore, the screen of the electronic device can be kept on to allow the user to quickly perform touch operations and improve the user experience. Alternatively, if the external object is far away from the electronic device, it can be inferred that the user is unlikely to want to perform touch operations on the electronic device to achieve the desired function. Therefore, the screen of the electronic device can be kept off to avoid the extra power consumption caused by the screen being on for a long time, and also to reduce the probability of accidental touches on the display screen of the electronic device by external objects other than the user's hand or touch device while the screen is on.

[0103] In this application, an electronic device can obtain a target detection result based on at least one of a first detection result, a second detection result, and attitude data. This target detection result indicates whether an external object is approaching or moving away from the electronic device, and the screen state of the electronic device is controlled to be either off or on based on the target detection result. Specifically, the first detection result is determined by an ultrasonic sensor, the second detection result is determined by an infrared proximity sensor, and the attitude data is collected by an attitude sensor. This allows the electronic device to comprehensively analyze the first detection result from the infrared proximity sensor, the second detection result from the ultrasonic sensor, and the attitude data collected by the attitude sensor to more accurately identify whether an external object is approaching or moving away from the electronic device, thereby achieving precise control over the screen state of the electronic device.

[0104] The following section provides a detailed description of the device control method provided in this application, primarily in the call mode.

[0105] Figure 5 This is a schematic flowchart of a device control method 500 provided in an embodiment of this application. Figure 5 As shown, the method 500 may include the following steps:

[0106] S501, when the electronic device is in call mode, acquires the first detection result determined by the ultrasonic sensor, acquires the second detection result determined by the infrared proximity sensor, and acquires the attitude data collected by the attitude sensor.

[0107] In some embodiments, the call mode may include at least one of an incoming call mode, an outgoing call mode, and a call in progress mode.

[0108] Incoming call mode refers to the ringing phase of a phone call, where the electronic device receives a call request and is in a waiting state. During this phase, the electronic device can emit a ringtone or vibration to alert the user. The user can choose to answer the call, hang up, or ignore it.

[0109] In one possible implementation, the electronic device can identify that it is in call mode based on the ringing status, received call requests, etc.

[0110] Outgoing call mode refers to the state where a user sends a call request through an electronic device. After the user enters a phone number and dials, the electronic device attempts to connect to another electronic device. During this stage, the electronic device may display a "Dialing" or "Connecting" message. If the called party answers, the call enters "In Call Mode"; if the called party does not answer or the call cannot be established, the electronic device may display a "Busy" or "Not Connected" message.

[0111] In some embodiments, an electronic device may identify that it is in outgoing call mode by a call request or the aforementioned status alert (such as "dialing").

[0112] "In-call mode" refers to a situation where a call (telephone) has been connected, meaning the user is currently talking to another electronic device through this device. In this mode, the user can engage in normal voice communication through this electronic device.

[0113] In some embodiments, an electronic device can identify that it is in a call mode through status alerts (such as "on call").

[0114] In one possible scenario, the call mode includes a normal call mode, where a user engages in normal voice communication with a user on another electronic device through their current electronic device.

[0115] In one possible scenario, the call mode includes a hold mode, where one party's electronic device holds the call, temporarily suspending the call, but the call is not ended.

[0116] In one possible scenario, the call mode includes a silent call mode, where the microphone of one or both electronic devices in the call is turned off, but the call continues.

[0117] In one possible scenario, the call mode includes a call transfer mode, where the call is transferred to another number or electronic device.

[0118] S502, based on at least one of the first detection result, the second detection result, and the attitude data, obtain the target detection result.

[0119] S503, determine whether the target detection result is used to indicate that an external object is approaching the electronic device.

[0120] S504, when the target detection result indicates that an external object is approaching the electronic device, control the screen state of the electronic device to be off.

[0121] Optionally, following the above S503, if the target detection result indicates that an external object is far away from the electronic device, the electronic device may also execute the following S505.

[0122] S505, when the target detection result indicates that an external object is moving away from the electronic device, the screen state of the electronic device is controlled to be on.

[0123] In this embodiment, when the electronic device is in call mode, a target detection result can be obtained based on at least one of a first detection result, a second detection result, and posture data. If the target detection result indicates that an external object is approaching the electronic device, the screen of the electronic device is controlled to be off; or, if the target detection result indicates that an external object is moving away from the electronic device, the screen of the electronic device is controlled to be on. The electronic device can acquire the first detection result determined by an ultrasonic sensor, the second detection result determined by an infrared proximity sensor, and posture data collected by a posture sensor. By using multiple sensors, the distance between the external object and the electronic device can be flexibly detected, enabling accurate control of the screen state of the electronic device in call mode. This avoids accidental control of the screen state, preventing issues that could affect normal user operation.

[0124] In some embodiments, the electronic device can determine a reference result among the first detection result, the second detection result and the attitude data (such as attitude result), i.e., at least one of the first detection result, the second detection result and the attitude data, and obtain a target detection result based on the reference result.

[0125] Figure 6 This is a schematic flowchart of a device control method 600 provided in an embodiment of this application. Figure 6 As shown, the method 600 may include the following steps:

[0126] S601, acquire the first detection result determined by the ultrasonic sensor, acquire the second detection result determined by the infrared proximity sensor, and acquire the attitude data collected by the attitude sensor.

[0127] S602, determine whether the first detection result and the second detection result are the same.

[0128] In some embodiments, the first detection result here is the same as the second detection result, which can be understood as the external objects and electronic devices indicated by the first detection result and the second detection result being in the same remote relationship.

[0129] For example, if both the first detection result and the second detection result indicate that the external object is moving away from the electronic device, it can be determined that the first detection result and the second detection result are the same. Alternatively, if both the first detection result and the second detection result indicate that the external object is approaching the electronic device, it can also be determined that the first detection result and the second detection result are the same.

[0130] In some embodiments, where the first detection result includes signal strength information of an ultrasonic signal and the second detection result includes signal strength information of an infrared light signal, the same here can also be understood as the signal strength information of the ultrasonic signal matching the signal strength information of the infrared light signal.

[0131] For example, the signal intensity information of different ultrasonic signals can characterize the distance between an external object and an electronic device, and the signal intensity information of different infrared light signals can also characterize the distance between an external object and an electronic device. The signal intensity information of infrared light signals characterizing the same distance is matched with the signal intensity information of ultrasonic signals.

[0132] In some embodiments, where the first detection result includes distance information (such as first distance information) and the second detection result includes distance information (such as second distance information), the sameness here can also be understood as the first distance information matching the second distance information.

[0133] For example, both the first distance information and the second distance information here can characterize the distance relationship between an external object and an electronic device. The first distance information and the second distance information that characterize the same distance relationship are matched, and the matched first distance information and the second distance information can be the same or different, such as the difference being less than the distance difference threshold.

[0134] Optionally, the sameness here can also be understood as the matching of the first distance information with the signal intensity information of infrared light, or the matching of the second distance information with the signal intensity information of ultrasonic signal. This application does not limit this.

[0135] S603, if the first detection result and the second detection result are the same, obtain the target detection result based on the first detection result or the second detection result.

[0136] In some embodiments, when the first detection result and the second detection result are the same, it can be determined that the detection result determined by the infrared proximity sensor and the ultrasonic sensor is more accurate, so the target detection result can be determined as the first detection result or the second detection result.

[0137] In one possible scenario, the first detection result indicates that the external object is moving away from the electronic device, and the second detection result indicates that the external object is moving away from the electronic device.

[0138] For example, if both the first and second detection results indicate that an external object is moving away from the electronic device, and if in call mode, it can be inferred that the probability of the electronic device being close to the user's head or ear is low (e.g., the call is about to end or the user is answering the call with the speakerphone on), then the target detection result can be determined to be either the first or second detection result indicating that an external object is moving away from the electronic device.

[0139] In another possible scenario, the first detection result indicates that an external object is approaching the electronic device, and the second detection result indicates that an external object is approaching the electronic device.

[0140] For example, if both the first detection result and the second detection result indicate that an external object is approaching the electronic device, and if it is in call mode, it can be inferred that the probability of the electronic device being close to the user's head or ear is relatively high, that is, the external object is the user's head or ear. Therefore, the target detection result can be determined as the first detection result or the second detection result indicating that an external object is approaching the electronic device.

[0141] Optionally, if it is determined that the first detection result and the second detection result are different, the electronic device may also execute S604.

[0142] S604, if it is determined that the first detection result and the second detection result are different, the above-mentioned target detection result is obtained based on the first detection result, the second detection result and the attitude data.

[0143] In one possible implementation, if the first detection result and the second detection result are different, since the first detection result and the second detection result indicate different distance relationships between the external object and the electronic device, it can be concluded that the detection result determined by the infrared proximity sensor or the ultrasonic sensor is incorrect. To avoid erroneous detection results leading to miscontrol of the screen state of the electronic device, the electronic device can further consider the attitude data collected by the attitude sensor based on the first detection result and the second detection result, so as to obtain the target detection result by combining the first detection result, the second detection result, and the attitude data.

[0144] In one possible scenario, the first detection result may differ from the second detection result, and may include the first detection result indicating that an external object is moving away from the electronic device, while the second detection result indicates that an external object is approaching the electronic device.

[0145] For example, if the first detection result indicates that the external object is away from the electronic device and the second detection result indicates that the external object is close to the electronic device, if the electronic device is in a call mode and the posture data indicates that the electronic device is in a call-answering posture, it can be inferred that the probability of the electronic device being close to the user's head or ear is high, that is, the external object is the user's head or ear. The accuracy of the first detection result determined by the ultrasonic sensor that the external object is away from the electronic device is not high, so the target detection result can be determined to be that the external object is close to the electronic device.

[0146] For example, if the first detection result indicates that an external object is away from the electronic device and the second detection result indicates that an external object is close to the electronic device, and if the electronic device is not in a call posture based on the posture data in call mode, it can be inferred that the probability of the electronic device being close to the user's head or ear is low, and it can be further determined that the accuracy of the second detection result determined by the infrared proximity sensor is not high. Therefore, it can be determined that the target detection result is that the external object is away from the electronic device.

[0147] In another possible scenario, the first detection result may differ from the second detection result, and may also include a situation where the first detection result indicates that an external object is approaching the electronic device, while the second detection result indicates that the external object is moving away from the electronic device.

[0148] For example, if the first detection result indicates that an external object is approaching the electronic device and the second detection result indicates that the external object is moving away from the electronic device, and if the electronic device is in a call mode and the posture data indicates that the electronic device is in a call-answering posture, it can be inferred that the probability of the electronic device being close to the user's head or ear is high, and it can be further determined that the accuracy of the second detection result determined by the infrared proximity sensor is not high. Therefore, it can be determined that the target detection result is that an external object is approaching the electronic device.

[0149] For example, if the first detection result indicates that an external object is approaching the electronic device and the second detection result indicates that an external object is moving away from the electronic device, and if the electronic device is not in a call-answering posture based on the posture data, it can be inferred that the probability of the electronic device being close to the user's head or ear is low, and it can be further determined that the accuracy of the first detection result determined by the ultrasonic sensor is not high. Therefore, it can be determined that the target detection result is that the external object is moving away from the electronic device.

[0150] It should be understood that the answering posture shown above is merely exemplary. In addition, the corresponding posture can be identified according to the specific usage mode or scenario, and the target detection result can be determined to achieve the device control method provided in this application. This application does not limit this.

[0151] S605, based on the target detection result, controls the screen state of the electronic device, which includes a screen off state or a screen on state.

[0152] For example, in call mode, if the target detection result indicates that an external object is approaching the electronic device, it can be deduced that the probability of the user's head or ear approaching the electronic device to make a call is relatively high. In order to avoid the user's head or ear accidentally touching the display screen of the electronic device, the screen state of the electronic device can be controlled to be off.

[0153] For example, in call mode, if the target detection result indicates that the external object is far away from the electronic device, it can be deduced that the probability of the user's head or ear being close to the electronic device to make a call is low. In order to avoid the electronic device's screen being off and affecting the user experience, the screen state of the electronic device can also be controlled to be on.

[0154] In this embodiment, the electronic device can obtain a target detection result based on at least one of the first detection result, the second detection result, and attitude data (such as a reference result), and thus control the screen state of the electronic device. The reference result is determined by the electronic device based on the first and second detection results. For example, if the first and second detection results are the same, it can be confirmed that the detection result determined by the infrared proximity sensor and the detection result determined by the ultrasonic sensor have high accuracy. In this case, the target detection result can be determined based on the first and / or second detection results. Alternatively, if the first and second detection results are different, it can be confirmed that at least one of the detection results determined by the infrared proximity sensor and the ultrasonic sensor is incorrect. To improve the accuracy of device control, in this case, the electronic device can obtain the target detection result based on the first, second, and attitude data. That is, by cross-checking the results determined by multiple sensors, the reference result is determined, and an accurate target detection result is obtained based on this reference result, thus achieving accurate control of the screen state of the electronic device.

[0155] In some embodiments, the electronic device may also acquire the target detection result based on the second detection result.

[0156] Figure 7 This is a schematic flowchart of a device control method 700 provided in an embodiment of this application. Figure 7As shown, the method 700 may include the following steps:

[0157] S701, acquire the first detection result determined by the ultrasonic sensor, acquire the second detection result determined by the infrared proximity sensor, and acquire the attitude data collected by the attitude sensor.

[0158] S702, determine whether the second detection result indicates that an external object is approaching the electronic device.

[0159] In some embodiments, the second detection result includes signal strength information of the infrared light signal. The electronic device can determine whether the drop detection result indicates that an external object is approaching the electronic device based on the relationship between this signal strength information and the infrared light signal threshold.

[0160] In some embodiments, the second detection result includes distance information. The electronic device can determine, based on this distance information and a distance threshold, whether the second detection result indicates that an external object is approaching the electronic device.

[0161] S703, if it is determined that the second detection result indicates that an external object is approaching the electronic device, the target detection result is determined to indicate that an external object is approaching the electronic device.

[0162] When the second detection result includes the signal strength information of the infrared light signal, if the signal strength information of the infrared light signal is greater than the first infrared light signal threshold, the signal strength information of the infrared light signal can indicate that an external object is approaching the electronic device, that is, the second detection result indicates that an external object is approaching the electronic device; or, if the signal strength information of the infrared light signal is less than or equal to the second infrared light signal threshold, the signal strength information of the infrared light signal can also indicate that an external object is moving away from the electronic device, that is, the second detection result is used to indicate that an external object is moving away from the electronic device, and the first infrared light signal threshold is greater than or equal to the second infrared light signal threshold.

[0163] If the second detection result includes distance information, and the distance information is less than the third distance threshold, the distance information can indicate that an external object is approaching the electronic device, i.e., the second detection result indicates that an external object is approaching the electronic device; or, if the distance information is greater than or equal to the fourth distance threshold, the distance information can indicate that an external object is moving away from the electronic device, i.e., the second detection result indicates that an external object is moving away from the electronic device, and the fourth distance threshold is greater than or equal to the third distance threshold.

[0164] Optionally, if the second detection result does not indicate that an external object is approaching the electronic device, the electronic device may also execute S704.

[0165] S704, based on the first detection result and the second detection result, determine a reference result from the first detection result, the second detection result and the attitude data.

[0166] For specific details, please refer to the above embodiments. Figure 6 To avoid repetition, the description will not be repeated here.

[0167] S705, the target detection result is obtained based on this reference result.

[0168] For specific details, please refer to the above embodiments. Figure 6 To avoid repetition, the description will not be repeated here.

[0169] S706, based on the target detection result, controls the screen state of the electronic device, which includes a screen off state or a screen on state.

[0170] In this embodiment of the application, the electronic device can also flexibly obtain a target detection result based on the second detection result. For example, if the second detection result indicates that an external object is approaching the electronic device, the target detection result is determined to indicate that an external object is approaching the electronic device, and the screen state of the electronic device is controlled based on the target detection result. For example, in call mode, the screen state of the electronic device is controlled to be off to reduce the probability of accidental touch on the screen of the electronic device.

[0171] Figure 8 This is a schematic diagram of the electronic device 800 provided in this application. Figure 8 The electronic device 800 includes an ultrasonic sensor 801, an attitude sensor 802, an infrared proximity sensor 803, and a proximity detection virtual sensor 804.

[0172] In some embodiments, such as Figure 8 As shown, the ultrasonic sensor 801 may include an ultrasonic transmitting unit and an ultrasonic receiving unit. The ultrasonic transmitting unit includes a handset 811, and the ultrasonic receiving unit includes a microphone 812, enabling the transmission and reception of ultrasonic signals solely based on existing audio hardware and software algorithms within the electronic device, without requiring additional hardware sensors. For example, the ultrasonic sensor 801 can transmit ultrasonic signals through the handset 811, receive the reflected signals of the ultrasonic signals through the microphone 812, and determine a first detection result based on the transmission time between the ultrasonic signal and the reflected signal, for acquisition and application by the electronic device. The attitude sensor 802 includes an accelerometer 821 and a gyroscope 822. The electronic device can acquire acceleration and angular velocity data collected by the accelerometer 821 and the gyroscope 822, acquire a second detection result determined by the infrared proximity sensor 803, and obtain the aforementioned target detection result based on the first detection result, the second detection result, and the attitude data, thereby achieving device control. See details below. Figure 9 .

[0173] Figure 9 This is a schematic diagram of the device control method provided in this application. Figure 9 As shown, the earpiece 811 in the ultrasonic sensor 801 can emit ultrasonic signals, and the microphone 812 can receive ultrasonic signals, i.e., the reflected signals of the ultrasonic signals. Based on the transmission time between the ultrasonic signals and the reflected signals, a first detection result, such as distance information, is obtained. The accelerometer sensor can collect acceleration data, the gyroscope sensor 822 can collect angular velocity data, and the infrared proximity sensor 803 can determine a second detection result. For specific details, please refer to the above embodiments; to avoid repetition, they will not be repeated here. Figure 9 As shown, the proximity detection virtual sensor 804 can acquire the first detection result, the second detection result, and attitude data (angular velocity data and acceleration data), and based on at least one of the first detection result, the second detection result, and the attitude data, obtain the target detection result and realize the control of the screen state of the electronic device.

[0174] It should be understood that when the electronic device is in call mode, the proximity detection virtual sensor 804 can also be referred to as the call mode detection virtual sensor.

[0175] Figure 10 This is a schematic diagram of the software architecture of an electronic device 1000 provided in an embodiment of this application. The layered architecture divides the software system of the electronic device 1000 into several layers, each with a clear role and division of labor. Layers communicate with each other through software interfaces. In this embodiment, the system can be divided into four layers: the application layer, the application framework layer (framework layer), the algorithm layer, the device driver layer, and the device layer. Figure 10 As shown, the application layer includes applications, and the application framework layer includes a proximity detection sensor service module. When an electronic device registers with the application to monitor the virtual proximity detection sensor for the call mode, the proximity detection sensor service module can activate the virtual proximity detection sensor for the call mode and the ultrasonic algorithm detection function upon receiving the registration and monitoring instruction. Figure 10 As shown, the algorithm layer includes a proximity detection virtual sensor and an ultrasonic detection algorithm engine. The device layer includes a microphone, earpiece, infrared proximity sensor, and attitude sensors, such as accelerometers and gyroscopes. The device driving layer includes an ultrasonic driver, an infrared proximity sensor driver, and an attitude sensor driver. Specifically, the ultrasonic driver is used to turn the microphone and earpiece on or off. The ultrasonic driver may further include a microphone driver and an earpiece driver, with the microphone driver turning the microphone on or off and the earpiece driver turning the earpiece on or off. The infrared proximity sensor driver is used to turn the infrared proximity sensor on or off, and the attitude sensor driver is used to turn the attitude sensor on or off. See details below. Figure 11 .

[0176] Figure 11 This is a schematic flowchart illustrating a device control method 1100 in call mode provided in an embodiment of this application. Figure 11 As shown, the method 1100 may include the following steps:

[0177] S1101, when the electronic device is in call mode, the system application in the application layer sends a registration instruction to the proximity detection sensor service module in the framework layer to listen to the virtual proximity detection sensor in this call mode. Correspondingly, the proximity detection sensor service module in the framework layer receives the registration instruction.

[0178] S1102, the proximity detection sensor service module in the framework layer sends an activation command to the call mode proximity detection virtual sensor in the algorithm layer based on the registration listening command. Correspondingly, the call mode proximity detection sensor in the algorithm layer receives the activation command.

[0179] S1103, the proximity detection sensor service module in the framework layer sends a command to the ultrasonic driver in the device driver layer to enable the ultrasonic algorithm detection function based on the registration listening command. Correspondingly, the ultrasonic driver in the device driver layer receives the command to enable the ultrasonic algorithm detection function.

[0180] S1104, the call mode proximity detection sensor in the algorithm layer sends a proximity detection command to the infrared proximity sensor driver in the device driver layer based on the activation command. Correspondingly, the infrared proximity sensor driver in the device driver layer receives the proximity detection command.

[0181] S1105, the proximity detection sensor in the call mode of the algorithm layer sends a proximity detection command to the attitude sensor driver in the device driver layer based on the activation command. Correspondingly, the attitude sensor driver in the device driver layer receives the proximity detection command.

[0182] S1106, the ultrasonic driver in the device driver layer sends a command to the earpiece in the device layer to transmit an ultrasonic signal based on the command to enable the ultrasonic algorithm detection function. Correspondingly, the earpiece in the device layer receives the command to transmit the ultrasonic signal.

[0183] S1107, the ultrasonic driver in the device driver layer sends a command to the microphone in the device layer to receive ultrasonic signals based on the command to enable the ultrasonic algorithm detection function. Correspondingly, the microphone in the device layer receives the command to receive ultrasonic signals.

[0184] S1108, the infrared proximity sensor driver in the device driving layer sends an enable command to the infrared proximity sensor in the device layer based on the proximity detection command. Correspondingly, the infrared proximity sensor in the device layer receives the enable command.

[0185] S1109, the attitude sensor driver in the device driver layer sends an enable command to the attitude sensor in the device layer based on the proximity detection command. Correspondingly, the attitude sensor in the device layer receives the enable command.

[0186] S1110, the earpiece in the device layer emits an ultrasonic signal, and the microphone receives the reflected ultrasonic signal.

[0187] S1111, the microphone in the device layer sends the reflected ultrasonic signal to the ultrasonic driver in the device driver layer. Correspondingly, the ultrasonic driver in the device driver layer receives the reflected ultrasonic signal.

[0188] S1112, the ultrasonic driver in the device driver layer sends the reflected signal of the ultrasonic signal to the ultrasonic detection algorithm module in the algorithm layer. Correspondingly, the ultrasonic detection algorithm module in the algorithm layer receives the reflected signal of the ultrasonic signal.

[0189] S1113, the ultrasonic detection algorithm module in the algorithm layer determines the first detection result based on the reflected signal of the ultrasonic signal.

[0190] S1114, the infrared proximity sensor in the device layer determines the second detection result, and the attitude sensor collects attitude data.

[0191] In step S1115, the infrared proximity sensor in the device layer sends the second detection result to the infrared proximity sensor driver, and the attitude sensor sends the attitude data to the attitude sensor driver. Correspondingly, the infrared receiving sensor driver in the device driver layer receives the second detection result, and the attitude sensor driver receives the attitude data.

[0192] S1116, the ultrasonic detection algorithm module in the algorithm layer sends the first detection result to the call proximity detection virtual sensor. Correspondingly, the call mode proximity detection virtual sensor receives the first detection result.

[0193] S1117, the infrared proximity sensor driver in the device driver layer sends the second detection result to the call mode proximity detection virtual sensor in the algorithm layer, and the attitude sensor driver sends the attitude data to the call mode proximity detection virtual sensor in the algorithm layer. Correspondingly, the call mode proximity detection virtual sensor in the algorithm layer receives the second detection result and the attitude data.

[0194] S1118, the virtual sensor for call mode proximity detection in the algorithm layer obtains the target detection result based on the posture data, the first detection result, and the second detection result.

[0195] S1119, the virtual proximity detection sensor in the call mode of the algorithm layer sends the target detection result to the proximity detection sensor service module in the framework layer. Correspondingly, the proximity detection sensor service module in the framework layer receives the target detection result.

[0196] S1120, the proximity detection sensor service module in the framework layer reports the target detection result to the system application in the application layer. Correspondingly, the system application in the application layer receives the target detection result.

[0197] S1121, The system application in the application layer controls the screen state of the electronic device based on the target detection results.

[0198] It should be understood that the various embodiments described above can also be coupled to each other, and this application does not limit this. Furthermore, the sequence number of each process does not imply 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 this application.

[0199] The above text combines Figures 1 to 11 The present application describes in detail the device control method according to the embodiments of this application. The following will be combined with... Figure 12 and Figure 13 The present application describes in detail the device control apparatus of the embodiments.

[0200] Figure 12 An embodiment of this application illustrates a device control apparatus 1200. The device control apparatus 1200 includes an acquisition module 1201 and a processing module 1202. The acquisition module 1201 is configured to: acquire a first detection result determined by an ultrasonic sensor, acquire a second detection result determined by an infrared proximity sensor, and acquire attitude data collected by an attitude sensor. The processing module 1202 is configured to: obtain a target detection result based on at least one of the first detection result, the second detection result, and the attitude data, the target detection result indicating whether an external object is approaching or moving away from the electronic device; and control the screen state of the electronic device according to the target detection result, the screen state including a screen-off state or a screen-on state.

[0201] Optionally, the acquisition module 1201 is configured to: acquire the first detection result determined by the ultrasonic sensor and the second detection result determined by the infrared proximity sensor when the electronic device is in call mode, and acquire the attitude data collected by the attitude sensor; the processing module 1202 is configured to: control the screen state of the electronic device to the off state when the target detection result indicates that an external object is approaching the electronic device; and / or, control the screen state of the electronic device to the on state when the target detection result indicates that an external object is moving away from the electronic device.

[0202] Optionally, the processing module 1202 is configured to: determine the target detection result as the first detection result or the second detection result when the first detection result is the same as the second detection result; or, when the first detection result is determined to be different from the second detection result, obtain the target detection result based on the first detection result, the second detection result and the attitude data.

[0203] Optionally, the processing module 1202 is configured to: indicate that the first detection result indicates that the external object is moving away from the electronic device, and that the second detection result indicates that the external object is approaching the electronic device; or, in the case where the first detection result indicates that the external object is approaching the electronic device, and the second detection result indicates that the external object is moving away from the electronic device.

[0204] Optionally, the processing module 1202 is configured to: when the first detection result indicates that an external object is approaching the electronic device and the second detection result indicates that an external object is moving away from the electronic device, if the electronic device is identified as being in an answering posture based on the posture data, then determine that the target detection result is that an external object is approaching the electronic device; and / or, when the first detection result indicates that an external object is approaching the electronic device and the second detection result indicates that an external object is moving away from the electronic device, if the electronic device is identified as not being in an answering posture based on the posture data, then determine that the target detection result is that an external object is moving away from the electronic device.

[0205] Optionally, the processing module 1202 is configured to: determine the target detection result as indicating that an external object is approaching the electronic device when the second detection result indicates that an external object is approaching the electronic device.

[0206] Optionally, the ultrasonic sensor includes an ultrasonic transmitting unit and an ultrasonic receiving unit. The ultrasonic transmitting unit includes an earpiece, and the ultrasonic receiving unit includes a microphone. The first detection result includes distance information. The processing module 1202 is configured to: transmit an ultrasonic signal through the earpiece; receive the reflected signal of the ultrasonic signal through the microphone; and obtain the distance information based on the transmission time between the ultrasonic signal and the reflected signal. Wherein, if the distance information is less than a first distance threshold, the first detection result indicates that an external object is approaching the electronic device; or, if the distance information is greater than or equal to a second distance threshold, the first detection result indicates that an external object is moving away from the electronic device. The second distance threshold is greater than or equal to the first distance threshold.

[0207] Optionally, the acquisition module 1201 is used to: acquire the first detection result determined by the ultrasonic sensor and the second detection result determined by the infrared proximity sensor through the proximity detection virtual sensor, and acquire the attitude data collected by the attitude sensor; the processing module 1202 is used to: obtain the target detection result based on the first detection result, the second detection result and the attitude data through the proximity detection virtual sensor.

[0208] It should be understood that the device control device 1200 here is embodied in the form of a functional module. The term "module" here can refer to an application-specific integrated circuit (ASIC), electronic circuitry, a processor (e.g., a shared processor, a proprietary processor, or a group processor, etc.) and memory for executing one or more software or firmware programs, integrated logic circuitry, and / or other suitable components supporting the described functions. In an alternative example, those skilled in the art will understand that the device control device 1200 can be specifically the electronic device in the above embodiments, or the functions of the electronic device in the above embodiments can be integrated into the device control device 1200. The device control device 1200 can be used to execute the various processes and / or steps corresponding to the electronic device in the above method embodiments; to avoid repetition, these will not be described again here. The device control device 1200 has the function of implementing the corresponding steps executed by the electronic device in the above method; the above functions can be implemented by hardware or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions. In the embodiments of this application, Figure 12 The device control unit 1200 in the middle can also be a chip or a chip system, such as a system on chip (SoC).

[0209] Figure 13An electronic device 1300 according to an embodiment of this application is shown. The electronic device 1300 includes a processor 1301, a memory 1302, a communication interface 1303, and a bus 1304. The memory 1302 stores instructions, and the processor 1301 executes the instructions stored in the memory 1302. The processor 1301, memory 1302, and communication interface 1303 are interconnected via the bus 1304.

[0210] The processor 1301 is configured to: acquire a first detection result determined by the ultrasonic sensor, acquire a second detection result determined by the infrared proximity sensor, and acquire attitude data collected by the attitude sensor; obtain a target detection result based on at least one of the first detection result, the second detection result, and the attitude data, the target detection result being used to indicate whether an external object is approaching or moving away from the electronic device; and control the screen state of the electronic device according to the target detection result, the screen state including a screen-off state or a screen-on state.

[0211] It should be understood that the electronic device 1300 may specifically be the electronic device in the above embodiments, or the functions of the electronic device in the above embodiments may be integrated into the electronic device 1300. The electronic device 1300 may be used to execute the various steps and / or processes corresponding to the electronic device in the above method embodiments. Optionally, the memory 1302 may include read-only memory and random access memory, and provide instructions and data to the processor 1301. A portion of the memory 1302 may also include non-volatile random access memory. For example, the memory 1302 may also store device type information. The processor 1301 may be used to execute instructions stored in the memory, and when the processor executes the instructions, the processor 1301 may execute the various steps and / or processes corresponding to the electronic device in the above method embodiments. It should be understood that in the embodiments of this application, the processor may be a central processing unit (CPU), or it may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor. In implementation, the steps of the above methods can be completed by integrated logic circuits in the processor's hardware or by instructions in software form. The steps of the methods disclosed in the embodiments of this application can be directly implemented by a hardware processor, or by a combination of hardware and software modules in the processor. The software modules can reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The storage medium is located in memory, and the processor executes the instructions in the memory, combining with its hardware to complete the steps of the above methods. To avoid repetition, detailed descriptions are not provided here. Those skilled in the art will recognize that the units and algorithm steps of the various examples 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 implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application. Those skilled in the art will readily understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. It should be understood from the several embodiments provided in this application that the disclosed systems, devices, and methods can be implemented in other ways.For example, the device embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division; in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some interfaces, indirect couplings, or communication connections between devices or units, and may be electrical, mechanical, or other forms. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs. Additionally, the functional units in the various embodiments of this 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. If the function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk. The above descriptions are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A device control method, characterized in that, Applied to an electronic device, the electronic device including an infrared proximity sensor, an ultrasonic sensor, and an attitude sensor, the method includes: Obtain the first detection result determined by the ultrasonic sensor, and obtain the second detection result determined by the infrared proximity sensor; obtain the attitude data collected by the attitude sensor. Based on at least one of the first detection result, the second detection result, and the posture data, a target detection result is obtained, which is used to indicate whether an external object is approaching or moving away from the electronic device. Based on the target detection results, the screen state of the electronic device is controlled, including a screen off state or a screen on state.

2. The method according to claim 1, characterized in that, The steps of acquiring the first detection result determined by the ultrasonic sensor, acquiring the second detection result determined by the infrared proximity sensor, and acquiring the attitude data collected by the attitude sensor include: When the electronic device is in call mode, the first detection result determined by the ultrasonic sensor is acquired, the second detection result determined by the infrared proximity sensor is acquired, and the attitude data collected by the attitude sensor is acquired. The step of controlling the screen state of the electronic device based on the target detection result includes: If the target detection result indicates that an external object is approaching the electronic device, the screen state of the electronic device is controlled to be the off-screen state; and / or, When the target detection result indicates that an external object is moving away from the electronic device, the screen state of the electronic device is controlled to be the on state.

3. The method according to claim 1, characterized in that, Obtaining a target detection result based on at least one of the first detection result, the second detection result, and the pose data includes: If the first detection result and the second detection result are the same, the target detection result is determined to be either the first detection result or the second detection result; or, If the first detection result is determined to be different from the second detection result, the target detection result is obtained based on the first detection result, the second detection result and the posture data.

4. The method according to claim 3, characterized in that, The determination that the first detection result is different from the second detection result includes: The first detection result indicates that an external object is moving away from the electronic device, and the second detection result indicates that an external object is approaching the electronic device; or... The first detection result indicates that an external object is approaching the electronic device, and the second detection result indicates that the external object is moving away from the electronic device.

5. The method according to claim 4, characterized in that, When it is determined that the first detection result and the second detection result are different, obtaining the target detection result based on the first detection result, the second detection result, and the posture data includes: If the first detection result indicates that an external object is approaching the electronic device, and the second detection result indicates that an external object is moving away from the electronic device, and if the electronic device is identified as being in an answering posture based on the posture data, then the target detection result is determined to be that an external object is approaching the electronic device; and / or, If the first detection result indicates that an external object is approaching the electronic device, and the second detection result indicates that an external object is moving away from the electronic device, and if the electronic device is not in an answering posture based on the posture data, then the target detection result is determined to be that an external object is moving away from the electronic device.

6. The method according to claim 1, characterized in that, Obtaining a target detection result based on at least one of the first detection result, the second detection result, and the pose data includes: If the second detection result indicates that an external object is approaching the electronic device, the target detection result is determined to indicate that an external object is approaching the electronic device.

7. The method according to claim 1, characterized in that, The ultrasonic sensor includes an ultrasonic transmitting unit and an ultrasonic receiving unit. The ultrasonic transmitting unit includes a receiver, and the ultrasonic receiving unit includes a microphone. The first detection result includes distance information, and acquiring the first detection result determined by the ultrasonic sensor includes: Ultrasonic signals are emitted through the earpiece; The reflected signal of the ultrasonic signal is received through the microphone; The distance information is obtained based on the transmission time between the ultrasonic signal and the reflected signal; Wherein, if the distance information is less than a first distance threshold, the first detection result indicates that an external object is approaching the electronic device; or, if the distance information is greater than or equal to a second distance threshold, the first detection result indicates that an external object is moving away from the electronic device; wherein the second distance threshold is greater than or equal to the first distance threshold.

8. The method according to claim 1, characterized in that, The steps of acquiring the first detection result determined by the ultrasonic sensor, acquiring the second detection result determined by the infrared proximity sensor, and acquiring the attitude data collected by the attitude sensor include: The first detection result determined by the ultrasonic sensor is obtained by the proximity detection virtual sensor, and the second detection result determined by the infrared proximity sensor is obtained, as well as the attitude data collected by the attitude sensor. Obtaining a target detection result based on at least one of the first detection result, the second detection result, and the pose data includes: The target detection result is obtained by using the proximity detection virtual sensor based on the first detection result, the second detection result, and the attitude data.

9. A device control apparatus, characterized in that, Applied to electronic devices, the electronic devices include infrared proximity sensors, ultrasonic sensors, and attitude sensors, and the device control device includes: The acquisition module is used to acquire the first detection result determined by the ultrasonic sensor, acquire the second detection result determined by the infrared proximity sensor, and acquire the attitude data collected by the attitude sensor. The processing module is configured to obtain a target detection result based on at least one of the first detection result, the second detection result, and the posture data, wherein the target detection result is used to indicate whether an external object is approaching or moving away from the electronic device; and to control the screen state of the electronic device according to the target detection result, wherein the screen state includes a screen-off state or a screen-on state.

10. An electronic device, characterized in that, It includes a processor and a memory, the memory being used to store code instructions; the processor being used to execute the code instructions to perform the method as described in any one of claims 1 to 8.

11. A computer program product, said computer program product comprising computer program code, characterized in that, When the computer program code is run on a computer, it causes the computer to implement the method as described in any one of claims 1 to 8.