Xiaomi Mi4
How to fix sensors not working issue on Xiaomi Mi4Xiaomi

Xiaomi Mi4 users are in for some great news as XDA senior member, Prince Chandela, has shared a simple guide to fix sensors not working issue on the flagship handset, after flashing any custom ROM or kernel. Furthermore, users with IR blaster issues on the Mi4 can set the kernel to Permissive, before applying this permanent fix.

Prerequisites

Steps to fix sensors not working issue on Xiaomi Mi4

  • Launch terminal app and enter the following commands:

Su

dd if=/dev/block/mmcblk0p22 of=/sdcard/persist.img

  • Now the persist.img file will be copied to your phone's internal storage.
  • Just copy this .img file to a safe location on your external hard drive or to a PC
  • Then copy the downloaded persistnew.img file to your phone's internal storage
  • Open the terminal emulator and enter the command:

dd if=/sdcard/persistnew.img of=/dev/block/mmcblk0p22

  • Reboot your smartphone and then run the sensor test with Senor Box app, which can be downloaded from the Google Play Store.

That is it. Your smartphone sensors should be working fine again.

[Source: XDA]