[Galaxy S6 General] stangdriver44:
[GUIDE]MMS Screen Off Receiving Notification for MM no smali edits​

Example of running a shell script using Rom Control​

First, I want to give another example of the use of shell (.sh) script using Rom Control app.

I am using to be able to have the screen either come on or stay off when receiving a new text message.

The reason for the script is either Samsung removed the smali for this or I just can't find it?

Either way, this script worked for what I wanted to achieve.

I will give a little more detail to what the script is doing because I believe the use of these scripts is very powerful and underused because not enough of us understand the script

In this example the script is going modify the preference file for MMS (com.android.mms_preferences.xml)

to run a shell script we need to call the applet by starting the code with this

#!/system/bin/sh
export PATH=/system/bin:$PATH

We also need to mount partitions RW (read, write) like this

busybox mount -o remount,rw /system

Now to begin the shell script

First it's going to confirm the file is present in the system and then begin to execute by using this command with the location to look

if [ -f /data/data/com.android.mms/shared_prefs/com.android.mms_preferences.xml ] ; then

Now I've noticed that the preference (boolean name="pref_key_backlight") we want to change isn't always present in the xml file

So the next part is going to search for and delete if it is present so we don't get duplicate entries

sed -i '/boolean name="pref_key_backlight" value="false"/d' /data/data/com.android.mms/shared_prefs/com.android.mms_preferences.xml
sed -i '/boolean name="pref_key_backlight" value="true"/d' /data/data/com.android.mms/shared_prefs/com.android.mms_preferences.xml

we also need to remove the part that represents the "end" (</map>) of the xml file like this

sed -i '/\/map/D' /data/data/com.android.mms/shared_prefs/com.android.mms_preferences.xml

So now we have clear any possibilities of adding duplicate lines and removed the closing line of the xml we can add the new line for the preference we want like this

echo ' <boolean name="pref_key_backlight" value="false" />' >> /data/data/com.android.mms/shared_prefs/com.android.mms_preferences.xml

for this mod "false" equals screen will NOT turn on when getting a new text message

and "true" means the screen WILL turn on

So we've added the line we want and now we need to close the xml with the ending we removed like this

echo '</map>' >> /data/data/com.android.mms/shared_prefs/com.android.mms_preferences.xml

and the to finish the command we use this

fi

The last part of this will be to run a restart cmd for the MMS app to take effect immediately

pkill -TERM -f com.android.mms

NOTE: for these scripts to be finished and ran properly you MUST have a blank line at the bottom

So now here is what the final script will look like so you can place the file in your assets folder to be run by your RC app

This is for the Screen to remain off

#!/system/bin/sh
export PATH=/system/bin:$PATH

busybox mount -o remount,rw /system
busybox mount -o remount,rw /data

if [ $? != 0 ] ; then exit
fi

if [ -f /data/data/com.android.mms/shared_prefs/com.android.mms_preferences.xml ] ; then
sed -i '/boolean name="pref_key_backlight" value="false"/d' /data/data/com.android.mms/shared_prefs/com.android.mms_preferences.xml
sed -i '/boolean name="pref_key_backlight" value="true"/d' /data/data/com.android.mms/shared_prefs/com.android.mms_preferences.xml
sed -i '/\/map/D' /data/data/com.android.mms/shared_prefs/com.android.mms_preferences.xml
echo ' <boolean name="pref_key_backlight" value="false" />' >> /data/data/com.android.mms/shared_prefs/com.android.mms_preferences.xml
echo '</map>' >> /data/data/com.android.mms/shared_prefs/com.android.mms_preferences.xml
fi

pkill -TERM -f com.android.mms

This is for the Screen turn on

#!/system/bin/sh
export PATH=/system/bin:$PATH

busybox mount -o remount,rw /system
busybox mount -o remount,rw /data

if [ $? != 0 ] ; then exit
fi

if [ -f /data/data/com.android.mms/shared_prefs/com.android.mms_preferences.xml ] ; then
sed -i '/boolean name="pref_key_backlight" value="false"/d' /data/data/com.android.mms/shared_prefs/com.android.mms_preferences.xml
sed -i '/boolean name="pref_key_backlight" value="true"/d' /data/data/com.android.mms/shared_prefs/com.android.mms_preferences.xml
sed -i '/\/map/D' /data/data/com.android.mms/shared_prefs/com.android.mms_preferences.xml
echo ' <boolean name="pref_key_backlight" value="true" />' >> /data/data/com.android.mms/shared_prefs/com.android.mms_preferences.xml
echo '</map>' >> /data/data/com.android.mms/shared_prefs/com.android.mms_preferences.xml
fi

pkill -TERM -f com.android.mms

Now for the RomControl additions

add these or the newly written script files to the assets/scripts, then add the following lines to the pref.xml of your choice

The lines in red are the names of the scripts.

NOTE: The script file will have the ".sh" extension at the end, but make SURE NOT to have the .sh in the RC xml lines

EXTRA NOTE: THIS METHOD FOR RUNNING SCRIPTS IS NOT COMPATIBLE FOR ROM CONTROL V2

<PreferenceScreen android:title="DO NOT Wake Screen for Incoming Text" android:key="script#[COLOR="red"]mms_screenwake_disable[/COLOR]" android:summary="Screen will Stays OFF when receiving a text" />
<PreferenceScreen android:title="Wake Screen for Incoming Text" android:key="script#[COLOR="red"]mms_screenwake_enable[/COLOR]" android:summary="Screen will Wake when receiving a text" />

So with the brief explanation of the specific cmd line of the shell script you should have a little better understanding and at least a starting point for other thing you might want to run.

With MM changing the way the Data Base is written and read this can still be useful for changing existing db edits.

We can get into that at a later time as I am still testing this.

I want to end by saying I CAN NOT guarantee this script will work for you and your device, but I do KNOW IT WORKS for me and using my TMO Flat S6 6.0.1

Good day and Happy Modding!!!