From bbf476904e0d90e4899ad0e928b4b30b48a18c91 Mon Sep 17 00:00:00 2001 From: egaunnac Date: Thu, 18 Apr 2024 20:48:35 -0600 Subject: [PATCH] dre: Setup sim restart shell script sm8450 and above have a very annoying SMS receiving bug where for some carriers it won't work after a device restart if QTI telephony injection isn't available, but one of the workarounds is to either use airplane mode toggle or eject the sim card and reinsert it Instead of doing that? Let's try and automate disabling and enabling the sim card EDIT: Some holi/blair devices have this problem too. Co-authored-by: Marc Bourgoin Change-Id: I76732c2a668ff179e32050aee4abe315de3d9357 --- device.mk | 1 + init/Android.bp | 5 +++++ init/init.oplus.rc | 7 +++++++ init/init.sim.restart.sh | 16 ++++++++++++++++ sepolicy/private/file_contexts | 1 + sepolicy/private/init_sim_restart.te | 14 ++++++++++++++ 6 files changed, 44 insertions(+) create mode 100755 init/init.sim.restart.sh create mode 100644 sepolicy/private/file_contexts create mode 100644 sepolicy/private/init_sim_restart.te diff --git a/device.mk b/device.mk index d85b46f..b870591 100644 --- a/device.mk +++ b/device.mk @@ -268,6 +268,7 @@ PRODUCT_PACKAGES += \ init.qcom.sh \ init.qcom.usb.rc \ init.qcom.usb.sh \ + init.sim.restart.sh \ init.target.rc \ ueventd.oplus.rc \ ueventd.qcom.rc diff --git a/init/Android.bp b/init/Android.bp index 6358f9e..105aadf 100644 --- a/init/Android.bp +++ b/init/Android.bp @@ -76,3 +76,8 @@ sh_binary { src: "init.qcom.sh", vendor: true, } + +sh_binary { + name: "init.sim.restart.sh", + src: "init.sim.restart.sh", +} \ No newline at end of file diff --git a/init/init.oplus.rc b/init/init.oplus.rc index edb1745..6057a57 100644 --- a/init/init.oplus.rc +++ b/init/init.oplus.rc @@ -44,6 +44,7 @@ on property:sys.boot_completed=1 copy /vendor/etc/Oppo_QC_LTM_Commercial_SM8250_2020_01_15.pfm /mnt/vendor/persist/data/pfm/licenses/1000-1000-no-exp-1186717196.pfm chmod 0600 /mnt/vendor/persist/data/pfm/licenses/1000-1000-no-exp-1186717196.pfm chown system system /mnt/vendor/persist/data/pfm/licenses/1000-1000-no-exp-1186717196.pfm + start sim-restart on property:vendor.post_boot.parsed=1 # IRQ Tuning @@ -109,3 +110,9 @@ service oplus_sensor_fb /odm/bin/oplus_sensor_fb group system class late_start oneshot + +service sim-restart /system/bin/init.sim.restart.sh + user root + class main + oneshot + disabled diff --git a/init/init.sim.restart.sh b/init/init.sim.restart.sh new file mode 100755 index 0000000..ee33bc9 --- /dev/null +++ b/init/init.sim.restart.sh @@ -0,0 +1,16 @@ +#!/system/bin/sh +# +# Copyright (C) 2024 The LineageOS Project +# +# SPDX-License-Identifier: Apache-2.0 +# + +sleep 1 + +service call phone 185 i32 0 i32 0 +service call phone 186 i32 0 i32 0 + +sleep 2 + +service call phone 185 i32 0 i32 1 +service call phone 186 i32 0 i32 1 diff --git a/sepolicy/private/file_contexts b/sepolicy/private/file_contexts new file mode 100644 index 0000000..1a8497e --- /dev/null +++ b/sepolicy/private/file_contexts @@ -0,0 +1 @@ +/system/bin/init\.sim\.restart\.sh u:object_r:init_sim_restart_exec:s0 diff --git a/sepolicy/private/init_sim_restart.te b/sepolicy/private/init_sim_restart.te new file mode 100644 index 0000000..39dc762 --- /dev/null +++ b/sepolicy/private/init_sim_restart.te @@ -0,0 +1,14 @@ +type init_sim_restart, domain, coredomain; +type init_sim_restart_exec, system_file_type, exec_type, file_type; + +init_daemon_domain(init_sim_restart) + +allow init_sim_restart init:unix_stream_socket connectto; +allow init_sim_restart property_socket:sock_file write; +allow init_sim_restart shell_exec:file { execute getattr map read }; +allow init_sim_restart toolbox_exec:file { execute execute_no_trans getattr map open read }; + +allow init_sim_restart radio:binder call; +allow init_sim_restart radio_service:service_manager find; +allow init_sim_restart servicemanager:binder call; +allow init_sim_restart system_file:file execute_no_trans;