Skip to content

Commit

Permalink
Nexus Logger: add the sepolicy and condition for property change
Browse files Browse the repository at this point in the history
1) add condition to run cnss_diag based on property value
2) add sepolicy to save the log file and conf into /data/cnss_diag
3) add sepoiicy required to run cnss_diag in cnss_diag.te

Bug: 31185979

Change-Id: I33ea066ef3745e97dd1b46e7c2c28ac6d2a5aa6d
Signed-off-by: Ecco Park <eccopark@google.com>
  • Loading branch information
eccopark committed Sep 28, 2016
1 parent 087182d commit 79ccae7
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 1 deletion.
22 changes: 22 additions & 0 deletions init.common.diag.rc.userdebug
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
on post-fs-data
# Modem logging collection
mkdir /data/diag_logs 0777 system system
# WLAN logging collection
mkdir /data/cnss_diag 0777 system system

# Copy OEM adb_keys if /data/misc/adb/adb_keys does not exist
copy /data/misc/adb/adb_keys /data/misc/adb/adb_keys_temp
Expand Down Expand Up @@ -88,3 +90,23 @@ on property:sys.usb.config=diag,serial_cdev,serial_tty,rmnet_ipa,mass_storage,ad
write /sys/class/android_usb/android0/enable 1
start adbd
setprop sys.usb.state ${sys.usb.config}

on property:persist.sys.cnss.diag_qxdm=true
start cnss_diag

on property:persist.sys.cnss.diag_qxdm=false
stop cnss_diag

on property:persist.sys.cnss.diag_txt=true
start cnss_diag_txt

on property:persist.sys.cnss.diag_txt=false
stop cnss_diag_txt

service cnss_diag_txt /system/bin/cnss_diag -s -f -m /data/cnss_diag/cnss_diag.conf
class late_start
user root
group root
disabled
oneshot

2 changes: 2 additions & 0 deletions sepolicy/cnss_diag.te
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ allow cnss-daemon sysfs_msm_core:file write;

userdebug_or_eng(`
allow cnss_diag diag_device:chr_file rw_file_perms;
allow cnss_diag cnss_diag_data_file:dir create_dir_perms;
allow cnss_diag cnss_diag_data_file:file create_file_perms;
')
3 changes: 2 additions & 1 deletion sepolicy/file.te
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ type firmware_file, fs_type, contextmount_type;

# /data
type diag_logs, file_type, data_file_type, mlstrustedobject;
type cnss_diag_data_file, file_type, data_file_type, mlstrustedobject;
type location_data_file, file_type, data_file_type;
type perfd_data_file, file_type, data_file_type;
type ramdump_data_file, file_type, data_file_type;
Expand Down Expand Up @@ -49,4 +50,4 @@ type persist_display_file, file_type;

# msm_irqbalance
type proc_irq, fs_type;
type irqbalance_socket, file_type;
type irqbalance_socket, file_type;
1 change: 1 addition & 0 deletions sepolicy/file_contexts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@

# /data
/data/diag_logs(/.*)? u:object_r:diag_logs:s0
/data/cnss_diag(/.*)? u:object_r:cnss_diag_data_file:s0
/data/nfc(/.*)? u:object_r:nfc_data_file:s0
/data/time(/.*)? u:object_r:time_data_file:s0
/data/ramdump(/.*)? u:object_r:ramdump_data_file:s0
Expand Down
5 changes: 5 additions & 0 deletions sepolicy/platform_app.te
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@ userdebug_or_eng(`
allow platform_app diag_logs:dir rw_dir_perms;
allow platform_app diag_logs:file create_file_perms;
allow platform_app diag_device:chr_file rw_file_perms;
allow platform_app cnss_diag_data_file:dir create_dir_perms;
allow platform_app cnss_diag_data_file:file create_file_perms;
dontaudit platform_app proc_sysrq:file getattr;
dontaudit platform_app proc_iomem:file getattr;
set_prop(platform_app, cnss_diag_prop);
')
1 change: 1 addition & 0 deletions sepolicy/property.te
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ type wc_prop, property_type;
type hw_sku_prop, property_type;
type mid_prop, property_type;
type ssr_prop, property_type;
type cnss_diag_prop, property_type;
1 change: 1 addition & 0 deletions sepolicy/property_contexts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ rcs.publish.status u:object_r:radio_prop:s0
ro.boot.hardware.sku u:object_r:hw_sku_prop:s0
ro.boot.mid u:object_r:mid_prop:s0
debug.ssrdump u:object_r:ssr_prop:s0
persist.sys.cnss. u:object_r:cnss_diag_prop:s0

0 comments on commit 79ccae7

Please sign in to comment.