yashsingh1/xdaforums huggingface dataset:
[Galaxy S II Android Development] Mirko ddd:
LSJ back to kill

I found really hard do it from scratch because samsung is using longpress back to show/hide the flash bar (for multiwindows feature), so i decided to use that method simply switching the subclass from $10 (flashbar show-hide) to $killconcept (back to kill).

This meant back to kill works only when mutiwindows is on, so i needed to recall the subclass even when multiwindow was off.

following the diff:

-1 switch $10 subclass to $KillConcept subclass

find

.line 1618
new-instance v0, Lcom/android/internal/policy/impl/PhoneWindowManager$10;

invoke-direct {v0, p0}, Lcom/android/internal/policy/impl/PhoneWindowManager$10;-><init>(Lcom/android/internal/policy/impl/PhoneWindowManager;)V

iput-object v0, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mBackLongPress:Ljava/lang/Runnable;

will become

.line 1618
new-instance v0, Lcom/android/internal/policy/impl/PhoneWindowManager$KillConcept;

invoke-direct {v0, p0}, Lcom/android/internal/policy/impl/PhoneWindowManager$KillConcept;-><init>(Lcom/android/internal/policy/impl/PhoneWindowManager;)V

iput-object v0, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mBackLongPress:Ljava/lang/Runnable;

this will let u use back to kill ONLY when multiwindows is on. So let s make it for every case, multiwindows on and off.

find

.line 6320
:cond_91a
move-object/from16 v0, p0

iget-boolean v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mIsMultiWindowUIEnabled:Z

move/from16 v27, v0

[B][U]if-eqz v27, :cond_68[/U][/B]

move-object/from16 v0, p0

iget v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mEnableMultiWindowUISetting:I

move/from16 v27, v0

[B][U] if-eqz v27, :cond_68[/U][/B]

focus on bolded underlined conds, we need to switch them with cond_951 so we will have:

.line 6320
:cond_91a
move-object/from16 v0, p0

iget-boolean v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mIsMultiWindowUIEnabled:Z

move/from16 v27, v0

[B][U]if-eqz v27, :cond_951[/U][/B]

move-object/from16 v0, p0

iget v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mEnableMultiWindowUISetting:I

move/from16 v27, v0

[B][U] if-eqz v27, :cond_951[/U][/B]

cond_951 may be different depending on your compiler, but we need to recall the cond that gives this:

.line 6325
[B][U]:cond_951[/U][/B]
move-object/from16 v0, p0

iget-object v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mHandler:Landroid/os/Handler;

move-object/from16 v27, v0

move-object/from16 v0, p0

iget-object v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mBackLongPress:Ljava/lang/Runnable;

move-object/from16 v28, v0

invoke-static {}, Landroid/view/ViewConfiguration;->getGlobalActionKeyTimeout()J

move-result-wide v29

invoke-virtual/range {v27 .. v30}, Landroid/os/Handler;->postDelayed(Ljava/lang/Runnable;J)Z

goto/16 :goto_68

add the attached subclass and recompile.

NOTE: is in beta phase, has to be improved so if some dev wanna help me in debugging is welcome.
[Galaxy S II Android Development] ApriliaM3:
Let me be the first to say thanks for your efforts on this Mirko and welcome to the NeatROM crew :)
[Galaxy S II Android Development] maanz "L":
this mod will be a great addition, mate..;)
[Galaxy S II Android Development] Many40:
Thanks Mirko. Installed on NeatromLite 3.5 and so far works as expected. Especially Tapatalk app annoyed me much - after closing it always stayed as running process for nothing. Now I can get rid of this by one long press. Great.

I gonna observe if it doesn't influence badly any other features of the rom (there were some issues with similar feature in Jkay's mod). Regards
[Galaxy S II Android Development] friccc81:
Mirko, flashed Sale's Neatrom lite v3.3 (LPX). your mod works very well but i think better idea is "long press to kill ALL apps". With your mood I can kill only the latest application where I am.

Thanks

Sorry for my English
[Galaxy S II Android Development] geroxx:
This is exactly what was i looking for. Thank you very much (:

I used the guide with Chameleon-ROM and it worked like a charm. But is there a way to change the longpressduration til the app gets killed?

- geroxx -
[Galaxy S II Android Development] Mr.Greg:
Great work Mirko. You got 5 star from me.
[Galaxy S II Android Development] bobdoblo:
Been waiting for long time for this!

Thanks very much, agree that a kill all button is needed for recent applications when the home button is held down though!

But very happy with this mod, thanks!:thumbup:

NeatROM -The Best!

Salesale - True Super-Dev!
[Galaxy S II Android Development] Mirko ddd:
:) thanks Aprilia

Since i cannot build my own rom at least i give a little of mine in many others xD

code is not 100% perfect but is bugless, tested almist 2days with logcats ;)

well that s the mod, to kill all app check out my systemui with kill all recents, or clear ram with task manager :)

yes timeout can be set into smalis :)

thx Greg :)

Answered two posts ago :)

Inviato dal mio GT-I9100 con Tapatalk 2
[Galaxy S II Android Development] maanz "L":
looking forward to the smali edits, mate..:good:
[Galaxy S II Android Development] sniper:
I love you <3 (no homo ;) )
[Galaxy S II Android Development] Mirko ddd:
ooh ok mate :D how many ms we have to set? i think is good enough, faster would be annoying because we could kill app mistaking, slower.. would be annoying too, but hey, i m not the boss here :silly:

5+5=10! where are my 10 stars? all fallen? make a wish! mmh, i made my wish but.. (check out my signature to better understand Salesale :eek:)

nice to see tdunham friends here, you are welcome!
[Galaxy S II Android Development] Goldie:
Good job buddy. Thanks for the heads up :)
[Galaxy S II Android Development] vrts:
I've been waiting for this! Thanks Mirko.

Could you add battery bar mod to your to do list?
[Galaxy S II Android Development] maanz "L":
let's ask the guys here, how long in ms would they want the longpressduration till the app gets killed.. that would be good, mate.
[Galaxy S II Android Development] Mirko ddd:
;)

you're welcome.

battery bar mod u mean aokp style or miui style?

I sincerily see this feature har to port without using romcontrol stuffs and miui stuffs.. if i remember well leomar made it for gingerbread, i will take a look, but i don t promise anything about :silly:
[Galaxy S II Android Development] geroxx:
thanks :D

However i am not really good in java-developing. So can you please tell me which values i must change to set the timeout.

- geroxx -
[Galaxy S II Android Development] Mirko ddd:
really no need to be good in java developing :D

if u take a look in the code (differences posted on github, u used to get it on chamaleon) u will have to focus on:

iget-object v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mBackLongPress:Ljava/lang/Runnable;

move-object/from16 v39, v0

invoke-static {}, Landroid/view/ViewConfiguration;->[B][COLOR="Red"]getGlobalActionKeyTimeout[/COLOR][/B]()J

this means we are recalling a method with this path:

Landroid/view/ViewConfiguration

so it s in framework jar/android/view/Viewconfiguration.smali

Open this smali file and look for the method getGlobalActionKeyTimeout

method say:

.method public static getGlobalActionKeyTimeout()J
.registers 2

.prologue
.line 669
[B]const-wide/16 v0, 0x1f4[/B]

return-wide v0
.end method

let s focus on bolded, this is the value in ms (i guess)

0x1f4 it s the time.

I really have problems with ex numbers so i google it and see this corresponding to 500ms (half second)

So we have two ways we can follow:

or edit the method

or repace this method with a convenient one (which have the timeout we want)

first is an asshole thing, because we will change the timeout of other things like power menu timeout, presshome timeout etc..

Second is more handy, so we can use an existing method (so no need to create nu) to our aim.

Let s investigate to find a nice timeout time :highfive: (Mirko wth are u talkin 'bout :eek:)

If I can you a can, only need to waste some time and have a passion for :D

Hope this will help you, for questions i m here, but don t forget to thank (i ignore people who don t support my efforts)
[Galaxy S II Android Development] vrts:
I mean MIUI style. I'm coming from Simplistic V and I get used to back to kill and battery bar mods and now which rom I install I'm looking forward this features.

By the way in my opinion force to close delay is a little shorty.
[Galaxy S II Android Development] Mirko ddd:
I find back to kill timeout perfect, but in case a post ago i mentioned an eventual how to..

i will look into battery bar stuffs, but this will be a nu thread, so let stay on topic :D
[Galaxy S II Android Development] geroxx:
WOW. Thank you for the comprehensive guide!! i set it to 1000ms (0x3E8) and it works fine..

I immediately clicked the thanks-button when i saw the length of the post :D

- geroxx -
[Galaxy S II Android Development] Mirko ddd:
nice, if a recognized noob like me can, you all can XD (just kiddin) :highfive:

report this to your rom developer
[Galaxy S II Android Development] Dalfin:
Unfortunately this mod has cancelled my 4way reboot. Any way to get it back?

EDIT: Sasa just uploaded a fix on NeatROM thread.
[Galaxy S II Android Development] Mirko ddd:
I gave to salesale this morning what you r looking for :)

Check it out into his thread or ask him for it :)
[Galaxy S II Android Development] tdunham:
Hi Mirko.

I ported this over to Sprint GSII and it works once then not again.

I had to change most values to match my phone. Only values I did not change in PhoneWindowManager (only in your code) are v8 and v11 and of course v0, v1.

Do you think there are there any values in PhoneWindowManager$KillConcept.smali I need to change also? (I took the one from the file you made. Much easier than writing new one. ;))
[Galaxy S II Android Development] Mirko ddd:
So works once?

Pls send me your phonewindowsnanager before applying the mod and once applied.

And public xml from your framework res.

I ll take a look asap
[Galaxy S II Android Development] tdunham:
Thank you, I see value of 0x1040219 in kill smali. It calls in my public.xml:

<public type="string" name="permlab_setAnimationScale" id="0x01040219" />

What line does it call in your framework?

---------- Post added at 02:55 PM ---------- Previous post was at 02:50 PM ----------

Here are my files. Very similar structure, different variables of course. Thank you.

https://www.dropbox.com/s/v0as4okabsrtohf/TD.Back to kill mod.zip?m
[Galaxy S II Android Development] Mirko ddd:
Ok i ll take a look. I need to go at work cuz i have not a pc.

See u later
[Galaxy S II Android Development] sniper:
I tried this out too but couldn't get it working yet. Check your pm's in a minute ;)

Click here for custom mods for your E4GT
[Galaxy S II Android Development] tdunham:
Alright, corrected kill smali line 234 value to 0x10401f9 to match my framework public.xml. Still same thing but at least that part is correct now.

---------- Post added at 04:22 PM ---------- Previous post was at 03:35 PM ----------

Ok, I got it. Missed a value change in the phonewindowmanager when I was porting this over. Works very well. Thanks again Mirko! TD

(to finish android.policy.jar, now all we need is skip music with volume toggles with screen off LOL ;))
[Galaxy S II Android Development] Mirko ddd:
Mate let me say to u a lovely **** you! XD

Ok so i work directly on volume rocker mod :P
[Galaxy S II Android Development] tdunham:
I think that has been done for your phone but I cannot find it. Thanks again.
[Galaxy S II Android Development] Mirko ddd:
I think so, but i want the tilt to change so i will go from scratch. End OT
[Galaxy S II Android Development] gabi11:
Hi Mirko,

I flashed your mod on XWLPY NeatRom Lite with mod pack 4.1 (your first mod, not the second from sale's thread that fixes 4 way reboot).

Well, it works but it disabled my ics lockscreen that comes with sale's mod pack 4.1.

now I have stock lockscreen.

Can it be fixed...? :o

Thanks man!!
[Galaxy S II Android Development] Mirko ddd:
Hello gabi i gave the mod to salesale, ask for it into his thread :)

Happy saturday nite!
[Galaxy S II Android Development] tdunham:
Hi Mirko. If I create new method to use instead of getGlobalActionKeyTimeout does it also need to be in framework.jar. Or is there an easier way to give timeout value directly.
[Galaxy S II Android Development] Mirko ddd:
Depends from the path i guess. But try to look for an existing method which has the timeout u desire :)

Inviato dal mio GT-I9100 con Tapatalk 2
[Galaxy S II Android Development] .Bambino:
Finally!!! I been looking forward to this. Was telling the TW devs about this and no one seemed interested. Glad someone was finally able to get it done. Thanks a lot. I know on some AOSP roms there was something you need to check off to use it. I flashed the zip and I hold the back button nothing worked and didn't find it in options. I am using FreeGS3 TW based ROM
[Galaxy S II Android Development] Mirko ddd:
Hello, please read OP, this is for I9100 LPX samsung based rons.

Comes with any toggles, only longpress back button to kill.
[Galaxy S II Android Development] glos7777:
hi

is it working on galaxy note stock 4.0.4 LRT ?
[Galaxy S II Android Development] ChitownWingMan:
will this work on a touch wiz rom running go launcher not touch wiz?

I am running on a t-mobile Galaxy SIII SGH-T999 32GB on UVALJ4 stock stock rom rooted, partially debloated and pimped.

Can I use your mod if I am using go launcher rather than touch wiz?

Thanks in advance...
[Galaxy S II Android Development] joeldroid:
Amazing...

Amazing work Mirko ddd.....
[Galaxy S II Android Development] toxicro:
Nice article made special for Mirko and his awesome work, step by step your work will be recognized by XDA,

only need is some patiance

http://www.xda-developers.com/android/cmaokp-style-long-press-back-to-kill-on-touchwiz-roms/
[Galaxy S II Android Development] Mirko ddd:
i guess so,but dont flash the zip, follow the HOW TO to implement into your rom

i guess so,but dont flash the zip, follow the HOW TO to implement into your rom

Thanks Joel ;)

Ooh, thanks buddy :D to you and who committed this article :D thanks.

well i needed this, after my request for RD has not been accepted -.-
[Galaxy S II Android Development] chenrp:
not working on SAMSUNG BASED ROM 4.0.3

on SIYAH KERNEL.

phone won't boot.
[Galaxy S II Android Development] Mirko ddd:
this because u flashed the zip, that how OP states is for LPX rom -.-

i m re writing the tutorial and takin off the link because people cannot read, right?
[Galaxy S II Android Development] chenrp:
"u can find a flashable zip here"

so it is not flashable !

i read what you wrote...
[Galaxy S II Android Development] Goldie:
Always amazes me how people will just blindly flash any zip into their expensive phone!!
[Galaxy S II Android Development] Mirko ddd:
this is what i wrote:

"I made it for

salesale's neat rom

, u can find a flashable zip here"

ergo: salesale' s neat rom is 4.0.4 rom

ergo: you cannot read.
[Galaxy S II Android Development] Mirko ddd:
Always amazes me how people will just scream at: "DON T WORK!" instead of reading
[Galaxy S II Android Development] Mirko ddd:
updated OP with the how to
[Galaxy S II Android Development] tdunham:
Everyone is loving this mod Mirko. What's the next great thing? :)
[Galaxy S II Android Development] Mirko ddd:
Volume rocker mod :)

Made it today but i m not satisfied yet. Wanna add some more

Inviato dal mio GT-I9100 con Tapatalk 2
[Galaxy S II Android Development] tdunham:
Very nice, I can hardly wait.
[Galaxy S II Android Development] Mirko ddd:
ok, volume rocker mod done, removed some code, no path to create and mod-ready-to-use, easier to port over :D

later or tomorrow i ll post a nu thread.
[Galaxy S II Android Development] tarekboukaf:
sorry for this question, but how to usee this smali thing???!! where to put it?
[Galaxy S II Android Development] Mirko ddd:
It s a phonewindowmanager subclass. It needs to do yourself da mod as OP states.

Did u read OP?

Inviato dal mio GT-I9100 con Tapatalk 2
[Galaxy S II Android Development] tarekboukaf:
ok , ill try, thksssssssssss
[Galaxy S II Android Development] yoelsd:
Any chance for a JB update ?
[Galaxy S II Android Development] Mirko ddd:
harder.. because longpress back method is busy with multiwindows stuffs.. :rolleyes:
[Galaxy S II Android Development] yoelsd:
Yeah , ive been working on it my self for an hour now.

If i get something outa it ill post !
[Galaxy S II Android Development] Mirko ddd:
and so? i got it yoel :P tutorial after i release my rom
[Galaxy S II Android Development] eresac:
This sounds interesting!

OT: which kind of rom? when? :)
[Galaxy S II Android Development] Mirko ddd:
Disaster ROM, LSJ based (4.1.2)
[Galaxy S II Android Development] Mirko ddd:
back to kill for LSJ post #2
[Galaxy S II Android Development] Seyaru:
Hi Mirko i have a question this dont break the multiwindow stuff when long press back open the left bar?
[Galaxy S II Android Development] Mirko ddd:
as i said:

is a compromise, but flash bar appears only when multiwindow is on, so u can use the dropdown toggle to show-hide it.

looking for better ways, but i won t hurry up, and probably i won t update til 3december.
[Galaxy S II Android Development] ivanfix:
Hi Mirko and sorry for the noob question... Which programs I need to decompile the android.policy file and to do this work?
[Galaxy S II Android Development] Mirko ddd:
U need smali baksmali. But it s better build a castle from roots instead of laying bricks from top.

Inviato dal mio GT-I9100 con Tapatalk 2
[Galaxy S II Android Development] tdunham:
Hey Mirko. I got your note that code was updated for Jellybean. We just got leak for JB for Epic 4G Touch recently that is almost ready but no Multi View support in our JB version yet so it may not matter for changes. I am waiting for fully working version of JB before I try to adapt code for our phone. Thanks for all the hard work you put into this.
[Galaxy S II Android Development] joeyfettucine:
Mirko,

I'd like to bring this over to HTC. Can you send me your phonewindowmanager.smali so I can see the file as a whole. I'm just kind of guessing and piecing together right now.

Thanks!
[Galaxy S II Android Development] Mirko ddd:
U can fork it from my github, github.com/Mirkoddd

Inviato dal mio GT-I9100 con Tapatalk 2
[Galaxy S II Android Development] joeyfettucine:
Sweet, thanks

Sent from my LTEVO running Frosty Jelly Belly
[Galaxy S II Android Development] RockRatt:
Is there a new link/mirror? When I try to download it says downloads have expired or something to that effect. Thanks

Sent from My SGH-I777 Running Spiderman Themed AOKP or Spiderman Themed CM10
[Galaxy S II Android Development] Mirko ddd:
Try to download what?
[Galaxy S II Android Development] RockRatt:
From the I777 post you have a link that says HERE for the cwm flashable mod of the back button kill mod. When I click on the HERE link it goes to a site to download but it says the downloads have expired.

Sent from My SGH-I777 Running Spiderman Themed AOKP or Spiderman Themed CM10
[Galaxy S II Android Development] Mirko ddd:
U could write there so :)

Anyways. . The link has been removed, tutorial is pretty simple to do and Probably that zip would be incompatible for your android version.

Follow the tutorial or contact your rom developer to implement it into your rom.

Or gimme your android.policy + 30 $ and i ll do for you (just kidding)
[Galaxy S II Android Development] RockRatt:
No problem. I can follow your tutorial. Thanks for the reply. Also I thought I had made the comment in the i777 section, my bad. Thanks again.

Sent from My SGH-I777 Running Spiderman Themed AOKP or Spiderman Themed CM10
[Galaxy S II Android Development] peter_baz:
may i and is it possible for me to port this to my Gingerbread rom for galaxy mini 2?

cant find the 1st part of the code...

the only similar is this

# instance fields
.field mAccelerometerDefault:I

.field mAllowLockscreenWhenOn:Z

.field mBroadcastDone:Landroid/content/BroadcastReceiver;

.field mBroadcastWakeLock:Landroid/os/PowerManager$WakeLock;

.field mCarDockEnablesAccelerometer:Z

.field mCarDockIntent:Landroid/content/Intent;

.field mCarDockRotation:I

.field mConsumeSearchKeyUp:Z

.field mContentBottom:I

.field mContentLeft:I

.field mContentRight:I

also .method public interceptKeyBeforeDispatching(Landroid/view/WindowManagerPolicy$WindowState;Landroid/view/KeyEvent;I)J is not there

but i find .method public interceptKeyBeforeDispatching(Landroid/view/WindowManagerPolicy$WindowState;IIIIIII)Z

etc...
[Galaxy S II Android Development] ruh01:
some help please...

hello, I tried to follow the steps for JB leak in post 2.

1. Downloaded rar

2. unarchived the file inside rar

3. decompiled android.policy.jar from my phone with ellesbb's GUI apk tool

4. added the file from inside rar to folder android.policy.jar\smali\com\android\internal\policy\impl

5. recompiled jar

6. checked log in GUI apk tool for errors and there were none

7. replaced android.policy.jar from phone with the one recompiled at step 5

8. changed permissions to my new jar as the ones of the older

9. rebooted phone

10....NO LUCK, even if I disabled multiwindow...

What have I done wrong, please?

LE. Managed with a cwm package found on google.
[Galaxy S II Android Development] Ryuinferno:
Just to share what fixed my problem. Sometimes the mod is applied successfully (i.e. Your phone boots up successfully) but the mod just won't work and shows weird messages instead...this may be caused by a mismatched value in PhoneWindowManager$KillConcept.smali...search for 0x1040219 in that file and replace it with the value that can be found in public.xml from framework-res.apk. Look for a line like this:

<public type="string" name="permlab_forceBack" id="0x0aaaaaaa" />

0x0aaaaaaa will differ according to your ROM...so using that value, replace 0x1040219 with 0xaaaaaaa (remove the zero!)...then smali back your classes.dex...and viola! You're done (hopefully)! :)

Thanks to tdunham for telling the correct value to match...:)
[Galaxy S II Android Development] ruh01:
wow, that goes beyond my primitive skills...I just discovered a cwm packae on google that does the trick, however thanks for kindness
[Galaxy S II Android Development] djmatt604:
Ported for Galaxy Tab 10.1 Wifi. Thanks for this AWESOME mod!! Full credit where credit is due :)
[Galaxy S II Android Development] garf02:
Mirko, this mod work with latest firmware XWLS8?
[Galaxy S II Android Development] tdunham:
Hi Mirko.

What is purpose of this code you added? I cannot find reference for it in your guide.

.field mLockScreenTimerActive:Z

[COLOR="Red"].field mLongPressBackKill:Z[/COLOR]

.field private mLongPressOnHomeBehavior:I
[Galaxy S II Android Development] Mirko ddd:
lol this is ICS way, u have to read LSJ way :)
[Galaxy S II Android Development] tdunham:
LSJ way?:

post 1 + 2 = LSJ Way

It does not hurt to have that extra line. I just do not see mLongPressBackKill referenced anywhere else in post #1 code so this is why I asked why you add it. ;)
[Galaxy S II Android Development] mani1999:
What do I have to change if I want "hold menu to kill"?

Thanks in advanced....;)
[Galaxy S II Android Development] mani1999:
AW: [MOD][HOW-TO] Back to kill for TW ROMs **updated 25 NOV 2012** LSJ #2post

Does anyone know that?
[Galaxy S II Android Development] mani1999:
Could PLEASE someone tell me where to find a tutorial of how to make a "hold menu button to kill" or what to change in this tutorial that I have a "hold menu button to kill".

Thanks....
[Galaxy S II Android Development] xfahim:
Using Xperia Go ICS .54fw,

Tried to do as you said but no success. Got bootloop twice. maybe because its Sony and your code is for Samsung.

I attached my phones android.policy if you can modify this? :) Please?
[Galaxy S II Android Development] mani1999:
How do I do this on XWLSD?
[Galaxy S II Android Development] Josehg:
Check you pm :D

Messages are not sent, I tried five times, is your inbox full?
[Galaxy S II Android Development] mani1999:
Thanks very much:) I got all your messages:D I'm trying right now....