diff --git a/device.mk b/device.mk
index 967882b98b6cf9ed972aab4d86362cee2bd313ed..27fb615341e2b6c169d00e9e539c0e6e522d8793 100644
--- a/device.mk
+++ b/device.mk
@@ -202,6 +202,10 @@ PRODUCT_COPY_FILES += \
     $(LOCAL_PATH)/gps/etc/sap.conf:$(TARGET_COPY_OUT_VENDOR)/etc/sap.conf \
     $(LOCAL_PATH)/gps/etc/xtwifi.conf:$(TARGET_COPY_OUT_VENDOR)/etc/xtwifi.conf
 
+# Healthd
+PRODUCT_PACKAGES += \
+    chargeonlymode
+
 # HIDL
 PRODUCT_PACKAGES += \
     android.hidl.base@1.0 \
diff --git a/rootdir/Android.mk b/rootdir/Android.mk
index 422e4f2ef57d93820ca6abe928f57824a179e7eb..3b29ce39342fae3ef14ef43a88dd4d903ec3bf9e 100644
--- a/rootdir/Android.mk
+++ b/rootdir/Android.mk
@@ -69,3 +69,14 @@ LOCAL_MODULE_CLASS := ETC
 LOCAL_SRC_FILES    := etc/init.qcom.post_boot.sh
 LOCAL_MODULE_PATH  := $(TARGET_OUT_VENDOR_EXECUTABLES)
 include $(BUILD_PREBUILT)
+
+# Offmode charging
+include $(CLEAR_VARS)
+LOCAL_MODULE          := chargeonlymode
+LOCAL_MODULE_OWNER    := xiaomi
+LOCAL_MODULE_PATH     := $(TARGET_ROOT_OUT_SBIN)
+LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_SBIN_UNSTRIPPED)
+LOCAL_SRC_FILES       := sbin/chargeonlymode
+LOCAL_MODULE_TAGS     := optional
+LOCAL_MODULE_CLASS    := EXECUTABLES
+include $(BUILD_PREBUILT)
diff --git a/rootdir/init.qcom.rc b/rootdir/init.qcom.rc
index 86e19d2d7560364cd27120a7aebca729abcb22d4..b50062354c54eb30b67bba373645943af3db79d5 100644
--- a/rootdir/init.qcom.rc
+++ b/rootdir/init.qcom.rc
@@ -574,11 +574,10 @@ service ril-daemon2 /vendor/bin/hw/rild -c 2
     group radio cache inet misc audio sdcard_r sdcard_rw diag oem_2901 log
     capabilities BLOCK_SUSPEND NET_ADMIN NET_RAW
 
-service charger /charger
+service charger /sbin/chargeonlymode
     class charger
     group system graphics
-    seclabel u:r:healthd:s0
-    writepid /dev/cpuset/system-background/tasks
+    seclabel u:r:charger:s0
 
 service vendor.msm_irqbalance /vendor/bin/msm_irqbalance -f /system/vendor/etc/msm_irqbalance.conf
     class core
diff --git a/rootdir/init.target.rc b/rootdir/init.target.rc
index ce80bff2fc3857231b704a7a8663ab484a82468d..f9be0bd0e1e41fed654c482f4c03bc9f84327365 100644
--- a/rootdir/init.target.rc
+++ b/rootdir/init.target.rc
@@ -185,9 +185,8 @@ on charger
     write /sys/devices/system/cpu/cpu2/online 0
     write /sys/devices/system/cpu/cpu3/online 0
     write /sys/module/lpm_levels/parameters/sleep_disabled 0
-    wait /dev/block/bootdevice/by-name/system
-    mount ext4 /dev/block/bootdevice/by-name/system /system ro barrier=1
     start hvdcp_opti
+    start thermal-engine
 
 on boot
 	write /dev/cpuset/top-app/cpus 0-7
diff --git a/rootdir/sbin/chargeonlymode b/rootdir/sbin/chargeonlymode
new file mode 100755
index 0000000000000000000000000000000000000000..e764100898c6d72c8f4e4c7ca65ac96ff71a9705
Binary files /dev/null and b/rootdir/sbin/chargeonlymode differ