[AT&T Samsung Galaxy S II SGH-I777] Mirko ddd:
For TouchWiz Jelly Bean Roms (LSJ)

This is a noob proof guide, very easy to do, and made to involve less :cond_ possible.

Is not a clean guide for developers, infact i will use existing parts of code (not used) to make the toggle.

Obviously, if u are a developer and have a little experience with smali code language and patience with cond you can figure this out easily ;)

requirements:

-apktool use (i won t teach u how to use apktool, i assume u can use it)

-attention

this tutorial is made on 2 parts:

-create a switch to change circle lockscreen with aosp lockscreen

-create a toggle to set the aosp lockscreen when checked

ready?

PART 1

We need to decompile android.policy.jar for first.

navigate: smali/com/android/internal/policy/impl/LockPatternKeyguardView.smali

look for

.method createLockScreen()Landroid/view/View;

and add the red lines

.method createLockScreen()Landroid/view/View;
.registers 7

.prologue
.line 1319
[COLOR="Red"]iget-object v0, p0, Lcom/android/internal/policy/impl/LockPatternKeyguardView;->mContext:Landroid/content/Context;

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

move-result-object v0

const-string v1, "aosp_lock"

const/4 v2, 0x0

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

move-result v0

if-nez v0, :cond_mirko
[/COLOR]
new-instance v0, Lcom/android/internal/policy/impl/sec/CircleLockScreen;

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

iget-object v2, p0, Lcom/android/internal/policy/impl/LockPatternKeyguardView;->mConfiguration:Landroid/content/res/Configuration;

iget-object v3, p0, Lcom/android/internal/policy/impl/LockPatternKeyguardView;->mLockPatternUtils:Lcom/android/internal/widget/LockPatternUtils;

iget-object v4, p0, Lcom/android/internal/policy/impl/LockPatternKeyguardView;->mUpdateMonitor:Lcom/android/internal/policy/impl/KeyguardUpdateMonitor;

iget-object v5, p0, Lcom/android/internal/policy/impl/LockPatternKeyguardView;->mKeyguardScreenCallback:Lcom/android/internal/policy/impl/KeyguardScreenCallback;

invoke-direct/range {v0 .. v5}, Lcom/android/internal/policy/impl/sec/CircleLockScreen;-><init>(Landroid/content/Context;Landroid/content/res/Configuration;Lcom/android/internal/widget/LockPatternUtils;Lcom/android/internal/policy/impl/KeyguardUpdateMonitor;Lcom/android/internal/policy/impl/KeyguardScreenCallback;)V

[COLOR="Red"]goto :goto_ddd[/COLOR]

.line 1325
[COLOR="Red"]:cond_mirko
new-instance v0, Lcom/android/internal/policy/impl/LockScreen;

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

iget-object v2, p0, Lcom/android/internal/policy/impl/LockPatternKeyguardView;->mConfiguration:Landroid/content/res/Configuration;

iget-object v3, p0, Lcom/android/internal/policy/impl/LockPatternKeyguardView;->mLockPatternUtils:Lcom/android/internal/widget/LockPatternUtils;

iget-object v4, p0, Lcom/android/internal/policy/impl/LockPatternKeyguardView;->mUpdateMonitor:Lcom/android/internal/policy/impl/KeyguardUpdateMonitor;

iget-object v5, p0, Lcom/android/internal/policy/impl/LockPatternKeyguardView;->mKeyguardScreenCallback:Lcom/android/internal/policy/impl/KeyguardScreenCallback;

invoke-direct/range {v0 .. v5}, Lcom/android/internal/policy/impl/LockScreen;-><init>(Landroid/content/Context;Landroid/content/res/Configuration;Lcom/android/internal/widget/LockPatternUtils;Lcom/android/internal/policy/impl/KeyguardUpdateMonitor;Lcom/android/internal/policy/impl/KeyguardScreenCallback;)V
[/COLOR]
.local v0, lockView:Landroid/view/View;
[COLOR="Red"]:goto_ddd[/COLOR]
invoke-direct {p0, v0}, Lcom/android/internal/policy/impl/LockPatternKeyguardView;->initializeTransportControlView(Landroid/view/View;)V

first part is done :)

recompile and push it on /system/framework

PART 2

this is the not clean part, i have not created new codes for a toggle, but i used an unused code with the form i needed (checkbox preference).

I decompiled SecSettings.apk /smali/com/android/settings/LockscreenSettings.smali

the unused code i used is "mSayCommand" one, infact has the checkbox preference form i needed as we can see

.field private mSayCommand:Landroid/preference/CheckBoxPreference;

ok let s start second part, we need to change all "mSayCommand" to "mAospLock" and change the keyword from "wake_up_lock_screen" to "aosp_lock" in order to recall the first part of the mod we made in android.policy.jar

red part is what we add, and purple what we delete.

[COLOR="Red"].field private mAospLock:Landroid/preference/CheckBoxPreference;[/COLOR]

.field private mCameraShortCut:Landroid/preference/SwitchPreferenceScreen;

.field private mClock:Landroid/preference/CheckBoxPreference;

.field private mDualclock:Landroid/preference/SwitchPreferenceScreen;

.field private mHelpText:Landroid/preference/CheckBoxPreference;

.field private mInformationTicker:Landroid/preference/SwitchPreferenceScreen;

.field private mInkEffect:Landroid/preference/PreferenceScreen;

.field mInkEffectSummary:[I

.field private mLockPatternUtils:Lcom/android/internal/widget/LockPatternUtils;

.field private mLockScreenShortcut:Landroid/preference/SwitchPreferenceScreen;

.field private mMotionDialog:Landroid/app/AlertDialog;

.field private mRippleEffect:Landroid/preference/CheckBoxPreference;

[COLOR="DarkOrchid"].field private mSayCommand:Landroid/preference/CheckBoxPreference;[/COLOR]
...

.line 319
:cond_f8
[COLOR="DarkOrchid"] iget-object v4, p0, Lcom/android/settings/LockScreenSettings;->mSayCommand:Landroid/preference/CheckBoxPreference;[/COLOR]

[COLOR="Red"]iget-object v4, p0, Lcom/android/settings/LockScreenSettings;->mAospLock:Landroid/preference/CheckBoxPreference;[/COLOR]

if-eqz v4, :cond_10e

.line 320
[COLOR="DarkOrchid"]iget-object v7, p0, Lcom/android/settings/LockScreenSettings;->mSayCommand:Landroid/preference/CheckBoxPreference;[/COLOR]

[COLOR="Red"]iget-object v7, p0, Lcom/android/settings/LockScreenSettings;->mAospLock:Landroid/preference/CheckBoxPreference;[/COLOR]

invoke-virtual {p0}, Lcom/android/settings/LockScreenSettings;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v4

[COLOR="DarkOrchid"]const-string v8, "wake_up_lock_screen"[/COLOR]

[COLOR="Red"]const-string v8, "aosp_lock"[/COLOR]

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

move-result v4

if-eqz v4, :cond_146

move v4, v5

:goto_10b
invoke-virtual {v7, v4}, Landroid/preference/CheckBoxPreference;->setChecked(Z)V

.line 225
const-string v9, "say_your_wakeup"

invoke-virtual {p0, v9}, Lcom/android/settings/LockScreenSettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;

move-result-object v9

check-cast v9, Landroid/preference/CheckBoxPreference;

[COLOR="DarkOrchid"] iput-object v9, p0, Lcom/android/settings/LockScreenSettings;->mSayCommand:Landroid/preference/CheckBoxPreference;[/COLOR]

[COLOR="Red"]iput-object v9, p0, Lcom/android/settings/LockScreenSettings;->mAospLock:Landroid/preference/CheckBoxPreference;[/COLOR]

.line 227
invoke-virtual {p0}, Lcom/android/settings/LockScreenSettings;->getActivity()Landroid/app/Activity;

move-result-object v9

invoke-static {v9}, Lcom/android/settings/Utils;->isTablet(Landroid/content/Context;)Z

move-result v9

if-eqz v9, :cond_20d

.line 228
[COLOR="DarkOrchid"]iget-object v9, p0, Lcom/android/settings/LockScreenSettings;->mSayCommand:Landroid/preference/CheckBoxPreference;[/COLOR]

[COLOR="Red"]iget-object v9, p0, Lcom/android/settings/LockScreenSettings;->mAospLock:Landroid/preference/CheckBoxPreference;[/COLOR]

invoke-virtual {p0}, Lcom/android/settings/LockScreenSettings;->getResources()Landroid/content/res/Resources;

move-result-object v10

const v11, 0x7f090d6f

invoke-virtual {v10, v11}, Landroid/content/res/Resources;->getString(I)Ljava/lang/String;

move-result-object v10

invoke-virtual {v9, v10}, Landroid/preference/CheckBoxPreference;->setSummary(Ljava/lang/CharSequence;)V

as u can see I left untouched keyword "say_your_wakeup", it s not a wrong writing, i left it and i will use that keyword in future steps.

.line 254
[COLOR="DarkOrchid"]iget-object v9, p0, Lcom/android/settings/LockScreenSettings;->mSayCommand:Landroid/preference/CheckBoxPreference;[/COLOR]

[COLOR="Red"]iget-object v9, p0, Lcom/android/settings/LockScreenSettings;->mAospLock:Landroid/preference/CheckBoxPreference;[/COLOR]

if-eqz v9, :cond_26d

.line 255
[COLOR="DarkOrchid"]invoke-virtual {p0}, Lcom/android/settings/LockScreenSettings;->getPreferenceScreen()Landroid/preference/PreferenceScreen;

move-result-object v9

iget-object v10, p0, Lcom/android/settings/LockScreenSettings;->mSayCommand:Landroid/preference/CheckBoxPreference;

invoke-virtual {v9, v10}, Landroid/preference/PreferenceScreen;->removePreference(Landroid/preference/Preference;)Z
[/COLOR]

we delete this part of code to make the option visible, infact i said we re using an unused part of code, and has been hidden from preference screen.

.line 259
:cond_276
const/4 v9, 0x0

invoke-static {v9}, Lcom/android/settings/Utils;->isTablet(Landroid/content/Context;)Z

move-result v9

if-nez v9, :cond_287

[COLOR="DarkOrchid"]iget-object v9, p0, Lcom/android/settings/LockScreenSettings;->mSayCommand:Landroid/preference/CheckBoxPreference;[/COLOR]

[COLOR="Red"]iget-object v9, p0, Lcom/android/settings/LockScreenSettings;->mAospLock:Landroid/preference/CheckBoxPreference;[/COLOR]

if-eqz v9, :cond_296

if-eqz v7, :cond_296

iget-object v9, p0, Lcom/android/settings/LockScreenSettings;->mCameraShortCut:Landroid/preference/SwitchPreferenceScreen;

if-nez v9, :cond_296

.line 262
:cond_296
iget-object v9, p0, Lcom/android/settings/LockScreenSettings;->mCameraShortCut:Landroid/preference/SwitchPreferenceScreen;

if-nez v9, :cond_2af

[COLOR="DarkOrchid"]iget-object v9, p0, Lcom/android/settings/LockScreenSettings;->mSayCommand:Landroid/preference/CheckBoxPreference;[/COLOR]

[COLOR="Red"]iget-object v9, p0, Lcom/android/settings/LockScreenSettings;->mAospLock:Landroid/preference/CheckBoxPreference;[/COLOR]

if-nez v9, :cond_2af

if-nez v7, :cond_2af

.line 356
:cond_b3
[COLOR="DarkOrchid"]iget-object v4, p0, Lcom/android/settings/LockScreenSettings;->mSayCommand:Landroid/preference/CheckBoxPreference;[/COLOR]

[COLOR="Red"]iget-object v4, p0, Lcom/android/settings/LockScreenSettings;->mAospLock:Landroid/preference/CheckBoxPreference;[/COLOR]

invoke-virtual {p2, v4}, Ljava/lang/Object;->equals(Ljava/lang/Object;)Z

move-result v4

if-eqz v4, :cond_1e

.line 357
invoke-virtual {p0}, Lcom/android/settings/LockScreenSettings;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v4

[COLOR="DarkOrchid"]const-string v5, "wake_up_lock_screen"[/COLOR]

[COLOR="Red"]const-string v5, "aosp_lock"[/COLOR]

[COLOR="DarkOrchid"]iget-object v6, p0, Lcom/android/settings/LockScreenSettings;->mSayCommand:Landroid/preference/CheckBoxPreference;[/COLOR]

[COLOR="Red"]iget-object v6, p0, Lcom/android/settings/LockScreenSettings;->mAospLock:Landroid/preference/CheckBoxPreference;[/COLOR]

invoke-virtual {v6}, Landroid/preference/CheckBoxPreference;->isChecked()Z

move-result v6

if-eqz v6, :cond_ce

smali part is done, and now the toggle is set and working :D

last part is to edit our unused part of the code in res/xml folder, lockscreen_settings.xml

[COLOR="DarkOrchid"]<CheckBoxPreference android:title="@string/samsung_unlock_option_say_your_wakeup_command_to_unlock_screen" android:key="say_your_wakeup" android:summary="@string/wakeup_in_lockscreen_summary" />
[/COLOR]
[COLOR="Red"]<CheckBoxPreference android:title="@string/your_string" android:key="say_your_wakeup" android:summary="@string/your_summary_string" />[/COLOR]

asu can see we have again the keyword i said before "say_your_wakeup" , if u want u can change it, but change it in the smali part too if not the toggle won t work.

Now simply add the strings in /res/values/strings.xml

<string name="your_string">AOSP Lockscreen</string>
<string name="your_summary_string">Original Jelly Bean Lockscreen</string>

that s it.

easy and noob proof :D

and this is the result;)