[Mod] Long press volume buttons to skip songs.

Search This thread

aerobahn

Senior Member
Feb 25, 2011
94
54
Attached is a mod I've spent the last week and a half working on for my friend and I. We were working out and found it a hassle to have to bring out our phones from our pocket in order to seek past tracks. This mod allows you to now seek from your pocket easily.
Those of you who've used CM6/7 are probably aware of a feature they have where you can seek music tracks with the screen off using the volume up (forward track) / volume down (previous track) buttons.

Essentially, I've ported this feature onto the Samsung Framework. Since the Samsung Framework is closed source, I had to reverse engineer a lot of their functions in the Android.Policy framework which took a while. Although the CM6/7 is open source, the code they provide is in Java which you can't really inline with dalvik assembler code so converting their relevant functions into .smali compatible code took more time.
Because of this, I'm only releasing this for Leomar75 (v. 2.6 XXKH3) Rom since it's the Rom I've settled on. I have not tested it on other roms, it may or may not work with others, I make no guarantees. However, I'm ~80% sure it will work with other KH3 based Samsung Firmwares. I don't have time, or the will, to port it to other roms so please don't ask.


Installation:
Make a Nandroid backup using Clockwork Recovery.
Wipe your Cache & Dalvik Cache.
Unzip the file.
ADB push the file to your phone:
Code:
adb push android.policy.jar /system/framework/
Make sure permissions are correct:
Code:
adb shell
busybox chmod -R 644 /system/framework/android.policy.jar

Reboot.

Usage:

When the screen is off, and music is playing, holding the volume up button for ~1 second will seek forward 1 track.
Holding the volume down button for ~1 second will seek back 1 track.

When you do either actions, the screen will not wake (battery life is conserved).
If the screen is ON, and music is playing, it will not seek forward/back if you hold the buttons.


Known bugs:
My friend told me this breaks JKAY AOSP Lockscreen mods. I don't use JKAY mods so that bug probably won't be fixed.


Caveats:

I don't want any donations, plz don't ask.
If you want to disassemble this using baksmali to try to see what I've changed, that's fine by me. I don't really care tbh.
If you have honest questions I will answer but if it's answerable with a Google search, I probably will not bother.

Credits:
Jon Boekenoogen (metalhead8816): First guy to submit the 'Long press volume buttons to skip songs' concept for CM6. Thanks for this simple, but great feature.
Obviously the CM6/7 team: I disassembled & used your code, thanks.
Leomar75: I use your rom, thanks.
JesusFreak: You made an awesome tool for disassembling and assembling .dex. Thanks.
 

Attachments

  • android.policy.zip
    154.6 KB · Views: 1,433

Sonic7

Senior Member
Jun 9, 2010
186
16
You are my hero ! Thx for this. But sadly not working on Batista 3.7.6 so I have to change to Leo Rom ;)

Sent from my GT-I9100 using xda premium
 
  • Like
Reactions: bagux

petsasj

Retired Recognized Developer
Mar 22, 2010
1,605
1,501
35
Athens
Could you please release the changes that were made in the android.policy.jar? Please post the code and what was changed so developers (and users) modify it themselves.

Thanks a lot.
 
  • Like
Reactions: shardul.phatak

nexxus.

Senior Member
May 27, 2011
80
8
Wow, nice work. I'll try this later.

Edit : works perfectly on leomars rom. Thank you very much!

Sent from my GT-I9100 using Tapatalk
 
Last edited:

Sonic7

Senior Member
Jun 9, 2010
186
16
Does not work with leo rom and root explorer have to try it later with adb but should not make any diiference

Edit: works fine even with explorer but tw 4.5 breaks it

Sent from my GT-I9100 using xda premium
 
Last edited:

Sonic7

Senior Member
Jun 9, 2010
186
16
I think fugutweaks breaks your mod do you have installed it ?

Sent from my GT-I9100 using xda premium
 

nexxus.

Senior Member
May 27, 2011
80
8
Does not work with leo rom and root explorer have to try it later with adb but should not make any diiference

Sent from my GT-I9100 using xda premium

It works with rootexplorer. I did it this way. Maybe you forgot to set permissions?


Sent from my GT-I9100 using Tapatalk
 

aerobahn

Senior Member
Feb 25, 2011
94
54
I think fugutweaks breaks your mod do you have installed it ?

Sent from my GT-I9100 using xda premium

I don't have it installed. If it modifies the android.policy.jar it will probably interfere with this. You could try installing this first and then applying fugutweaks.
 

eiraku

Senior Member
Oct 22, 2007
339
63
Working fabulously with VR 2.4.2 /w EDT tweaks + Ninpo latest. Transfered into /system/app with TotalCom, sorted out permissions and voila.

Now I can uninstall JustShake, which was wonky in use anyways.

Thanks bud!

EDIT: Scratch that. It's conflicting with power menu. Sigh.
 
Last edited:

nitsuajd

Senior Member
Jul 16, 2008
226
49
Badalona
Hi aerobahn, first of all Thanks for your hard work in this excellent mod. I'm actually using jkay and of course this mod breaks jkay lockscreen options, because jkay also modifies android.policy. For this reason i'm trying to adapt your mod over jkay android.policy

I see your mod only modifies two files
GlobalActions.smali
PhoneWindowManager.smali

and add 5 files
GlobalActions$8. smali
GlobalActions$9. smali
GlobalActions$10. smali

PhoneWindowManager$12.smali
PhoneWindowManager$13.smali

The PhoneWindowManager is ready, I've pasted all the code into jkay PhoneWindowManager. My problem is with GlobalActions because jkay also uses files named 8, 9 and 10... until 20. I think it's possible change your files to the next numbers availables like this GlobalActions$21, 22 and 23 and modify the code to refer it with this new name.



Then, I need add this code to jkay's GlobalActions.smali and change the hex values for const, but don't know how can I do it... i'm newbie editing smali code...

Code:
    aput-object v2, v0, v1

    const/4 v1, 0x4

    new-instance v2, Lcom/android/internal/policy/impl/GlobalActions$21;

    const v3, 0x108045b

    const v4, 0x1040505

    invoke-direct {v2, p0, v3, v4}, Lcom/android/internal/policy/impl/GlobalActions$21;-><init>(Lcom/android/internal/policy/impl/GlobalActions;II)V

    aput-object v2, v0, v1

    const/4 v1, 0x5

    new-instance v2, Lcom/android/internal/policy/impl/GlobalActions$22;

    const v3, 0x108045c

    const v4, 0x1040503

    invoke-direct {v2, p0, v3, v4}, Lcom/android/internal/policy/impl/GlobalActions$22;-><init>(Lcom/android/internal/policy/impl/GlobalActions;II)V

    aput-object v2, v0, v1

    const/4 v1, 0x6

    new-instance v2, Lcom/android/internal/policy/impl/GlobalActions$23;

    const v3, 0x1080456

    const v4, 0x1040504

    invoke-direct {v2, p0, v3, v4}, Lcom/android/internal/policy/impl/GlobalActions$23;-><init>(Lcom/android/internal/policy/impl/GlobalActions;II)V

¿Can you help me please? I added the files. For if you can take a look. Thanks in advance

Ps: I know... my english is horrible!! xD sorry for this
 

Attachments

  • GlobalActions.rar
    8.1 KB · Views: 28

_JKay_

Retired Recognized Developer
Aug 12, 2010
5,495
14,689
Can others please verify... I'd have added this feature to my Deluxe Themes but it seems to break radio volume control!

How to test: start radio instead music player and turn off screen. Now try and change volume using volume keys... on my phone nothing happens!!!

Sent from my GT-I9100 using xda premium
 

nitsuajd

Senior Member
Jul 16, 2008
226
49
Badalona
Can others please verify... I'd have added this feature to my Deluxe Themes but it seems to break radio volume control!

How to test: start radio instead music player and turn off screen. Now try and change volume using volume keys... on my phone nothing happens!!!

Sent from my GT-I9100 using xda premium

On my phone works fine...
 

soyef

Senior Member
Feb 26, 2010
212
50
London
Hi aerobahn, first of all Thanks for your hard work in this excellent mod. I'm actually using jkay and of course this mod breaks jkay lockscreen options, because jkay also modifies android.policy. For this reason i'm trying to adapt your mod over jkay android.policy

I see your mod only modifies two files
GlobalActions.smali
PhoneWindowManager.smali

and add 5 files
GlobalActions$8. smali
GlobalActions$9. smali
GlobalActions$10. smali

PhoneWindowManager$12.smali
PhoneWindowManager$13.smali

The PhoneWindowManager is ready, I've pasted all the code into jkay PhoneWindowManager. My problem is with GlobalActions because jkay also uses files named 8, 9 and 10... until 20. I think it's possible change your files to the next numbers availables like this GlobalActions$21, 22 and 23 and modify the code to refer it with this new name.



Then, I need add this code to jkay's GlobalActions.smali and change the hex values for const, but don't know how can I do it... i'm newbie editing smali code...

Code:
    aput-object v2, v0, v1

    const/4 v1, 0x4

    new-instance v2, Lcom/android/internal/policy/impl/GlobalActions$21;

    const v3, 0x108045b

    const v4, 0x1040505

    invoke-direct {v2, p0, v3, v4}, Lcom/android/internal/policy/impl/GlobalActions$21;-><init>(Lcom/android/internal/policy/impl/GlobalActions;II)V

    aput-object v2, v0, v1

    const/4 v1, 0x5

    new-instance v2, Lcom/android/internal/policy/impl/GlobalActions$22;

    const v3, 0x108045c

    const v4, 0x1040503

    invoke-direct {v2, p0, v3, v4}, Lcom/android/internal/policy/impl/GlobalActions$22;-><init>(Lcom/android/internal/policy/impl/GlobalActions;II)V

    aput-object v2, v0, v1

    const/4 v1, 0x6

    new-instance v2, Lcom/android/internal/policy/impl/GlobalActions$23;

    const v3, 0x1080456

    const v4, 0x1040504

    invoke-direct {v2, p0, v3, v4}, Lcom/android/internal/policy/impl/GlobalActions$23;-><init>(Lcom/android/internal/policy/impl/GlobalActions;II)V

¿Can you help me please? I added the files. For if you can take a look. Thanks in advance

Ps: I know... my english is horrible!! xD sorry for this

I ported the mod to my XXKG2 rom and i never modifed anything except phonewindowmanager and added $12 and $13 files and its working fine

Maybe i did something wrong but it seems fine to me....

Hope that helps

Sent from my GT-I9100
 

Top Liked Posts

  • There are no posts matching your filters.
  • 28
    Attached is a mod I've spent the last week and a half working on for my friend and I. We were working out and found it a hassle to have to bring out our phones from our pocket in order to seek past tracks. This mod allows you to now seek from your pocket easily.
    Those of you who've used CM6/7 are probably aware of a feature they have where you can seek music tracks with the screen off using the volume up (forward track) / volume down (previous track) buttons.

    Essentially, I've ported this feature onto the Samsung Framework. Since the Samsung Framework is closed source, I had to reverse engineer a lot of their functions in the Android.Policy framework which took a while. Although the CM6/7 is open source, the code they provide is in Java which you can't really inline with dalvik assembler code so converting their relevant functions into .smali compatible code took more time.
    Because of this, I'm only releasing this for Leomar75 (v. 2.6 XXKH3) Rom since it's the Rom I've settled on. I have not tested it on other roms, it may or may not work with others, I make no guarantees. However, I'm ~80% sure it will work with other KH3 based Samsung Firmwares. I don't have time, or the will, to port it to other roms so please don't ask.


    Installation:
    Make a Nandroid backup using Clockwork Recovery.
    Wipe your Cache & Dalvik Cache.
    Unzip the file.
    ADB push the file to your phone:
    Code:
    adb push android.policy.jar /system/framework/
    Make sure permissions are correct:
    Code:
    adb shell
    busybox chmod -R 644 /system/framework/android.policy.jar

    Reboot.

    Usage:

    When the screen is off, and music is playing, holding the volume up button for ~1 second will seek forward 1 track.
    Holding the volume down button for ~1 second will seek back 1 track.

    When you do either actions, the screen will not wake (battery life is conserved).
    If the screen is ON, and music is playing, it will not seek forward/back if you hold the buttons.


    Known bugs:
    My friend told me this breaks JKAY AOSP Lockscreen mods. I don't use JKAY mods so that bug probably won't be fixed.


    Caveats:

    I don't want any donations, plz don't ask.
    If you want to disassemble this using baksmali to try to see what I've changed, that's fine by me. I don't really care tbh.
    If you have honest questions I will answer but if it's answerable with a Google search, I probably will not bother.

    Credits:
    Jon Boekenoogen (metalhead8816): First guy to submit the 'Long press volume buttons to skip songs' concept for CM6. Thanks for this simple, but great feature.
    Obviously the CM6/7 team: I disassembled & used your code, thanks.
    Leomar75: I use your rom, thanks.
    JesusFreak: You made an awesome tool for disassembling and assembling .dex. Thanks.
    7
    For Deodexed XWLP7/8 roms. Attached android.policy.jar with this mod only.

    If you want use this with 4-way reboot, home button lagfix, torch on lockscreen etc. Check following link
    http://xdaforums.com/showpost.php?p=24927413&postcount=519
    5
    +1
    A pain in the rear... I'm trying to port it over to Moto... Is it only the PhoneWindowManager.smali (plus adding the new $17, $18, $19 (for me) smali files)? Or are there other file edits too?
    Plus, it looks like it will add the camera button to wake mod also (or maybe I was looking at a different modded android.policy.jar...)?
    Either way, I'll give it another go later... I am getting closer.. I hope.

    I guess you guys are too lazy to download hole rom for diffing :)

    So here's zip what contains original and moded PhoneWindowManager.smali and two extra files that you will need. Those files are for bamf rom (Galaxy Nexus), but it dosent matter, just diff and you'll find lines.
    I also changed delay to 200ms (original in this mod was 1000ms). If you like to change that, check my thread from signature. I told there what you need to change for that (also some other delays, like recent window and power dialog).
    3
    Hi aerobahn, first of all Thanks for your hard work in this excellent mod. I'm actually using jkay and of course this mod breaks jkay lockscreen options, because jkay also modifies android.policy. For this reason i'm trying to adapt your mod over jkay android.policy

    I see your mod only modifies two files
    GlobalActions.smali
    PhoneWindowManager.smali

    and add 5 files
    GlobalActions$8. smali
    GlobalActions$9. smali
    GlobalActions$10. smali

    PhoneWindowManager$12.smali
    PhoneWindowManager$13.smali

    The PhoneWindowManager is ready, I've pasted all the code into jkay PhoneWindowManager. My problem is with GlobalActions because jkay also uses files named 8, 9 and 10... until 20. I think it's possible change your files to the next numbers availables like this GlobalActions$21, 22 and 23 and modify the code to refer it with this new name.



    Then, I need add this code to jkay's GlobalActions.smali and change the hex values for const, but don't know how can I do it... i'm newbie editing smali code...

    Code:
        aput-object v2, v0, v1
    
        const/4 v1, 0x4
    
        new-instance v2, Lcom/android/internal/policy/impl/GlobalActions$21;
    
        const v3, 0x108045b
    
        const v4, 0x1040505
    
        invoke-direct {v2, p0, v3, v4}, Lcom/android/internal/policy/impl/GlobalActions$21;-><init>(Lcom/android/internal/policy/impl/GlobalActions;II)V
    
        aput-object v2, v0, v1
    
        const/4 v1, 0x5
    
        new-instance v2, Lcom/android/internal/policy/impl/GlobalActions$22;
    
        const v3, 0x108045c
    
        const v4, 0x1040503
    
        invoke-direct {v2, p0, v3, v4}, Lcom/android/internal/policy/impl/GlobalActions$22;-><init>(Lcom/android/internal/policy/impl/GlobalActions;II)V
    
        aput-object v2, v0, v1
    
        const/4 v1, 0x6
    
        new-instance v2, Lcom/android/internal/policy/impl/GlobalActions$23;
    
        const v3, 0x1080456
    
        const v4, 0x1040504
    
        invoke-direct {v2, p0, v3, v4}, Lcom/android/internal/policy/impl/GlobalActions$23;-><init>(Lcom/android/internal/policy/impl/GlobalActions;II)V

    ¿Can you help me please? I added the files. For if you can take a look. Thanks in advance

    Ps: I know... my english is horrible!! xD sorry for this

    I did not modify any part of GlobalActions.smali

    The GlobalActions dialog gets called up when you hold down the power menu for a set duration (defaulted @ 500ms). Since JKay modifies this menu to add other toggles, his GlobalActions.smali will be different than mine so you can't just compare the two for changes.

    PhoneWindowManager$12.smali and PhoneWindowManager$13.smali contain the functions used to skip forward and back a track. The main handler is located in PhoneWindowManager.smali. Therefore, if you wanted to port this mod to your ROM, you should look for the changes I made in:

    PhoneWindowManager.smali
    PhoneWindowManager$12.smali
    PhoneWindowManager$13.smali

    If done right, you should be able to port this mod to any Android device ROM.
    2
    On my phone works fine...

    Hmm... ok I'll see if I can get the FM radio volume to work in my mod too... then I'll include this great feature into version 10 of JKay Deluxe.

    Sent from my GT-I9100 using xda premium