[MOD][HOW-TO] Add Flashlight quick toggle [4.3|4.4]

Search This thread

oneleft.ak

Member
Aug 5, 2012
48
38
Anchorage
Cant get systemui.apk to compile with the flashlight smali provided by OP

I had no problems decompiling systemui.apk using apktool 2.0.0rc1. However, I noticed there was already a FlashLightQuickSettingButton.smali file in systemui. When I replaced the FlashLightQuickSettingButton.smali with the file provided by the OP I got the following error when trying to re-compile systemui:
Code:
I: Smaling...
systemui\smali\com\android\systemui\statusbar\policy\quicksetting\FlashLightQuic
kSettingButton.smali[22,4] Error for input '.parameter': Invalid directive
systemui\smali\com\android\systemui\statusbar\policy\quicksetting\FlashLightQuic
kSettingButton.smali[22,15] mismatched input '"context"' expecting END_METHOD_DI
RECTIVE
systemui\smali\com\android\systemui\statusbar\policy\quicksetting\FlashLightQuic
kSettingButton.smali[121,4] Error for input '.parameter': Invalid directive
systemui\smali\com\android\systemui\statusbar\policy\quicksetting\FlashLightQuic
kSettingButton.smali[121,15] mismatched input '"paramBoolean"' expecting END_MET
HOD_DIRECTIVE
Exception in thread "main" brut.androlib.AndrolibException: Could not smali file
: com/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButto
n.smali
        at brut.androlib.src.SmaliBuilder.buildFile(SmaliBuilder.java:72)
        at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:56)
        at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:41)
        at brut.androlib.Androlib.buildSourcesSmali(Androlib.java:342)
        at brut.androlib.Androlib.buildSources(Androlib.java:303)
        at brut.androlib.Androlib.build(Androlib.java:289)
        at brut.androlib.Androlib.build(Androlib.java:262)
        at brut.apktool.Main.cmdBuild(Main.java:236)
        at brut.apktool.Main.main(Main.java:88)

Here is the content of the original FlashLightQuickSettingButton.smali:

Code:
.class public Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;
.super Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingButton;
.source "FlashLightQuickSettingButton.java"

# interfaces
.implements Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingButton$Listener;


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton$FlashLightObserver;
    }
.end annotation


# static fields
.field private static final TW_TAG:Ljava/lang/String; = "STATUSBAR-FlashLightController"


# instance fields
.field private mContentResolver:Landroid/content/ContentResolver;

.field private mFlashLightObserver:Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton$FlashLightObserver;

.field private mState:Z


# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .locals 9
    .param p1, "context"    # Landroid/content/Context;

    .prologue
    const v1, 0x7f0b020f

    const/4 v8, 0x1

    const/4 v5, 0x0

    .line 49
    const/4 v0, 0x0

    sget-boolean v2, Lcom/android/systemui/statusbar/Feature;->mIsTablet:Z

    invoke-direct {p0, p1, v0, v2}, Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingButton;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;Z)V

    .line 50
    const v3, 0x7f02020f

    const v4, 0x7f020211

    move-object v0, p0

    move v2, v1

    move v6, v5

    move v7, v5

    invoke-virtual/range {v0 .. v7}, Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingButton;->initLayout(IIIIIII)V

    .line 57
    invoke-virtual {p0, p0}, Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingButton;->setListener(Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingButton$Listener;)V

    .line 58
    invoke-virtual {p1}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v0

    const-string v1, "flash_light_start"

    invoke-static {v0, v1, v5}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

    move-result v0

    if-eqz v0, :cond_0

    move v5, v8

    :cond_0
    iput-boolean v5, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;->mState:Z

    .line 59
    iget-boolean v0, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;->mState:Z

    if-eqz v0, :cond_1

    :goto_0
    invoke-virtual {p0, v8}, Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingButton;->setActivateStatus(I)V

    .line 60
    invoke-virtual {p1}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v0

    iput-object v0, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;->mContentResolver:Landroid/content/ContentResolver;

    .line 61
    new-instance v0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton$FlashLightObserver;

    invoke-direct {v0, p0}, Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton$FlashLightObserver;-><init>(Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;)V

    iput-object v0, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;->mFlashLightObserver:Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton$FlashLightObserver;

    .line 62
    return-void

    .line 59
    :cond_1
    const/4 v8, 0x2

    goto :goto_0
.end method

.method static synthetic access$000(Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;)Z
    .locals 1
    .param p0, "x0"    # Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;

    .prologue
    .line 40
    iget-boolean v0, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;->mState:Z

    return v0
.end method

.method static synthetic access$002(Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;Z)Z
    .locals 0
    .param p0, "x0"    # Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;
    .param p1, "x1"    # Z

    .prologue
    .line 40
    iput-boolean p1, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;->mState:Z

    return p1
.end method

.method static synthetic access$100(Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;)Landroid/content/ContentResolver;
    .locals 1
    .param p0, "x0"    # Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;

    .prologue
    .line 40
    iget-object v0, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;->mContentResolver:Landroid/content/ContentResolver;

    return-object v0
.end method


# virtual methods
.method public deinit()V
    .locals 2

    .prologue
    .line 70
    iget-object v0, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;->mContentResolver:Landroid/content/ContentResolver;

    iget-object v1, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;->mFlashLightObserver:Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton$FlashLightObserver;

    invoke-virtual {v0, v1}, Landroid/content/ContentResolver;->unregisterContentObserver(Landroid/database/ContentObserver;)V

    .line 71
    return-void
.end method

.method public init()V
    .locals 5

    .prologue
    .line 65
    iget-object v0, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;->mContentResolver:Landroid/content/ContentResolver;

    const-string v1, "flash_light_start"

    invoke-static {v1}, Landroid/provider/Settings$System;->getUriFor(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v1

    const/4 v2, 0x0

    iget-object v3, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;->mFlashLightObserver:Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton$FlashLightObserver;

    const/4 v4, -0x2

    invoke-virtual {v0, v1, v2, v3, v4}, Landroid/content/ContentResolver;->registerContentObserver(Landroid/net/Uri;ZLandroid/database/ContentObserver;I)V

    .line 67
    return-void
.end method

.method public onClick(Z)V
    .locals 3
    .param p1, "state"    # Z

    .prologue
    .line 74
    const-string v0, "STATUSBAR-FlashLightController"

    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v2, "onClick state="

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(Z)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

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

    .line 75
    const/4 v0, 0x1

    if-ne p1, v0, :cond_0

    .line 77
    const-string v0, "com.android.settings"

    const-string v1, "com.android.settings.flashlight.FlashLightDisplay"

    invoke-virtual {p0, v0, v1}, Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingButton;->callActivity(Ljava/lang/String;Ljava/lang/String;)V

    .line 83
    :goto_0
    return-void

    .line 81
    :cond_0
    iget-object v0, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;->mContentResolver:Landroid/content/ContentResolver;

    const-string v1, "flash_light_start"

    const/4 v2, 0x0

    invoke-static {v0, v1, v2}, Landroid/provider/Settings$System;->putInt(Landroid/content/ContentResolver;Ljava/lang/String;I)Z

    goto :goto_0
.end method

.method public onLongClick()V
    .locals 0

    .prologue
    .line 88
    return-void
.end method

Here is the content of the FlashLightQuickSettingButton.smali from the zip in OP that is throwing the error on compile:
Code:
.class public Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;
.super Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingButton;
.source "FlashlightQuickSettingButton.java"

# interfaces
.implements Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingButton$Listener;


# static fields
.field private static final TW_TAG:Ljava/lang/String; = "STATUSBAR-FlashlightQuickSettingButton"


# instance fields
.field private mContext:Landroid/content/Context;

.field private mFlashlight:I


# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .locals 7
    .parameter "context"

    .prologue
    const/4 v4, 0x0

    .line 16
    const/4 v0, 0x0

    invoke-direct {p0, p1, v0, v4}, Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingButton;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;Z)V

    .line 17
    invoke-virtual {p1}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v0

    const-string v1, "quickpanel_flashlight_text"

    const-string v2, "string"

    const-string v3, "com.android.systemui"

    invoke-virtual {v0, v1, v2, v3}, Landroid/content/res/Resources;->getIdentifier(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I

    move-result v1

    .line 18
    invoke-virtual {p1}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v0

    const-string v2, "tw_quick_panel_icon_flashlight_on"

    const-string v3, "drawable"

    const-string v5, "com.android.systemui"

    invoke-virtual {v0, v2, v3, v5}, Landroid/content/res/Resources;->getIdentifier(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I

    move-result v2

    .line 19
    invoke-virtual {p1}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v0

    const-string v3, "tw_quick_panel_icon_flashlight_off"

    const-string v5, "drawable"

    const-string v6, "com.android.systemui"

    invoke-virtual {v0, v3, v5, v6}, Landroid/content/res/Resources;->getIdentifier(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I

    move-result v3

    move-object v0, p0

    move v5, v4

    move v6, v4

    .line 17
    invoke-virtual/range {v0 .. v6}, Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;->initLayout(IIIIII)V

    .line 23
    iput-object p1, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;->mContext:Landroid/content/Context;

    .line 24
    invoke-virtual {p0, p0}, Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;->setListener(Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingButton$Listener;)V

    .line 25
    return-void
.end method


# virtual methods
.method public deinit()V
    .locals 0

    .prologue
    .line 27
    return-void
.end method

.method public init()V
    .locals 1

    .prologue
    .line 30
    const/4 v0, 0x2

    invoke-virtual {p0, v0}, Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;->setActivateStatus(I)V

    .line 31
    return-void
.end method

.method public onClick(Z)V
    .locals 5
    .parameter "paramBoolean"

    .prologue
    .line 34
    const/4 v2, 0x0

    .line 35
    .local v2, localIntent:Landroid/content/Intent;
    const/4 v1, 0x0

    .line 37
    .local v1, bc:Ljava/lang/String;
    const/4 v0, 0x2

    .line 39
    .local v0, activateStatus:I
    iget v3, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;->mFlashlight:I

    add-int/lit8 v3, v3, 0x1

    iput v3, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;->mFlashlight:I

    .line 41
    iget v3, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;->mFlashlight:I

    rem-int/lit8 v3, v3, 0x2

    iput v3, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;->mFlashlight:I

    .line 43
    iget v3, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;->mFlashlight:I

    const/4 v4, 0x1

    if-ne v3, v4, :cond_0

    .line 44
    const-string v1, "com.sec.samsung.torchwidget.torch_on_3"

    .line 45
    const/4 v0, 0x1

    .line 50
    :goto_0
    invoke-virtual {p0, v0}, Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;->setActivateStatus(I)V

    .line 52
    new-instance v2, Landroid/content/Intent;

    .end local v2           #localIntent:Landroid/content/Intent;
    invoke-direct {v2, v1}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

    .line 54
    .restart local v2       #localIntent:Landroid/content/Intent;
    iget-object v3, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;->mContext:Landroid/content/Context;

    invoke-virtual {v3, v2}, Landroid/content/Context;->sendBroadcast(Landroid/content/Intent;)V

    .line 55
    return-void

    .line 47
    :cond_0
    const-string v1, "com.sec.samsung.torchwidget.torch_off"

    goto :goto_0
.end method

.method public onLongClick()V
    .locals 0

    .prologue
    .line 57
    return-void
.end method

I am compiling for Stock Deodexed i747 4.4.2 NE4
Any help getting this to compile would be greatly appreciated-
 

oneleft.ak

Member
Aug 5, 2012
48
38
Anchorage
I had no problems decompiling systemui.apk using apktool 2.0.0rc1. However, I noticed there was already a FlashLightQuickSettingButton.smali file in systemui. When I replaced the FlashLightQuickSettingButton.smali with the file provided by the OP I got the following error when trying to re-compile systemui:
Code:
I: Smaling...
systemui\smali\com\android\systemui\statusbar\policy\quicksetting\FlashLightQuic
kSettingButton.smali[22,4] Error for input '.parameter': Invalid directive
systemui\smali\com\android\systemui\statusbar\policy\quicksetting\FlashLightQuic
kSettingButton.smali[22,15] mismatched input '"context"' expecting END_METHOD_DI
RECTIVE
systemui\smali\com\android\systemui\statusbar\policy\quicksetting\FlashLightQuic
kSettingButton.smali[121,4] Error for input '.parameter': Invalid directive
systemui\smali\com\android\systemui\statusbar\policy\quicksetting\FlashLightQuic
kSettingButton.smali[121,15] mismatched input '"paramBoolean"' expecting END_MET
HOD_DIRECTIVE
Exception in thread "main" brut.androlib.AndrolibException: Could not smali file
: com/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButto
n.smali
        at brut.androlib.src.SmaliBuilder.buildFile(SmaliBuilder.java:72)
        at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:56)
        at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:41)
        at brut.androlib.Androlib.buildSourcesSmali(Androlib.java:342)
        at brut.androlib.Androlib.buildSources(Androlib.java:303)
        at brut.androlib.Androlib.build(Androlib.java:289)
        at brut.androlib.Androlib.build(Androlib.java:262)
        at brut.apktool.Main.cmdBuild(Main.java:236)
        at brut.apktool.Main.main(Main.java:88)

Here is the content of the original FlashLightQuickSettingButton.smali:

Code:
.class public Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;
.super Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingButton;
.source "FlashLightQuickSettingButton.java"

# interfaces
.implements Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingButton$Listener;


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton$FlashLightObserver;
    }
.end annotation


# static fields
.field private static final TW_TAG:Ljava/lang/String; = "STATUSBAR-FlashLightController"


# instance fields
.field private mContentResolver:Landroid/content/ContentResolver;

.field private mFlashLightObserver:Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton$FlashLightObserver;

.field private mState:Z


# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .locals 9
    .param p1, "context"    # Landroid/content/Context;

    .prologue
    const v1, 0x7f0b020f

    const/4 v8, 0x1

    const/4 v5, 0x0

    .line 49
    const/4 v0, 0x0

    sget-boolean v2, Lcom/android/systemui/statusbar/Feature;->mIsTablet:Z

    invoke-direct {p0, p1, v0, v2}, Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingButton;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;Z)V

    .line 50
    const v3, 0x7f02020f

    const v4, 0x7f020211

    move-object v0, p0

    move v2, v1

    move v6, v5

    move v7, v5

    invoke-virtual/range {v0 .. v7}, Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingButton;->initLayout(IIIIIII)V

    .line 57
    invoke-virtual {p0, p0}, Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingButton;->setListener(Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingButton$Listener;)V

    .line 58
    invoke-virtual {p1}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v0

    const-string v1, "flash_light_start"

    invoke-static {v0, v1, v5}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

    move-result v0

    if-eqz v0, :cond_0

    move v5, v8

    :cond_0
    iput-boolean v5, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;->mState:Z

    .line 59
    iget-boolean v0, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;->mState:Z

    if-eqz v0, :cond_1

    :goto_0
    invoke-virtual {p0, v8}, Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingButton;->setActivateStatus(I)V

    .line 60
    invoke-virtual {p1}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v0

    iput-object v0, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;->mContentResolver:Landroid/content/ContentResolver;

    .line 61
    new-instance v0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton$FlashLightObserver;

    invoke-direct {v0, p0}, Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton$FlashLightObserver;-><init>(Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;)V

    iput-object v0, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;->mFlashLightObserver:Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton$FlashLightObserver;

    .line 62
    return-void

    .line 59
    :cond_1
    const/4 v8, 0x2

    goto :goto_0
.end method

.method static synthetic access$000(Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;)Z
    .locals 1
    .param p0, "x0"    # Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;

    .prologue
    .line 40
    iget-boolean v0, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;->mState:Z

    return v0
.end method

.method static synthetic access$002(Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;Z)Z
    .locals 0
    .param p0, "x0"    # Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;
    .param p1, "x1"    # Z

    .prologue
    .line 40
    iput-boolean p1, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;->mState:Z

    return p1
.end method

.method static synthetic access$100(Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;)Landroid/content/ContentResolver;
    .locals 1
    .param p0, "x0"    # Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;

    .prologue
    .line 40
    iget-object v0, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;->mContentResolver:Landroid/content/ContentResolver;

    return-object v0
.end method


# virtual methods
.method public deinit()V
    .locals 2

    .prologue
    .line 70
    iget-object v0, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;->mContentResolver:Landroid/content/ContentResolver;

    iget-object v1, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;->mFlashLightObserver:Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton$FlashLightObserver;

    invoke-virtual {v0, v1}, Landroid/content/ContentResolver;->unregisterContentObserver(Landroid/database/ContentObserver;)V

    .line 71
    return-void
.end method

.method public init()V
    .locals 5

    .prologue
    .line 65
    iget-object v0, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;->mContentResolver:Landroid/content/ContentResolver;

    const-string v1, "flash_light_start"

    invoke-static {v1}, Landroid/provider/Settings$System;->getUriFor(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v1

    const/4 v2, 0x0

    iget-object v3, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;->mFlashLightObserver:Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton$FlashLightObserver;

    const/4 v4, -0x2

    invoke-virtual {v0, v1, v2, v3, v4}, Landroid/content/ContentResolver;->registerContentObserver(Landroid/net/Uri;ZLandroid/database/ContentObserver;I)V

    .line 67
    return-void
.end method

.method public onClick(Z)V
    .locals 3
    .param p1, "state"    # Z

    .prologue
    .line 74
    const-string v0, "STATUSBAR-FlashLightController"

    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v2, "onClick state="

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(Z)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

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

    .line 75
    const/4 v0, 0x1

    if-ne p1, v0, :cond_0

    .line 77
    const-string v0, "com.android.settings"

    const-string v1, "com.android.settings.flashlight.FlashLightDisplay"

    invoke-virtual {p0, v0, v1}, Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingButton;->callActivity(Ljava/lang/String;Ljava/lang/String;)V

    .line 83
    :goto_0
    return-void

    .line 81
    :cond_0
    iget-object v0, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashLightQuickSettingButton;->mContentResolver:Landroid/content/ContentResolver;

    const-string v1, "flash_light_start"

    const/4 v2, 0x0

    invoke-static {v0, v1, v2}, Landroid/provider/Settings$System;->putInt(Landroid/content/ContentResolver;Ljava/lang/String;I)Z

    goto :goto_0
.end method

.method public onLongClick()V
    .locals 0

    .prologue
    .line 88
    return-void
.end method

Here is the content of the FlashLightQuickSettingButton.smali from the zip in OP that is throwing the error on compile:
Code:
.class public Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;
.super Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingButton;
.source "FlashlightQuickSettingButton.java"

# interfaces
.implements Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingButton$Listener;


# static fields
.field private static final TW_TAG:Ljava/lang/String; = "STATUSBAR-FlashlightQuickSettingButton"


# instance fields
.field private mContext:Landroid/content/Context;

.field private mFlashlight:I


# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .locals 7
    .parameter "context"

    .prologue
    const/4 v4, 0x0

    .line 16
    const/4 v0, 0x0

    invoke-direct {p0, p1, v0, v4}, Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingButton;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;Z)V

    .line 17
    invoke-virtual {p1}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v0

    const-string v1, "quickpanel_flashlight_text"

    const-string v2, "string"

    const-string v3, "com.android.systemui"

    invoke-virtual {v0, v1, v2, v3}, Landroid/content/res/Resources;->getIdentifier(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I

    move-result v1

    .line 18
    invoke-virtual {p1}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v0

    const-string v2, "tw_quick_panel_icon_flashlight_on"

    const-string v3, "drawable"

    const-string v5, "com.android.systemui"

    invoke-virtual {v0, v2, v3, v5}, Landroid/content/res/Resources;->getIdentifier(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I

    move-result v2

    .line 19
    invoke-virtual {p1}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v0

    const-string v3, "tw_quick_panel_icon_flashlight_off"

    const-string v5, "drawable"

    const-string v6, "com.android.systemui"

    invoke-virtual {v0, v3, v5, v6}, Landroid/content/res/Resources;->getIdentifier(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I

    move-result v3

    move-object v0, p0

    move v5, v4

    move v6, v4

    .line 17
    invoke-virtual/range {v0 .. v6}, Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;->initLayout(IIIIII)V

    .line 23
    iput-object p1, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;->mContext:Landroid/content/Context;

    .line 24
    invoke-virtual {p0, p0}, Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;->setListener(Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingButton$Listener;)V

    .line 25
    return-void
.end method


# virtual methods
.method public deinit()V
    .locals 0

    .prologue
    .line 27
    return-void
.end method

.method public init()V
    .locals 1

    .prologue
    .line 30
    const/4 v0, 0x2

    invoke-virtual {p0, v0}, Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;->setActivateStatus(I)V

    .line 31
    return-void
.end method

.method public onClick(Z)V
    .locals 5
    .parameter "paramBoolean"

    .prologue
    .line 34
    const/4 v2, 0x0

    .line 35
    .local v2, localIntent:Landroid/content/Intent;
    const/4 v1, 0x0

    .line 37
    .local v1, bc:Ljava/lang/String;
    const/4 v0, 0x2

    .line 39
    .local v0, activateStatus:I
    iget v3, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;->mFlashlight:I

    add-int/lit8 v3, v3, 0x1

    iput v3, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;->mFlashlight:I

    .line 41
    iget v3, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;->mFlashlight:I

    rem-int/lit8 v3, v3, 0x2

    iput v3, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;->mFlashlight:I

    .line 43
    iget v3, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;->mFlashlight:I

    const/4 v4, 0x1

    if-ne v3, v4, :cond_0

    .line 44
    const-string v1, "com.sec.samsung.torchwidget.torch_on_3"

    .line 45
    const/4 v0, 0x1

    .line 50
    :goto_0
    invoke-virtual {p0, v0}, Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;->setActivateStatus(I)V

    .line 52
    new-instance v2, Landroid/content/Intent;

    .end local v2           #localIntent:Landroid/content/Intent;
    invoke-direct {v2, v1}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

    .line 54
    .restart local v2       #localIntent:Landroid/content/Intent;
    iget-object v3, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;->mContext:Landroid/content/Context;

    invoke-virtual {v3, v2}, Landroid/content/Context;->sendBroadcast(Landroid/content/Intent;)V

    .line 55
    return-void

    .line 47
    :cond_0
    const-string v1, "com.sec.samsung.torchwidget.torch_off"

    goto :goto_0
.end method

.method public onLongClick()V
    .locals 0

    .prologue
    .line 57
    return-void
.end method

I am compiling for Stock Deodexed i747 4.4.2 NE4
Any help getting this to compile would be greatly appreciated-

EDIT- Looks like the answer is in post #289. Had to change the smali for apktool2
 
  • Like
Reactions: DarkAngel

sudhamana

Senior Member
Jan 7, 2012
270
75
chennai
But i got two different images in system ui and edit notification panel.
Please see the attachment.
Can you give any clue to solve this issue?
 

Attachments

  • Screenshot_2014-10-03-23-17-54.png
    Screenshot_2014-10-03-23-17-54.png
    212.6 KB · Views: 904
  • Screenshot_2014-10-03-23-18-17.png
    Screenshot_2014-10-03-23-18-17.png
    232.4 KB · Views: 889

tdunham

Inactive Recognized Contributor
Jun 21, 2008
13,686
36,465
TampaBay
But i got two different images in system ui and edit notification panel.
Please see the attachment.
Can you give any clue to solve this issue?
I think you need the S5 style flashlight files. It was posted way back in the thread so I have no idea who posted it but try looking through the attached file.
And I 'think' I had an issue with the icons being slightly too large even though they were the same size resolution as the rest so I had to downsize one or more of them a little at a time until I was happy with the way they displayed.
 

Attachments

  • Flashlight_Files_S5.zip
    10.2 KB · Views: 275

edwardsiow

Senior Member
Oct 1, 2013
427
79
Last edited:

tdunham

Inactive Recognized Contributor
Jun 21, 2008
13,686
36,465
TampaBay
Hi

I have done everything stated in OP but my settings force closed when I try to edit quick panel settings...

Is it because I changed the string name of notification_panel_flashlight to Torch? I MUST use the name Flashlight?

any clue? please help me....

Here are the file (I already changed the string name back to Flashlight):
https://docs.google.com/uc?export=download&confirm=jNub&id=0B0NFJR3xcB2jNFV0S1VsNVRTQlk

Dear @tdunham, do you know why?
In strings.xml, you only changed this (see below)? The string name notification_panel_flashlight must stay the same unless you also change it in smali.

Code:
<string name="notification_panel_flashlight">[COLOR="Red"]Torch[/COLOR]</string>


---------- Post added at 02:45 PM ---------- Previous post was at 02:37 PM ----------

Also Edward, you have this working 100% without making that change too?
 
So I searched this thread and a couple similar ones, is there any way to adjust the brightness that this toggle activates? Alternatively, I converted the Torch app from the play store into a system app because it gives a brighter light than the system default and other third-party apps. Would there be a way to make this toggle use the Torch app instead? Basically I just want a way for this flashlight to be brighter, any ideas?
 
Aug 12, 2010
46
6
I'm having an issue where I can get it to show up on the available buttons but will not show up on the notification. Any ideas? When I drag the available button to the notification it looks like it is there but it is not. Updated with some screenshots if it helps.
 
Last edited:

PineSmokes

Member
Aug 29, 2014
38
7
Note 3 (NK3 4.4.2) | I'm SOO close I can almost taste it XD

I worked all through the night figures hah :) I managed to get the entire mod of the SystemUI.apk and SecSettings.apk and my phone didn't hand on the boot screen or have any sort of issues after restarting! YAY! But wait, I still have no flashlight toggle... ?? Yes I did the "/system/csc/feature.xml" edit with a reboot and still nothing, hmmm. I pulled my SystemUI.apk and SecSettings.apk to decompile and check them out. They look legit, they have all the needed mods to my knowledge. Could someone check them out for me or tell me what I'm doing wrong? The flashable zip to enable the toggles isn't on the home page anymore it's broken so the features.xml is the only way I can do it.

EDIT: Additional information, I purchased the SQL Editor and used it to add ";Flashlight" to the end of the needed 3 lines and still nothing. I'm using the .smali file from post 283 and the edits from post 289, if I try the S5 files from post 404 I get errors recompiling so that's probably just the wrong file. I have no errors with .smali 283, all the public id's are correct and everything.

These were too big to attach on XDA so Dropbox it is :)

MODS
SystemUI.apk (Modded):
https://www.dropbox.com/s/swzz46c2adt1kyb/SystemUI.apk?dl=0
SystemUI (Decompiled):
https://www.dropbox.com/s/rrft93dcjdou20j/SystemUI-Decompiled.zip?dl=0
SecSettings.apk (Modded):
https://www.dropbox.com/s/fkm43yfdjkfponw/SecSettings.apk?dl=0
SecSettings-Decompiled.zip (Modded):
https://www.dropbox.com/s/mu2hg3kgvd55fqx/SecSettings-Decompiled.zip?dl=0

ORIGINALS:
SystemUI (Odex) (NK3 4.4.2):
https://www.dropbox.com/s/vw7raajgs9go9sa/SystemUI (Odex).zip?dl=0
SystemUI (Deodexed) (NK3 4.4.2):
https://www.dropbox.com/s/abn6p0y6nt2hzjl/SystemUI-Original.apk?dl=0
SecSettings (Odex) (NK3 4.4.2):
https://www.dropbox.com/s/4d08zw0hg1286o2/SecSettings (Odex).zip?dl=0
SecSettings (Deodexed) (NK3 4.4.2):
https://www.dropbox.com/s/syanbhjdlbaicpk/SecSettings-Original.apk?dl=0

Stock.tar.md5 Extracting Tip
For anyone who doesn't know the only way I was able to get files out of my "system.img.ext4" was to first extract it from my stock.tar.md5 with 7-Zip/WinRar, then convert it by dragging it into sgs2toext4. Sgs2toext4 outputs a file "system.img.ext4.img" which you mount with ext2explore. From there you browse through the files and save whatever files you would like to work on. :cool:
 
Last edited:

PineSmokes

Member
Aug 29, 2014
38
7
Hmmm

After I do any modification inside the SystemUI.apk, recompile and push it onto my phone, nothing changes. I've edited the color of some of the graphics to see if I could even notice a minor change and nothing. Am I missing something? This is probably the reason the mod isn't working after I complete it and replace the SystemUI.apk in the /system/priv-app/ folder

Confused :cool:
 

tx_dbs_tx

Senior Member
Jan 19, 2009
2,025
8,718
Texas, USA
Has anyone been able to use this on the Galaxy S5 on Lollipop?

I'm doing it now. i'll let you all know when I get it working. I'm on the Note 4 but it should be the same. I've done this mod several times already.


Edit: Upon initially going over of the flashlight smali and lollipop smali, there will need to be some changes made to FlashlightQuickSettingButton.smali which I'm doing now. Java sources are different in Lollipop so this is the biggest reason for fails on Lollipop right now. It still may not work and may need to be completely rewritten. I'll find out soon enough.
 
Last edited:

josephpatrick

Senior Member
Jan 24, 2012
1,213
237
Bangalore
Notification Panel settings FC

Hi, I got the systemui mod working and have the flashlight toggle in the notification panel, however it does not show up under 'Notification Panel' under 'Settings'. If i use the reset button it removes the toggle, because it does not show up under settings, i cannot really move it around.

Modded secsettings as per OP however Settings crashes/FC when i click on option 'Notification Panel'.
 

Wuby986

Senior Member
Oct 18, 2013
2,144
2,440
Hi, I got the systemui mod working and have the flashlight toggle in the notification panel, however it does not show up under 'Notification Panel' under 'Settings'. If i use the reset button it removes the toggle, because it does not show up under settings, i cannot really move it around.



Modded secsettings as per OP however Settings crashes/FC when i click on option 'Notification Panel'.


of course you need to mod differently if it fc.. you are not supposed to apply code, without understanding.. however you can set it in database and it should appear in both section
 

josephpatrick

Senior Member
Jan 24, 2012
1,213
237
Bangalore
of course you need to mod differently if it fc.. you are not supposed to apply code, without understanding.. however you can set it in database and it should appear in both section

The systemui code is more complicated and I was able to get it working, the settings apk does not have hex code replacement editing and so it is weird it is FC'ing.
 

Wuby986

Senior Member
Oct 18, 2013
2,144
2,440
The systemui code is more complicated and I was able to get it working, the settings apk does not have hex code replacement editing and so it is weird it is FC'ing.


there could be several reasons for it.. logcat can help you get where the problem is.. or as i said above you can leave stock and use db to set the toggle.. you should have already the hidden files for it in settings so enabling in db should be enough to show in both places
 

erikalin

Senior Member
Sep 4, 2012
1,062
2,906
Twin Cities, Mini Soda USA
Hi @tdunham @CNexus, I'm using s3 neo with deodex rom and It does not appear flashlight in the quick panel. But it seems in the edit panel. Any idea? Thanks.

:confused: This thread is more than two years old. I am only replying here because for some reason you have now sent me a PM about this mod. It is not my mod. I don't know why you are asking me for help with your decompiled files. And because this is a really old thread, you won't get a reply here either. I have to post on this thread to reply TO YOU because even though you sent me a PM about this other person's work, your profile is set to not receive PMs, so I couldn't reply to tell you any of this, lol.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 98
    Hey guys! Today I'll be showing you how to add the Flashlight toggle to your quick toggles:

    i4gop5j.png

    UPDATE: Once you have completed the mod below, you (and your users) can enable the flashlight toggle by flashing the zip HERE. It uses busybox and an included binary to add the toggle to notification_panel_active_app_list, so it will work with all devices that this mod applies to. Again, feel free to share this but give credits where due!

    Items you will need
    1. SystemUI.apk from the rom you are modding
    2. SecSettings.apk from the rom you are modding
    3. Notepad++ or another text editor of your choice (NOT regular Notepad, it messes up the encoding)
    4. apktool or baksmali+smali or VTS, etc


    Now before we get started, download the attachment with the files you will need for this mod (attached to this post...make sure you grab the right version for the system you are modifying)




    Now lets get started!


    [size=+1]Step 1: Modding SystemUI.apk[/size]
    1. Decompile SystemUI.apk and navigate to com/android/systemui/statusbar/policy/quicksetting in your file browser
    2. Copy and paste FlashlightQuickSettingButton.smali from inside the zip you downloaded (flashlight_files.zip/SystemUI/FlashlightQuickSettingButton.smali) into this folder
    3. Navigate to SystemUI/res/drawable-xhdpi (or SystemUI/res/drawable-xxhdpi depending on your device)
    4. Copy and paste the two pngs (tw_quick_panel_icon_flashlight_off.png and tw_quick_panel_icon_flashlight_on.png) from the SystemUI folder of the attachment into the decompiled drawable folder you opened above
    5. Now navigate to SystemUI/res/values and open the strings.xml with your text editor
    6. Search for "quickpanel_flashlight_text". If it does not exist anywhere in the file, add this to the bottom of your strings.xml file:
      PHP:
      <string name="quickpanel_flashlight_text">Flashlight</string>
    7. That's it or SystemUI! Now recompile SystemUI.apk and move on to step 2. At this point, the toggle will show up in the full toggles view (when you add ";Flashlight" to the CscFeature... or to the notification_panel_active_app_list in /data/data/com.android.providers.settings/settings.db) in the status bar, but Settings will FC if you try to go into edit mode/rearrange toggles mode
    74
    [SIZE=+1]Step 2: Modding SecSettings.apk[/SIZE]
    1. Decompile SecSettings and navigate to com/android/settings
    2. Open NotificationPanelMenu.smali and search for the method ".method private makeConvertPanelName"
    3. Make sure that the following lines are present somewhere in the makeConvertPanelName method. Notice that they are NOT the same, but indeed very similar.
      Code:
      iget-object v0, p0, Lcom/android/settings/NotificationPanelMenu;->mConvertPanelItemstring:Ljava/util/HashMap;
      const-string v1, "Flashlight"
      const-string v2, "notification_panel_flashlight"
      invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
      
      [B]AND[/B]
      
      iget-object v0, p0, Lcom/android/settings/NotificationPanelMenu;->mConvertPanelItemstring:Ljava/util/HashMap;
      const-string v1, "notification_panel_flashlight"
      const-string v2, "Flashlight"
      invoke-virtual {v0, v1, v2}, Ljava/util/HashMap;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

      If the 8 lines above are not anywhere in the
      Code:
      makeConvertPanelName
      method, then add them to the end of the method before the
      Code:
      return-void
    4. Now save the file and close it and navigate to SecSettings/res/values/strings.xml
    5. Add the following line to your strings.xml if it does not already exist (yes, it has the same name as the image. That's supposed to happen so don't worry)
      PHP:
      <string name="notification_panel_flashlight">Flashlight</string>
    6. Save and close strings.xml and navigate to SecSettings/res/drawable-xhdpi or drawable-xxhdpi depending on your device
    7. Extract the notification_panel_flashlight.png from attachment.zip/SecSettings and copy it into the drawable folder from above
    8. Finally, recompile SecSettings with your modifications


    Now for the final step, take your modified SecSettings.apk, SystemUI.apk and add them to the /system/app folder of your rom and you are good to go!

    Congratulations, you just added the Flashlight toggle to your rom. Enjoy :D:D

    AzsLTFa.png
    ENxGR0l.png

    Note: Devs are free to use this mod in their rom. Just make sure you give credits where they are due :)
    If you have any issues, I'd be more than happy to help :good:


    Thanks to:
    Samsung for the AT&T base code this was pulled from!
    Rompnit for finding the at&t code and the first part of the mod!
    Google for the wonderful logcat tool built into Android that allowed me to figure out the second part of the mod!!
    9
    @Chad The Pathfinder @vesatile1
    Here is a new smali for SystemUI that is working for me on 4.4.2.
    Give it a try and let me know how it works for you. I fought with this bad boy for quite a while. :rolleyes:

    Instructions:
    This smali requires you to compile then decompile your completed SystemUI (then compile one last time once the values are correct) to input the appropriate values for the public construct. I added fields to each line for which public values to look for. You can leave those comment lines in, they will be ignored when you compile the smali.
    Code:
    .method public constructor <init>(Landroid/content/Context;)V
        .locals 8
    
        const v2, 0x7f0b0211  [COLOR="Blue"]## quickpanel_flashlight_text[/COLOR]
    
        const v1, 0x7f0b0211  [COLOR="Blue"]## quickpanel_flashlight_text[/COLOR]
    
        const/4 v5, 0x0
    
        const/4 v0, 0x0
    
        sget-boolean v3, Lcom/android/systemui/statusbar/Feature;->mIsTablet:Z
    
        invoke-direct {p0, p1, v0, v3}, Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingButton;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;Z)V
    
        sget-boolean v0, Lcom/android/systemui/statusbar/Feature;->mIsPhone:Z
    
        if-eqz v0, :cond_0
    
        const v3, 0x7f020355  [COLOR="Blue"]## tw_quick_panel_icon_flashlight_on[/COLOR]
    
        const v4, 0x7f020354  [COLOR="Blue"]## tw_quick_panel_icon_flashlight_off[/COLOR]
    
        move-object v0, p0
    
        move v6, v5
    
        move v7, v5
    
        invoke-virtual/range {v0 .. v7}, Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;->initLayout(IIIIIII)V
    
        iput-object p1, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;->mContext:Landroid/content/Context;
    
        :goto_0
        invoke-virtual {p0, p0}, Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;->setListener(Lcom/android/systemui/statusbar/policy/quicksetting/QuickSettingButton$Listener;)V
    
        return-void
    
        :cond_0
        const v0, 0x7f020354  [COLOR="Blue"]## tw_quick_panel_icon_flashlight_off
    [/COLOR]
        invoke-virtual {p0, v1, v2, v0}, Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;->initLayout(III)V
    
        goto :goto_0
    .end method

    Also see this post:
    http://xdaforums.com/showpost.php?p=53122589&postcount=321
    9
    MOD UPDATED
    ==============
    - 4.3 and 4.4 zips added
    - No need to write down ANY id's anymore. I've made it so that the id's get looked up on the fly by name, so just make sure you don't rename the drawables/string names as per this guide
    - Flashlight is super fast now, no need to use an external app
    8
    Ok here it is

    Replace the onClick method of the FlashlightQuickSettingButton.smali with the following, then you don't need an external app

    Code:
    .method public onClick(Z)V
        .locals 5
        .parameter "paramBoolean"
    
        .prologue
        .line 29
        const/4 v2, 0x0
    
        .line 30
        .local v2, localIntent:Landroid/content/Intent;
        const/4 v1, 0x0
    
        .line 32
        .local v1, bc:Ljava/lang/String;
        const/4 v0, 0x2
    
        .line 34
        .local v0, activateStatus:I
        iget v3, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;->mFlashlight:I
    
        add-int/lit8 v3, v3, 0x1
    
        iput v3, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;->mFlashlight:I
    
        .line 36
        iget v3, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;->mFlashlight:I
    
        rem-int/lit8 v3, v3, 0x2
    
        iput v3, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;->mFlashlight:I
    
        .line 38
        iget v3, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;->mFlashlight:I
    
        const/4 v4, 0x1
    
        if-ne v3, v4, :cond_0
    
        .line 39
        const-string v1, "com.sec.samsung.torchwidget.torch_on_3"
    
        .line 40
        const/4 v0, 0x1
    
        .line 45
        :goto_0
        invoke-virtual {p0, v0}, Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;->setActivateStatus(I)V
    
        .line 47
        new-instance v2, Landroid/content/Intent;
    
        .end local v2           #localIntent:Landroid/content/Intent;
        invoke-direct {v2, v1}, Landroid/content/Intent;->(Ljava/lang/String;)V
    
        .line 49
        .restart local v2       #localIntent:Landroid/content/Intent;
        iget-object v3, p0, Lcom/android/systemui/statusbar/policy/quicksetting/FlashlightQuickSettingButton;->mContext:Landroid/content/Context;
    
        invoke-virtual {v3, v2}, Landroid/content/Context;->sendBroadcast(Landroid/content/Intent;)V
    
        .line 53
        return-void
    
        .line 42
        :cond_0
        const-string v1, "com.sec.samsung.torchwidget.torch_off"
    
        goto :goto_0
    .end method