CM7DX2 WIFI and Dialer fix/mod!
If you are having problems with WIFI staying connected... Read this!
If you are having problems with the Dialer dialing out 30-120 (or more) seconds after hitting the call button... Read this!
DISCLAIMER: This have ONLY been tested to work on CM7DX2! Also, as with any of my mods or fixes, you are doing this at your own risk. I cannot and will not be held liable or responsible for what YOU choose to do to your phone.
The reason I chose to implement the cron instead of just running scripts or something like that was because I didn't want anyone to have to download one or more apps to do this, and I also wanted to keep the overhead as low as possible.
Now, on to the good stuff!
If you are impatient, download the flashable zip and flash it in BSR. No need to wipe data, cache, or dalvik-cache, although wiping cache and dalvik-cache can't/won't hurt.
In addition to flashing this, you also, MUST enable WIFI Never Sleep! Goto Menu -> Settings -> Wireless & Networks -> Wi-Fi Settings -> Menu -> Advanced -> Wi-Fi- Sleep Policy, then tape Never and hit the back button 4 times!
Background:
After test driving CM7DX2 for DragonZKiller, I had turned it into my daily driver. Everyone who has tried it knows that it is a very stable ROM and works very well. Anyhow, after having it as my daily driver for about 2 weeks, I noticed, on some occasions, it would take 30-120 (or more) seconds to actually dial the call AFTER I hit the Call button, or worse, it would FC on me. Over time, this became very frustrating to me because I could reboot my phone and my outgoing calls would be sent practically the moment I tapped the Call button. This was frustrating to no end because I couldn't nail down what or why it was doing it.
I then started keeping a log of my use of my phone and my observations (yes, true engineer here). I noticed after about 60 minutes of idle time, me not futzing with my phone, the dialer lag (or FC) would appear. That got me to thinking that something was killing the dialer, so I started looking at the CyanogenMod settings as I remembered there was a setting to "Purge Assests" or something like that... Because I set the setting weeks earlier when I was playing with the phone...
I found the setting in Menu -> Settings -> CyanogenMod Settings -> Performance Settings -> Allow Purging of Assets. I removed the check mark next to it and, to be safe, rebooted the phone.
Again, I went back to logging my usage on my phone... Again, after about 60 minutes of idle time, the dialer lag (or FC) would be back.
This has me very frustrated now, because, silly me, I would like my phone to act like a phone when I need it to be a phone... And, not just a development tool, or a device to play Angry Birds, or... You get the idea.
I started poking around to see what was happening to the dialer, when I remembered that ZepplinRox had a thread somewhere pertaining to renicing an app... [FIX] Bulletproof Background Apps! Hot damn! I think this is what I need to look at! Now to find the dialer...
This is easier said then done. I thought I would be a smart ass and just type:
Well, that didn't work. Okay, then I tried:
and various permutations of dialer. Still can't find any process called dialer! Damn it! WTF? I then remembered taking with DZK during the development of the CM7DX2 ROM and he was saying something about the phone/dialer not working... Wait.... Phone?!?!?! Okay, so back to ps..
BINGO! Pay dirt! Well, almost. So, I found the "dailer" process... com.android.phone. Great! Now what? Then I remembered DZK saying something about rild... And there was a problem there that was linked to the radio/phone/dialer. Wait, radio?!?!?! Rild?!?!?!?! WTF now? Now I have to look at renicing two things? Great... *sigh*
So, I started looking at ZepplinRox's scripts to renice the dialer, phone, rild, radio... What ever! I was trying to figure out a consistent way to run the renice command at a specific interval... Wait, ZepplinRox is using init.d to run his scripts and it has a sleep command in the script so it sleeps for that long then restarts the command. That is good, but what keeps the android scheduler from killing the script... Android Scheduler?!?!?! Wait... Hold on a sec! I think that is where the problem lies! So, off to do more research!
So within adb, I started running htop to watch the nice level on the com.android.phone process, and in another adb session, I reniced the process com.android.phone. After about 35-40 minutes, I noticed the nice level on the com.android.phone process was being elevated. Then at about 60 minutes, when I tried to use the dialer, it lagged. Ah ha! Now, how do I renice the dialer so that is sticks and works.
I understand cron in Linux, and thought about enabling the cron on Android. I found this blog by imoseyon: cron on android is awesome which pointed me in the right direction.
The Solution:
After much work, I finally was able to have cron running on my DX2!
I created a flashable zip that would install the cron files and enable it on boot. I then created a folder in /data called scripts and put my cron called script (com_android_phone.sh) in there. I set up the cron job to run every 30 minutes. this script doesn't actually renice the process, it renices ALL processes owned by the user radio, which is both com.android.phone and /system/bin/rild. That way, they both stay at a low enough nice level to stay active.
I also enabled logging on the crond and logging for the script which logs to /data/scripts/log/com_android_phone.log. Then, I thought that the script's log file (which logs the renice every 30 minutes) would, over time, fill up all available space in /data. I then created a second cron job that would delete this log file every Sunday morning at 5:00AM.
Myself, litetaker, lesismore, and a couple of others have been testing this and the WIFI cron job and it seems to be working.
WIFI cron job:
So, then I wondered if the Android Scheduler could possibly be affecting WIFI in sleep mode as well. I found there is a user WIFI that owns the wifi process /system/bin/wpa_supplicant, and the wpa_supplicant process is present with both open and secured access points, and is only running when WIFI is connected.
So, I created a cron job to renice all processes owned by wifi and have that one running every 15 minutes because I noticed that the disconnects seem to happen after 15-30 minutes of idle time. (In my original thread, I stated that I was not having WIFI connection issues... This is not entirely true, I use tasker to activate/deactivate several wifi situational profiles, so I wasn't seeing it.) This script also writes a log to /data/scripts/log/wpa_supplicant_renice.log every time it runs so I have that script being deleted every Sunday morning at 5:00AM as well.
I sincerely hope this mod helps everyone that has WIFI issues on CM7DX2. This mod MIGHT work on other DX2 ROMs, but I specifically did not test other ROMs as the problem was primarily in CM7DX2.
If you know what you are doing, feel free to open up the zip and port to cron to other ROMs. Also, make sure you set the correct permissions on and scripts you create and on the root "crontab" are all correct, to avoid issues with the scripts not running.
DOWNLOAD:
cron_scheduler_signed.zip
If you have issues, please note them in this thread, or better yet, come to IRC at http://webchat.freenode.net and join channel #cm7dx2. I'm usually in there. Enjoy!
Ciao!
If you are having problems with WIFI staying connected... Read this!
If you are having problems with the Dialer dialing out 30-120 (or more) seconds after hitting the call button... Read this!
DISCLAIMER: This have ONLY been tested to work on CM7DX2! Also, as with any of my mods or fixes, you are doing this at your own risk. I cannot and will not be held liable or responsible for what YOU choose to do to your phone.
The reason I chose to implement the cron instead of just running scripts or something like that was because I didn't want anyone to have to download one or more apps to do this, and I also wanted to keep the overhead as low as possible.
Now, on to the good stuff!
If you are impatient, download the flashable zip and flash it in BSR. No need to wipe data, cache, or dalvik-cache, although wiping cache and dalvik-cache can't/won't hurt.
In addition to flashing this, you also, MUST enable WIFI Never Sleep! Goto Menu -> Settings -> Wireless & Networks -> Wi-Fi Settings -> Menu -> Advanced -> Wi-Fi- Sleep Policy, then tape Never and hit the back button 4 times!
Background:
After test driving CM7DX2 for DragonZKiller, I had turned it into my daily driver. Everyone who has tried it knows that it is a very stable ROM and works very well. Anyhow, after having it as my daily driver for about 2 weeks, I noticed, on some occasions, it would take 30-120 (or more) seconds to actually dial the call AFTER I hit the Call button, or worse, it would FC on me. Over time, this became very frustrating to me because I could reboot my phone and my outgoing calls would be sent practically the moment I tapped the Call button. This was frustrating to no end because I couldn't nail down what or why it was doing it.
I then started keeping a log of my use of my phone and my observations (yes, true engineer here). I noticed after about 60 minutes of idle time, me not futzing with my phone, the dialer lag (or FC) would appear. That got me to thinking that something was killing the dialer, so I started looking at the CyanogenMod settings as I remembered there was a setting to "Purge Assests" or something like that... Because I set the setting weeks earlier when I was playing with the phone...
I found the setting in Menu -> Settings -> CyanogenMod Settings -> Performance Settings -> Allow Purging of Assets. I removed the check mark next to it and, to be safe, rebooted the phone.
Again, I went back to logging my usage on my phone... Again, after about 60 minutes of idle time, the dialer lag (or FC) would be back.
This has me very frustrated now, because, silly me, I would like my phone to act like a phone when I need it to be a phone... And, not just a development tool, or a device to play Angry Birds, or... You get the idea.
I started poking around to see what was happening to the dialer, when I remembered that ZepplinRox had a thread somewhere pertaining to renicing an app... [FIX] Bulletproof Background Apps! Hot damn! I think this is what I need to look at! Now to find the dialer...
This is easier said then done. I thought I would be a smart ass and just type:
Code:
ps | grep dialer
Code:
ps | grep Dialer
Code:
ps | grep phone
radio 2179 2037 147608 25472 ffffffff afd0c7cc S com.android.phone
So, I started looking at ZepplinRox's scripts to renice the dialer, phone, rild, radio... What ever! I was trying to figure out a consistent way to run the renice command at a specific interval... Wait, ZepplinRox is using init.d to run his scripts and it has a sleep command in the script so it sleeps for that long then restarts the command. That is good, but what keeps the android scheduler from killing the script... Android Scheduler?!?!?! Wait... Hold on a sec! I think that is where the problem lies! So, off to do more research!
So within adb, I started running htop to watch the nice level on the com.android.phone process, and in another adb session, I reniced the process com.android.phone. After about 35-40 minutes, I noticed the nice level on the com.android.phone process was being elevated. Then at about 60 minutes, when I tried to use the dialer, it lagged. Ah ha! Now, how do I renice the dialer so that is sticks and works.
I understand cron in Linux, and thought about enabling the cron on Android. I found this blog by imoseyon: cron on android is awesome which pointed me in the right direction.
The Solution:
After much work, I finally was able to have cron running on my DX2!
I created a flashable zip that would install the cron files and enable it on boot. I then created a folder in /data called scripts and put my cron called script (com_android_phone.sh) in there. I set up the cron job to run every 30 minutes. this script doesn't actually renice the process, it renices ALL processes owned by the user radio, which is both com.android.phone and /system/bin/rild. That way, they both stay at a low enough nice level to stay active.
I also enabled logging on the crond and logging for the script which logs to /data/scripts/log/com_android_phone.log. Then, I thought that the script's log file (which logs the renice every 30 minutes) would, over time, fill up all available space in /data. I then created a second cron job that would delete this log file every Sunday morning at 5:00AM.
Myself, litetaker, lesismore, and a couple of others have been testing this and the WIFI cron job and it seems to be working.
WIFI cron job:
So, then I wondered if the Android Scheduler could possibly be affecting WIFI in sleep mode as well. I found there is a user WIFI that owns the wifi process /system/bin/wpa_supplicant, and the wpa_supplicant process is present with both open and secured access points, and is only running when WIFI is connected.
So, I created a cron job to renice all processes owned by wifi and have that one running every 15 minutes because I noticed that the disconnects seem to happen after 15-30 minutes of idle time. (In my original thread, I stated that I was not having WIFI connection issues... This is not entirely true, I use tasker to activate/deactivate several wifi situational profiles, so I wasn't seeing it.) This script also writes a log to /data/scripts/log/wpa_supplicant_renice.log every time it runs so I have that script being deleted every Sunday morning at 5:00AM as well.
I sincerely hope this mod helps everyone that has WIFI issues on CM7DX2. This mod MIGHT work on other DX2 ROMs, but I specifically did not test other ROMs as the problem was primarily in CM7DX2.
If you know what you are doing, feel free to open up the zip and port to cron to other ROMs. Also, make sure you set the correct permissions on and scripts you create and on the root "crontab" are all correct, to avoid issues with the scripts not running.
DOWNLOAD:
cron_scheduler_signed.zip
If you have issues, please note them in this thread, or better yet, come to IRC at http://webchat.freenode.net and join channel #cm7dx2. I'm usually in there. Enjoy!
Ciao!
Last edited: