From 47ef5fd5b2bba82d64647113099881c5006a3dca Mon Sep 17 00:00:00 2001 From: Vachounet Date: Mon, 8 Jan 2018 15:54:29 +0100 Subject: [PATCH] sanders: init: cleanup * Remove some proprietary scripts * Should help for sepolicy rules --- init/init_sanders.cpp | 1 + rootdir/etc/init.mmi.touch.sh | 349 ---------------------------------- rootdir/etc/init.oem.hw.sh | 130 ------------- sepolicy/file.te | 1 - sepolicy/file_contexts | 5 - sepolicy/mmi_touch_te.te | 27 --- sepolicy/oem-hw-sh.te | 17 -- sepolicy/ueventd.te | 2 - 8 files changed, 1 insertion(+), 531 deletions(-) delete mode 100644 rootdir/etc/init.mmi.touch.sh delete mode 100644 rootdir/etc/init.oem.hw.sh delete mode 100644 sepolicy/mmi_touch_te.te delete mode 100755 sepolicy/oem-hw-sh.te diff --git a/init/init_sanders.cpp b/init/init_sanders.cpp index 336e823..83fa89d 100644 --- a/init/init_sanders.cpp +++ b/init/init_sanders.cpp @@ -82,6 +82,7 @@ void vendor_load_properties() property_set("ro.hw.device", device.c_str()); property_set("ro.hw.radio", radio.c_str()); property_set("ro.hw.fps", "true"); + property_set("ro.hw.imager", "12MP"); num_sims(); } diff --git a/rootdir/etc/init.mmi.touch.sh b/rootdir/etc/init.mmi.touch.sh deleted file mode 100644 index ea71fd0..0000000 --- a/rootdir/etc/init.mmi.touch.sh +++ /dev/null @@ -1,349 +0,0 @@ -#!/system/bin/sh - -PATH=/sbin:/system/sbin:/system/bin:/system/xbin -export PATH - -while getopts ds op; -do - case $op in - d) dbg_on=1;; - s) dump_statistics=1;; - esac -done -shift $(($OPTIND-1)) - -scriptname=${0##*/} -touch_class_path=/sys/class/touchscreen -touch_product_string=$(ls $touch_class_path) -touch_status_prop=hw.touch.status - -debug() -{ - [ $dbg_on ] && echo "Debug: $*" -} - -notice() -{ - echo "$*" - echo "$scriptname: $*" > /dev/kmsg -} - -sanity_check() -{ - read_touch_property flashprog || return 1 - [[ ( -z "$property" ) || ( "$property" == "1" ) ]] && return 1 - read_touch_property productinfo || return 1 - [[ ( -z "$property" ) || ( "$property" == "0" ) ]] && return 1 - read_touch_property buildid || return 1 - config_id=${property#*-} - [[ ( -z "$config_id" ) || ( "$config_id" == "0" ) ]] && return 1 - build_id=${property%-*} - [[ ( -z "$build_id" ) || ( "$build_id" == "0" ) ]] && return 1 - return 0 -} - -error_and_leave() -{ - local err_msg - local err_code=$1 - local touch_status="unknown" - case $err_code in - 1) err_msg="Error: No response from touch IC" - touch_status="dead";; - 2) err_msg="Error: Cannot read property $2";; - 3) err_msg="Error: No matching firmware file found";; - 4) err_msg="Error: Touch IC is in bootloader mode" - touch_status="dead";; - 5) err_msg="Error: Touch provides no reflash interface" - touch_status="dead";; - 6) err_msg="Error: Touch driver is not running" - touch_status="absent";; - 7) err_msg="Warning: Touch firmware is not the latest";; - esac - notice "$err_msg" - - # perform sanity check and declare touch ready if error is not fatal - if [ "$touch_status" == "unknown" ]; then - touch_status="ready" - sanity_check - [ "$?" == "1" ] && touch_status="dead" - fi - - # perform recovery if touch is declared dead - if [ "$touch_status" == "dead" ]; then - notice "Touch needs to go through recovery!!!" - reboot_cnt=$(getprop $touch_status_prop 2>/dev/null) - [ -z "$reboot_cnt" ] && reboot_cnt=0 - debug "current reboot counter [$reboot_cnt]" - fi - - setprop $touch_status_prop $touch_status - notice "property [$touch_status_prop] set to [`getprop $touch_status_prop`]" - - if [ "$touch_status" == "dead" ]; then - if [ $((reboot_cnt)) -lt 2 ]; then - notice "Touch is not working; rebooting..." - debug "sleep 3s to allow touch-dead-sh service to run" - sleep 3 - [ -z "$dbg_on" ] && reboot - else - notice "Although touch is not working, no more reboots" - fi - fi - - exit $err_code -} - -[ -z "$touch_product_string" ] && error_and_leave 6 - -touch_vendor=$(cat $touch_class_path/$touch_product_string/vendor) -debug "touch vendor [$touch_vendor]" -touch_path=/sys$(cat $touch_class_path/$touch_product_string/path) -debug "sysfs touch path: $touch_path" -panel_path=/sys/devices/virtual/graphics/fb0 -debug "sysfs panel path: $panel_path" - -if [ $dump_statistics ]; then - debug "dumping touch statistics" - cat $touch_path/ic_ver - [ -f $touch_path/stats ] && cat $touch_path/stats - return 0 -fi - -[ -f $touch_path/doreflash ] || error_and_leave 5 -[ -f $touch_path/poweron ] || error_and_leave 5 - -selinux=$(getprop ro.boot.selinux 2> /dev/null) - -if [ "$selinux" == "permissive" ]; then - debug "loosen permissions to touch report sysfs entries" - touch_report_files="reporting query stats" - for entry in $touch_report_files; do - chmod 0666 $touch_path/$entry - debug "change permissions of $touch_path/$entry" - done - for entry in $(ls $touch_path/f54/ 2>/dev/null); do - chmod 0666 $touch_path/f54/$entry - debug "change permissions of $touch_path/f54/$entry" - done - unset touch_report_files -fi - -# Set permissions to enable factory touch tests -chown root:oem_5004 $touch_path/drv_irq -chown root:oem_5004 $touch_path/hw_irqstat -chown root:oem_5004 $touch_path/reset -# Set permissions to allow Bug2Go access to touch statistics -chown root:log $touch_path/stats - -debug "wait until driver reports ..." -while true; do - readiness=$(cat $touch_path/poweron) - if [ "$readiness" == "1" ]; then - debug "ready to flash!!!" - break; - fi - sleep 1 - debug "not ready; keep waiting..." -done -unset readiness - -device_property=ro.hw.device -hwrev_property=ro.boot.hardware.revision -firmware_path=/system/etc/firmware - -let dec_cfg_id_boot=0; dec_cfg_id_latest=0; - -read_touch_property() -{ - property="" - debug "retrieving property: [$touch_path/$1]" - property=$(cat $touch_path/$1 2> /dev/null) - debug "touch property [$1] is: [$property]" - [ -z "$property" ] && return 1 - return 0 -} - -read_panel_property() -{ - property="" - debug "retrieving panel property: [$panel_path/$1]" - property=$(cat $panel_path/$1 2> /dev/null) - debug "panel property [$1] is: [$property]" - [ -z "$property" ] && return 1 - return 0 -} - -find_latest_config_id() -{ - local fw_mask=$1 - local skip_fields=$2 - local dec max z str_hex i - - str_cfg_id_latest="" - - debug "scanning dir for files matching [$fw_mask]" - let dec=0; max=0; - for file in $(ls $fw_mask 2>/dev/null); - do - z=$file - i=0 - while [ ! $i -eq $skip_fields ]; - do - z=${z#*-} - i=$((i+1)) - done - - str_hex=${z%%-*}; - - let dec=0x$str_hex - if [ $dec -gt $max ]; - then - let max=$dec; dec_cfg_id_latest=$dec; - str_cfg_id_latest=$str_hex - fi - done - - [ -z "$str_cfg_id_latest" ] && return 1 - return 0 -} - -read_touch_property flashprog || error_and_leave 1 -bl_mode=$property -debug "bl mode: $bl_mode" - -read_touch_property productinfo || error_and_leave 1 -touch_product_id=$property -if [ -z "$touch_product_id" ] || [ "$touch_product_id" == "0" ]; -then - debug "touch ic reports invalid product id" - error_and_leave 1 -fi -debug "touch product id: $touch_product_id" - -read_touch_property buildid || error_and_leave 1 -str_cfg_id_boot=${property#*-} -let dec_cfg_id_boot=0x$str_cfg_id_boot -debug "touch config id: $str_cfg_id_boot" - -build_id_boot=${property%-*} -debug "touch build id: $build_id_boot" - -typeset -l product_id -product_id=$(getprop $device_property 2> /dev/null) -[ -z "$product_id" ] && error_and_leave 2 $device_property -product_id=${product_id%-*} -product_id=${product_id%_*} -debug "product id: $product_id" - -hwrev_id=$(getprop $hwrev_property 2> /dev/null) -[ -z "$hwrev_id" ] && notice "hw revision undefined" -debug "hw revision: $hwrev_id" - -read_panel_property "panel_supplier" -supplier=$property -[ -z "$supplier" ] && debug "driver does not report panel supplier" -debug "panel supplier: $supplier" - -cd $firmware_path - -find_best_match() -{ - local hw_mask=$1 - local panel_supplier=$2 - local skip_fields fw_mask - - while [ ! -z "$hw_mask" ]; do - if [ "$hw_mask" == "-" ]; then - hw_mask="" - fi - - if [ ! -z "$panel_supplier" ]; - then - skip_fields=3 - fw_mask="$touch_vendor-$panel_supplier-$touch_product_id-*-$product_id$hw_mask.*" - else - skip_fields=2 - fw_mask="$touch_vendor-$touch_product_id-*-$product_id$hw_mask.*" - fi - - find_latest_config_id "$fw_mask" "$skip_fields" && break - - hw_mask=${hw_mask%?} - done - - [ -z "$str_cfg_id_latest" ] && return 1 - - if [ -z "$panel_supplier" ]; then - firmware_file=$(ls $touch_vendor-$touch_product_id-$str_cfg_id_latest-*-$product_id$hw_mask.*) - else - firmware_file=$(ls $touch_vendor-$panel_supplier-$touch_product_id-$str_cfg_id_latest-*-$product_id$hw_mask.*) - fi - notice "Firmware file for upgrade $firmware_file" - - return 0 -} - -hw_mask="-$hwrev_id" -debug "hw_mask=$hw_mask" - -match_not_found=1 -if [ ! -z "$supplier" ]; -then - debug "search for best hw revision match with supplier" - find_best_match "-$hwrev_id" "$supplier" - match_not_found=$? -fi - -if [ "$match_not_found" -ne "0" ]; -then - debug "search for best hw revision match without supplier" - find_best_match "-$hwrev_id" || error_and_leave 3 -fi - -recovery=0 -if [ "$bl_mode" == "1" ] || [ "$build_id_boot" == "0" ]; -then - recovery=1 - notice "Initiating touch firmware recovery" - notice " bl mode = $bl_mode" - notice " build id = $build_id_boot" -fi - -if [ $dec_cfg_id_boot -ne $dec_cfg_id_latest ] || [ "$recovery" == "1" ]; -then - debug "forcing firmware upgrade" - echo 1 > $touch_path/forcereflash - debug "sending reflash command" - echo $firmware_file > $touch_path/doreflash - read_touch_property flashprog || error_and_leave 1 - bl_mode=$property - [ "$bl_mode" == "1" ] && error_and_leave 4 - read_touch_property buildid || error_and_leave 1 - str_cfg_id_new=${property#*-} - build_id_new=${property%-*} - - notice "Touch firmware config id at boot time $str_cfg_id_boot" - notice "Touch firmware config id in the file $str_cfg_id_latest" - notice "Touch firmware config id currently programmed $str_cfg_id_new" - - [ "$str_cfg_id_latest" != "$str_cfg_id_new" ] && error_and_leave 7 - - if [ -f $touch_path/f54/force_update ]; then - notice "forcing F54 registers update" - echo 1 > $touch_path/f54/force_update - fi -fi - -notice "Touch firmware is up to date" -setprop $touch_status_prop "ready" -notice "property [$touch_status_prop] set to [`getprop $touch_status_prop`]" - -unset device_property hwrev_property supplier -unset str_cfg_id_boot str_cfg_id_latest str_cfg_id_new -unset dec_cfg_id_boot dec_cfg_id_latest match_not_found -unset hwrev_id product_id touch_product_id scriptname -unset synaptics_link firmware_path touch_path -unset bl_mode dbg_on hw_mask firmware_file property - -return 0 diff --git a/rootdir/etc/init.oem.hw.sh b/rootdir/etc/init.oem.hw.sh deleted file mode 100644 index b0de12a..0000000 --- a/rootdir/etc/init.oem.hw.sh +++ /dev/null @@ -1,130 +0,0 @@ -#!/system/bin/sh - -PATH=/sbin:/system/sbin:/system/bin:/system/xbin -export PATH - -while getopts dpfr op; -do - case $op in - d) dbg_on=1;; - p) populate_only=1;; - f) dead_touch=1;; - r) reset_touch=1;; - esac -done -shift $(($OPTIND-1)) - -scriptname=${0##*/} -hw_mp=/proc/hw -config_mp=/proc/config -reboot_utag=$hw_mp/.reboot -touch_status_prop=hw.touch.status -hw_cfg_file=hw_config.xml -vhw_file=/system/etc/vhw.xml -bp_file=/system/build.prop -oem_file=/oem/oem.prop -load_error=3 -need_to_reload=2 -reload_in_progress=1 -reload_done=0 -ver_utag=".version" -version_fs="unknown" -xml_version="unknown" -device_params="" -xml_file="" -set -A prop_names -set -A prop_overrides -prop_names=(ro.product.device ro.product.name) - -debug() -{ - [ $dbg_on ] && echo "Debug: $*" -} - -notice() -{ - echo "$*" - echo "$scriptname: $*" > /dev/kmsg -} - -reload_utags() -{ - local mp=$1 - local value - echo "1" > $mp/reload - value=$(cat $mp/reload) - while [ "$value" == "$reload_in_progress" ]; do - notice "waiting for loading to complete" - sleep 1; - value=$(cat $mp/reload) - notice "'$mp' current status [$value]" - done -} - -procfs_wait_for_device() -{ - local __result=$1 - local status - local mpi - local IFS=' ' - while [ ! -f $hw_mp/reload ] || [ ! -f $config_mp/reload ]; do - notice "waiting for devices" - sleep 1; - done - for mpi in $hw_mp; do - status=$(cat $mpi/reload) - notice "mount point '$mpi' status [$status]" - if [ "$status" == "$need_to_reload" ]; then - notice "force $mpi reloading" - reload_utags $mpi - fi - done - for mpi in $hw_mp; do - status=$(cat $mpi/reload) - notice "$mpi reload is [$status]" - while [ "$status" != "$reload_done" ]; do - notice "waiting for loading to complete" - sleep 1; - status=$(cat $mpi/reload) - done - done - eval $__result=$status -} - - - -set_ro_hw_properties() -{ - local utag_path - local utag_name - local prop_prefix - local utag_value - local verify - for hwtag in $(find $hw_mp -name '.system'); do - debug "path $hwtag has '.system' in its name" - prop_prefix=$(cat $hwtag/ascii) - verify=${prefix%.} - # esure property ends with '.' - if [ "$prop_prefix" == "$verify" ]; then - prop_prefix="$prop_prefix." - debug "added '.' at the end of [$prop_prefix]" - - fi - utag_path=${hwtag%/*} - utag_name=${utag_path##*/} - utag_value=$(cat $utag_path/ascii) - setprop $prop_prefix$utag_name "$utag_value" - notice "ro.hw.$utag_name='$utag_value'" - done -} - -# Main starts here -IFS=$'\n' - -notice "initializing procfs" -procfs_wait_for_device readiness - -set_ro_hw_properties - -return 0 - diff --git a/sepolicy/file.te b/sepolicy/file.te index 5792cc1..1836688 100644 --- a/sepolicy/file.te +++ b/sepolicy/file.te @@ -35,7 +35,6 @@ type netmgr_data_file, file_type, data_file_type; type sysfs_adsp, fs_type, sysfs_type; type sysfs_homebutton, fs_type, sysfs_type, mlstrustedobject; type sysfs_mmi_fp, fs_type, sysfs_type; -type sysfs_mmi_touch, fs_type, sysfs_type; type sysfs_capsense, fs_type, sysfs_type; type sysfs_batt, fs_type, sysfs_type; diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts index df8179c..046ba69 100644 --- a/sepolicy/file_contexts +++ b/sepolicy/file_contexts @@ -10,8 +10,6 @@ /system/bin/charge_only_mode u:object_r:charge_only_exec:s0 /system/bin/hci_qcomm_init u:object_r:config_bluetooth_exec:s0 /system/bin/init\.mmi\.boot\.sh u:object_r:mmi_boot_exec:s0 -/system/bin/init\.mmi\.touch\.sh u:object_r:mmi_touch_sh_exec:s0 -/system/bin/init\.oem\.hw\.sh u:object_r:oem-hw-sh_exec:s0 /system/bin/wlan_carrier_bin\.sh u:object_r:init_wifi_exec:s0 /system/bin/motosh u:object_r:sensor_hub_exec:s0 /system/bin/akmd09912 u:object_r:akmd_exec:s0 @@ -30,9 +28,6 @@ /sys/devices/soc/7af8000.spi/spi_master/spi8/spi8.0(/.*)? u:object_r:sysfs_fpc:s0 -# mmi_touch related /sys files -/sys/devices/soc/78b7000\.i2c/i2c-3/3-0020(/.*)? u:object_r:sysfs_mmi_touch:s0 - # Modem /persist/mdm(/.*)? u:object_r:persist_modem_file:s0 diff --git a/sepolicy/mmi_touch_te.te b/sepolicy/mmi_touch_te.te deleted file mode 100644 index 225e34c..0000000 --- a/sepolicy/mmi_touch_te.te +++ /dev/null @@ -1,27 +0,0 @@ -type mmi_touch_sh, domain; -type mmi_touch_sh_exec, exec_type, file_type; -init_daemon_domain(mmi_touch_sh) - -# shell scripts need to execute /system/bin/sh -allow mmi_touch_sh shell_exec:file rx_file_perms; -allow mmi_touch_sh toolbox_exec:file rx_file_perms; - -# Logs to /dev/kmsg -allow mmi_touch_sh kmsg_device:chr_file w_file_perms; - -# Write to /sys/path/to/firmware/forcereflash -# Read from /sys/path/to/firmware/poweron (and others) -allow mmi_touch_sh sysfs_mmi_touch:file rw_file_perms; -allow mmi_touch_sh sysfs_mmi_touch:file setattr; -allow mmi_touch_sh sysfs_mmi_touch:dir search; -allow mmi_touch_sh system_file:dir r_file_perms; -allow mmi_touch_sh self:capability chown; - -# WRONG -allow mmi_touch_sh sysfs:dir r_dir_perms; -allow mmi_touch_sh sysfs:file rw_file_perms; -allow mmi_touch_sh sysfs:file setattr; -allow mmi_touch_sh sysfs:lnk_file getattr; - -set_prop(mmi_touch_sh, touch_prop); -set_prop(mmi_touch_sh, hw_rev_prop); diff --git a/sepolicy/oem-hw-sh.te b/sepolicy/oem-hw-sh.te deleted file mode 100755 index 99d88bf..0000000 --- a/sepolicy/oem-hw-sh.te +++ /dev/null @@ -1,17 +0,0 @@ -type oem-hw-sh, domain; -type oem-hw-sh_exec, exec_type, file_type; -init_daemon_domain(oem-hw-sh) - -allow oem-hw-sh hw_block_device:blk_file { open read write }; -allow oem-hw-sh init:unix_stream_socket connectto; -allow oem-hw-sh kmsg_device:chr_file { write open }; -allow oem-hw-sh proc:file { write getattr open read }; -allow oem-hw-sh property_socket:sock_file write; -allow oem-hw-sh rootfs:file {entrypoint read open }; -allow oem-hw-sh self:capability dac_override; -allow oem-hw-sh shell_exec:file { entrypoint read getattr }; -allow oem-hw-sh system_file:file execute_no_trans; -allow oem-hw-sh system_prop:property_service set; -allow oem-hw-sh toolbox_exec:file { execute execute_no_trans getattr open read }; -allow oem-hw-sh touch_prop:file { getattr open read }; -allow oem-hw-sh touch_prop:property_service set; diff --git a/sepolicy/ueventd.te b/sepolicy/ueventd.te index d360c5a..fd4653d 100644 --- a/sepolicy/ueventd.te +++ b/sepolicy/ueventd.te @@ -1,6 +1,4 @@ allow ueventd sysfs_mmi_fp:file w_file_perms; -allow ueventd sysfs_mmi_touch:file w_file_perms; -allow ueventd sysfs_mmi_touch:dir search; allow ueventd synaptics_rmi_device:chr_file { rw_file_perms relabelfrom relabelto}; allow ueventd sysfs_fpc:file rw_file_perms;