flo: Disable diag device in normal mode.

Remove the diag device when the device is in normal mode.

Bug: 18203257
Change-Id: I878ac648c49ef0940d55d5b6695bac24742847c8
diff --git a/device-common.mk b/device-common.mk
index b0acd2a..bdcb44d 100644
--- a/device-common.mk
+++ b/device-common.mk
@@ -120,6 +120,15 @@
 	frameworks/native/data/etc/android.hardware.bluetooth_le.xml:system/etc/permissions/android.hardware.bluetooth_le.xml \
 	frameworks/native/data/etc/android.hardware.ethernet.xml:system/etc/permissions/android.hardware.ethernet.xml
 
+# Modem debugger
+ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT)))
+PRODUCT_COPY_FILES += \
+    device/asus/flo/init.flo.diag.rc.userdebug:root/init.flo.diag.rc
+else
+PRODUCT_COPY_FILES += \
+    device/asus/flo/init.flo.diag.rc.user:root/init.flo.diag.rc
+endif
+
 PRODUCT_PROPERTY_OVERRIDES += \
 	ro.opengles.version=196608
 
diff --git a/init.flo.diag.rc.user b/init.flo.diag.rc.user
new file mode 100644
index 0000000..e6f1b2d
--- /dev/null
+++ b/init.flo.diag.rc.user
@@ -0,0 +1,4 @@
+# This file gets copied as /init.flo.diag.rc
+
+on post-fs-data
+    rm /dev/diag
diff --git a/init.flo.diag.rc.userdebug b/init.flo.diag.rc.userdebug
new file mode 100644
index 0000000..d43fdd4
--- /dev/null
+++ b/init.flo.diag.rc.userdebug
@@ -0,0 +1,6 @@
+# This file gets copied as /init.flo.diag.rc
+
+on post-fs-data
+    # Modem logging collection
+    mkdir /data/diag_logs 0777 system system
+    chmod 666 /dev/diag
diff --git a/init.flo.rc b/init.flo.rc
index 218a13f..933376d 100644
--- a/init.flo.rc
+++ b/init.flo.rc
@@ -15,6 +15,7 @@
 #
 
 import init.flo.usb.rc
+import init.flo.diag.rc
 
 on early-init
     mount debugfs debugfs /sys/kernel/debug