Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,729,324 Members 42,823 Now Online
XDA Developers Android and Mobile Development Forum

[MOD][HOW-TO] Back to kill for TW ROMs **updated 25 NOV 2012** LSJ #2post

Tip us?
 
Mirko ddd
Old
(Last edited by Mirko ddd; 12th November 2012 at 11:54 AM.)
#1  
Mirko ddd's Avatar
Recognized Contributor / Recognized Developer - OP
Thanks Meter 4721
Posts: 1,450
Join Date: Nov 2010
Location: Piazza Armerina

 
DONATE TO ME
Default [MOD][HOW-TO] Back to kill for TW ROMs **updated 25 NOV 2012** LSJ #2post

Hello xda'ers,
is me again, sorry to bother but today I bring to you a famous mod from AOKP: back longpress to kill.

HOW TO:

1. we need to decompile android.policy.jar;

2. then let s edit android.policy.jar/smali/com/android/internal/policy/impl/PhoneWindowManager.smali

3. adding fields on "# instance fields" (red is what you add):

Code:
# instance fields
.field mAccelerometerDefault:I

.field mAllowAllRotations:I

.field mAllowHdmiRotation:Z

.field mAllowLockscreenWhenOn:Z

.field final mAllowSystemUiDelay:Ljava/lang/Runnable;

.field mBackKillTimeout:Z

.field mBackLongPress:Ljava/lang/Runnable;

.field mBootMsgDialog:Landroid/app/ProgressDialog;

...

.field mLockScreenTimeout:I

.field mLockScreenTimerActive:Z

.field mLongPressBackKill:Z

.field private mLongPressOnHomeBehavior:I

...
4. add a new instance in the last lines of .method public constructor <init>()V to recall our new subclass (red is what to add):

Code:
...
    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;

    new-instance v0, Lcom/android/internal/policy/impl/PhoneWindowManager$25;

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

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

    .line 5754
    return-void
.end method
5. now we need to take a look in .method public interceptKeyBeforeDispatching(Landroid/view/WindowManagerPolicy$WindowState;Landroid/view/KeyEvent;I)J

Code:
    :cond_13c

    const/16 v39, 0x3

    move/from16 v0, v21

    move/from16 v1, v39

    if-ne v0, v1, :cond_15a

    move-object/from16 v0, p0

    iget-boolean v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mHomeKeyConsumedByScreenshotChord:Z
after :cond_13c we need to add some code (note: :cond_13c may be different depending on your compiler) and we will get:

Code:
    :cond_13c
    const/16 v28, 0x4

    move/from16 v0, v28

    move/from16 v1, v21

    if-ne v1, v0, :cond_mi

    if-nez v8, :cond_mi

    .line 1741
    and-int/lit8 v28, v11, 0x20

    if-nez v28, :cond_mi

    .line 1742
    move-object/from16 v0, p0

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

    move-object/from16 v28, v0

    move-object/from16 v0, p0

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

    move-object/from16 v1, v28

    invoke-virtual {v1, v0}, Landroid/os/Handler;->removeCallbacks(Ljava/lang/Runnable;)V

    .line 1743
    add-int/lit8 v28, v11, 0x20

    move-object/from16 v0, p2

    move/from16 v1, v28

    invoke-static {v0, v1}, Landroid/view/KeyEvent;->changeFlags(Landroid/view/KeyEvent;I)Landroid/view/KeyEvent;

    .line 1744
    const/16 v28, 0x0

    move/from16 v0, v28

    move-object/from16 v1, p0

    iput-boolean v0, v1, Lcom/android/internal/policy/impl/PhoneWindowManager;->mBackKillTimeout:Z

    .line 1752
    :cond_mi
    const/16 v39, 0x3

    move/from16 v0, v21

    move/from16 v1, v39

    if-ne v0, v1, :cond_15a

    move-object/from16 v0, p0

    iget-boolean v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mHomeKeyConsumedByScreenshotChord:Z
6. into the same method look for: .line 2495:

Code:
    .end local v9           #e:Landroid/os/RemoteException;
    :cond_45c

    const/16 v39, 0xd4

    move/from16 v0, v21

    move/from16 v1, v39

    if-eq v0, v1, :cond_46c

    const/16 v39, 0xd5

    move/from16 v0, v21

    move/from16 v1, v39

    if-ne v0, v1, :cond_489
we ll add a code here too, getting:

Code:
    .end local v9           #e:Landroid/os/RemoteException;
    :cond_45c
    const/16 v28, 0x4

    move/from16 v0, v28

    move/from16 v1, v21

    if-ne v1, v0, :cond_mirko

    .line 1863
    move-object/from16 v0, p0

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

    move/from16 v28, v0

    if-nez v28, :cond_mirko

    if-eqz v8, :cond_mirko

    if-nez v29, :cond_mirko

    .line 1864
    move-object/from16 v0, p0

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

    move-object/from16 v38, v0

    move-object/from16 v0, p0

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

    move-object/from16 v39, v0

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

    move-result-wide v40

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

    .line 1865
    const/16 v28, 0x1

    move/from16 v0, v28

    move-object/from16 v1, p0

    iput-boolean v0, v1, Lcom/android/internal/policy/impl/PhoneWindowManager;->mBackKillTimeout:Z

    .line 1875
    :cond_mirko
    const/16 v39, 0xd4

    move/from16 v0, v21

    move/from16 v1, v39

    if-eq v0, v1, :cond_46c

    const/16 v39, 0xd5

    move/from16 v0, v21

    move/from16 v1, v39

    if-ne v0, v1, :cond_489
7. add the new subclass attached in the directory of the smali we edited
Attached Files
File Type: rar PhoneWindowManager$KillConcept.rar - [Click for QR Code] (1.9 KB, 834 views)
NICOLA SAVED ME!

If I helped you and/or you like my rom consider a small donation and/or join Disaster Family on Facebook
I DON'T ANSWER ON PM ABOUT ROM/MODDING STUFFS

The Following 92 Users Say Thank You to Mirko ddd For This Useful Post: [ Click to Expand ]
 
Mirko ddd
Old
(Last edited by Mirko ddd; 25th November 2012 at 11:23 PM.)
#2  
Mirko ddd's Avatar
Recognized Contributor / Recognized Developer - OP
Thanks Meter 4721
Posts: 1,450
Join Date: Nov 2010
Location: Piazza Armerina

 
DONATE TO ME
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
Code:
    .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
Code:
    .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
Code:
    .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

    if-eqz v27, :cond_68

    move-object/from16 v0, p0

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

    move/from16 v27, v0

    if-eqz v27, :cond_68
focus on bolded underlined conds, we need to switch them with cond_951 so we will have:
Code:
    .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

    if-eqz v27, :cond_951

    move-object/from16 v0, p0

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

    move/from16 v27, v0

    if-eqz v27, :cond_951
cond_951 may be different depending on your compiler, but we need to recall the cond that gives this:
Code:
    .line 6325
    :cond_951
    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.
Attached Files
File Type: rar PhoneWindowManager$KillConcept.rar - [Click for QR Code] (1.9 KB, 288 views)
NICOLA SAVED ME!

If I helped you and/or you like my rom consider a small donation and/or join Disaster Family on Facebook
I DON'T ANSWER ON PM ABOUT ROM/MODDING STUFFS

The Following 30 Users Say Thank You to Mirko ddd For This Useful Post: [ Click to Expand ]
 
ApriliaM3
Old
#3  
ApriliaM3's Avatar
RC-RT Committee / Senior Moderator
Thanks Meter 13434
Posts: 5,860
Join Date: Feb 2012
Location: Songkhla
Let me be the first to say thanks for your efforts on this Mirko and welcome to the NeatROM crew

The Following 2 Users Say Thank You to ApriliaM3 For This Useful Post: [ Click to Expand ]
 
maanz "L"
Old
#4  
maanz "L"'s Avatar
Recognized Contributor
Thanks Meter 768
Posts: 1,011
Join Date: Sep 2010
Location: singapore

 
DONATE TO ME
Quote:
Originally Posted by Mirko ddd View Post
Hello xda'ers,
is me again, sorry to bother but today I bring to you a famous mod from AOKP: back longpress to kill.

You can find the how to into my github here

It really easy to do and port an any other samsung rom, simply check out github commit, it s very clear.

I made it for salesale's neat rom, u can find a flashable zip here

Would be appreciate to make a nandroid backup, just in case.

If u have requests for other roms please ask to your rom developer to contact me.

Cheers

Credits to:
AOKP
CM
xda sharing
this mod will be a great addition, mate..



A member of X-TremE Team.
____________________________________________
________________________________

"Thanks button is just to avoid "thanks" posts in threads. Nothing more than that.
Don't ask in signature or post for it and defeat the purpose why it was introduced"


"Support for Mirko and LegendK95 against piracy..."

"Devs stealing Goldieking's Alliance App.."

Support Silent Circle and the BlackPhone.
Protecting our privacies from NSA and governments threats.
The Following User Says Thank You to maanz "L" For This Useful Post: [ Click to Expand ]
 
Many40
Old
#5  
Many40's Avatar
Recognized Contributor
Thanks Meter 18050
Posts: 5,060
Join Date: Nov 2009
Location: Ω⌂
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

Sent from my GT-I9100 using xda premium

 
My current setup:
Device: SGS2 (i9100)
Kernel: Siyah6.0 beta 4/SuperSU
CPU: 10 steps (100-1000MHz)/UV, pegasusq/sio
GPU: 5 steps (54, 66, 108, 160, 267 MHz)/UV
ROM: JB 4.1.2 XWMS3 NeatRomLite v6.2
The Following User Says Thank You to Many40 For This Useful Post: [ Click to Expand ]
 
friccc81
Old
#6  
Member
Thanks Meter 13
Posts: 64
Join Date: Apr 2012
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
 
geroxx
Old
#7  
geroxx's Avatar
Senior Member
Thanks Meter 454
Posts: 126
Join Date: Nov 2011
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 -
 
Mr.Greg
Old
#8  
Mr.Greg's Avatar
Senior Member
Thanks Meter 5434
Posts: 6,397
Join Date: Sep 2010

 
DONATE TO ME
Great work Mirko. You got 5 star from me.
 
bobdoblo
Old
#9  
bobdoblo's Avatar
Senior Member
Thanks Meter 21137
Posts: 6,930
Join Date: Apr 2012
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!
 
Mirko ddd
Old
#10  
Mirko ddd's Avatar
Recognized Contributor / Recognized Developer - OP
Thanks Meter 4721
Posts: 1,450
Join Date: Nov 2010
Location: Piazza Armerina

 
DONATE TO ME
Quote:
Originally Posted by ApriliaM3 View Post
Let me be the first to say thanks for your efforts on this Mirko and welcome to the NeatROM crew
thanks Aprilia






Quote:
Originally Posted by maanz View Post
this mod will be a great addition, mate..
Since i cannot build my own rom at least i give a little of mine in many others xD





Quote:
Originally Posted by Many40 View Post
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

Sent from my GT-I9100 using xda premium



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


Quote:
Originally Posted by friccc81 View Post
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

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




Quote:
Originally Posted by geroxx View Post
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 -



yes timeout can be set into smalis


Quote:
Originally Posted by 078gregory View Post
Great work Mirko. You got 5 star from me.

thx Greg




Quote:
Originally Posted by bobdoblo View Post
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!
Answered two posts ago

Inviato dal mio GT-I9100 con Tapatalk 2
NICOLA SAVED ME!

If I helped you and/or you like my rom consider a small donation and/or join Disaster Family on Facebook
I DON'T ANSWER ON PM ABOUT ROM/MODDING STUFFS


The Following 2 Users Say Thank You to Mirko ddd For This Useful Post: [ Click to Expand ]
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes