[Verizon Samsung Galaxy S 4] Didact74:
How to enable AOSP lockscreen for the S4​

As always, for reasons of keeping things simple I use my Rom Control file to house all my MOD settings. Its easier to add and remove code and never changes with updates.

We will be working with three files:

SecSettings

framework-res

android.policy

We will begin with SecSettings

Navigate to res/values/strings and add the following:

<string name="lockscreen_title">Enable AOSP lockscreen</string>
<string name="lockscreen_summary">Choose AOSP or TW lockscreen</string>

Navigate to res/xml/rom_settings (or your xml of choice) and add the following:

<CheckBoxPreference android:title="@string/lockscreen_title" android:key="aosp_lock_enabled" android:summary="@string/lockscreen_summary" />

Navigate to smali/com/android/settings/didact/RomSettings.smali (or your settings smali of choice) and add the following:

The first lines just describe what method to add the code to. Dont copy them into the file.

.field mAospLock:Landroid/preference/CheckBoxPreference;

[B]In .method public onCreate(Landroid/os/Bundle;)V.....[/B]

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

const-string v1, "aosp_lock_enabled"

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

move-result-object v1

check-cast v1, Landroid/preference/CheckBoxPreference;

iput-object v1, p0, Lcom/android/settings/didact/RomSettings;->mAospLock:Landroid/preference/CheckBoxPreference;

iget-object v4, p0, Lcom/android/settings/didact/RomSettings;->mAospLock:Landroid/preference/CheckBoxPreference;

invoke-virtual {p0}, Lcom/android/settings/didact/RomSettings;->getActivity()Landroid/app/Activity;

move-result-object v1

invoke-virtual {v1}, Landroid/app/Activity;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v1

const-string v5, "aosp_lock_enabled"

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

move-result v1

if-ne v1, v2, :cond_5

move v1, v2

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

[B]in .method public onPreferenceTreeClick(Landroid/preference/PreferenceScreen;Landroid/preference/Preference;)Z[/B]

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

goto/16 :goto_0

:cond_a
iget-object v2, p0, Lcom/android/settings/didact/RomSettings;->mAospLock:Landroid/preference/CheckBoxPreference;

if-ne p2, v2, :cond_1

invoke-virtual {p0}, Lcom/android/settings/didact/RomSettings;->getActivity()Landroid/app/Activity;

move-result-object v2

invoke-virtual {v2}, Landroid/app/Activity;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v2

const-string v3, "aosp_lock_enabled"

check-cast p2, Landroid/preference/CheckBoxPreference;

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

move-result v4

if-eqz v4, :cond_b

move v0, v1

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

goto/16 :goto_0
.end method

Thats it for SecSettings. Again, you may wish to add these mods to lockscreen settings ot your own xml control. If you want to add them to lockscreen settings, have a look at my guide for the S3, it goes into how to do that. Now on to Framework-res in the next section......

AOSP Lockscreen with toggle, part 2.....framework-res​

​

In this file we will be doing two things:

Centering the glowpad in your screen

adding lock targets with camera (stock only adds unlock).

Navigate to res/layout/keyguard_selector_view.xml and replace the whole file with the following:

<?xml version="1.0" encoding="utf-8"?>
<com.android.internal.policy.impl.keyguard.KeyguardSelectorView android:orientation="vertical" android:id="@id/keyguard_selector_view" android:clipChildren="false" android:clipToPadding="false" android:layout_width="fill_parent" android:layout_height="fill_parent" android:contentDescription="@string/keyguard_accessibility_slide_unlock" android:layout_maxHeight="@dimen/keyguard_security_height" android:layout_maxWidth="420.0dip"
xmlns:prvandroid="http://schemas.android.com/apk/prv/res/android"
xmlns:android="http://schemas.android.com/apk/res/android">
<FrameLayout android:gravity="center" android:layout_gravity="center" android:clipChildren="false" android:clipToPadding="false" android:layout_width="fill_parent" android:layout_height="fill_parent">
<include android:layout_width="fill_parent" android:layout_height="wrap_content" layout="@layout/keyguard_message_area" />
<View android:id="@id/keyguard_selector_view_frame" android:background="@drawable/kg_bouncer_bg_white" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_marginLeft="16.0dip" android:layout_marginRight="16.0dip" />
<include layout="@layout/keyguard_glow_pad_container" />
<include android:layout_gravity="bottom|center" android:id="@id/keyguard_selector_fade_container" android:visibility="gone" android:layout_width="fill_parent" android:layout_height="0.0dip" layout="@layout/keyguard_eca" />
</FrameLayout>
</com.android.internal.policy.impl.keyguard.KeyguardSelectorView>

Navigate to res/layout/keyguard_glow_pad_view.xml and replace the entire file with the following:

<?xml version="1.0" encoding="utf-8"?>
<com.android.internal.widget.multiwaveview.GlowPadView android:gravity="center" android:layout_gravity="center" android:orientation="horizontal" android:id="@id/glow_pad_view" android:layout_width="wrap_content" android:layout_height="wrap_content" prvandroid:innerRadius="@dimen/glowpadview_inner_radius" android:contentDescription="@string/keyguard_accessibility_slide_area" prvandroid:targetDescriptions="@array/lockscreen_target_descriptions_with_camera" prvandroid:directionDescriptions="@array/lockscreen_direction_descriptions" prvandroid:outerRingDrawable="@drawable/ic_lockscreen_outerring" prvandroid:pointDrawable="@drawable/ic_lockscreen_glowdot" prvandroid:glowRadius="@dimen/glowpadview_glow_radius" prvandroid:firstItemOffset="@integer/kg_glowpad_rotation_offset" prvandroid:magneticTargets="true" prvandroid:allowScaling="true" prvandroid:targetDrawables="@array/lockscreen_targets_with_camera" prvandroid:handleDrawable="@drawable/ic_lockscreen_handle" prvandroid:outerRadius="@dimen/glowpadview_target_placement_radius" prvandroid:vibrationDuration="20" prvandroid:snapMargin="@dimen/glowpadview_snap_margin" prvandroid:feedbackCount="1"
xmlns:prvandroid="http://schemas.android.com/apk/prv/res/android"
xmlns:android="http://schemas.android.com/apk/res/android" />

Thats it for framework-res. The last section is for android.policy

AOSP Lockscreen with toggle part 3, android.policy​

This last part will add the AOSP functionality with toggle.

Navigate to smali/com/android/internal/policy/impl/keyguard/KeyguardHostView.smali

Add the following:

.field private mAospLock:I

Find .method private getLayoutIdFor(Lcom/android/internal/policy/impl/keyguard/KeyguardSecurityModel$SecurityMode;)I

Replace from pswitch_0 to pswitch_1 with the following code:

:pswitch_0
iget-object v2, p0, Lcom/android/internal/policy/impl/keyguard/KeyguardHostView;->mContext:Landroid/content/Context;

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

move-result-object v2

const-string v3, "aosp_lock_enabled"

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

move-result v2

iput v2, p0, Lcom/android/internal/policy/impl/keyguard/KeyguardHostView;->mAospLock:I

iget v2, p0, Lcom/android/internal/policy/impl/keyguard/KeyguardHostView;->mAospLock:I

if-eqz v2, :cond_nocrt

const v1, 0x1090084

goto :goto_1

:cond_nocrt
const v1, 0x1090091

goto :goto_1

:pswitch_1

Thats it. Recompile and push the files to your phone. Enjoy AOSP Lockscreen.

I am currently working to add more functions such as weather and added shortcuts so stay tuned....

Thanks Button!!