I have seen many apps that give the ability to wake up phone screen simply by picking the phone up off a table (not talking about proximity sensor here). One thing they all have in-common is that this feature places a wakelock on the device, and therefore it drains battery, and therefore it times out after a preset amount (1-10 minutes). From what I understand, it works by monitoring front camera.
My question is: how do Moto X and Nexus phones do that then? They have this feature in-built, but does that also place a wakelock? A 24-hour wakelock? Or do they use something other than front camera? And if such, why isn't there an app that can replicate this behaviour for all phones?
Devices like Moto X and Nexus 5X/6P use a sensor hub to achieve this feature, which is a:
microcontroller unit/coprocessor/DSPxc2xa0that helps to integrate data from different sensors and process them.xc2xa0This technology can help off-load these jobs from a product's mainxc2xa0central processing unit, thus saving battery consumptionxc2xa0and providing a performance improvement.
The Android specifications suggest that the manufacturer implement a sensor hub:
The sensor stack of a device can optionally include a sensor hub, useful to perform some low-level computation at low power while the SoC can be in a suspend mode. For example, step counting or sensor fusion can be performed on those chips. It is also a good place to implement sensor batching, adding hardware FIFOs for the sensor events. See Batching for more information.
How the sensor hub is materialized depends on the architecture. It is sometimes a separate chip, and sometimes included on the same chip as the SoC. Important characteristics of the sensor hub is that it should contain sufficient memory for batching and consume very little power to enable implementation of the low power Android sensors. Some sensor hubs contain a microcontroller for generic computation, and hardware accelerators to enable very low power computation for low power sensors.
So the availability of this feature depends on the hardware of the device: if the manufacturer includes a sensors hub, then the power consumption will be optimized because the central processor isn't involved. Otherwise, the only possibility is to install dedicated apps (see for example the one cited in my comment) that will monitor the accelerometer, resulting, though, in a higher battery drain.