Screen Input Guard (screen_input_guard.h)
Functions to enable Screen Input Guard.
Screen Input Guard is a feature of the device whereby the screen turns off and the touchscreen is disabled during a phone call or similar voice chat. This ensures that the caller's face or ear do not trigger unwanted touches on the device causing unintended events.
Screen Input Guard turns off the screen and disables the touchscreen when something (assumed to be a face) is detected near the screen. When the user takes the device away from their face, Screen Input Guard turns on the screen and enables the touchscreen. However, Screen Input Guard does not turn off the screen and disable the touchscreen if the device is face up, e.g. lying on a table.
For best results, call screen_input_guard_request_events() at least 200 milliseconds before you need to enable Screen Input Guard. This amount of time allows the face detection sensors to stabilize and give more accurate readings. Once you actually need the screen to turn off and the touchscreen to be disabled when a face is detected, call screen_input_guard_enable(). You can also call screen_input_guard_request_events() and screen_input_guard_enable() immediately after each other, without delay. Note that once you call screen_input_guard_request_events(), extra power is used, so it should not be used when not required.
For example, call screen_input_guard_request_events() as soon as an incoming phone call comes in. Face detection will stabilize during the time it takes for the user to answer the phone call. If the user rejects the phone call, call screen_input_guard_stop_events(). If the user accepts the phone call, immediately call screen_input_guard_enable(). The screen and the touchscreen will turn off when the user places the phone next to their face, and the screen and the touchscreen will turn on when the device is moved away from their face. When the phone call ends, call screen_input_guard_disable() and screen_input_guard_stop_events().
As another example, when the user starts to make an outgoing phone call, call screen_input_guard_request_events(). Face detection will stabilize while the user is dialing. As soon as the user starts the phone call and is likely to place the phone next to their face, call screen_input_guard_enable(). When the phone call ends, call screen_input_guard_disable() and screen_input_guard_stop_events(). However, if you expect the user to be on the dial screen for a long period of time without actually dialing, it would be better for power usage to wait until the phone call is started to call screen_input_guard_request_events() and screen_input_guard_enable().
Last modified: 2013-12-21