[Galaxy S II Android Development] gerryS2:
Custom text on lockscreen

Hi, I have create a mod to insert a text on lockscreen like S4 lockscreen, this text you can edit it with an edit text that I create in Settings.

I have I tried to create this mod in two ways.

First of all, I added this line in the layout file keyguard_circlelock_main.xml in framework-res:

<TextView android:textSize="32.0dip" android:textColor="#ffe6e6e6" android:gravity="left" android:orientation="horizontal" android:id="@id/customtext_lockscreen" android:visibility="gone" android:layout_marginTop="26.0dip" android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="@string/custom_text_lockscreen" android:singleLine="true" />

I have open the CircleLockScreen.smali that are in android.policy in smali/com/android/internal/policy/impl/sec.

If you want to try, just enter the red lines.

Insert this field in instance fiels:

.field private mLockscreenTextSize:I

First way is to put the code in .method public constructor <init>

:cond_1ea
new-instance v3, Lcom/android/internal/policy/impl/sec/CircleLockScreenMotion;

move-object/from16 v0, p1

move-object/from16 v1, p5

invoke-direct {v3, v0, v1}, Lcom/android/internal/policy/impl/sec/CircleLockScreenMotion;-><init>(Landroid/content/Context;Lcom/android/internal/policy/impl/KeyguardScreenCallback;)V

move-object/from16 v0, p0

iput-object v3, v0, Lcom/android/internal/policy/impl/sec/CircleLockScreen;->mCircleLockScreenMotion:Lcom/android/internal/policy/impl/sec/CircleLockScreenMotion;

.line 490
:cond_1f7
[COLOR="red"]const v3, 0x010205ae

move-object/from16 v0, p0

invoke-virtual {v0, v3}, Lcom/android/internal/policy/impl/sec/CircleLockScreen;->findViewById(I)Landroid/view/View;

move-result-object v3

check-cast v3, Landroid/widget/TextView;

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

move-result-object v2

const-string v4, "text_color_lockscreen"

const v5, -0x111112

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

move-result v2

invoke-virtual {v3, v2}, Landroid/widget/TextView;->setTextColor(I)V

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

move-result-object v2

const-string v4, "text_edit_lockscreen"

invoke-static {v2, v4}, Landroid/provider/Settings$System;->getString(Landroid/content/ContentResolver;Ljava/lang/String;)Ljava/lang/String;

move-result-object v2

invoke-virtual {v3, v2}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

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

move-result-object v2

const-string v4, "text_lockscreen_size"

const v5, 0x21

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

move-result v2

move-object/from16 v0, p0

iput v2, v0, Lcom/android/internal/policy/impl/sec/CircleLockScreen;->mLockscreenTextSize:I

move-object/from16 v0, p0

iget v2, v0, Lcom/android/internal/policy/impl/sec/CircleLockScreen;->mLockscreenTextSize:I

int-to-float v2, v2

invoke-virtual {v3, v2}, Landroid/widget/TextView;->setTextSize(F)V

const v3, 0x010205ae

move-object/from16 v0, p0

invoke-virtual {v0, v3}, Lcom/android/internal/policy/impl/sec/CircleLockScreen;->findViewById(I)Landroid/view/View;

move-result-object v3

const v8, 0x0

invoke-virtual {v3, v8}, Landroid/view/View;->setVisibility(I)V

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

move-result-object v2

const-string v4, "enable_text_lockscreen"

const v8, 0x0

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

move-result v2

const v8, 0x0

if-ne v2, v8, :cond_new

const v3, 0x010205ae

move-object/from16 v0, p0

invoke-virtual {v0, v3}, Lcom/android/internal/policy/impl/sec/CircleLockScreen;->findViewById(I)Landroid/view/View;

move-result-object v3

const v6, 0x8

invoke-virtual {v3, v6}, Landroid/view/View;->setVisibility(I)V

:cond_new
const v3, 0x010205af

move-object/from16 v0, p0

invoke-virtual {v0, v3}, Lcom/android/internal/policy/impl/sec/CircleLockScreen;->findViewById(I)Landroid/view/View;

move-result-object v3

const v8, 0x0

invoke-virtual {v3, v8}, Landroid/view/View;->setVisibility(I)V

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

move-result-object v2

const-string v4, "show_image_lockscreen"

const v8, 0x0

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

move-result v2

const v8, 0x0

if-ne v2, v8, :cond_new2

const v3, 0x010205af

move-object/from16 v0, p0

invoke-virtual {v0, v3}, Lcom/android/internal/policy/impl/sec/CircleLockScreen;->findViewById(I)Landroid/view/View;

move-result-object v3

const v6, 0x8

invoke-virtual {v3, v6}, Landroid/view/View;->setVisibility(I)V

:cond_new2[/COLOR]
const v3, 0x10202fd

move-object/from16 v0, p0

invoke-virtual {v0, v3}, Lcom/android/internal/policy/impl/sec/CircleLockScreen;->findViewById(I)Landroid/view/View;

move-result-object v3

check-cast v3, Landroid/widget/TextView;

move-object/from16 v0, p0

iput-object v3, v0, Lcom/android/internal/policy/impl/sec/CircleLockScreen;->mHelpText:Landroid/widget/TextView;

0x010205ae is the public id of @id/customtext_lockscreen

0x010202fd is the public id of @id/circle_lockscreen_help_text

0x010205af is the public id of an custom id for hide an image in lockscreen

The second way is to create a connection in .method public constructor <init> with a virtual method like.

For the connection I have insert this line in .method public constructor <init>.

const v3, 0x10202fd

move-object/from16 v0, p0

invoke-virtual {v0, v3}, Lcom/android/internal/policy/impl/sec/CircleLockScreen;->findViewById(I)Landroid/view/View;

move-result-object v3

check-cast v3, Landroid/widget/TextView;

move-object/from16 v0, p0

iput-object v3, v0, Lcom/android/internal/policy/impl/sec/CircleLockScreen;->mHelpText:Landroid/widget/TextView;

.line 491
move-object/from16 v0, p0

iget-object v3, v0, Lcom/android/internal/policy/impl/sec/CircleLockScreen;->mHelpText:Landroid/widget/TextView;

const/4 v4, 0x1

invoke-virtual {v3, v4}, Landroid/widget/TextView;->setFocusableInTouchMode(Z)V

[COLOR="red"]move-object/from16 v0, p0

invoke-virtual {v0}, Lcom/android/internal/policy/impl/sec/CircleLockScreen;->custom_text_lockscreen()V[/COLOR]

Then I have create a virtual method like this:

.method custom_text_lockscreen()V
.locals 6

.prologue
const v3, 0x010205ae

invoke-virtual {p0, v3}, Lcom/android/internal/policy/impl/sec/CircleLockScreen;->findViewById(I)Landroid/view/View;

move-result-object v3

check-cast v3, Landroid/widget/TextView;

iget-object v0, p0, Lcom/android/internal/policy/impl/sec/CircleLockScreen;->mContext:Landroid/content/Context;

invoke-virtual {v0}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v0

const-string v1, "text_color_lockscreen"

const v2, -0x111112

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

move-result v0

invoke-virtual {v3, v0}, Landroid/widget/TextView;->setTextColor(I)V

iget-object v0, p0, Lcom/android/internal/policy/impl/sec/CircleLockScreen;->mContext:Landroid/content/Context;

invoke-virtual {v0}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v0

const-string v1, "text_edit_lockscreen"

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

move-result-object v0

invoke-virtual {v3, v0}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

iget-object v0, p0, Lcom/android/internal/policy/impl/sec/CircleLockScreen;->mContext:Landroid/content/Context;

invoke-virtual {v0}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v0

const-string v1, "text_lockscreen_size"

const v2, 0x21

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

move-result v0

iput v0, p0, Lcom/android/internal/policy/impl/sec/CircleLockScreen;->mLockscreenTextSize:I

iget v0, p0, Lcom/android/internal/policy/impl/sec/CircleLockScreen;->mLockscreenTextSize:I

int-to-float v0, v0

invoke-virtual {v3, v0}, Landroid/widget/TextView;->setTextSize(F)V

const v3, 0x010205ae

invoke-virtual {p0, v3}, Lcom/android/internal/policy/impl/sec/CircleLockScreen;->findViewById(I)Landroid/view/View;

move-result-object v3

const v4, 0x0

invoke-virtual {v3, v4}, Landroid/view/View;->setVisibility(I)V

iget-object v0, p0, Lcom/android/internal/policy/impl/sec/CircleLockScreen;->mContext:Landroid/content/Context;

invoke-virtual {v0}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v0

const-string v1, "enable_text_lockscreen"

const v4, 0x0

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

move-result v0

const v4, 0x0

if-ne v0, v4, :cond_new

const v3, 0x010205ae

invoke-virtual {p0, v3}, Lcom/android/internal/policy/impl/sec/CircleLockScreen;->findViewById(I)Landroid/view/View;

move-result-object v3

const v5, 0x8

invoke-virtual {v3, v5}, Landroid/view/View;->setVisibility(I)V

:cond_new
const v3, 0x010205af

invoke-virtual {p0, v3}, Lcom/android/internal/policy/impl/sec/CircleLockScreen;->findViewById(I)Landroid/view/View;

move-result-object v3

const v4, 0x0

invoke-virtual {v3, v4}, Landroid/view/View;->setVisibility(I)V

iget-object v0, p0, Lcom/android/internal/policy/impl/sec/CircleLockScreen;->mContext:Landroid/content/Context;

invoke-virtual {v0}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v0

const-string v1, "show_image_lockscreen"

const v4, 0x0

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

move-result v0

const v4, 0x0

if-ne v0, v4, :cond_new2

const v3, 0x010205af

invoke-virtual {p0, v3}, Lcom/android/internal/policy/impl/sec/CircleLockScreen;->findViewById(I)Landroid/view/View;

move-result-object v3

const v5, 0x8

invoke-virtual {v3, v5}, Landroid/view/View;->setVisibility(I)V

:cond_new2
return-void
.end method

This effect works in the beginning, but as soon as I rotate the screen or after some time I get a bootloop, Can someone help me to insert this mod?