Label timestamp_switch file in sysfs and grant access

avc: granted { read } name="timestamp_switch" scontext=u:r:radio:s0
tcontext=u:object_r:sysfs:s0 tclass=file
avc: granted { read open }
path="/sys/module/diagchar/parameters/timestamp_switch"
scontext=u:r:radio:s0 tcontext=u:object_r:sysfs:s0 tclass=file
avc: denied { read } for name="timestamp_switch"
scontext=u:r:hal_gnss_default:s0 tcontext=u:object_r:sysfs:s0
tclass=file

Bug: 37730994
Test: Build and boot Marlin. Make phone calls. Use cellular data.
      Get location on Maps.

Change-Id: I326e777e987302e5735a479b8f03f1305620a236
diff --git a/sepolicy/file.te b/sepolicy/file.te
index 7a58541..5081d8e 100644
--- a/sepolicy/file.te
+++ b/sepolicy/file.te
@@ -30,11 +30,12 @@
 type sysfs_net, sysfs_type, fs_type, mlstrustedobject;
 type sysfs_perf, sysfs_type, fs_type;
 type sysfs_pcie, sysfs_type, fs_type, mlstrustedobject;
+type sysfs_power_management, sysfs_type, fs_type;
 type sysfs_rmtfs, sysfs_type, fs_type;
 type sysfs_soc, sysfs_type, fs_type, mlstrustedobject;
+type sysfs_timestamp_switch, sysfs_type, fs_type;
 type sysfs_video, sysfs_type, fs_type;
 type sysfs_wifi, sysfs_type, fs_type, mlstrustedobject;
-type sysfs_power_management, sysfs_type, fs_type;
 
 # debugfs
 type debugfs_msm_core, debugfs_type, fs_type;
diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts
index b5b741f..e1bbb3c 100644
--- a/sepolicy/file_contexts
+++ b/sepolicy/file_contexts
@@ -217,7 +217,8 @@
 /sys/module/lpm_levels/parameters(/.*)?                u:object_r:sysfs_power_management:s0
 /sys/devices/soc/qpnp-fg-[0-9a-f]+/power_supply/bms/capacity             u:object_r:sysfs_batteryinfo:s0
 /sys/devices/soc/qpnp-smbcharger-[0-9a-f]+/power_supply/battery/capacity u:object_r:sysfs_batteryinfo:s0
-/sys/devices/virtual/timed_output/vibrator/voltage_level u:object_r:sysfs_vibrator:s0
+/sys/devices/virtual/timed_output/vibrator/voltage_level   u:object_r:sysfs_vibrator:s0
+/sys/module/diagchar/parameters/timestamp_switch           u:object_r:sysfs_timestamp_switch:s0
 
 # debugfs
 /sys/kernel/debug/msm_core(/.*)?                 u:object_r:debugfs_msm_core:s0
diff --git a/sepolicy/hal_gnss.te b/sepolicy/hal_gnss.te
index 3bf7b51..d4cf242 100644
--- a/sepolicy/hal_gnss.te
+++ b/sepolicy/hal_gnss.te
@@ -10,10 +10,12 @@
   allow hal_gnss diag_device:chr_file { read write open ioctl};
 ')
 
-#access to /sys/bus/esoc/devices
+# access to /sys/bus/esoc/devices
 allow hal_gnss sysfs:dir { read open };
 
+# access to /sys/devices/soc0/soc_id and /sys/devices/soc0/hw_platform
 allow hal_gnss sysfs_soc:dir search;
-
-#access to /sys/devices/soc0/soc_id and /sys/devices/soc0/hw_platform
 allow hal_gnss sysfs_soc:file { read open getattr };
+
+# read access to sys/module/diagchar/parameters/timestamp_switch
+allow hal_gnss sysfs_timestamp_switch:file r_file_perms;
diff --git a/sepolicy/radio.te b/sepolicy/radio.te
index 7825fe6..55e8dee 100644
--- a/sepolicy/radio.te
+++ b/sepolicy/radio.te
@@ -31,3 +31,6 @@
 # Needed for use .so files in /vendor/lib64 needed by ims which runs as com.android.phone (radio)
 # r_dir_file(radio, vendor_file)
 allow radio vendor_file:file rx_file_perms;
+
+# read access to sys/module/diagchar/parameters/timestamp_switch
+allow radio sysfs_timestamp_switch:file r_file_perms;