# Policy for /vendor/bin/thermal-engine
type thermal-engine, domain;
type thermal-engine_exec, exec_type, vendor_file_type, file_type;

init_daemon_domain(thermal-engine)

# Grant access to Qualcomm MSM Interface (QMI) radio sockets
qmux_socket(thermal-engine)

allow thermal-engine self:socket create_socket_perms;
allowxperm thermal-engine self:socket ioctl msm_sock_ipc_ioctls;

# /dev/msm_thermal_query
allow thermal-engine thermal_device:chr_file rw_file_perms;

# files in /sys/
r_dir_file(thermal-engine, sysfs_type)
allow thermal-engine sysfs_msm_subsys:file write;
allow thermal-engine sysfs_thermal:file write;

allow thermal-engine uio_device:chr_file rw_file_perms;

# access to /dev/diag on debug builds
userdebug_or_eng(`
  allow thermal-engine diag_device:chr_file rw_file_perms;
')

# write proc/sysrq-trigger for remount r/o during reboot
allow thermal-engine proc_sysrq:file w_file_perms;
# reboot warnings and errors to kernel via klog
allow thermal-engine kmsg_device:chr_file w_file_perms;

# write file last_reboot_reason to inform of previous thermal shutdown
allow thermal-engine reboot_data_file:dir ra_dir_perms;
allow thermal-engine reboot_data_file:file create_file_perms;

# reboot/shutdown for thermal limits exceeded
set_prop(thermal-engine, powerctl_prop)