Remove All Ads from XDA

[Fix] Decrease home button lag

18 posts
Thanks Meter: 89
By Oliwe, Junior Member on 20th August 2011, 09:40 PM
Post Reply Email Thread
Hi all, hope this is the right forum.

This thread is meant for ROM cooks only!

Let's start: I found a way to decrease the home button lag and would like to share this fix with you.

Some theory first:
The way from home button click to the home screen can be separated in two parts:
  1. System will wait about 0.5s for another tap. This is due to the double click to voice-search feature, Samsung implemented. You won't find this lag on any other phone.
    The good news is, that we can avoid it with some changes in framework.
  2. The second part is the time the launcher needs to load. It's about 0.3 - 0.5 sec, depending on which app is currently running.

Now to the fix:
  1. You have to decompile android.policy.jar (framework folder) using baksmali.
  2. Open com\android\internal\policy\impl\PhoneWindowManage r.smali and search for lines 3896 to 3922. They should look like this:
        const/4 v4, 0x3
        move/from16 v0, p4
        move v1, v4
        if-ne v0, v1, :cond_1
        .line 1279
        move-object/from16 v0, p0
        iget-object v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mHomeKeyDoubleClickConcept:Lcom/android/internal/policy/impl/PhoneWindowManager$HomeKeyDoubleClickConcept;
        move-object v4, v0
        move-object v0, v4
        move/from16 v1, p2
        move/from16 v2, p7
        move v3, v13
        invoke-virtual {v0, v1, v2, v3}, Lcom/android/internal/policy/impl/PhoneWindowManager$HomeKeyDoubleClickConcept;->addAction(IIZ)V
        .line 1288
    Delete all of these lines.

  3. Now go a few lines deeper to lines 3920 - 3922. They should be
        invoke-virtual {v4, v5}, Landroid/os/Handler;->removeCallbacks(Ljava/lang/Runnable;)V
        .line 1294
    Replace these two lines with:
        invoke-virtual {v4, v5}, Landroid/os/Handler;->removeCallbacks(Ljava/lang/Runnable;)V
        move-object/from16 v0, p0
        iget-boolean v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mHomePressed:Z
        move v4, v0
        if-eqz v4, :cond_2
        invoke-virtual/range {p0 .. p0}, Lcom/android/internal/policy/impl/PhoneWindowManager;->launchHomeFromHotKey()V
        .line 1294
    (Note that the first and last line are the original ones.)
  4. Warning: take a look at line 3933. If it is not ":cond_2", you have to replace the cond_2 in "if-eqz v4, :cond_2" with the cond from line 3933.
    It looks like the naming sceme depends on the baksmali version you're using.
  5. Now recompile with smali and you're done

Some notes:
  1. The device will no longer wait for double clicks of home key. This means, that the voice-search obviously can no longer be started with a double-tap on home key.
  2. You will still notice some lag on home key. That's the time the home launcher needs to load. Try it from within the launcher (for example in the app chooser) and it will react instant. It should now be comparable to any other phone.
  3. The given line-numbers are from a KH3 ROM. The numbers may change in future roms.
  4. I would call this fix "experimental". I tested it for a few days without any issues, but I can't guarantee that it is bug free.
    The problem is, that Samsung made the single click listener depend on the double click listener, so removing the double-click listener might cause some problems.

That's it. I hope, I could help you
The Following 86 Users Say Thank You to Oliwe For This Useful Post: [ View ] Gift Oliwe Ad-Free
20th August 2011, 10:00 PM |#2  
designgears's Avatar
Inactive Recognized Developer
Flag SLC
Thanks Meter: 8,976
Donate to Me
Very nicely done! This will be in the next Cognition release!
The Following 5 Users Say Thank You to designgears For This Useful Post: [ View ] Gift designgears Ad-Free
20th August 2011, 10:04 PM |#3  
Techvir's Avatar
Senior Member
Thanks Meter: 849
Great news... Thanks for the idea
20th August 2011, 10:13 PM |#4  
Senior Member
Thanks Meter: 82
Anyone wanna compile this into an for the lazy? :D
20th August 2011, 10:21 PM |#5  
winwiz's Avatar
Senior Member
Thanks Meter: 658
Originally Posted by designgears

Very nicely done! This will be in the next Cognition release!

woooo hoooo

20th August 2011, 10:33 PM |#6  
kahvitahra's Avatar
Senior Member
Thanks Meter: 1,159
Working great!
Many thanks mate!
20th August 2011, 11:02 PM |#7  
King Shady's Avatar
Senior Member
Thanks Meter: 154
Thanks so much for this fix !
20th August 2011, 11:14 PM |#8  
CaspaTheGhost's Avatar
Senior Member
Flag London
Thanks Meter: 1,442
Excellent tweak OP, thank you!
20th August 2011, 11:20 PM |#9  
xan's Avatar
Retired Recognized Developer
Flag Crack-ow
Thanks Meter: 459
Donate to Me
I had a problem with this line:
 if-eqz v4, :cond_2
smali complained about it during recompilation of Batista framework.

Just change it to next cond_[something] you find just after the part you inserted.
The Following 2 Users Say Thank You to xan For This Useful Post: [ View ] Gift xan Ad-Free
20th August 2011, 11:33 PM |#10  
KLoNe1's Avatar
Senior Member
Flag Brisbane
Thanks Meter: 86
Donate to Me
The Devs/Cooks are going to LOVE you! The flac they've copped recently from thus 'bug'/feature has been enoumous!

Sent from my GT-I9100 using XDA Premium App
20th August 2011, 11:39 PM |#11  
jameslfc5's Avatar
Senior Member
Thanks Meter: 192
Will this produce the same effect as removing voice command or will it make it faster than that?

Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes