move FSG reload properties into /persist/mdm

persistent properties aren't available before encryption, so
use files in /persist/mdm to keep track of which carrier we
last loaded (etc.)

Leave persist.radio.fsg_reload_on=1 here, so we can disable
it for some lab testing.

b/17013394 Shamu After Sub System Restart Radio does not connect
b/16876072 Device fails to show screen after decrypting device

Change-Id: I5c5b6bcad90661cd1402b1a295a2943f5051e8a1
Signed-off-by: Iliyan Malchev <malchev@google.com>
diff --git a/CleanSpec.mk b/CleanSpec.mk
index 92d1150..1dd7dfd 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -54,3 +54,4 @@
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libart_*)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libartd_*)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
diff --git a/device.mk b/device.mk
index 8fa0e9f..d20fea6 100644
--- a/device.mk
+++ b/device.mk
@@ -213,12 +213,9 @@
     ro.telephony.default_network=10 \
     telephony.lteOnCdmaDevice=1
 
-# SIM based FSG loading
+# SIM based FSG loading default enabled
 PRODUCT_PROPERTY_OVERRIDES += \
-    persist.radio.customer_id="" \
     persist.radio.fsg_reload_on=1 \
-    persist.radio.siminfo_cache_max=3 \
-    persist.radio.efs_img_left=0
 
 # Camera configuration
 PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
diff --git a/init.shamu.rc b/init.shamu.rc
index bc1ee37..da1b29e 100644
--- a/init.shamu.rc
+++ b/init.shamu.rc
@@ -53,7 +53,7 @@
     # results in failure to launch late-start class.
 
     wait /dev/block/platform/msm_sdcc.1/by-name/persist
-    mount ext4 /dev/block/platform/msm_sdcc.1/by-name/persist /persist nosuid nodev barrier=1
+    mount ext4 /dev/block/platform/msm_sdcc.1/by-name/persist /persist nosuid nodev barrier=1 defcontext=u:object_r:persist_file:s0
 
     mkdir /fsg 0755 root root
     mount ext4 /dev/block/platform/msm_sdcc.1/by-name/mdm1m9kefs3 /fsg ro nosuid nodev barrier=0
@@ -92,6 +92,8 @@
     symlink /system/vendor/lib/hw/ValidityPersistentData /data/validity/ValidityPersistentData
     symlink /system/vendor/lib/hw/6_03f_moto.xefwext /data/validity/fwext/6_03f_moto.xefwext
 
+    mkdir /persist/mdm 0770 radio radio
+
 on early-boot
     # set RLIMIT_MEMLOCK to 64MB
     setrlimit 8 67108864 67108864
diff --git a/sepolicy/file.te b/sepolicy/file.te
index 5b7396c..bb024a8 100644
--- a/sepolicy/file.te
+++ b/sepolicy/file.te
@@ -11,3 +11,5 @@
 
 type sysfs_rmnet, fs_type, sysfs_type;
 type sysfs_smdcntl_open_timeout, fs_type, sysfs_type;
+
+type persist_file, file_type;
diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts
index a168eee..c97e75d 100644
--- a/sepolicy/file_contexts
+++ b/sepolicy/file_contexts
@@ -95,3 +95,6 @@
 
 # Sysfs files used by qmuxd
 /sys/devices/virtual/smdpkt/smdcntl([0-9])+/open_timeout u:object_r:sysfs_smdcntl_open_timeout:s0
+
+# Persist partition
+/persist/(/.*)?                 u:object_r:persist_file:s0
diff --git a/sepolicy/mdm_helper.te b/sepolicy/mdm_helper.te
index 37f6df7..7da34f3 100644
--- a/sepolicy/mdm_helper.te
+++ b/sepolicy/mdm_helper.te
@@ -19,3 +19,6 @@
 # Let qcks access /dev/mdm node (modem driver)??
 allow mdm_helper radio_device:chr_file r_file_perms;
 allow mdm_helper modem_block_device:blk_file r_file_perms;
+
+allow mdm_helper persist_file:dir rw_dir_perms;
+allow mdm_helper persist_file:file create_file_perms;
diff --git a/sepolicy/rild.te b/sepolicy/rild.te
index 3d38535..aee7c36 100644
--- a/sepolicy/rild.te
+++ b/sepolicy/rild.te
@@ -3,4 +3,7 @@
 binder_service(rild)
 
 # Grant access to Qualcomm MSM Interface (QMI) radio sockets to RILD
-qmux_socket(rild)
\ No newline at end of file
+qmux_socket(rild)
+
+allow rild persist_file:dir rw_dir_perms;
+allow rild persist_file:file create_file_perms;