[PATCH][MOD] Ringer volume control vibrate & silent (7/21/11, EF02 port)

Search This thread

mkasick

Retired Recognized Developer
Aug 10, 2009
470
830
7/21/11 Update: RandomKing has ported this mod to EF02. It's available here. Thanks!

Attached is a platform source patch against android-cts-2.2_r2 that modifies the ringer volume control (side rocker) to include both vibrate & silent options, as was present in Eclair. Also attached is a smali patch against EC05's /system/framework/framework.odex that implements the fix in bytecode.

Finally, attached are testkey-recovery (e.g., ClockworkMod) flashable "update.zip"s, one containing a modified framework.jar for deodexed ROMs, the other containing a modified framework.odex for odexed (stock) ROMs. Both updates include this modification, as well as the TWS bug fix.

I've tested the odex update under stock (w/testkey) recovery, but not ClockworkMod as I currently don't use it, although I imagine it works fine. I've not tested the deodex update as I run an odexed ROM (edit: others report it works too). I have no reason to suspect it wouldn't work, but the usual caveat of keeping a copy of Odin+tar, ClockworkMod backup, etc., to restore should something unexpected happen applies.

Edit: If you're running a custom ROM with other framework.jar changes, it's probably best to wait for that ROM to incorporate the patch.

Background:

The Eclair ringer volume control (popup on press of the side volume rocker) contains "ringer vibrate" and "ringer silent" options. In Froyo, this was simplified to a single "ringer vibrate" or "ringer silent" option, depending on the Vibrate setting (Settings -> Sound -> Vibrate). While perhaps conceptually simpler, this has upset some folks who make frequent use of both options, as it requires going into the Settings and fumbling around with a control that really isn't that intuitive to begin with.

Behavior:

This modification doesn't quite restore Eclair behavior, rather it depends on the Vibrate setting. When Vibrate is set to "Always" or "Only in silent mode", both vibrate & silent options are available in the ringer volume control; otherwise, the default "Silent mode" option (Settings -> Sound -> Silent mode, power long-press, or notification panel widget) is still to vibrate. When Vibrate is set to "Never" or "Only when not in silent mode" then the default Froyo behavior is preserved: only silent is available in the ringer volume control, and "Silent mode" always silences (not vibrates) the ringer.

The modification is implemented this way as to be inoffensive to folks who dislike the vibrate option, and never under any circumstance would want their phone to accidentally vibrate. Similarly, it should be mostly inoffensive to folks who always prefer the vibrate option--the only way to activate the silent ringer is by the volume down rocker. So, as long as folks are careful to not accidentally press volume down "too many times", this modification is strictly beneficial (and thus, it's inclusion in ROMs shouldn't be of significant debate :)).

Detials:

With regard to the code: while Froyo simplified the vibrate/silent options in the UI, it's actually gotten a bit more complicated in code. With regard to the ringer, there's three state variables influence what happens. AudioService#mRingerMode is the main variable, with options RINGER_MODE_NORMAL, _VIBRATE, and _SILENT. AudioService::checkForRingerModeChange is the method that implements the volume rocker logic, and setting the ringer mode to one of the above three options is all that's necessary to achieve the desired effect.

The second influential variable is AudioService#mVibrateSetting which indirectly determines when the phone should vibrate. It's not to be queried directly however, rather AudioManager/AudioService::shouldVibrate considers both the Vibrate setting and the ringer mode. Specifically, RINGER_MODE_SILENT should override any instance of a ring or notification vibrate. This is why setting RINGER_MODE_SILENT is sufficient to silence the phone without also having to change the Vibrate setting. Even though the Froyo UI forces one to this, the Eclair behavior is, fortunately for this modification, still preserved in code.

Finally, the third variable, which is new in Froyo, is System.VIBRATE_IN_SILENT (via content provider). It's set by SoundSettings::setPhoneVibrateSettingValue as a function of the Vibrate setting ("Always", "Only in silent mode" are true; "Never", "Only when not in silent mode"" are false) and updated concurrently with it. Normally the ringer volume control queries this variable to determine which "silent" ringer mode to enter. With the modification, this variable is queried to determine if "ringer vibrate" should be presented as an option, and if so, allows for either mode. It's also used by other methods (e.g., Settings -> Sound -> Silent mode) to determine which ringer mode to enter, which isn't altered by the modification.

For the modification, I did consider always presenting "ringer vibrate" and "ringer silent" options, updating VIBRATE_IN_SILENT as necessary so that other activations of "Silent mode" would use the previous setting. But the SoundSettings activity actively updates the Vibrate setting whenever the two variables are in conflict, which would result in a bit of behavioral confusion. It's simpler, both conceputally and in code, to leave it alone.

Anyways, I figured it was worth documenting the behavor here since there's a bit more that goes on behind the scenes than the relatively-simple modification would suggest. I'm not sure which, if any of this changes in Gingerbread. But if the semantics were changed significantly, that might make a port of this modification a little less obvious.

Mirror link (does not require forum login):
platform_ringer_vib_silent.diff
platform_ringer_vib_silent_smali.diff
tws_fix_ringer_vib_silent-EC05-deodex.zip
tws_fix_ringer_vib_silent-EC05-odex.zip
 

Attachments

  • platform_ringer_vib_silent.diff.txt
    1.2 KB · Views: 74
  • platform_ringer_vib_silent_smali.diff.txt
    2.1 KB · Views: 56
  • tws_fix_ringer_vib_silent-EC05-deodex.zip
    3.4 MB · Views: 75
  • tws_fix_ringer_vib_silent-EC05-odex.zip
    3.4 MB · Views: 21
Last edited:

Custodian

Senior Member
Feb 27, 2011
2,271
408
Deodexed tested...consumer approved:cool: awsome job! The vibrate function is working as intended.
 

jbadboy2007

Senior Member
Sep 22, 2010
2,035
318
Lansing MI
Dude from mod to mod you are awesome. Can we have a progress log of what you are gonna try next lol.

Sent from my SPH-D700 using XDA App
 

running_the_dream

Senior Member
Jan 10, 2011
636
81
Dub C
So I flashed the zip for deodexed roms first. Didn't work for me. Then, I flashed the zip for odexed roms. Still doesn't work. Do one of you guys know what I am doing wrong?

Edit: Oh yeah, I'm on an EB13 based rom. I guess that's the problem?
 
Last edited:

mkasick

Retired Recognized Developer
Aug 10, 2009
470
830
Deodexed tested...consumer approved:cool: awsome job! The vibrate function is working as intended.
Great, thanks for testing!

Can we have a progress log of what you are gonna try next lol.
I don't like to make promises, just in case it takes a long time or I can't figure it out. Although if I make enough progress on an issue I'd probably at least post my thoughts so other folks can continue the work.

Any more progress on the keyboard patch??
Not yet, I had to step away from it for a bit to think.

Do one of you guys know what I am doing wrong?
Which ROM are you running?
 
  • Like
Reactions: qbking77

ragnarokx

Senior Member
Sep 1, 2010
2,330
511
Southwest
Not working here either. Flashed the deodexed version on Syndicate 1.1.0 with no change. Tried toggling the Vibrate option in Settings as well.
 

mkasick

Retired Recognized Developer
Aug 10, 2009
470
830
Not working here either. Flashed the deodexed version on Syndicate 1.1.0 with no change.
You might have to clear the dalvik-cache for it to take effect. However, I'm fairly certain that SRF comes with other framework changes which this would undo. It's probably best to wait for k0nane to incorporate it in the next SRF release.
 
Last edited:

sinman02

Senior Member
Nov 4, 2008
251
18
I'll start a $10 bounty for getting the tv out functionality to work!

Sent from my SPH-D700 using Tapatalk
 

ragnarokx

Senior Member
Sep 1, 2010
2,330
511
Southwest
You might have to clear the dalvik-cache for it to take effect. However, I'm fairly certain that SRF comes with other framework changes which this would undo. It's probably best to wait for k0nane to incorporate it in the next SRF release.

Still a no go with wiping dalvik-cache. Thanks anyway, will wait for ROM incorporation.
 

mkasick

Retired Recognized Developer
Aug 10, 2009
470
830
Rats, I have no idea how to patch the framework in order to incorporate this fix.
It's not terribly difficult if you're a bit familiar with a command line.

You need a copy of smali (the two jar downloads) and a copy of /system/framework/framework.jar from your phone (for deodexed ROMs). You'll also need the "patch" program, which typically comes with development packages for Mac & Linux. On Windows, you can get it with Cygwin, make sure to select the "patch", "zip" & "unzip" packages (if they're separate, going from memory from a long time ago). You'll also need the Java JRE if you don't have it already.

Then put all the smali downloads, framework.jar, and the platform_ringer_vib_silent_smali.diff patch all in the same directory. Then pull up a command line shell (e.g., Cygwin) and run:
Code:
java -jar baksmali-1.2.6.jar framework.jar
cd out; patch -p 1 < ../platform_ringer_vib_silent_smali.diff; cd ..
java -jar smali-1.2.6.jar -o classes.dex out
zip -9 framework.jar classes.dex

Then you can replace /system/framework/framework.jar in the update.zip with the new copy and it should work.

At least, that's the general idea.
 
Last edited:

running_the_dream

Senior Member
Jan 10, 2011
636
81
Dub C
It's not terribly difficult if you're a bit familiar with a command line.

You need a copy of ...Then you can replace /system/framework/framework.jar in the update.zip with the new copy and it should work.

At least, that's the general idea.

Awesome! I do have Jave JRE. I can extract the framework.jar and make a test copy of it. I'll look into Cygwin and do a lil research on it. Will report back if I can get this thing going. Thanks!
 

jbadboy2007

Senior Member
Sep 22, 2010
2,035
318
Lansing MI
I didn't exactly want a progress log exactly. But I would like to know what other things you might consider taking a look at so if people have any suggestions or something.

Sent from my SPH-D700 using XDA App
 

k0nane

Inactive Recognized Developer
Feb 7, 2008
3,991
3,783
127.0.0.1
www.k0nane.info
mkasick...

notworthy.jpg


Out of curiosity, are you making your edits in Java, recompiling, then pulling the smali out and using it for the diffs, or editing the existing smali directly?

It's probably best to wait for k0nane to incorporate it in the next SRF release.
For once, someone assumes something about me or what I'm going to do and hits a bullseye. ;)
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 10
    7/21/11 Update: RandomKing has ported this mod to EF02. It's available here. Thanks!

    Attached is a platform source patch against android-cts-2.2_r2 that modifies the ringer volume control (side rocker) to include both vibrate & silent options, as was present in Eclair. Also attached is a smali patch against EC05's /system/framework/framework.odex that implements the fix in bytecode.

    Finally, attached are testkey-recovery (e.g., ClockworkMod) flashable "update.zip"s, one containing a modified framework.jar for deodexed ROMs, the other containing a modified framework.odex for odexed (stock) ROMs. Both updates include this modification, as well as the TWS bug fix.

    I've tested the odex update under stock (w/testkey) recovery, but not ClockworkMod as I currently don't use it, although I imagine it works fine. I've not tested the deodex update as I run an odexed ROM (edit: others report it works too). I have no reason to suspect it wouldn't work, but the usual caveat of keeping a copy of Odin+tar, ClockworkMod backup, etc., to restore should something unexpected happen applies.

    Edit: If you're running a custom ROM with other framework.jar changes, it's probably best to wait for that ROM to incorporate the patch.

    Background:

    The Eclair ringer volume control (popup on press of the side volume rocker) contains "ringer vibrate" and "ringer silent" options. In Froyo, this was simplified to a single "ringer vibrate" or "ringer silent" option, depending on the Vibrate setting (Settings -> Sound -> Vibrate). While perhaps conceptually simpler, this has upset some folks who make frequent use of both options, as it requires going into the Settings and fumbling around with a control that really isn't that intuitive to begin with.

    Behavior:

    This modification doesn't quite restore Eclair behavior, rather it depends on the Vibrate setting. When Vibrate is set to "Always" or "Only in silent mode", both vibrate & silent options are available in the ringer volume control; otherwise, the default "Silent mode" option (Settings -> Sound -> Silent mode, power long-press, or notification panel widget) is still to vibrate. When Vibrate is set to "Never" or "Only when not in silent mode" then the default Froyo behavior is preserved: only silent is available in the ringer volume control, and "Silent mode" always silences (not vibrates) the ringer.

    The modification is implemented this way as to be inoffensive to folks who dislike the vibrate option, and never under any circumstance would want their phone to accidentally vibrate. Similarly, it should be mostly inoffensive to folks who always prefer the vibrate option--the only way to activate the silent ringer is by the volume down rocker. So, as long as folks are careful to not accidentally press volume down "too many times", this modification is strictly beneficial (and thus, it's inclusion in ROMs shouldn't be of significant debate :)).

    Detials:

    With regard to the code: while Froyo simplified the vibrate/silent options in the UI, it's actually gotten a bit more complicated in code. With regard to the ringer, there's three state variables influence what happens. AudioService#mRingerMode is the main variable, with options RINGER_MODE_NORMAL, _VIBRATE, and _SILENT. AudioService::checkForRingerModeChange is the method that implements the volume rocker logic, and setting the ringer mode to one of the above three options is all that's necessary to achieve the desired effect.

    The second influential variable is AudioService#mVibrateSetting which indirectly determines when the phone should vibrate. It's not to be queried directly however, rather AudioManager/AudioService::shouldVibrate considers both the Vibrate setting and the ringer mode. Specifically, RINGER_MODE_SILENT should override any instance of a ring or notification vibrate. This is why setting RINGER_MODE_SILENT is sufficient to silence the phone without also having to change the Vibrate setting. Even though the Froyo UI forces one to this, the Eclair behavior is, fortunately for this modification, still preserved in code.

    Finally, the third variable, which is new in Froyo, is System.VIBRATE_IN_SILENT (via content provider). It's set by SoundSettings::setPhoneVibrateSettingValue as a function of the Vibrate setting ("Always", "Only in silent mode" are true; "Never", "Only when not in silent mode"" are false) and updated concurrently with it. Normally the ringer volume control queries this variable to determine which "silent" ringer mode to enter. With the modification, this variable is queried to determine if "ringer vibrate" should be presented as an option, and if so, allows for either mode. It's also used by other methods (e.g., Settings -> Sound -> Silent mode) to determine which ringer mode to enter, which isn't altered by the modification.

    For the modification, I did consider always presenting "ringer vibrate" and "ringer silent" options, updating VIBRATE_IN_SILENT as necessary so that other activations of "Silent mode" would use the previous setting. But the SoundSettings activity actively updates the Vibrate setting whenever the two variables are in conflict, which would result in a bit of behavioral confusion. It's simpler, both conceputally and in code, to leave it alone.

    Anyways, I figured it was worth documenting the behavor here since there's a bit more that goes on behind the scenes than the relatively-simple modification would suggest. I'm not sure which, if any of this changes in Gingerbread. But if the semantics were changed significantly, that might make a port of this modification a little less obvious.

    Mirror link (does not require forum login):
    platform_ringer_vib_silent.diff
    platform_ringer_vib_silent_smali.diff
    tws_fix_ringer_vib_silent-EC05-deodex.zip
    tws_fix_ringer_vib_silent-EC05-odex.zip
    2
    I'm not sure which, if any of this changes in Gingerbread. But if the semantics were changed significantly, that might make a port of this modification a little less obvious.

    I ported it into Gingerbread EF02. Confirmed working on marcusant's [EF02] ACS Bamboozle 1.0.

    MOD EDIT: Please don't link to banned developers' ROMs

    RandomKing EDIT: Sorry, wasn't aware he was banned. I don't keep up on the politics.
    1
    Deodexed tested...consumer approved:cool: awsome job! The vibrate function is working as intended.
    Great, thanks for testing!

    Can we have a progress log of what you are gonna try next lol.
    I don't like to make promises, just in case it takes a long time or I can't figure it out. Although if I make enough progress on an issue I'd probably at least post my thoughts so other folks can continue the work.

    Any more progress on the keyboard patch??
    Not yet, I had to step away from it for a bit to think.

    Do one of you guys know what I am doing wrong?
    Which ROM are you running?
    1
    Since I am on stocke eco05 odex like yourself, I am hoping that this will work for me.
    The odexed zip does work on EC05 stock. As for the SD card issue, there was a report of an SD card going bad concurrent with using the original TWS patch. I think that was a coicidence and I've found no reason (nor reports) that the patch causes SD issues.

    That said, both TWS and the ringer volume mod are incorporated in most ROMs these days. I recommend going with one of them as they're well maintained.
    1
    could this patch be made for GB?
    It's on my TODO list for after the official release. I probably won't be able to before though.