Unlike the traditional pocket mode that constantly checks the proximity and light sensors, this mode only checks them when the phone is in lockscreen. Therefore, the battery life will be extended and deep sleep mode will be optimised.
In case the screen automatically turns off after being taken out of the pocket, please wait for a few seconds and everything will work again.
Define two line in device tree source device.mk
PRODUCT_PACKAGES += \
PocketMode
...
PRODUCT_COPY_FILES += \
$(LOCAL_PATH)/pocket/privapp-permissions-pocketmode.xml:$(TARGET_COPY_OUT_PRODUCT)/etc/permissions/privapp-permissions-pocketmode.xml
And add to this repo into pocket
folder.