FORUMS

Dr.Ketan Brings The S6 Theme Store To The Note 4

Dr.Ketan has submitted a video to the forums showing a functional port of the Galaxy S6 … more

Do You Have Insurance on Your Smartphone?

While affordable smartphones are becoming more available, the majority of high-end flagships … more

Apple Music Will Increase iTunes Match to 100,000 Songs

The battle for music streaming subscription dominance is starting to really heat … more

Xposed Framework Updated to v65

Xposed Framework is an extremely popular modification platform for Android, so much so that we included … more

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

1,454 posts
Thanks Meter: 4,734
 
By Mirko ddd, Recognized Contributor / Recognized Developer on 2nd November 2012, 12:31 PM
Post Reply Subscribe to Thread Email Thread
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, 913 views)
Last edited by Mirko ddd; 12th November 2012 at 11:54 AM.
The Following 93 Users Say Thank You to Mirko ddd For This Useful Post: [ View ]
 
 
2nd November 2012, 12:32 PM |#2  
Mirko ddd's Avatar
OP Recognized Contributor / Recognized Developer
Flag Piazza Armerina
Thanks Meter: 4,734
 
Donate to Me
More
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, 317 views)
Last edited by Mirko ddd; 25th November 2012 at 11:23 PM.
The Following 30 Users Say Thank You to Mirko ddd For This Useful Post: [ View ]
2nd November 2012, 12:50 PM |#3  
ApriliaM3's Avatar
RC-RT Committee / Senior Moderator
Flag Melbourne
Thanks Meter: 14,864
 
More
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: [ View ]
2nd November 2012, 01:06 PM |#4  
maanz "L"'s Avatar
Recognized Contributor
Flag singapore
Thanks Meter: 771
 
Donate to Me
More
Quote:
Originally Posted by Mirko ddd

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..
The Following User Says Thank You to maanz "L" For This Useful Post: [ View ]
2nd November 2012, 01:33 PM |#5  
Many40's Avatar
Recognized Contributor
Flag Poland
Thanks Meter: 18,427
 
More
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
The Following User Says Thank You to Many40 For This Useful Post: [ View ]
2nd November 2012, 01:37 PM |#6  
Member
Thanks Meter: 16
 
More
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
2nd November 2012, 02:08 PM |#7  
Senior Member
Thanks Meter: 468
 
More
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 -
2nd November 2012, 04:19 PM |#8  
Mr.Greg's Avatar
Senior Member
Thanks Meter: 5,440
 
Donate to Me
More
Great work Mirko. You got 5 star from me.
2nd November 2012, 05:55 PM |#9  
bobdoblo's Avatar
Senior Member
Thanks Meter: 21,164
 
More
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!
2nd November 2012, 06:41 PM |#10  
Mirko ddd's Avatar
OP Recognized Contributor / Recognized Developer
Flag Piazza Armerina
Thanks Meter: 4,734
 
Donate to Me
More
Quote:
Originally Posted by ApriliaM3

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

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

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

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

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

Great work Mirko. You got 5 star from me.


thx Greg




Quote:
Originally Posted by 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!

Answered two posts ago

Inviato dal mio GT-I9100 con Tapatalk 2
The Following 2 Users Say Thank You to Mirko ddd For This Useful Post: [ View ]
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes