yashsingh1/xdaforums huggingface dataset:
[Galaxy S II Themes and Apps] aerobahn:
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:

adb push android.policy.jar /system/framework/

Make sure permissions are correct:

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.
[Galaxy S II Themes and Apps] Sonic7:
You are my hero ! Thx for this. But sadly not working on Batista 3.7.6 so I have to change to Leo Rom ;)
[Galaxy S II Themes and Apps] petsasj:
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.
[Galaxy S II Themes and Apps] nexxus.:
Wow, nice work. I'll try this later.

Edit : works perfectly on leomars rom. Thank you very much!
[Galaxy S II Themes and Apps] huwande1acruz:
Works on Cognition ROM 1.5.1 ! :)

edit post . :(( restore a nandroid backup .
[Galaxy S II Themes and Apps] Sonic7:
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
[Galaxy S II Themes and Apps] Sonic7:
I think fugutweaks breaks your mod do you have installed it ?
[Galaxy S II Themes and Apps] nexxus.:
It works with rootexplorer. I did it this way. Maybe you forgot to set permissions?
[Galaxy S II Themes and Apps] Thialala:
Awesome feature. It works on Criskelo rom. Thanks a lot.
[Galaxy S II Themes and Apps] Sonic7:
I installed the touchwiz 4.5 and I think this breaks the mod. It works fine on a fresh instal
[Galaxy S II Themes and Apps] aerobahn:
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.
[Galaxy S II Themes and Apps] mcdai:
it's possible to flash with cwm?
[Galaxy S II Themes and Apps] eiraku:
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.
[Galaxy S II Themes and Apps] nitsuajd:
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...

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
[Galaxy S II Themes and Apps] _JKay_:
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!!!
[Galaxy S II Themes and Apps] nitsuajd:
On my phone works fine...
[Galaxy S II Themes and Apps] _JKay_:
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.
[Galaxy S II Themes and Apps] Sonic7:
This would make my day JKay ( wow that rhymes ;) )
[Galaxy S II Themes and Apps] soyef:
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
[Galaxy S II Themes and Apps] raul_lg:
Works Fine with Criskelo Rom!!!

Thanks
[Galaxy S II Themes and Apps] evenelia:
Works on Cognition 1.5.1, but when I press the power button to get to the power menu the phone freezes and restarts :) Too bad, cuz I'd really like to have this feature on my phone.
[Galaxy S II Themes and Apps] aerobahn:
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.
[Galaxy S II Themes and Apps] _JKay_:
Hi.. I have fixed the fm radio volume bug and added support for fm radio channel switching using longClick on volume up and down keys... I can post the source code if you like (XXKH3).
[Galaxy S II Themes and Apps] petsasj:
When can we expect an update Jkay? :D
[Galaxy S II Themes and Apps] 89luca89:
Yes source wouold be useful :D
[Galaxy S II Themes and Apps] nitsuajd:
@_Jkay_ Yes please!

@aerobahn thanks for explanation
[Galaxy S II Themes and Apps] _JKay_:
I want to add a few more features before release.. :)
[Galaxy S II Themes and Apps] aerobahn:
Awesome addition! :cool:
[Galaxy S II Themes and Apps] _JKay_:
Here is the source code... hope it works... cuz I have removed a lot of the code from my upcoming mod...
[Galaxy S II Themes and Apps] A|G:
...

would it be to much to ask to make me a complete file so i can just copy/push to my device kh3 bro, pretty please!

EDIT: nevermind, it seems all those years modding motorola payed off cause i incorporated all this awesomeness to my rom (modaco hk3 ag edition) thanxx to all of you much ;-)
[Galaxy S II Themes and Apps] neo_hito:
Thank you for the great work aerobahn! I've been looking for ways to do this too, was going to make an app/service but hit a hurdle and had to settle with player pro's lockscreen widget. You made me switch roms just to get this feature :P

I have a question though, I don't know how to deodex/decode/use smali so hopefully you can explain: how does it achieve the 'next track' action? Does it emulate a 'next track' hardware key? or does it send a command to the default player?

I'm asking because I have player pro set as my default player, this mod only works for that and not the default android player.
[Galaxy S II Themes and Apps] soyef:
Works on all for me

Sent from my GT-I9100
[Galaxy S II Themes and Apps] aerobahn:
Hi, thanks I'm glad you like it. I use PlayerPro too but I found their lockscreen track change implementation to be too quirky. Personally, I don't know why Google doesn't have this feature in it's AOSP build.

To answer your question, when you hold a volume up/down button for a set duration, a KeyEvent action is passed onto the frameworks sendOrderedBroadcast function which will then tell the mediaserver to skip forward/back a track (or do whatever KeyEvent you specified).

[ As an aside, the reason why you can't get this feature from an app (apk) directly is because the sendOrderedBroadcast function is protected. This is why PlayerPro has to simulate a lockscreen which it used to intercept the volume up/down key press.]

Since every music player (3rd party or not) plays music through the mediaserver (Proof: check your battery usage breakdown after listening to music for a while and you'll see "Mediaserver" not the app that you use to play music.) it should be able to send the Next Track/Previous Track event to any media player currently playing music.

So to directly answer your question, it sorta emulates a hardware 'next track' key. I say sorta because technically when you hit the next track button on the touchscreen it communicates to the mediaserver in the same way as it's done in this mod.
[Galaxy S II Themes and Apps] soyef:
So would it then be possible to change the power key into a play/pause button whilst the screen is off??

Sent from my GT-I9100
[Galaxy S II Themes and Apps] _JKay_:
Found another bug in this mod... you can't adjust music/radio volume from the lockscreen!!
[Galaxy S II Themes and Apps] kahvitahra:
With original locksreen atleast I can. Tested on kg6 and kh3.
[Galaxy S II Themes and Apps] _JKay_:
Maybe this is only the case when using radio...
[Galaxy S II Themes and Apps] kahvitahra:
Did not test that. I don't even have that apk so can't test. Finnish radio stations is full of s**t.. haha
[Galaxy S II Themes and Apps] aerobahn:
yes you could.

@Jkay

You're doing something wrong in your port. Volume control worked fine when i tested it using the FM app.
[Galaxy S II Themes and Apps] _JKay_:
Maybe... its weird... sometime it works sometimes not... maybe its my rom....
[Galaxy S II Themes and Apps] _JKay_:
Ok bug fixed.. now lockscreen volume control works like without this mod.

Anyone want the source?
[Galaxy S II Themes and Apps] giga502:
you mean so that we can use your lockscreen AND this epic feature?

i'd love to be able to ^.^
[Galaxy S II Themes and Apps] _JKay_:
Yes it will be released soon...
[Galaxy S II Themes and Apps] giga502:
Awesome because whenever I go on trips I manually change to the music switcher then later on to your lock screen as I love it so much.
[Galaxy S II Themes and Apps] ludalex07:
This.

And I have another little issue: the mod works with PlayerPro but not with stock music player (which supports descending last added playlist ant it's great).

Also, GREAT MOD BRO'. Been waiting it for a loooong time :)
[Galaxy S II Themes and Apps] sewe:
Mine freezes aswell when I backs out of program and it breaks the ability to change volume in calls when the screen is off
[Galaxy S II Themes and Apps] nitsuajd:
Yes please!
[Galaxy S II Themes and Apps] _JKay_:
I think that is fixed in JKay Deluxe v10...
[Galaxy S II Themes and Apps] sewe:
Yes, volume in calls is fixed, thank you
[Galaxy S II Themes and Apps] soraxd:
this was the biggest regret going to android, from my beloved Sony Ericsson phones, and now youve added it.. UGH what a great thing youve done.

can anyone report if it works on Villian Rom?
[Galaxy S II Themes and Apps] A|G:
...

is this only when using ur lockscreeen or stock cus im on stock kh3 and have no problems as i implemeted this myself but i have not try the phonecalls issue ur talking about...

---------- Post added at 10:00 AM ---------- Previous post was at 09:52 AM ----------

may i please have the source now that u fixed this issues bro, as mention i dont suffer of the volume while screen off and playing music/radio but i do have the call volume issue ;-(
[Galaxy S II Themes and Apps] eiraku:
It works on VR, through Kahvi's Adv. Power Menu mod (if you use APM). Otherwise I think the first post mod is usable as it is.

I'm running it on the latest VR with zero issues.
[Galaxy S II Themes and Apps] A|G:
NO GO!

I got the proper files from ur V10 mod but now the skipping doesnt work only volume does ;-S
[Galaxy S II Themes and Apps] _JKay_:
You can't use my mod directly... I need to remove some code first... I will post the source here soon.
[Galaxy S II Themes and Apps] A|G:
...

thanxxx much bro, please do so ;-)
[Galaxy S II Themes and Apps] A|G:
PLEASE!

...I heed that source ^^^ please anyone!!!
[Galaxy S II Themes and Apps] _JKay_:
OK... here is the source for XXKH3... I hope it works.... I have not tested it!
[Galaxy S II Themes and Apps] A|G:
Thanx bro!

...thank u much, ill check bro ;-)
[Galaxy S II Themes and Apps] soyef:
VR 3.0

this is the modded android.policy.jar for VR 3.0

also has the homelag fix
[Galaxy S II Themes and Apps] the_Calen:
could somebody please be so kind to add a version for cognition 1.5.1?

thanks in advance :)
[Galaxy S II Themes and Apps] soyef:
Can you give me your android.policy.jar so I can try and add the changes

Sent from my GT-I9100
[Galaxy S II Themes and Apps] comnam90:
have ported for darkyrom2 xxki3 base

http://dl.dropbox.com/u/23356668/darykrom2_KI3_Volume_button_mod.zip
[Galaxy S II Themes and Apps] astoncheah:
will this work on Leomar2.7? thanks.
[Galaxy S II Themes and Apps] soyef:
Don't think so, does that rom have APM?

Sent from my GT-I9100
[Galaxy S II Themes and Apps] astoncheah:
flashed it on Leo2.7 and...it works!! thanks
[Galaxy S II Themes and Apps] soyef:
Just double check that a long press of the power button doesn't crash anything

Sent from my GT-I9100
[Galaxy S II Themes and Apps] astoncheah:
yes, no problem with power button, but i lost those APM setting and now just have default one only... but i can live with it untill JKay's KI3 v11 out..:)
[Galaxy S II Themes and Apps] suchevent:
please delete post
[Galaxy S II Themes and Apps] blueseeker:
Thank you for one of the most brilliant MODS. I missed this feature from my SE phone. It was frustrating to take the phone out from my pocket everytime I didn't liked a song.

I don't know why this isn't default ...
[Galaxy S II Themes and Apps] aerobahn:
You're welcome.

I am very happy that _JKay_ has implemented this into his theme/mod pack. He's always updating it with the newest firmware releases and it works with many ROM's, you guys should definitely check it out.
[Galaxy S II Themes and Apps] comnam90:
Does this work with changing the station when listening to the FM radio?
[Galaxy S II Themes and Apps] chiefroastbeef:
Wow, I have been looking for a mod like this forever, two things Samsung got wrong on this phone, long press volume button skipping, and no notification LED.

Now we just need a pause button... :)

Downloading LEOMAR 2.7.1 now!

Thanks!
[Galaxy S II Themes and Apps] blueseeker:
I'm using LeoMar 2.7.1 with revolution theme and jkay theme deluxe app, and it's working, but long pressing the + / - volume buttons scans for previous/next radio station available, it's not swapping between the custom presets
[Galaxy S II Themes and Apps] KroonBerg:
Great! Thanks! :)
[Galaxy S II Themes and Apps] :
Could you please release what changes you made to what files for that other devs can implement this on other ROMS ;) - I guess you might have forgotten by now, I know I would have xD
[Galaxy S II Themes and Apps] rajaspidey:
can u post flushable zip :-)
[Galaxy S II Themes and Apps] CamoGeko:
Cheers mate. :D

Edit: "Flushable".... hahaha

Transmitted from a Galaxy far far away via XDA lightspeed telepathy.
[Galaxy S II Themes and Apps] vers55:
Hello! very good idea.

But I think "BACK TRACK" is not so great function then "PLAY/PAUSE"

Because when you listen to music in transport in "mix mode" (random songs) and you dont like current song - just need to change song (never mind next or previous). But when you need to speak with someone you need just stop music and get off earphones. And after that start music again...

Is it possible to make file policy.jar with tho function

1. PLAY/PAUSE

2. NEXT TRACK

?
[Galaxy S II Themes and Apps] aydc:
Can this be updated to work on ICS builds like LP2?

I always used JKay's mod so I didn't need this fix separately, but I don't think we'll see JKay's mod for ICS for a long time, so in the meantime, people like me who listen to music with the phone in their pockets need this.

I hope it can be made to work with ICS. I really miss this functionality on ICS.
[Galaxy S II Themes and Apps] 7OH:
Please tell, where to look in other brand to values like in this topic (87 and 88) ?

(PhoneWindowManager.this.sendMediaButtonEvent(88);)

Downloading Leomar75 (v. 2.6 XXKH3) Rom and watching KL files - i see:

key 163 MEDIA_NEXT WAKE

key 165 MEDIA_PREVIOUS WAKE

so even in HEX 163=0xa3 and 165=a5 ?

So wich values i must send to system ?
[Galaxy S II Themes and Apps] aydc:
I'm trying to port this to the first daily usable ICS rom, XXLPB.

I renamed PhoneWindowManager$12.smali and PhoneWindowManager$13.smali and changed PhoneWindowManager.smali to refer to these files, but the result was a big juicy bootloop.

I guess a real dev is needed here, this is beyond my very limited knowledge.
[Galaxy S II Themes and Apps] 7OH:
Give me framework-res.apk and android.policy.jar - I will try.
[Galaxy S II Themes and Apps] aydc:
Here's android.policy.jar and framework-res.apk from deodexed XXLPB. We used to only modify android.policy on Gingerbread, though.

http://www.mediafire.com/?cpimuezm0epr38n

http://www.mediafire.com/?dw59vb6ig1knhqj
[Galaxy S II Themes and Apps] 7OH:
He - ICS moded code with many diff.

Trying to watch smali and java source, but

it's hard to adapt without device with ICS.

Wait to Aplril (until SE made for us ICS) or ask other modders.

(will be interesting to see what do you already change (p.m.))
[Galaxy S II Themes and Apps] kahvitahra:
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
[Galaxy S II Themes and Apps] pilgrim011:
Thank you so much!:)
[Galaxy S II Themes and Apps] medo159:
YOU ARE THE BEST!

I have been waiting for this mod for a long time, thanks man :)
[Galaxy S II Themes and Apps] Skye Menjou:
Could someone make a LP8 one?
[Galaxy S II Themes and Apps] kahvitahra:
That LP7 version should work on deodexed LP8 also. Nothing changed between those firmwares in android.policy.jar. Report back after testing pls.
[Galaxy S II Themes and Apps] Joloxx9:
How to install this mod?

Wysłane z mojego GT-I9100 za pomocą Tapatalk
[Galaxy S II Themes and Apps] Skye Menjou:
Tested, Sorry!

It works fine, thanks!
[Galaxy S II Themes and Apps] Splder:
im also trying to do this mod for the sensation but im kinda new to this and have no clue what i need to do is there any kind of guide or would anyone like to explain what i need to do

i also uploaded my android.policy.jar and framework-res.apk if anyone wanted to maybe do it for me :P

http://www.mediafire.com/?pb37hx6pssakfbw

http://www.mediafire.com/?nuy4a8h0ano6swt

thanks for any kind of help :)
[Galaxy S II Themes and Apps] aerobahn:
The Baksmali Wiki.

For those wondering, I'll update this when the official Samsung ICS ROM is released.
[Galaxy S II Themes and Apps] bagux:
Hi, i'm trying to port this usefull mod to my Galaxy W. By studying your work i was able to extract the needed code for the mod, but the result is that only volume down button is working, with a long press it skip to previous track; instead by long pressing volume up the volume just increase...I've tryed many times to look if i forgot something, and to make changes to code, but the result is always the same :( can u please take a look to my files? I've attacched the zip with them, if u can direct me in what i'm doing wrong...thanks :o

Edit: I've finding the mistake, now all works :D
[Galaxy S II Themes and Apps] uoY_redruM:
Can anyone post what lines were actually added?

It's extremely hard to match up the PowerWindowManager from SGSII with SGSIII. Tried comparing the two for several hours and I'm just having such a hard time...
[Galaxy S II Themes and Apps] alteredlikeness:
+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.
[Galaxy S II Themes and Apps] kahvitahra:
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).
[Galaxy S II Themes and Apps] alteredlikeness:
Yes and no. I thought I could do it without downloading the whole ROM for comparing one smali file... But, this will be helpful.. Thank you for the files!