[Galaxy S III Android Development] bullonwheels:
[MENTION=3562083]wanam[/MENTION] sir or Some other xda member,

My phone doesn't have camera flash, so I imported a couple of things from [MENTION=4054594]lidroid[/MENTION] sir's code and got the white-screen flashlight working.

However, there are 2 minor glitches.

1: While in the lockscreen, when pressed, it doesn't unlock the screen and display the white-screen flashlight.

2: The toggle icon doesn't change from 'stat_flashlight_off.png' to 'stat_flashlight_on.png'.

Please help me rectify these glitches.

Here are the changes I made...

In AndroidManifest.xml:

(changes are in blue)

<?xml version="1.0" encoding="utf-8" standalone="no"?>
[COLOR="navy"]<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:process="system" android:sharedUserId="android.uid.system" coreApp="true" package="com.android.systemui">[/COLOR]
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
.
.
.
.
.

<uses-library android:name="com.sec.android.app.minimode" android:required="false"/>
<uses-library android:name="touchwiz"/>
[COLOR="navy"]<activity android:clearTaskOnLaunch="true" android:configChanges="keyboardHidden|orientation" android:launchMode="singleTask" android:name="com.wanam.systemui.quickpanel.FlashlightActivity" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/>[/COLOR]
</application>
</manifest>

Added smali\com\wanam\systemui\quickpanel\FlashlightActivity.smali

.class public Lcom/wanam/systemui/quickpanel/FlashlightActivity;
.super Landroid/app/Activity;
.source "FlashlightActivity.java"

# static fields
.field private static final SCREEN_TIMEOUT_MAX:I = 0x927c0

# instance fields
.field private mOrigScreenTimeout:I

.field private mWakeLock:Landroid/os/PowerManager$WakeLock;

# direct methods
.method public constructor <init>()V
.locals 0

.prologue
.line 16
invoke-direct {p0}, Landroid/app/Activity;-><init>()V

return-void
.end method

# virtual methods
.method public onPause()V
.locals 3

.prologue
.line 40
invoke-super {p0}, Landroid/app/Activity;->onPause()V

.line 42
iget-object v0, p0, Lcom/wanam/systemui/quickpanel/FlashlightActivity;->mWakeLock:Landroid/os/PowerManager$WakeLock;

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

.line 43
invoke-virtual {p0}, Lcom/wanam/systemui/quickpanel/FlashlightActivity;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v0

const-string v1, "screen_off_timeout"

iget v2, p0, Lcom/wanam/systemui/quickpanel/FlashlightActivity;->mOrigScreenTimeout:I

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

.line 45
invoke-virtual {p0}, Lcom/wanam/systemui/quickpanel/FlashlightActivity;->finish()V

.line 46
return-void
.end method

.method public onResume()V
.locals 6

.prologue
const-string v5, "screen_off_timeout"

.line 23
invoke-super {p0}, Landroid/app/Activity;->onResume()V

.line 25
invoke-virtual {p0}, Lcom/wanam/systemui/quickpanel/FlashlightActivity;->getWindow()Landroid/view/Window;

move-result-object v2

invoke-virtual {v2}, Landroid/view/Window;->getAttributes()Landroid/view/WindowManager$LayoutParams;

move-result-object v0

.line 26
.local v0, lp:Landroid/view/WindowManager$LayoutParams;
const/high16 v2, 0x3f80

iput v2, v0, Landroid/view/WindowManager$LayoutParams;->screenBrightness:F

.line 27
invoke-virtual {p0}, Lcom/wanam/systemui/quickpanel/FlashlightActivity;->getWindow()Landroid/view/Window;

move-result-object v2

invoke-virtual {v2, v0}, Landroid/view/Window;->setAttributes(Landroid/view/WindowManager$LayoutParams;)V

.line 28
invoke-virtual {p0}, Lcom/wanam/systemui/quickpanel/FlashlightActivity;->getWindow()Landroid/view/Window;

move-result-object v2

new-instance v3, Landroid/graphics/drawable/ColorDrawable;

const/4 v4, -0x1

invoke-direct {v3, v4}, Landroid/graphics/drawable/ColorDrawable;-><init>(I)V

invoke-virtual {v2, v3}, Landroid/view/Window;->setBackgroundDrawable(Landroid/graphics/drawable/Drawable;)V

.line 30
const-string v2, "power"

invoke-virtual {p0, v2}, Lcom/wanam/systemui/quickpanel/FlashlightActivity;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

move-result-object v1

check-cast v1, Landroid/os/PowerManager;

.line 31
.local v1, pm:Landroid/os/PowerManager;
const/4 v2, 0x6

const-string v3, "Flashlight"

invoke-virtual {v1, v2, v3}, Landroid/os/PowerManager;->newWakeLock(ILjava/lang/String;)Landroid/os/PowerManager$WakeLock;

move-result-object v2

iput-object v2, p0, Lcom/wanam/systemui/quickpanel/FlashlightActivity;->mWakeLock:Landroid/os/PowerManager$WakeLock;

.line 32
iget-object v2, p0, Lcom/wanam/systemui/quickpanel/FlashlightActivity;->mWakeLock:Landroid/os/PowerManager$WakeLock;

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

.line 33
invoke-virtual {p0}, Lcom/wanam/systemui/quickpanel/FlashlightActivity;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v2

const-string v3, "screen_off_timeout"

const/4 v3, 0x0

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

move-result v2

iput v2, p0, Lcom/wanam/systemui/quickpanel/FlashlightActivity;->mOrigScreenTimeout:I

.line 35
invoke-virtual {p0}, Lcom/wanam/systemui/quickpanel/FlashlightActivity;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v2

const-string v3, "screen_off_timeout"

const v3, 0x927c0

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

.line 37
return-void
.end method

smali\com\wanam\systemui\quickpanel\FlashlightButton.smali:

.class public Lcom/wanam/systemui/quickpanel/FlashlightButton;
.super Lcom/wanam/systemui/quickpanel/PowerButton;
.source "FlashlightButton.java"

# instance fields
.field private mGotInfo:Z

.field private mIsFlashSupported:Z

.field private mLedController:Lcom/wanam/util/LedController;

# direct methods
.method public constructor <init>()V
.locals 1

.prologue
.line 13
invoke-direct {p0}, Lcom/wanam/systemui/quickpanel/PowerButton;-><init>()V

.line 11
const/4 v0, 0x0

iput-boolean v0, p0, Lcom/wanam/systemui/quickpanel/FlashlightButton;->mGotInfo:Z

.line 14
invoke-static {}, Lcom/wanam/util/LedController;->getInstance()Lcom/wanam/util/LedController;

move-result-object v0

iput-object v0, p0, Lcom/wanam/systemui/quickpanel/FlashlightButton;->mLedController:Lcom/wanam/util/LedController;

.line 15
const-string v0, "toggleFlashlight"

iput-object v0, p0, Lcom/wanam/systemui/quickpanel/FlashlightButton;->mType:Ljava/lang/String;

.line 16
const/4 v0, 0x2

iput v0, p0, Lcom/wanam/systemui/quickpanel/FlashlightButton;->mState:I

.line 17
return-void
.end method

.method private startFlashlightActivity()V
.locals 3

.prologue
.line 32
iget-object v2, p0, Lcom/wanam/systemui/quickpanel/FlashlightButton;->mView:Landroid/view/View;

invoke-virtual {v2}, Landroid/view/View;->getContext()Landroid/content/Context;

move-result-object v0

.line 33
.local v0, context:Landroid/content/Context;
new-instance v1, Landroid/content/Intent;

const-class v2, Lcom/wanam/systemui/quickpanel/FlashlightActivity;

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

.line 34
.local v1, intent:Landroid/content/Intent;
const/high16 v2, 0x1000

invoke-virtual {v1, v2}, Landroid/content/Intent;->addFlags(I)Landroid/content/Intent;

.line 35
invoke-virtual {v0, v1}, Landroid/content/Context;->startActivity(Landroid/content/Intent;)V

.line 36
return-void
.end method

# virtual methods
.method protected getText()I
.locals 1

.prologue
.line 62
const v0, 0x50b004e

return v0
.end method

.method protected handleLongClick()Z
.locals 1

.prologue
.line 66
const/4 v0, 0x0

return v0
.end method

.method protected toggleState()V
.locals 3

.prologue
const/4 v2, 0x2

const/4 v1, 0x1

.line 39
iget-boolean v0, p0, Lcom/wanam/systemui/quickpanel/FlashlightButton;->mGotInfo:Z

if-nez v0, :cond_0

.line 40
iget-object v0, p0, Lcom/wanam/systemui/quickpanel/FlashlightButton;->mLedController:Lcom/wanam/util/LedController;

invoke-virtual {v0}, Lcom/wanam/util/LedController;->isFlashSupported()Z

move-result v0

iput-boolean v0, p0, Lcom/wanam/systemui/quickpanel/FlashlightButton;->mIsFlashSupported:Z

.line 41
iput-boolean v1, p0, Lcom/wanam/systemui/quickpanel/FlashlightButton;->mGotInfo:Z

.line 44
:cond_0
iget-boolean v0, p0, Lcom/wanam/systemui/quickpanel/FlashlightButton;->mIsFlashSupported:Z

if-eqz v0, :cond_2

.line 45
iget v0, p0, Lcom/wanam/systemui/quickpanel/FlashlightButton;->mState:I

if-ne v0, v1, :cond_1

.line 46
iput v2, p0, Lcom/wanam/systemui/quickpanel/FlashlightButton;->mState:I

.line 47
iget-object v0, p0, Lcom/wanam/systemui/quickpanel/FlashlightButton;->mLedController:Lcom/wanam/util/LedController;

invoke-virtual {v0}, Lcom/wanam/util/LedController;->off()V

.line 53
:goto_0
invoke-virtual {p0}, Lcom/wanam/systemui/quickpanel/FlashlightButton;->update()V

.line 59
:goto_1
return-void

.line 50
:cond_1
iput v1, p0, Lcom/wanam/systemui/quickpanel/FlashlightButton;->mState:I

.line 51
iget-object v0, p0, Lcom/wanam/systemui/quickpanel/FlashlightButton;->mLedController:Lcom/wanam/util/LedController;

invoke-virtual {v0}, Lcom/wanam/util/LedController;->on()V

goto :goto_0

.line 56
:cond_2
iput v2, p0, Lcom/wanam/systemui/quickpanel/FlashlightButton;->mState:I

.line 57
invoke-direct {p0}, Lcom/wanam/systemui/quickpanel/FlashlightButton;->startFlashlightActivity()V

goto :goto_1
.end method

.method protected updateState()V
.locals 1

.prologue
.line 20
iget v0, p0, Lcom/wanam/systemui/quickpanel/FlashlightButton;->mState:I

packed-switch v0, :pswitch_data_0

.line 26
const v0, 0x502008d

iput v0, p0, Lcom/wanam/systemui/quickpanel/FlashlightButton;->mIcon:I

.line 29
:goto_0
return-void

.line 22
:pswitch_0
const v0, 0x502008e

iput v0, p0, Lcom/wanam/systemui/quickpanel/FlashlightButton;->mIcon:I

goto :goto_0

.line 20
nop

:pswitch_data_0
.packed-switch 0x1
:pswitch_0
.end packed-switch
.end method