[Verizon Samsung Galaxy S III] Didact74:
[MOD] [GUIDE] AOSP LockScreen with Toggle

AOSP LockScreen with Toggle​

ORIGINAL THREAD​

As always feel free to use these MODs with your ROM but since it took a few days to get this coded correctly just give me some thanks and some credit in your thread please.

[Q] What does this MOD do?

[A] It allows you to toggle between TW lock screen or AOSP lock screen.

*****EDIT******

If you experience your lock screen freezing when you turn it to landscape mode, just go to lockscreen options and make sure all settings are UNTICKED......except for AOSP lockscreen that is :).

Thanks to jdub251 for the feedback.

Here are the goodies.....

We will be working in two files.

-SecSettings

-android.policy

As always, I will assume you know how to compile/decompile so I will not be providing information how to do that.

Lets begin with the easiest file, Android.policy.jar

Navigate to smali/com/android/internal/policy/imp/LockPatternKeyguardView

Find the following code

.method createLockScreen()Landroid/view/View;

We are going to replace the whole method with the following code.

.method createLockScreen()Landroid/view/View;
.locals 6

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

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

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

move-result-object v5

const-string v4, "enable_aosp_lock"

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

move-result v5

if-nez v5, :cond_0

.line 1044

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

.line 1274
.local v0, lockView:Landroid/view/View;
:goto_0
invoke-direct {p0, v0}, Lcom/android/internal/policy/impl/LockPatternKeyguardView;->initializeTransportControlView(Landroid/view/View;)V

.line 1275
return-object v0

:cond_0

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

.line 1274
goto :goto_0
.end method

Thats it for android.policy.jar. Recompile and push to /system/app. If you want to Diff out the exact changes feel free.

Now for SecSettings.

Navigate to res/values/strings

Add the following lines somewhere in this file. In the middle or end, it doesnt matter.

<string name="enable_aosp_lock">Enable AOSP lockscreen</string>
<string name="enable_aosp_lock_text">Enable AOSP lockscreen in place of circle lockscreen</string>

Navigate to res/xml/Lockscreen_Settings.xml

Add the following line below in RED.

<PreferenceCategory android:title="@string/display_settings" />
[COLOR="red"]<CheckBoxPreference android:title="@string/enable_aosp_lock" android:key="enable_aosp_lock" android:summary="@string/enable_aosp_lock_text" />
[/COLOR] <SwitchPreferenceScreen android:title="@string/lock_screen_shortcut_title" android:key="lock_screen_shortcut" android:summary="@string/lock_screen_shortcut_summary">

Now lets hit some smali.....

Still in SecSettings, lets navigate to smali/com/android/settings/LockScreenSettings

Find the following code

.field private mWeather:Landroid/preference/SwitchPreferenceScreen;

Add this line below it

.field private mAospLock:Landroid/preference/CheckBoxPreference;

Find the following code and add the parts in RED

.method private updateState()V
.locals 9

.prologue
const/4 v5, 0x1

const/4 v6, 0x0

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

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

move-result-object v4

const-string v8, "enable_aosp_lock"

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_7

move v4, v5

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

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

move-result-object v4
[/COLOR]
iget-object v7, p0, Lcom/android/settings/LockScreenSettings;->mClock:Landroid/preference/CheckBoxPreference;

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

move-result-object v4

const-string v8, "show_clock"

Find the following code and add the parts in RED

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

const/4 v10, 0x0

invoke-virtual {v9, v10}, Landroid/preference/CheckBoxPreference;->setPersistent(Z)V

[COLOR="red"]const-string v9, "enable_aosp_lock"

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;

iput-object v9, p0, Lcom/android/settings/LockScreenSettings;->mAospLock:Landroid/preference/CheckBoxPreference;

.line 159
iget-object v9, p0, Lcom/android/settings/LockScreenSettings;->mAospLock:Landroid/preference/CheckBoxPreference;

const/4 v10, 0x0

invoke-virtual {v9, v10}, Landroid/preference/CheckBoxPreference;->setPersistent(Z)V
[/COLOR]
.line 161
const-string v9, "weather"

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

move-result-object v9

Find the following code and add the parts in RED

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

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

move-result v4

if-eqz v4, [COLOR="red"]:cond_b
[/COLOR]
.line 338
invoke-virtual {p0}, Lcom/android/settings/LockScreenSettings;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v4

const-string v5, "wake_up_lock_screen"

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

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

move-result v6

if-eqz v6, :cond_a

Find the following code and add the parts in RED

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

goto/16 :goto_1

:cond_a
move v2, v3

goto :goto_5

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

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

move-result v4

if-eqz v4, :cond_0

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

move-result-object v4

const-string v5, "enable_aosp_lock"

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

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

move-result v6

if-eqz v6, :cond_c

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

.line 314
invoke-direct {p0}, Lcom/android/settings/LockScreenSettings;->updateState()V

.line 340
invoke-super {p0, p1, p2}, Lcom/android/settings/SettingsPreferenceFragment;->onPreferenceTreeClick(Landroid/preference/PreferenceScreen;Landroid/preference/Preference;)Z

move-result v2

return v2

:cond_c
move v2, v3

.line 313
goto :goto_6
[/COLOR]
.line 337

.end method

.method public onResume()V
.locals 0

.prologue
.line 257
invoke-super {p0}, Lcom/android/settings/SettingsPreferenceFragment;->onResume()V

.line 258
invoke-direct {p0}, Lcom/android/settings/LockScreenSettings;->updateState()V

Thats it! Recompile and push to /system/app

You will find your new toggle in lockscreen options.

Enjoy!

FLASHABLE ZIP FOR BLK1 Deodexed ROMs NANDROID FIRST!!!!!

Thanks Button!