[Galaxy S II Android Development] Mirko ddd:
Hello xda'ers.

Today I post this thread to help people who want volume rocker mod in their I9100.

This thread is not supposed to be a request thread, especially for non thanking people, but is open to help, support and debug (or improves).

For DEVs the how to on jelly bean [LSJ] (add green parts)

edit PhoneWindowManager.smali in android.policy.jar

.field private mIsSensorhubEnabled:Z

.field mIsSleepWithCameraOnTop:Z

.field private mIsTablet:Z

.field private mIsVisibleSPenGestureView:Z

[COLOR="YellowGreen"].field mIsVolumeAction:Z

.field mIsVolumeBlocking:Z
[/COLOR]
.field mKeyboardTapVibePattern:[J

.field mKeyguard:Landroid/view/WindowManagerPolicy$WindowState;

.field mKeyguardMediator:Lcom/android/internal/policy/impl/KeyguardViewMediator;

.field private mVolumeDownKeyTime:J

.field private mVolumeDownKeyTriggered:Z

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

.field private final mVolumeKeyLongPressforOneTouchReport:Ljava/lang/Runnable;

.field private mVolumeUpKeyConsumedByOneTouchReportChord:Z

.field private mVolumeUpKeyConsumedByScreenRecordChord:Z

.field private mVolumeUpKeyTime:J

.field private mVolumeUpKeyTriggered:Z

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

.field mWindowManager:Landroid/view/IWindowManager;

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

.line 7234
new-instance v0, Lcom/android/internal/policy/impl/PhoneWindowManager$35;

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

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

[COLOR="YellowGreen"] .line 8130
new-instance v0, Lcom/android/internal/policy/impl/PhoneWindowManager$SkipNext;

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

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

.line 8131
new-instance v0, Lcom/android/internal/policy/impl/PhoneWindowManager$SkipPrev;

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

iput-object v0, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mVolumeDownLongPress:Ljava/lang/Runnable;
[/COLOR]
.line 8132
return-void
.end method

.method handleVolumeKey(II)V
.registers 8
.parameter "stream"
.parameter "keycode"

.prologue
.line 5405
[COLOR="YellowGreen"] move-object/from16 v0, p0

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

if-nez v0, :cond_c[/COLOR]

invoke-static {}, Lcom/android/internal/policy/impl/PhoneWindowManager;->getAudioService()Landroid/media/IAudioService;

move-result-object v0

.line 5406
.local v0, audioService:Landroid/media/IAudioService;
if-nez v0, :cond_7

.line 5437
[COLOR="YellowGreen"] :cond_c
:goto_c[/COLOR]
return-void
[COLOR="Red"]:goto_6[/COLOR]

.line 5435
iget-object v2, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mBroadcastWakeLock:Landroid/os/PowerManager$WakeLock;

invoke-virtual {v2}, Landroid/os/PowerManager$WakeLock;->release()V

[COLOR="YellowGreen"]goto :goto_c[/COLOR]
[COLOR="Red"] goto :goto_6[/COLOR]

.line 5435
iget-object v2, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mBroadcastWakeLock:Landroid/os/PowerManager$WakeLock;

invoke-virtual {v2}, Landroid/os/PowerManager$WakeLock;->release()V

[COLOR="YellowGreen"]goto :goto_c[/COLOR]
[COLOR="Red"]goto :goto_6[/COLOR]

add this just above .method public hasNavigationBar()Z

[COLOR="YellowGreen"].method handleVolumeLongPress(I)V
.registers 6
.parameter "keycode"

.prologue
const/4 v1, 0x1

move-object/from16 v0, p0

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

const/4 v1, 0x0

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

const/16 v1, 0x18

if-ne p1, v1, :cond_19

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

.local v0, btnHandler:Ljava/lang/Runnable;
:goto_e
iget-object v1, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mHandler:Landroid/os/Handler;

invoke-static {}, Landroid/view/ViewConfiguration;->getTapTimeout()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

.end local v0 #btnHandler:Ljava/lang/Runnable;
:cond_19
iget-object v0, p0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mVolumeDownLongPress:Ljava/lang/Runnable;

.restart local v0 #btnHandler:Ljava/lang/Runnable;
goto :goto_e
.end method

.method handleVolumeLongPressAbort()V
.registers 3

.prologue
const/4 v1, 0x0

move-object/from16 v0, p0

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

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]

.line 5838
:cond_388
:goto_388
[COLOR="YellowGreen"]if-eqz v5, :cond_mir[/COLOR]
[COLOR="Red"]if-eqz v5, :cond_4f3[/COLOR]

.line 5926
.end local v6 #ex:Landroid/os/RemoteException;
:cond_4c0
move-object/from16 v0, p0

[COLOR="YellowGreen"] iget-boolean v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mScreenOnEarly:Z

if-nez v0, :cond_new

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

move-result v25

if-eqz v25, :cond_new

move-object/from16 v0, p0

move/from16 v14, v18

invoke-virtual {v0, v14}, Lcom/android/internal/policy/impl/PhoneWindowManager;->handleVolumeLongPress(I)V

:cond_new
move-object/from16 v0, p0
[/COLOR]
iget-object v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mSamsungVolumeControlThread:Lcom/android/internal/policy/impl/PhoneWindowManager$SamsungVolumeControlThread;

move-object/from16 v27, v0

if-nez v27, :cond_68

.line 5934
.end local v26 #telephonyService:Lcom/android/internal/telephony/ITelephony;
[COLOR="Red"]:cond_4f3[/COLOR]
[COLOR="YellowGreen"]:cond_mir
if-nez v5, :cond_ko

move-object/from16 v0, p0

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

if-eqz v0, :cond_ko

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

move-object/from16 v0, p0

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

if-nez v0, :cond_ko

move-object/from16 v0, p0

const/4 v3, 0x0

move/from16 v14, v18

invoke-virtual {v0, v3, v14}, Lcom/android/internal/policy/impl/PhoneWindowManager;->handleVolumeKey(II)V

:cond_ko[/COLOR]
move-object/from16 v0, p0

iget-object v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mSamsungVolumeControlThread:Lcom/android/internal/policy/impl/PhoneWindowManager$SamsungVolumeControlThread;

move-object/from16 v27, v0

if-eqz v27, :cond_68

add this method under .method sendCloseSystemWindows(Ljava/lang/String;)V

[COLOR="YellowGreen"].method protected sendMediaButtonEvent(I)V
.registers 15
.parameter "code"

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

move-result-wide v1

.local v1, eventtime:J
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

.local v11, downIntent:Landroid/content/Intent;
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

.local v0, downEvent:Landroid/view/KeyEvent;
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

.local v12, upIntent:Landroid/content/Intent;
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

.local v3, upEvent:Landroid/view/KeyEvent;
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

const/4 v8, 0x1

move-object/from16 v9, p0

iput-boolean v8, v9, Lcom/android/internal/policy/impl/PhoneWindowManager;->mIsVolumeAction:Z

return-void
.end method[/COLOR]

done.

now add the 2 subclasses attached and recompile.