[Fix] Decrease home button lag

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:
    Code:
    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
    :cond_1
    Delete all of these lines.
  3. Now go a few lines deeper to lines 3920 - 3922. They should be
    Code:
    invoke-virtual {v4, v5}, Landroid/os/Handler;->removeCallbacks(Ljava/lang/Runnable;)V

    .line 1294
    Replace these two lines with:

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


[HowTo] Reduce Home Button Lag - Disable Home button double click (thanks to wannam)


As i you know, a Double click feature was implemented for the Home button on Samsung Roms to launch Vlingo on SGS2 and S-Voice on SGS3.

This feature may be seen a useless Lag because most of us don't use these apps, so this is a small how to disable it, this mod was based on Oliwe and Jkay mods, thanks to them.

You need to decompile android.policy.jar (get Smali here ), Edit "androidpolicyjar\com\android\internal\policy\impl \PhoneWindowManager.smali" and make these changes :


Code:
.line 2282
:cond_236
++goto :cond_24b
--if-eqz v26, :cond_24b

.line 2283
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/from16 v41, v0

invoke-virtual/range {p2 .. p2}, Landroid/view/KeyEvent;->getAction()I
Code:
.line 2289
const/16 v41, 0x0

move/from16 v0, v41

move-object/from16 v1, p0

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

++invoke-virtual/range {p0 .. p0}, Lcom/android/internal/policy/impl/PhoneWindowManager;->launchHomeFromHotKey()V

.line 2291
if-nez v26, :cond_2a3
Code:
.line 2371
++goto :cond_332
--if-eqz v26, :cond_332

.line 2372
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/from16 v41, v0

invoke-virtual/range {v41 .. v41}, Lcom/android/internal/policy/impl/PhoneWindowManager$HomeKeyDoubleClickConcept;->setHomeDownEventSent()V
You may get a different conditions Ids, track the methods name.

Compile & Enjoy!

0 comments:

Post a Comment

Open Panel

Blogroll

counter