[Guide] LockScreen torch mod

majdinj

Senior Member
Nov 25, 2006
980
3,437
0
AlAhsa
This mod will make you able to have torch flash light while you are on LockScreen by long pressing on the home button...!!!

Actual mod was done by RobbieHood and eybee1970

Needed tools:
1) Backsmali/Smali program from here
2) Notepad++ program from here
3) WinRAR or 7-zip archiver

The procedure:
- Backsmali android.policy.jar
- Navigate to classout/com/android/internal/policy/impl/ folder
- We will be working on 3 smali files:

KeyguardViewMediator$4.smali
- Search for "packed-switch" and add the blue line just above "return-void":
Code:
    .line 1255
    iget v2, p1, Landroid/os/Message;->what:I

    packed-switch v2, :pswitch_data_72

    .line 1298
    :goto_7
    [B][COLOR="Blue"]:pswitch_7[/COLOR][/B]
    return-void

    .line 1257
- Search for ":catchall" and add these lines above it:
Code:
    .line 1295
    monitor-exit v1

    goto :goto_[B][COLOR="Red"]7[/COLOR][/B]

[B][COLOR="Blue"]    :pswitch_6e
    iget-object v2, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator$4;->this$0:Lcom/android/internal/policy/impl/KeyguardViewMediator;

    iget v3, p1, Landroid/os/Message;->arg1:I

    if-eqz v3, :cond_majdi

    move v3, v0

    :goto_nj
    #calls: Lcom/android/internal/policy/impl/KeyguardViewMediator;->handleSetTorch(Z)V
    invoke-static {v2, v3}, Lcom/android/internal/policy/impl/KeyguardViewMediator;->access$2400(Lcom/android/internal/policy/impl/KeyguardViewMediator;Z)V

    goto :goto_[COLOR="Red"]7[/COLOR]

    :cond_majdi
    move v3, v1

    goto :goto_nj[/COLOR][/B]

    :catchall_7b
    move-exception v0

    monitor-exit v1
N.B: pay attention to number 7 in goto :goto_7 that could be different in your smali according to your ROM, make sure it is the same as the first one which is just above the new line ":pswitch_6e"
- Search for "nop" and another "nop" line bellow it (don't forget to leave empty line in between):
Code:
    .line 1255
    nop

    [B][COLOR="Blue"]nop[/COLOR][/B]
- Now go to the end of smali and add these switches above ".end packed-switch" line:
Code:
    :pswitch_data_72
    .packed-switch 0x1
        :pswitch_8
        :pswitch_10
        :pswitch_16
        :pswitch_1c
        :pswitch_22
        :pswitch_28
        :pswitch_2e
        :pswitch_38
        :pswitch_40
        :pswitch_4c
        :pswitch_52
        :pswitch_58
        :pswitch_64
        [B][COLOR="Blue"]:pswitch_7
        :pswitch_7
        :pswitch_7
        :pswitch_7
        :pswitch_7
        :pswitch_7
        :pswitch_6e[/COLOR][/B]
    .end packed-switch
.end method
N.B: if your smali has :pswitch_7 and :pswitch_6e by default, then use another :pswitch_value for :pswitch_7 and :pswitch_6e. If you do so, then don't forget to change :pswitch_7 and :pswitch_6e value in added codes from the beginning above as well
Save changes...

KeyguardViewMediator.smali
- Search for ".field private static final SET_HIDDEN:I = 0xc" and add this line bellow it (the blue one):
Code:
.field private static final SET_HIDDEN:I = 0xc

[B][COLOR="Blue"].field private static final SET_TORCH:I = 0x14[/COLOR][/B]

.field private static final SHOW:I = 0x2
- Search for ".field private mTelephonyManager:Landroid/telephony/TelephonyManager;" and add thses lines bellow it (the blue ones):
Code:
.field private mTelephonyManager:Landroid/telephony/TelephonyManager;

[B][COLOR="Blue"].field private mTorchEnabled:Z

.field private mTorchStateChanged:Z[/COLOR][/B]

.field private mUnlockSoundId:I
- Search for this method ".method public constructor <init>(Landroid/content/Context;Lcom/android/internal/policy/impl/PhoneWindowManager;Landroid/os/LocalPowerManager;)V" and add these lines (the blue ones):
Code:
.method public constructor <init>(Landroid/content/Context;Lcom/android/internal/policy/impl/PhoneWindowManager;Landroid/os/LocalPowerManager;)V
    .registers 15
    .parameter "context"
    .parameter "callback"
    .parameter "powerManager"

    .prologue
    .line 308
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 188
    [B][COLOR="Blue"]const/4 v0, 0x1

    iput-boolean v0, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mTorchEnabled:Z[/COLOR][/B]

    const/4 v0, 0x1
- Search for "const-string v0, "power"" and add these lines above it (the blue lines):
Code:
    .line 311
    iput-object p3, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mRealPowerManager:Landroid/os/LocalPowerManager;

    .line 312
    [B][COLOR="Blue"]const/4 v0, 0x0

    iput-boolean v0, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mTorchEnabled:Z

    const/4 v0, 0x0

    iput-boolean v0, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mTorchStateChanged:Z[/COLOR][/B]

    const-string v0, "power"
- Search for this method ".method static synthetic access$300(Lcom/android/internal/policy/impl/KeyguardViewMediator;I)V" and add this new method above it:
Code:
.method static synthetic access$2300(Lcom/android/internal/policy/impl/KeyguardViewMediator;Z)V
    .registers 2
    .parameter "x0"
    .parameter "x1"

    .prologue
    .line 110
    invoke-direct {p0, p1}, Lcom/android/internal/policy/impl/KeyguardViewMediator;->handleSetHidden(Z)V

    return-void
.end method

[B][COLOR="Blue"].method static synthetic access$[COLOR="Red"]2400[/COLOR](Lcom/android/internal/policy/impl/KeyguardViewMediator;Z)V
    .registers 2

    invoke-direct {p0, p1}, Lcom/android/internal/policy/impl/KeyguardViewMediator;->handleSetTorch(Z)V

    return-void
.end method[/COLOR][/B]

.method static synthetic access$300(Lcom/android/internal/policy/impl/KeyguardViewMediator;I)V
N.B: pay attention to $2400, that is increment to the method above it
- Search for the method ".method private handleHide()V" and add this line at end of this method (the blue one) just after "monitor-exit p0":
Code:
.method private handleHide()V
..
..
..
    .line 1449
    monitor-exit p0

    [B][COLOR="Blue"]invoke-direct {p0}, Lcom/android/internal/policy/impl/KeyguardViewMediator;->resetTorchState()V[/COLOR][/B]

    goto :goto_18

    :catchall_45
    move-exception v0

    monitor-exit p0
    :try_end_47
    .catchall {:try_start_1 .. :try_end_47} :catchall_45

    throw v0
.end method

.method private handleKeyguardDone(Z)V
- Search for the method ".method private handleNotifyScreenOff()V" and add this line (the blue one) just above "return-void":
Code:
.method private handleNotifyScreenOff()V
    .registers 3

    .prologue
    .line 1597
    monitor-enter p0

    .line 1598
    :try_start_1
    const-string v0, "KeyguardViewMediator"

    const-string v1, "handleNotifyScreenOff"

    invoke-static {v0, v1}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 1599
    iget-object v0, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mKeyguardViewManager:Lcom/android/internal/policy/impl/KeyguardViewManager;

    invoke-virtual {v0}, Lcom/android/internal/policy/impl/KeyguardViewManager;->onScreenTurnedOff()V

    .line 1600
    monitor-exit p0

    .line 1601
    [B][COLOR="Blue"]invoke-direct {p0}, Lcom/android/internal/policy/impl/KeyguardViewMediator;->resetTorchState()V[/COLOR][/B]

    return-void
- Search for the method ".method private handleSetHidden(Z)V" and add this line (the blue one) above the defined condition in the method:
Code:
.method private handleSetHidden(Z)V
    .registers 3
    .parameter "isHidden"

    .prologue
    .line 688
    monitor-enter p0

    .line 689
    :try_start_1
    iget-boolean v0, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mHidden:Z

    if-eq v0, p1, :cond_10

    .line 690
    iput-boolean p1, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mHidden:Z

    .line 691
    invoke-direct {p0}, Lcom/android/internal/policy/impl/KeyguardViewMediator;->updateActivityLockScreenState()V

    .line 692
    invoke-direct {p0}, Lcom/android/internal/policy/impl/KeyguardViewMediator;->adjustUserActivityLocked()V

    .line 693
    invoke-direct {p0}, Lcom/android/internal/policy/impl/KeyguardViewMediator;->adjustStatusBarLocked()V

    .line 695
    [B][COLOR="Blue"]invoke-direct {p0}, Lcom/android/internal/policy/impl/KeyguardViewMediator;->resetTorchState()V[/COLOR][/B]

    :cond_10
    monitor-exit p0
- Search for the method ".method private handleShow()V" and add the following new method above it:
Code:
[B][COLOR="Blue"].method private handleSetTorch(Z)V
    .registers 8

    const/4 v5, 0x0

    const/4 v4, 0x1

    :try_start_2
    iget-boolean v1, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mTorchStateChanged:Z

    if-nez v1, :cond_majdi

    iput-boolean v1, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mTorchEnabled:Z

    const/4 v1, 0x1

    iput-boolean v1, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mTorchStateChanged:Z

    :cond_[COLOR="Red"]b[/COLOR]
    :goto_[COLOR="Red"]b[/COLOR]
    return-void

    :cond_majdi
    iget-boolean v1, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mTorchEnabled:Z

    if-eq v1, p1, :cond_[COLOR="Red"]b[/COLOR]

    iput-boolean p1, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mTorchEnabled:Z

    new-instance v0, Landroid/content/Intent;

    const-string v1, "net.cactii.flash2.TOGGLE_FLASHLIGHT"

    invoke-direct {v0, v1}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

    const-string v1, "net.cactii.flash2.EXTRA_DISABLE_NOTIFICATION"

    const/4 v2, 0x1

    invoke-virtual {v0, v1, v2}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Z)Landroid/content/Intent;

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

    invoke-virtual {v1, v0}, Landroid/content/Context;->sendBroadcast(Landroid/content/Intent;)V
    :try_end_maj
    .catch Ljava/lang/Exception; {:try_start_2 .. :try_end_maj} :catch_jdi

    goto :goto_[COLOR="Red"]b[/COLOR]

    :catch_jdi
    move-exception v1

    goto :goto_[COLOR="Red"]b[/COLOR]
.end method[/COLOR][/B]

.method private handleShow()V
N.B: pay attention to :cond_b and :goto_b that could be differ according to your ROM where b should be the exact the same first condition in this method ".method public isGlanceViewVisible()Z"
Code:
.method public isGlanceViewVisible()Z
    .registers 2

    .prologue
    .line 666
    iget-object v0, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mKeyguardViewManager:Lcom/android/internal/policy/impl/KeyguardViewManager;

    if-eqz v0, [B][COLOR="Red"]:cond_b[/COLOR][/B]

    .line 667
- Search for method ".method private handleShow()V", then search bellow for "Landroid/os/PowerManager$WakeLock;->release()V" and add these lines bellow it (the blue ones):
Code:
.method private handleShow()V
    .registers 3

    .prologue
    .line 1400
    monitor-enter p0

    .line 1401
    :try_start_1
    const-string v0, "KeyguardViewMediator"
...
...
...
    invoke-virtual {v0}, Landroid/os/PowerManager$WakeLock;->release()V

    .line 1419
    [B][COLOR="Blue"]const/4 v0, 0x1

    iput-boolean v0, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mTorchStateChanged:Z[/COLOR][/B]

    monitor-exit p0
- Search for the method ".method private resetStateLocked()V" and add these lines (the blue ones) at the end before "return-void" line:
Code:
.method private resetStateLocked()V
    .registers 4
...
...
    invoke-virtual {v1, v0}, Landroid/os/Handler;->sendMessage(Landroid/os/Message;)Z
    
    .line 809
    [B][COLOR="Blue"]return-void
.end method

.method private resetTorchState()V
    .registers 2

    iget-boolean v0, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mTorchStateChanged:Z

    if-eqz v0, :cond_[COLOR="Red"]8[/COLOR]

    const/4 v0, 0x0

    invoke-direct {p0, v0}, Lcom/android/internal/policy/impl/KeyguardViewMediator;->handleSetTorch(Z)V

    :cond_[COLOR="Red"]8[/COLOR][/COLOR][/B]
    return-void
.end method
N.B: pay attention to :cond_8 that could be differ according to your ROM where 8 should be the exact the same first DEFINED condition in this method ".method private playSounds(Z)V"
Code:
.method private playSounds(Z)V
    .registers 10
    .parameter "locked"

    .prologue
    const/4 v5, 0x0

    const/4 v4, 0x1

    .line 1362
    iget-boolean v0, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mSuppressNextLockSound:Z

    if-eqz v0, :cond_9

    .line 1363
    iput-boolean v5, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mSuppressNextLockSound:Z

    .line 1385
    [B][COLOR="Red"]:cond_8[/COLOR][/B]
    :goto_8
    return-void
- Search for the method ".method public verifyUnlock(Landroid/view/WindowManagerPolicy$OnKeyguardExitResult;)V" and add this new method above it (the blue lines):
Code:
[B][COLOR="Blue"].method public setTorch(Z)V
    .registers 7

    const/16 v4, 0x14

    const/4 v3, 0x0

    iget-boolean v1, p0, Lcom/android/internal/policy/impl/KeyguardViewMediator;->mScreenOn:Z

    if-eqz v1, :cond_newa

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

    invoke-virtual {v1, v4}, Landroid/os/Handler;->removeMessages(I)V

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

    if-eqz p1, :cond_newb

    const/4 v2, 0x1

    :goto_[COLOR="Red"]11[/COLOR]
    invoke-virtual {v1, v4, v2, v3}, Landroid/os/Handler;->obtainMessage(III)Landroid/os/Message;

    move-result-object v0

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

    invoke-virtual {v1, v0}, Landroid/os/Handler;->sendMessage(Landroid/os/Message;)Z

    :cond_newa
    return-void

    :cond_newb
    move v2, v3

    goto :goto_[COLOR="Red"]11[/COLOR]
.end method[/COLOR][/B]

.method public verifyUnlock(Landroid/view/WindowManagerPolicy$OnKeyguardExitResult;)V
N.B: pay attention to :goto_11 that could be differ according to your ROM where 11 should be the exact the same goto action in this method ".method public isInputRestricted()Z"
Code:
.method public isInputRestricted()Z
    .registers 2
..
..
    [B][COLOR="Red"]:goto_11[/COLOR][/B]
    return v0

    :cond_12
    const/4 v0, 0x0

    goto :goto_11
.end method
Save changes..

PhoneWindowManager.smali

All changes here, will be in this method ".method public interceptKeyBeforeDispatching(Landroid/view/WindowManagerPolicy$WindowState;Landroid/view/KeyEvent;I)J"; so it is better to know from which part of smali this method starts and ends in order to not touch other methods!!

- First search for the method ".method public interceptKeyBeforeDispatching(Landroid/view/WindowManagerPolicy$WindowState;Landroid/view/KeyEvent;I)J",
- Search for "Lcom/android/internal/policy/impl/PhoneWindowManager;->mHomePressed:Z" and add these lines bellow it (the blue ones):
Code:
.method public interceptKeyBeforeDispatching(Landroid/view/WindowManagerPolicy$WindowState;Landroid/view/KeyEvent;I)J
    .registers 56
...
...
...
...
    .line 3364
    :cond_2ba
    if-nez v15, :cond_[B][COLOR="Red"]38c[/COLOR][/B]

    .line 3365
    move-object/from16 v0, p0

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

    [B][COLOR="Blue"]if-eqz v0, :cond_[COLOR="Red"]38c[/COLOR]

    const/16 v3, 0x0[/COLOR][/B]

    move/from16 v20, v0
N.B: pay attention to if-eqz v0, :cond_38c where the condition number 38c is the same as IF condition above it
- Search for this portion (you can search down for ".catch Landroid/os/RemoteException" to locate this portion) and add this line (the blue one):
Code:
    .line 3373
    invoke-interface/range {v44 .. v44}, Lcom/android/internal/statusbar/IStatusBarService;->cancelPreloadRecentApps()V
    :try_end_2dd
    .catch Landroid/os/RemoteException; {:try_start_2d4 .. :try_end_2dd} :catch_329

    .line 3381
    .end local v44           #statusbar:Lcom/android/internal/statusbar/IStatusBarService;
    :cond_2dd
    :goto_2dd
    const/4 v3, 0x0

    move-object/from16 v0, p0

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

    [B][COLOR="Blue"]invoke-virtual/range {p0 .. p0}, Lcom/android/internal/policy/impl/PhoneWindowManager;->launchHomeFromHotKey()V[/COLOR][/B]

    .line 3382
    if-nez v36, :cond_32c
- Search down for "Lcom/android/internal/policy/impl/PhoneWindowManager$HomeKeyDoubleClickConcept;->setHomeDownEventSent()V" and add this new code after defined condition:
Code:
    .line 3470
    move-object/from16 v0, p0

    iget-object v3, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mHomeKeyDoubleClickConcept:Lcom/android/internal/policy/impl/PhoneWindowManager$HomeKeyDoubleClickConcept;

    invoke-virtual {v3}, Lcom/android/internal/policy/impl/PhoneWindowManager$HomeKeyDoubleClickConcept;->setHomeDownEventSent()V

    .line 3473
    :cond_3a6
    [B][COLOR="Blue"]new-instance v0, Ljava/io/File;

    const-string v1, "/sdcard/Android"

    invoke-direct {v0, v1}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    invoke-virtual {v0}, Ljava/io/File;->exists()Z

    move-result v0

    if-eqz v0, :cond_majdi

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mKeyguardMediator:Lcom/android/internal/policy/impl/KeyguardViewMediator;

    move-object/from16 v3, v0

    invoke-virtual/range {v3 .. v3}, Lcom/android/internal/policy/impl/KeyguardViewMediator;->isShowingAndNotHidden()Z

    move-result v3

    if-eqz v3, :cond_majdi

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mKeyguardMediator:Lcom/android/internal/policy/impl/KeyguardViewMediator;

    move-object/from16 v3, v0

    move-object/from16 v0, v3

    move v1, v15

    invoke-virtual {v0, v1}, Lcom/android/internal/policy/impl/KeyguardViewMediator;->setTorch(Z)V

    rem-int/lit8 v3, v41, 0xf

    if-nez v3, :cond_majdi

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/android/internal/policy/impl/PhoneWindowManager;->mKeyguardMediator:Lcom/android/internal/policy/impl/KeyguardViewMediator;

    move-object/from16 v3, v0

    invoke-virtual/range {v3 .. v3}, Lcom/android/internal/policy/impl/KeyguardViewMediator;->pokeWakelock()V

    :cond_majdi[/COLOR][/B]
    const-wide/16 v3, 0x0

    goto/16 :goto_8f
- Search down for "const/16 v3, 0xbb" (v3 may differ according to ROM) and do the following editing:
before:
Code:
    .line 3635
    :cond_[B][COLOR="Red"]536[/COLOR][/B]   [B][COLOR="Green"]<-- we need to copy bellow condition over it[/COLOR][/B]
    const/16 v3, 0xbb

    move/from16 v0, v32

    if-ne v0, v3, :cond_[B][COLOR="Red"]56f[/COLOR][/B]   [B][COLOR="Green"]<-- we need to define new condition[/COLOR][/B]

    .line 3637
    move-object/from16 v0, p0
after:
Code:
    .line 3635
    :cond_[B][COLOR="Blue"]56f[/COLOR][/B]
    const/16 v3, 0xbb

    move/from16 v0, v32

    if-ne v0, v3, :cond_[B][COLOR="Blue"]nj[/COLOR][/B]

    .line 3637
    move-object/from16 v0, p0
- Now we need to redefine mentioned cond_56f (it could be differ according to ROM), search UP for ".catch Landroid/content/ActivityNotFoundException;" and modify the IF-NE condition bellow it:
before:
Code:
    .catch Landroid/content/ActivityNotFoundException; {:try_start_4fd .. :try_end_506} :catch_705

    .line 3839
    .end local v43           #shortcutIntent:Landroid/content/Intent;
    :cond_506
    :goto_506
    const-wide/16 v3, -0x1

    goto/16 :goto_8f

    .line 3621
    .end local v31           #kcm:Landroid/view/KeyCharacterMap;
    :cond_50a
    const/16 v3, 0x54

    move/from16 v0, v32

    if-ne v0, v3, [B][COLOR="Red"]:cond_536[/COLOR]   [COLOR="Green"]<-- redefine this condition[/COLOR][/B]

    .line 3622
    if-eqz v15, :cond_522
after:
Code:
    .catch Landroid/content/ActivityNotFoundException; {:try_start_4fd .. :try_end_506} :catch_705

    .line 3839
    .end local v43           #shortcutIntent:Landroid/content/Intent;
    :cond_506
    :goto_506
    const-wide/16 v3, -0x1

    goto/16 :goto_8f

    .line 3621
    .end local v31           #kcm:Landroid/view/KeyCharacterMap;
    :cond_50a
    const/16 v3, 0x54

    move/from16 v0, v32

    if-ne v0, v3, [B][COLOR="Blue"]:cond_56f[/COLOR][/B]

    .line 3622
    if-eqz v15, :cond_522
- Search down for "const/16 v3, 0xdb" (v3 may differ according to ROM) and change the condition value above it to the new condition from above mentioned edited code:
before:
Code:
    .line 3654
    .end local v16           #e:Landroid/os/RemoteException;
    [B][COLOR="Red"]:cond_56f[/COLOR]   [COLOR="Green"]<-- change it to the new condition[/COLOR][/B]
    const/16 v3, 0xdb

    move/from16 v0, v32

    if-ne v0, v3, :cond_5a4
after:
Code:
    .line 3654
    .end local v16           #e:Landroid/os/RemoteException;
    [B][COLOR="Blue"]:cond_nj[/COLOR][/B]
    const/16 v3, 0xdb

    move/from16 v0, v32

    if-ne v0, v3, :cond_5a4
Save changes...

Now backsmali classsout folder to get new classes.dex file. Now Open android.policy.jar by WinRAR or 7-zip and drag and drop the new classes.dex file inside it; then push it to your device framework folder and fix permissions to chmod 644.

Download Torch.apk from attachment bellow and push it to your device app folder and fix permissions to chmod 644 as well... and viola.. lockscreen the device and do long pressing on home button to have torch flash light..:laugh:

If you could manage to shorten this tutorial by omitting unnecessary steps, then share your experience here please
 

Attachments

Last edited:

djoni_gitara

Senior Member
Apr 9, 2012
608
293
0
Slavonski Brod - Zagreb
youtu.be
wow a lot of work, and of course big thanks
your tutorials provide a real value for comunity, I have learned a lot with these.

thanks once again and keep up a great work!

p.s. waiting for someone to qoute op lol :D

edit: why your tutorials are not sticky threads (wondering)

Sent from my GT-N7000 using xda app-developers app
 
Last edited:

sharkteef

Senior Member
Jul 2, 2010
319
81
0
my most loved app from robbie and miui roms. these however look like rocket science to me. therefore i'll leave this rocket science to the geniuses.
thank u. mcuh appreciatrd that everyone can now embed this wonderful feature into more roms.
 

davidwilson83

Retired Forum Moderator / Inactive Recognized Them
Apr 20, 2012
4,150
12,707
263
37
Perth
With the steps that you have done in this mod, does long pressing the home button turn the torch on until the screen locks so that you can take your finger off the home button, or do you need to keep your finger on the home button the whole time for the torch to stay on?
 

hara74

Senior Member
Feb 9, 2012
1,409
632
0
46
Herrstein
With the steps that you have done in this mod, does long pressing the home button turn the torch on until the screen locks so that you can take your finger off the home button, or do you need to keep your finger on the home button the whole time for the torch to stay on?
press and hold = light on
release button = light off

sent from my G-Note
 

davidwilson83

Retired Forum Moderator / Inactive Recognized Them
Apr 20, 2012
4,150
12,707
263
37
Perth
press and hold = light on
release button = light off

sent from my G-Note
Thanks for the reply.

Is there any way of implementing the mods done in this thread: [MOD] [GUIDE] [JB BLK1] LockScreen Torch with toggle?

This actually keeps the torch on even after you release the home button, but it will turn off when the screen turns off either by timing out or pressing the lock button.

I tried to port it to Galaxy S II but I am not a master dev like majdinj so I couldn't get it to work. I am not too worried about the toggle to turn it on and off, but keeping the torch on after letting go of the home button would be great.

Thanks in advance,

Dave
 

majdinj

Senior Member
Nov 25, 2006
980
3,437
0
AlAhsa
Thanks for the reply.

Is there any way of implementing the mods done in this thread: [MOD] [GUIDE] [JB BLK1] LockScreen Torch with toggle?

This actually keeps the torch on even after you release the home button, but it will turn off when the screen turns off either by timing out or pressing the lock button.

I tried to port it to Galaxy S II but I am not a master dev like majdinj so I couldn't get it to work. I am not too worried about the toggle to turn it on and off, but keeping the torch on after letting go of the home button would be great.

Thanks in advance,

Dave
You should pay attention to conditions buddy.. "You will not reach glory until you taste patience".. so try and try and try till you success :good:
 

davidwilson83

Retired Forum Moderator / Inactive Recognized Them
Apr 20, 2012
4,150
12,707
263
37
Perth
You should pay attention to conditions buddy.. "You will not reach glory until you taste patience".. so try and try and try till you success :good:
Thank you majdinj.

So what you're saying is, everywhere that I see a cond_ written in a method, I need to pay attention to where that cond is and what it does? Sorry, but smali code is like Swahili to me!

Thanks for your advice.

All the best,

Dave
 

bratboo

Senior Member
Dec 20, 2009
782
244
0
Hi!

I'm having problem with PhoneWindowManager.smali. Most of the .line #### is not present. Should I add them? This is for Pristine ROM v4.0.

Sample.
On ".method public interceptKeyBeforeDispatching(Landroid/view/WindowManagerPolicy$WindowState;Landroid/view/KeyEvent;I)J"
I should add a line under;
" .line 3365
move-object/from16 v0, p0

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

but this codes are not present;
" .line 3364
:cond_2ba
if-nez v15, :cond_38c

.line 3365
move-object/from16 v0, p0

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

and so on. Any help please? Thanks!
 
Last edited:

saryatto

New member
May 9, 2012
4
1
0
I was searching for this mod for a long time ago.. I just found it in TeamUnion ROM .. I like the ROM but after a while it drain my battery so fast.. so I decide to install one clean Stock ROM like ebyee's ROM and add some little mod like call recording and etc.. was searching for this mod but haven't ever could figure out how it works.. Thanks majdinj for posting it here :) :good:
 

rcheung28

Senior Member
Jul 27, 2012
199
14
0
Vancouver
Sorry for bumping this thread. I don't entirely understand the tutorial.
I believe I'm on an odex rom (where .apk and .odex are in /system/app), and I'm not sure if it'll work for me.

I've downloaded all the programs (backsmali/smali/notepad++), but I don't understand what the procedure says. What does it mean to backsmali android.policy.jar? Where do I get this android.policy.jar?
 

davidwilson83

Retired Forum Moderator / Inactive Recognized Them
Apr 20, 2012
4,150
12,707
263
37
Perth
Sorry for bumping this thread. I don't entirely understand the tutorial.
I believe I'm on an odex rom (where .apk and .odex are in /system/app), and I'm not sure if it'll work for me.

I've downloaded all the programs (backsmali/smali/notepad++), but I don't understand what the procedure says. What does it mean to backsmali android.policy.jar? Where do I get this android.policy.jar?
It's in /system/framework but you will also need android.policy.odex which you will need to deodex to be able to see the smali files.

There is a thread in Samsung Galaxy SII Original Android Development by sicopat here: http://forum.xda-developers.com/showthread.php?t=1208320 which states how to deodex a jar file.

You will also need all of the other jar files from /system/framework to be able to deodex it properly.

If you need a hand or some tips, just ask.

Sent from my GT-I9505 using Tapatalk 4 Beta
 
Last edited:
  • Like
Reactions: dsmas