[Sprint HTC EVO 4G LTE] swagstr:
VOLUME ROCKER MOD

The Mod

When listening to music, with the screen off, long-press the VOL+ key to change tracks forward and long-press the VOL- key to change tracks backwards.

Decompile

You gotta figure this one out! Learn how to use apktool, baksmali or VTS. It is HIGHLY recommended that if you are decompiling with apktool or baksmali to add "-b" modifier. If using VTS, uncheck the smali debug code. This will make your smali code MUCH smaller - less system space = MORE RAM.

What Needs to Be Added

This mod requires two smali files that do not exist in the stock android.policy.jar you will find them attached at the bottom of this post.

PhoneWindowManager$VolumeLongPressF.smali

PhoneWindowManager$VolumeLongPressR.smali

They go in \com\android\internal\policy\impl\

What needs to Be Changed [The long part]

Using Notepad++ or a similar text editor (ie not Notepad) navigate to \com\android\internal\policy\impl\PhoneWindowManager.smali

SEARCH FOR

.field mIsGuestMode:Z

ADD TEXT IN GREEN

.field mIsGuestMode:Z

.field mIsHtcDockScreenAsHome:Z

[COLOR="SeaGreen"].field mIsLongPress:Z[/COLOR]

.field mKeyEventsBlocked:Z

.field mKeyboardTapVibePattern:[J

SEARCH FOR

.field private mVolumeDownKeyTime:J

ADD TEXT IN GREEN

.field private mVolumeDownKeyTime:J

.field private mVolumeDownKeyTriggered:Z

[COLOR="SeaGreen"].field mVolumeDownLongPress:Ljava/lang/Runnable;[/COLOR]

.field private mVolumeUpKeyTriggered:Z

[COLOR="SeaGreen"].field mVolumeUpLongPress:Ljava/lang/Runnable;

.field mWakeAcquired:Z[/COLOR]

.field mWindowManager:Landroid/view/IWindowManager;

.field mWindowManagerFuncs:Landroid/view/WindowManagerPolicy$WindowManagerFuncs;

SEARCH FOR:

.method public constructor <init>()V

NOW SCROLL UNTIL YOU FIND THIS TEXT, ADD TEXT IN GREEN

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

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

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

[COLOR="SeaGreen"]new-instance v0, Lcom/android/internal/policy/impl/PhoneWindowManager$VolumeLongPressF;

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

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

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

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

iput-object v0, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mVolumeDownLongPress:Ljava/lang/Runnable;[/COLOR]

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

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

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

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

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

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

return-void
.end method

SEARCH FOR

.method handleVolumeKey(II)V

SCROLL TO THE END OF THIS METHOD AND ADD NEW METHODS IN GREEN

.end method

[COLOR="SeaGreen"].method handleVolumeLongPress(I)V
.locals 4

const/16 v1, 0x18

if-ne p1, v1, :cond_11

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

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

invoke-static {}, Landroid/view/ViewConfiguration;->getLongPressTimeout()I

move-result v2

int-to-long v2, v2

invoke-virtual {v1, v0, v2, v3}, Landroid/os/Handler;->postDelayed(Ljava/lang/Runnable;J)Z

return-void

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

goto :goto_6
.end method

.method handleVolumeLongPressAbort()V
.locals 2

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

iget-object v1, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mVolumeUpLongPress:Ljava/lang/Runnable;

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

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

iget-object v1, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mVolumeDownLongPress:Ljava/lang/Runnable;

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

return-void
.end method[/COLOR]

.method public hasNavigationBar()Z

SEARCH FOR

sparse-switch v13, :sswitch_data_6[COLOR="red"]82[/COLOR]

CHANGE TO

sparse-switch v13, :sswitch_data_6[COLOR="Red"]c4[/COLOR]

SEARCH FOR

:sswitch_274

BELOW THIS, YOU WILL NEED TO REPLACE EVERYTHING UNTIL AND INCLUDING

:sswitch_data_6c4
.sparse-switch
0x5 -> :sswitch_699
0x6 -> :sswitch_38a
0x18 -> :sswitch_274
0x19 -> :sswitch_274
0x1a -> :sswitch_49b
0x4f -> :sswitch_65c
0x55 -> :sswitch_64e
0x56 -> :sswitch_65c
0x57 -> :sswitch_65c
0x58 -> :sswitch_65c
0x59 -> :sswitch_65c
0x5a -> :sswitch_65c
0x5b -> :sswitch_65c
0x7e -> :sswitch_64e
0x7f -> :sswitch_64e
0x82 -> :sswitch_65c
0xa4 -> :sswitch_274
.end sparse-switch
.end method

THE CODE TO ADD CAN BE FOUND HERE:

http://goo.gl/1SfRm

IT'S TOO BIG FOR XDA

SEARCH FOR

.method sendEvent(IIIJ)V

SCROLL TO THE END OF THIS METHOD AND ADD NEW METHOD IN GREEN

.end method

[COLOR="SeaGreen"].method protected sendMediaButtonEvent(I)V
.locals 13

invoke-static {}, Landroid/os/SystemClock;->uptimeMillis()J

move-result-wide v1

new-instance v11, Landroid/content/Intent;

const-string v4, "android.intent.action.MEDIA_BUTTON"

const/4 v5, 0x0

invoke-direct {v11, v4, v5}, Landroid/content/Intent;-><init>(Ljava/lang/String;Landroid/net/Uri;)V

new-instance v0, Landroid/view/KeyEvent;

const/4 v5, 0x0

const/4 v7, 0x0

move-wide v3, v1

move v6, p1

invoke-direct/range {v0 .. v7}, Landroid/view/KeyEvent;-><init>(JJIII)V

const-string v4, "android.intent.extra.KEY_EVENT"

invoke-virtual {v11, v4, v0}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Landroid/os/Parcelable;)Landroid/content/Intent;

iget-object v4, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mContext:Landroid/content/Context;

const/4 v5, 0x0

invoke-virtual {v4, v11, v5}, Landroid/content/Context;->sendOrderedBroadcast(Landroid/content/Intent;Ljava/lang/String;)V

new-instance v12, Landroid/content/Intent;

const-string v4, "android.intent.action.MEDIA_BUTTON"

const/4 v5, 0x0

invoke-direct {v12, v4, v5}, Landroid/content/Intent;-><init>(Ljava/lang/String;Landroid/net/Uri;)V

new-instance v3, Landroid/view/KeyEvent;

const/4 v8, 0x1

const/4 v10, 0x0

move-wide v4, v1

move-wide v6, v1

move v9, p1

invoke-direct/range {v3 .. v10}, Landroid/view/KeyEvent;-><init>(JJIII)V

const-string v4, "android.intent.extra.KEY_EVENT"

invoke-virtual {v12, v4, v3}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Landroid/os/Parcelable;)Landroid/content/Intent;

iget-object v4, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mContext:Landroid/content/Context;

const/4 v5, 0x0

invoke-virtual {v4, v12, v5}, Landroid/content/Context;->sendOrderedBroadcast(Landroid/content/Intent;Ljava/lang/String;)V

return-void
.end method[/COLOR]

.method setAttachedWindowFrames(Landroid/view/WindowManagerPolicy$WindowState;IILandroid/view/WindowManagerPolicy$WindowState;ZLandroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;)V

The Final Step

Now that all the smali files have been edited, recompile your .jar, rename your file to android.policy.jar and push to /system/framework/android.policy.jar. Smali files are stored in classes.dex inside of .apks and .jars, I have uploaded some classes.dexs that include the other mods listed here as well as modified/unmodified smalis. Enjoy!

EXTRA FILES

PhoneWindowManager$VolumeLongPressF.smali

PhoneWindowManager$VolumeLongPressR.smali

STOCK FILES

PhoneWindowManager.smali

classes.dex

android.policy.jar

VOL-TRACK FILES

PhoneWindowManager.smali

classes.dex

android.policy.jar

APM + VOL-TRACK FILES

classes.dex

android.policy.jar

APM + VOL-TRACK + BACK-KILL FILES

classes.dex

android.policy.jar

#ASOP