Enable/Disable Stamina Mode with Shell Script - Sony Cross-Device General

Hello people.
First, I must apologize for my bad English. I speak and write not often in English.
So now back to the topic.
I have searched for a way to Stamina mode also be able to control via script, so you can use it for example in combination with Tasker.
Now I have found the solution and wanted to share with you.
The script is just an example of how to use it and can of course be reprogrammed.
The prerequisite is your Smartphone must be rooted.
Script:
#!/system/bin/sh
if [ "$USER" != "root" ]; then
su - root -s "$0" && exit;
elif [ "$(content query --uri content://com.sonymobile.superstamina.xperiapowerservice.provider/xssm/enabled --projection name=enabled --where "name='0'")" == "Row: 0 enabled=false" ]; then
content update --uri content://com.sonymobile.superstamina.xperiapowerservice.provider/xssm/enabled --bind enabled:b:true --where "name='0'";
else
content update --uri content://com.sonymobile.superstamina.xperiapowerservice.provider/xssm/enabled --bind enabled:b:false --where "name='0'";
fi;
Click to expand...
Click to collapse

DarknessFox said:
Hello people.
First, I must apologize for my bad English. I speak and write not often in English.
So now back to the topic.
I have searched for a way to Stamina mode also be able to control via script, so you can use it for example in combination with Tasker.
Now I have found the solution and wanted to share with you.
The script is just an example of how to use it and can of course be reprogrammed.
The prerequisite is your Smartphone must be rooted.
Script:
Click to expand...
Click to collapse
I get this error when trying to execute this on Z1 Compact running 4.4.4:
Code:
[ERROR] Unsupported argument: vider/xssm/enabled

I'm sorry, I have found a mistake in my post. Between pro and vider, must not be a space. So it must be written provider. My Post I have edited.

That's more like it! Thanks very much. I feel so stupid for not figuring that out myself :'(
BTW, should I worry about this output when executing?
Code:
[email protected]:/ # /tmp/toggle_stamina.sh
WARNING: linker: app_process has text relocations. This is wasting memory and is a security risk. Please fix.
WARNING: linker: app_process has text relocations. This is wasting memory and is a security risk. Please fix.
WARNING: linker: app_process has text relocations. This is wasting memory and is a security risk. Please fix.
WARNING: linker: app_process has text relocations. This is wasting memory and is a security risk. Please fix.
[email protected]:/ #
Edit: I just figured out that this is caused by xposed and that there is nothing to worry about. Thanks once again.
Sent from my D5503 using XDA Free mobile app

Hello @DarknessFox , is this script enable both Extended Usage and Extended Standby?

DarknessFox said:
Hello people.
First, I must apologize for my bad English. I speak and write not often in English.
So now back to the topic.
I have searched for a way to Stamina mode also be able to control via script, so you can use it for example in combination with Tasker.
Now I have found the solution and wanted to share with you.
The script is just an example of how to use it and can of course be reprogrammed.
The prerequisite is your Smartphone must be rooted.
Script:
Click to expand...
Click to collapse
Hey can you explain me how to do this.. I am faily new to tasker and shell.. I want to enable stamina mode automatically at 11:00Pm and disable it at 7:00Am. An help would be appreciated.
Thanks

Can someone tell me why stamina mode won't enable wireless data when I move away from WiFi and how can I fix it thanks

Fantastic!!! Is this a script to toggle Stamina Mode? How should it be changed to have only the enable or disable mode?

the gladiator said:
Fantastic!!! Is this a script to toggle Stamina Mode? How should it be changed to have only the enable or disable mode?
Click to expand...
Click to collapse
Code:
#!/system/bin/sh
SCR=$(basename $0)
SET=$1
case $SET in
"on")
content update --uri content://com.sonymobile.superstamina.xperiapowerservice.provider/xssm/enabled --bind enabled:b:true --where "name='0'";
;;
"off")
content update --uri content://com.sonymobile.superstamina.xperiapowerservice.provider/xssm/enabled --bind enabled:b:false --where "name='0'";
;;
*)
echo "USAGE: $SCR <on/off>"
esac

paffo said:
Code:
#!/system/bin/sh
SCR=$(basename $0)
SET=$1
case $SET in
"on")
content update --uri content://com.sonymobile.superstamina.xperiapowerservice.provider/xssm/enabled --bind enabled:b:true --where "name='0'";
;;
"off")
content update --uri content://com.sonymobile.superstamina.xperiapowerservice.provider/xssm/enabled --bind enabled:b:false --where "name='0'";
;;
*)
echo "USAGE: $SCR <on/off>"
esac
Click to expand...
Click to collapse
Can't toggle stamina mode with tasker.
"USAGE: tmp-mksh <on/off>" this is what i am getting as output.

mnsk said:
Can't toggle stamina mode with tasker.
"USAGE: tmp-mksh <on/off>" this is what i am getting as output.
Click to expand...
Click to collapse
You used my proposition for script that need to be run with parameter.
Did you tried in terminal at all ?
USAGE: <scriptname> <on/off>
means
place all code in one file, EX: /system/xbin/staminamode
give execute attrib to this file
run with parameter "on" or "off"

paffo said:
You used my proposition for script that need to be run with parameter.
Did you tried in terminal at all ?
USAGE: <scriptname> <on/off>
means
place all code in one file, EX: /system/xbin/staminamode
give execute attrib to this file
run with parameter "on" or "off"
Click to expand...
Click to collapse
I don't have much knowledge of this. I just tried running the script with tasker with root and show you the output.
If i have to run it with terminal doesn't i have to do it every time?
Please tell how to run it with tasker.

mnsk said:
I don't have much knowledge of this. I just tried running the script with tasker with root and show you the output.
If i have to run it with terminal doesn't i have to do it every time?
Please tell how to run it with tasker.
Click to expand...
Click to collapse
As I said, save this in a file, place in xbin folder, and give executive attribute. In tasker you will have to only run "scriptname on" or "scriptname off"
Dont know how deep is your knowledge, but its crucial to know anything to not break your android.
You can simply place in tasker to run such command for turning on stammina:
Code:
content update --uri content://com.sonymobile.superstamina.xperiapowerservice.provider/xssm/enabled --bind enabled:b:true --where "name='0'";
And for turning off staminna next task with:
Code:
content update --uri content://com.sonymobile.superstamina.xperiapowerservice.provider/xssm/enabled --bind enabled:b:false --where "name='0'";

paffo said:
As I said, save this in a file, place in xbin folder, and give executive attribute. In tasker you will have to only run "scriptname on" or "scriptname off"
Dont know how deep is your knowledge, but its crucial to know anything to not break your android.
You can simply place in tasker to run such command for turning on stammina:
Code:
content update --uri content://com.sonymobile.superstamina.xperiapowerservice.provider/xssm/enabled --bind enabled:b:true --where "name='0'";
And for turning off staminna next task with:
Code:
content update --uri content://com.sonymobile.superstamina.xperiapowerservice.provider/xssm/enabled --bind enabled:b:false --where "name='0'";
Click to expand...
Click to collapse
Okay! help me out..Please check the steps
-save your code in staminamode file
-give it 755 permissions (read only attribute)
- put it in system/xbin
-run shell command from tasker "staminamode on" with root
Is that it?

mnsk said:
Okay! help me out..Please check the steps
-save your code in staminamode file
-give it 755 permissions (read only attribute)
- put it in system/xbin
-run shell command from tasker "staminamode on" with root
Is that it?
Click to expand...
Click to collapse
Yes.
Be aware, that giving 755 permissions not mean read only (7 means read,write,executable, 5 means read,executable), also owner should be "root", so:
Code:
chown root:root /system/xbin/staminamode
chmod 755 /system/xbin/staminamode

paffo said:
Yes.
Be aware, that giving 755 permissions not mean read only (7 means read,write,executable, 5 means read,executable), also owner should be "root", so:
Code:
chown root:root /system/xbin/staminamode
chmod 755 /system/xbin/staminamode
Click to expand...
Click to collapse
Now running shell command staminamode on is giving this error
"/system/bin/sh: SCR=$(basename $0) SET=$1 case $SET in "on") content update --uri content://com.sonymobile.superstamina.xperia: No such file or directory"

mnsk said:
Now running shell command staminamode on is giving this error
"/system/bin/sh: SCR=$(basename $0) SET=$1 case $SET in "on") content update --uri content://com.sonymobile.superstamina.xperia: No such file or directory"
Click to expand...
Click to collapse
Try attached file as your script and please try to run this from adb shell.

paffo said:
Try attached file as your script and please try to run this from adb shell.
Click to expand...
Click to collapse
Tried with terminal emulator and getting same error.

@DarknessFox
Can you help in making a tasker profile for this?

I found an answer
I found a way to toggle STAMINA mode with Tasker.
In Tasker, just create a new task of type "Send Intent". Then in "Action" field, enter :
Code:
com.sonymobile.superstamina.appwidget.TOGGLE_STAMINA_MODE
Then exist Task.
Now, when you enter this Task with a profile, STAMINA mode is toggled on or off. You can check this by adding the STAMINA widget on your home, or by looking at the "+" sign near the battery indicator.
Hope this helps !

Related

Root and android-wifi-tether

Hi!
Short and simple:
I've used this guide to 'root' my HTC magic.
Concerning the guide, my phone is root'ed.
Output of adb shell id
Code:
uid=0(root) gid=0(root)
Now I want to use android-wifi-tether, but the app tells me I ain't got root.
Am I missing something?
Thanks for help,
xenator
xenator said:
Hi!
Short and simple:
I've used this guide to 'root' my HTC magic.
Concerning the guide, my phone is root'ed.
Output of adb shell id
Code:
uid=0(root) gid=0(root)
Now I want to use android-wifi-tether, but the app tells me I ain't got root.
Am I missing something?
Thanks for help,
xenator
Click to expand...
Click to collapse
Does the su-binary exist /system/bin/su?
You could type something like: "ls /system/bin/su" to check that.
If this binary does not exist execute following commands:
adb shell
cd /system/bin
cat sh > su
chmod 4755 su
... try again ...
Code:
# cat sh > su
cat sh > su
cannot create su: read-only file system
Seems like I've to re-mount with 'rw'?
I'm a linux guy, but I don't want to break anything on the phone
Code:
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
Did the job.
Now it seems that my kernel is missing 'netfilter'.
How do I get a kernel with that option compiled?
And again I could help myself
See here.
Thanks for the help so far!
xenator
android-wifi-tether works just fine, but I'm not able to use my "normal" WLAN anymore.
Anytime I try to activate WLAN in the settings it says "WLAN could not be started".
Anyone can help?

Android 4.2.2 (PAC, CM10.1, etc): Mount CIFS share on /sdcard (incl. nls_utf8)

With Android 4.2's multi-user stuff and the dreaded "0" folder, Google broke mounting of CIFS shares for good. (They basically implemented something utterly useless for my needs, and broke something I need on a daily basis.) Cyanogenmod fixed that for mounts outside the /storage hierarchy, but many apps can't go there. And with 4.2.2, Google made using adb on the device very annoying as well, which adds to problems for a workaround for mounting shares in a useful place.
So I looked around for various fixes for that issue and compiled those into one method that works perfectly well for me on a P6810 running the current PAC ROM 20130629. It should probably work for any other CM10.1 or PA3.6x-based ROM as well. A nls_utf8.ko module compiled for the Nexus 10 is included as well, which can be loaded via punchmod (at least in PAC), so you can access shares with Ümläüts in them.
Prerequisites: SManager, SMWidgets, and a working Busybox install (I use Stericson's Busybox Installer).
1.) Extract nls_utf8.ko and punchmod from the attached .zip file and put them in /system/lib/modules. You can put them in some other place as well, but my scripts need to be adjusted then. Next, give the files sufficient permissions:
Code:
chmod 644 /system/lib/modules/nls_utf8.ko
chmod 755 /system/lib/modules/punchmod
2.) Optional: if you want the module to auto-start, create a file called 00punch-nls_utf8 (or whatever you like) with the content below, put it in /etc/init.d and chmod it to 755. To check if nls-utf8 is loaded after a reboot, type lsmod in a terminal window or adb shell - it should display the module name. If punchmod auto-detection fails, read here how to get the right vermagic string for your device: http://forum.xda-developers.com/showthread.php?p=41920265#post41920265
Code:
#!/system/bin/sh
sleep 10
/system/lib/modules/punchmod /system/lib/modules/nls_utf8.ko ""
3.) Here's the script that mounts a CIFS share. Edit the settings on top and either put your correct vermagic string as well, or delete the "$VERMAGIC" part in line 22 and try your luck with auto-detection. I put some sanity checks in the script, but it might not work for all directories in /sdcard (or, /data/media/0, to call it by its 'real' name/location). If you don't want to use the nls-utf8 module, just delete lines 18-23, and iocharset=utf8 in line 67.
Name the script mount-music.sh or something, put the script wherever you like, open SManager and navigate to the script. Run the script with SU permissions. If everything goes well, it will ask you to accept an adb RSA key, and then adb mounts the share. You can also add a desktop widget for quick access to the script with SMWidgets.
Code:
#!/system/bin/sh
# Your settings here
IP="192.168.1.123"
SHARE="Music"
USER="yourusername"
PASS="yourpassword"
MOUNTPOINT="/data/media/0/cifs"
VERMAGIC="3.0.31-CM-ga034655-dirty SMP preempt mod_unload ARMv7 p2v8 "
# Load cifs (if it isn't already loaded)
if [ `lsmod | grep -o cifs` ] ; then
:
else
insmod /system/lib/modules/cifs.ko
fi
# Load nls_utf8 brute-force style (if it isn't already loaded)
if [ `lsmod | grep -o nls_utf8` ] ; then
:
else
/system/lib/modules/punchmod /system/lib/modules/nls_utf8.ko "" "$VERMAGIC"
fi
# Check if cifs $MOUNTPOINT dir exists, create it if not, give sufficient permissions
if [ -d $MOUNTPOINT ] ; then
:
else
mkdir $MOUNTPOINT
fi
chmod 755 $MOUNTPOINT
# Check if $SHARE directory is empty - if not, unmount the share
if [ "$(su root -c busybox ls -A $MOUNTPOINT/$SHARE 2> /dev/null)" == "" ] ; then
:
else
/system/xbin/busybox umount -l $MOUNTPOINT/$SHARE
fi
# Create $SHARE directory if necessary, give sufficient permissions
if [ -d $MOUNTPOINT/$SHARE ] ; then
:
else
mkdir $MOUNTPOINT/$SHARE
fi
chmod 755 $MOUNTPOINT/$SHARE
# Starting adb
adb kill-server
export HOME=/sdcard
# PORT=`getprop service.adb.tcp.port`
setprop service.adb.tcp.port 5555
adb start-server
cat /sdcard/.android/adbkey.pub >> /data/misc/adb/adb_keys
stop adbd
start adbd
adb connect localhost
# Make sure we only use the first device (sometimes there is more than one)
SERIAL=`adb devices | head -n2 | tail -n1 | cut -f1`
if [ "$SERIAL" = "" ] ; then
echo "ERROR: Could not find ADB device.";
fi
# Mounting share via adb
echo Mounting share via adb...
adb -s $SERIAL shell su root -c /system/xbin/busybox mount -t cifs //$IP/$SHARE $MOUNTPOINT/$SHARE -o user=$USER,pass=$PASS,iocharset=utf8,cache=none,directio,CIFSMaxBufSize=130048,rw,file_mode=0777,dir_mode=0777,uid=1015,gid=1015
# If you started adb, then stop it here for security
adb disconnect localhost
stop adbd
PORT=`getprop service.adb.tcp.port`
setprop service.adb.tcp.port $PORT
start adbd
# Show some results
RESULT=`mount | grep $MOUNTPOINT/$SHARE`
if [ "$RESULT" = "" ] ; then
echo "FAILED! //$IP/$SHARE could not be mounted."
else
echo "SUCCESS! //$IP/$SHARE has been mounted on $MOUNTPOINT/$SHARE."
fi
echo
echo All done. You may close this script window now.
4.) This is the script to unmount the share. Name it unmount-music.sh or similar, and edit your settings at the beginning of the script. Again, run it in SManager with SU permissions, and add a desktop widget with SMWidgets if you like.
Code:
#!/system/bin/sh
# Your settings here
SHARE="Music"
MOUNTPOINT="/data/media/0/cifs"
# Check if $SHARE directory exists
if [ -d $MOUNTPOINT/$SHARE ] ; then
# Check if $SHARE directory is empty - if not, unmount the share
if [ "$(su root -c busybox ls -A $MOUNTPOINT/$SHARE 2> /dev/null)" == "" ] ; then
echo "$MOUNTPOINT/$SHARE is empty."
else
su root -c busybox umount -l $MOUNTPOINT/$SHARE
fi
fi
# Show some results
RESULT=`mount | grep $MOUNTPOINT/$SHARE`
if [ "$RESULT" = "" ] ; then
echo "SUCCESS! $MOUNTPOINT/$SHARE has been unmounted."
else
echo "FAILED! $MOUNTPOINT/$SHARE could not be unmounted."
fi
echo
echo All done. You may close this script window now.
Hope this helps some of you. It sure stumped me how incredibly convoluted this simple and much needed procedure has become on Android 4.2.2... just because of that multi-account stuff and new restrictions on adb.
Credits:
Script bits and nls_utf8.ko by H3g3m0n
More script bits by dafunk60 and jmtw000
Punchmod by Jann Horn
Punchmod info by idcrisis
Thanks man, looks awesome, I am going to try it on my 6800.
Do you know how to mount ext4 or ntfs sdcard on CM10.1 based roms?
Removed the original post, still trying to make it work!
I checked vermagic in some existing ko files and found that it is exactly the same as yours.
Sent from my GT-p6800 using Tapatalk HD
m0bster said:
Removed the original post, still trying to make it work!
I checked vermagic in some existing ko files and found that it is exactly the same as yours.
Sent from my GT-p6800 using Tapatalk HD
Click to expand...
Click to collapse
You can try loading the UTF8 module without vermagic string as well, it should work on PAC. Or, make sure you have a blank space at the end of the vermagic string, it is required. Maybe read the short tutorial here: http://forum.xda-developers.com/showthread.php?p=41920265#post41920265
dfkt_ said:
You can try loading the UTF8 module without vermagic string as well, it should work on PAC. Or, make sure you have a blank space at the end of the vermagic string, it is required. Maybe read the short tutorial here: http://forum.xda-developers.com/showthread.php?p=41920265#post41920265
Click to expand...
Click to collapse
I finally managed to mount cifs shares, after loading original cifs and punmode load of nls_utf8.ko.
But I mounted it with cifsmanager. The script always shows "failure to mount" !

Minfree script to /etc/init.d

Please script to /etc/init.d to set the minfree. I don't want any application, I want the script to autostart.
The script will be ok? I'm not asking about the value.
Code:
#!/system/bin/sh
#Created by hinxnz
#Set Minfree and Adj values
bb=$(find /system/ -name 'swapon')
if [ -n "$bb" ] && [ -e "$bb" ] ; then
bb=${bb%/*}
cd $bb
./busybox chmod 664 /sys/module/lowmemorykiller/parameters/minfree
./busybox echo "0,1,2,5,7,16" > /sys/module/lowmemorykiller/parameters/adj
./busybox chmod 444 /sys/module/lowmemorykiller/parameters/adj
./busybox chmod 664 /sys/module/lowmemorykiller/parameters/minfree
./busybox echo "9933,10728,14950,17510,20019,31385" > /sys/module/lowmemorykiller/parameters/minfree
./busybox chmod 444 /sys/module/lowmemorykiller/parameters/minfree
fi
Tell someone? The above and below are not working:
Code:
echo "0,1,2,5,7,15" > /sys/module/lowmemorykiller/parameters/adj
echo "5120,7680,11520,15360,20480,25600" > /sys/module/lowmemorykiller/parameters/minfree
This is the Nexus 7 2013 forum. I think you want this thread.
I know that this forum Nexus 7 2013. To him I need a script.
WSZR said:
I know that this forum Nexus 7 2013. To him I need a script.
Click to expand...
Click to collapse
Does the kernel you are using support init.d? What kernel?
If you have a kernel that supports it, is the perms set so it can execute? is it getting executed at all at startup?, maybe have it echo a value into a file to make sure it is getting executed. Does it execute and work if you run it manually?
I use ElementalX, supports init.d. BusyBox installed. In the terminal script "echo" works. Changing "minfree" in applications "Kernel Tweaker" works.
I can't verify startup. I tried the script from entering text into a blank file, not be made.
Code:
echo test > /data/data/file
In "init.d" is script to configure the kernel and perhaps to perform.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
I don't know how to manage permissions in "init.d". File with the script I gave full permissions. A postscript of permissions must be before the script?
The script is executed:
Code:
#!/system/bin/sh
chmod 664 /data/data/file
echo test > /data/data/file
chmod 444 /data/data/file
I'll try to convert to "minfree".
WSZR said:
I use ElementalX, supports init.d. BusyBox installed. In the terminal script "echo" works. Changing "minfree" in applications "Kernel Tweaker" works.
I can't verify startup. I tried the script from entering text into a blank file, not be made.
Code:
echo test > /data/data/file
In "init.d" is script to configure the kernel and perhaps to perform.
I don't know how to manage permissions in "init.d". File with the script I gave full permissions. A postscript of permissions must be before the script?
Click to expand...
Click to collapse
I use the same kernel.
The script for minfree that you try to run from init.d, did you set the perms to 777 on it? It sounds like you have, but I am just making sure.
Have you tried appending the lines (from your post #2 above), to /etc/init.d/99elementalx to see if they get executed?
Something else to try:
Backup 99elementalx first, then try placing these lines in 99elementalx at the bottom, just above "exit 0". (This assumes you have the binary busybox in /system/xbin (you should, it's the proper place for it for this device), or a path that is in your $PATH environment.)
Code:
chmod 664 /sys/module/lowmemorykiller/parameters/minfree
echo "0,1,2,5,7,16" > /sys/module/lowmemorykiller/parameters/adj
chmod 444 /sys/module/lowmemorykiller/parameters/adj
chmod 664 /sys/module/lowmemorykiller/parameters/minfree
echo "9933,10728,14950,17510,20019,31385" > /sys/module/lowmemorykiller/parameters/minfree
chmod 444 /sys/module/lowmemorykiller/parameters/minfree
#test to see if executed
echo test > /sdcard/minfreetest.txt
Reboot, and see if there is the word test in /sdcard/minfreetest.txt.
If so, cat your minfree and adj files and see if they have your desired values.
mdamaged said:
I use the same kernel.
The script for minfree that you try to run from init.d, did you set the perms to 777 on it? It sounds like you have, but I am just making sure.
Have you tried appending the lines (from your post #2 above), to /etc/init.d/99elementalx to see if they get executed?
Something else to try:
Backup 99elementalx first, then try placing these lines in 99elementalx at the bottom, just above "exit 0". (This assumes you have the binary busybox in /system/xbin (you should, it's the proper place for it for this device), or a path that is in your $PATH environment.)
Code:
chmod 664 /sys/module/lowmemorykiller/parameters/minfree
echo "0,1,2,5,7,16" > /sys/module/lowmemorykiller/parameters/adj
chmod 444 /sys/module/lowmemorykiller/parameters/adj
chmod 664 /sys/module/lowmemorykiller/parameters/minfree
echo "9933,10728,14950,17510,20019,31385" > /sys/module/lowmemorykiller/parameters/minfree
chmod 444 /sys/module/lowmemorykiller/parameters/minfree
#test to see if executed
echo test /sdcard/minfreetest.txt
Reboot, and see if there is the word test in /sdcard/minfreetest.txt.
If so, cat your minfree and adj files and see if they have your desired values.
Click to expand...
Click to collapse
When added to 99elementalx script works.
Strange that in a separate file does not work, even though other scripts are running.
Thanks for your help.
WSZR said:
When added to 99elementalx script works.
Strange that in a separate file does not work, even though other scripts are running.
Thanks for your help.
Click to expand...
Click to collapse
Well try this.
Comment out those lines from 99elementalx and create a new file /etc/init.d/98minfree
Put the contents in it below:
Code:
#!/system/bin/sh
chmod 664 /sys/module/lowmemorykiller/parameters/minfree
echo "0,1,2,5,7,16" > /sys/module/lowmemorykiller/parameters/adj
chmod 444 /sys/module/lowmemorykiller/parameters/adj
chmod 664 /sys/module/lowmemorykiller/parameters/minfree
echo "9933,10728,14950,17510,20019,31385" > /sys/module/lowmemorykiller/parameters/minfree
chmod 444 /sys/module/lowmemorykiller/parameters/minfree
#test to see if executed
echo newtest > /sdcard/minfreetest.txt
save it as /etc/init.d/98minfree ...then chmod it 777 (rwxrwxrwx), then reboot, and see if it worked.
If you have to leave it in 99elementalx to make it work, it will get wiped the next time you flash the kernel again. Alternatively, you can just forget init.d, and use tasker to execute the commands.

Make Viper4Android 2.4.0.1 work on Android 6.0

I had some trouble trying to make Viper4Android v2.4.0.1 work on my Honor 5C running Android 6.0. This could be helpful…
Viper4Android didn't work after installation and reboot, the driver status showing as "abnormal". It seems related to a change in default SELinux policy.
I read that changing globally the SELlinux policy to "permissive" can solve the problem but it may be an extreme solution (SELinux is a security feature to restrict what an application can do, I don't know the potential edge effects).
I found another solution on the web, which consists in patching the SELinux policies at boot, just enough for Viper4Android to work.
If you did not make a systemless installation of SuperSU, open an adb shell and use these commands (courtesy of androiding.how):
Code:
su
mount -o rw,remount /system
cd /system/su.d
echo '#! /system/bin/sh' > 50viper.sh
echo '/system/xbin/supolicy --live "allow mediaserver mediaserver_tmpfs:file { read write execute };"' >> 50viper.sh
chmod 755 50viper.sh
cd /
mount -o ro,remount /system
And reboot.
If you did make a systemless installation of SuperSU, open an adb shell and use this instead:
Code:
su
mount -o rw,remount /su
cd /su/su.d
echo '#! /system/bin/sh' > 50viper.sh
echo '/su/bin/supolicy --live "allow mediaserver mediaserver_tmpfs:file { read write execute };"' >> 50viper.sh
chmod 755 50viper.sh
cd /
mount -o ro,remount /su
exit
And reboot.
Didn't work for me, tried the 2nd method as the first one gave an error at the 3rd step, completed everything, rebooted, still no luck
imrock said:
Didn't work for me, tried the 2nd method as the first one gave an error at the 3rd step, completed everything, rebooted, still no luck
Click to expand...
Click to collapse
I just noticed that in my 2nd block the characters ’ and ” were used instead of ' and ". I'm not a POSIX shell expert but since these are not the same characters it can make a difference.
I've updated the 2nd method, you can give it a try — you can use it "as it is", it will overwrite the previously created file.
This trick didn't work for me.
I ended up installing SELinuxModeChanger and now Viper is rockin' :good:

[SCRIPT] Log CPU Usage with interval (Linux)

Hey guys, I've just decided to get inside of the Android development world. Anyways, I'm mostly a fan of Linux, so I've made my first Linux script, I know it's simple, but I've never interacted with the user before, or picked an output. When I knew that Android made use of Linux in its core, my interest on working inside it grew up faster than ever.
In my script, firstly, you type the filename. For compatibility reasons, it'll everytime save to /sdcard/filename. Then, it will ask you how many times you want the script to log everything, and lately, every how many seconds should it save everything to the file.
The script will save, before every entry at the log, the screen status (if it's on or off), that can help to, for example, if your device has been lagging as a result of a bad screen driver or UI error.
Last thnig: it also works on recovery (maybe it give some error, and if no dumpsys is present on your recovery's ramdisk, it'll save everything as OFF).
Remember to send it anywhere excepting from /storage and any sbudir, it won't work as the Android permissions system blocks script execution on those dirs.
Code:
clear
# Wipe $logfile content in /sdcard (if any existing)
echo "Please type the filename where you want to save the log: "
read -r logfile
echo "" > /sdcard/$logfile
echo "Deleted previous log."
echo "SCREEN | CPU" >> /sdcard/$logfile
#cont=60
cont=1
#SHOWLOG=X
echo "Please type how many times the cycle must repeat: "
read -r maxcont
echo "Please type how many seconds will the interval take: "
read -r maxmin
clear
# Here it counts how many times the logging script has been ran
while [ $cont -lt $((maxcont + 1)) ];
do
# That nested while takes control of how many seconds have passed in the current cycle
while [ "$contmin" -lt "$maxmin" ];
do
contmin=$((contmin + 1))
sleep 1
clear
echo "C: $cont/$maxcont - T: $contmin/$maxmin"
done
# echo "$maxmin seconds passed."
# Logs the fist line of "busybox top" to a var
LOGVAR=$(busybox top -d 1 -n 1 | grep "idle")
# Logs the screen state (on or off) to another var
SCREENSTATE=$(dumpsys input_method | grep mScreenOn | tr -dc '[:alnum:]\n\r' | tr '[:upper:]' '[:lower:]')
# Saves a string that tells what it should expect if the screen is on
SCREENSTATEON="msystemreadytruemscreenontrue"
if [ "$SCREENSTATE" == "$SCREENSTATEON" ]
then
echo "ON: $LOGVAR" >> /sdcard/$logfile
else
echo "OFF: $LOGVAR" >> /sdcard/$logfile
fi
cont=$((cont + 1))
contmin=0
done
echo "Show logged values? [Y/N]"
read -r SHOWLOG
case $SHOWLOG in
[yY] | [yY][Ee][Ss] )
cat /sdcard/$logfile
;;
[nN] | [n|N][O|o] )
echo "Ok, goodbye. You'll see a what you've asked me to log in /sdcard/$logfile";
exit 1
;;
*) echo "You must write Y or N to continue."
;;
esac
exit 0
For example, save it as script.sh (remember to save it using Unix codifcation, if you're running Windows, else, it'll tell you that it's unable to find many binaries, as long as Linux isn't ok with CR+LF and requires LF as newline). Then, send it to the sdcard (over USB or adb push script.sh /sdcard/) , now, run ADB shell. Type the following commands:
Code:
su -c "cp -f /sdcard/script.sh /data/local/;chmod 777 /data/local/script.sh"
Then, if you want to run it:
Code:
su
sh /data/local/script.sh
That's all, I hope you enjoy it and not so many people kills me for explaining and feeling so grateful for that simple script.

Categories

Resources