Google is rolling out a new feature called on-body detection that is a smart lock mode. This feature makes use of the device’s inbuilt accelerometer to find out when you are holding the device in your hand or have it in your pocket and will lock the device if not.
Basically, this feature will lock your device if you have forgotten it on a table or some other place. This way, the data stored in your device will be protected from unwanted people accessing it.
If you have unlocked your phone, it will be unlocked while you are holding it or when it is in your pocket. If it is set down on some other place, it will lock itself. Once you pick it up, it needs manual unlocking.
Notably, the feature will not lock your device if the phone is with someone else when it is unlocked as it can recognize when you are holding the device. The on-body detection feature knows when the device is held or pocketed and when it is not.
This new smart lock mode feature was found on Nexus 4 that is running on the Android 5.0.1 Lollipop iteration initially and now it is seen on other Nexus devices as well. Your device should be running on Android 5.0+ for this feature to work on it. Google will be rolling out the new on-body detection smart lock mode feature in phases and we might get it on more devices soon.