Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

[GUIDE][HOW TO] Toggle to choose AOSP Lockscreen **11DEC**

OP Mirko ddd

3rd June 2012, 03:24 PM   |  #1  
Mirko ddd's Avatar
OP Recognized Contributor / Recognized Developer
Flag Piazza Armerina
Thanks Meter: 4,730
 
1,453 posts
Join Date:Joined: Nov 2010
Donate to Me
More
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

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

    .prologue
    .line 1319
    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

    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

    goto :goto_ddd
    
    .line 1325
    :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

    .local v0, lockView:Landroid/view/View;
    :goto_ddd
    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

Code:
.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.

Code:
.field private mAospLock:Landroid/preference/CheckBoxPreference;

.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;

.field private mSayCommand:Landroid/preference/CheckBoxPreference;
...
Code:
    .line 319
    :cond_f8
    iget-object v4, p0, Lcom/android/settings/LockScreenSettings;->mSayCommand:Landroid/preference/CheckBoxPreference;

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

    if-eqz v4, :cond_10e

    .line 320
    iget-object v7, p0, Lcom/android/settings/LockScreenSettings;->mSayCommand:Landroid/preference/CheckBoxPreference;

    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, "wake_up_lock_screen"

    const-string v8, "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_146

    move v4, v5

    :goto_10b
    invoke-virtual {v7, v4}, Landroid/preference/CheckBoxPreference;->setChecked(Z)V
Code:
    .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;

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

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

    .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
    iget-object v9, p0, Lcom/android/settings/LockScreenSettings;->mSayCommand:Landroid/preference/CheckBoxPreference;

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

    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.

Code:
    .line 254
    iget-object v9, p0, Lcom/android/settings/LockScreenSettings;->mSayCommand:Landroid/preference/CheckBoxPreference;

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

    if-eqz v9, :cond_26d

    .line 255
    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
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.

Code:
    .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

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

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

    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
Code:
    .line 262
    :cond_296
    iget-object v9, p0, Lcom/android/settings/LockScreenSettings;->mCameraShortCut:Landroid/preference/SwitchPreferenceScreen;

    if-nez v9, :cond_2af

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

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

    if-nez v9, :cond_2af

    if-nez v7, :cond_2af
Code:
    .line 356
    :cond_b3
    iget-object v4, p0, Lcom/android/settings/LockScreenSettings;->mSayCommand:Landroid/preference/CheckBoxPreference;

    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_1e

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

    move-result-object v4

    const-string v5, "wake_up_lock_screen"

    const-string v5, "aosp_lock"

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

    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_ce
smali part is done, and now the toggle is set and working
last part is to edit our unused part of the code in res/xml folder, lockscreen_settings.xml

Code:
    <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" />

<CheckBoxPreference android:title="@string/your_string" android:key="say_your_wakeup" android:summary="@string/your_summary_string" />
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

Code:
    <string name="your_string">AOSP Lockscreen</string>
    <string name="your_summary_string">Original Jelly Bean Lockscreen</string>
that s it.
easy and noob proof

and this is the result


Last edited by Mirko ddd; 11th December 2012 at 03:55 PM.
The Following 66 Users Say Thank You to Mirko ddd For This Useful Post: [ View ]
3rd June 2012, 08:00 PM   |  #2  
LegendK95's Avatar
Recognized Developer
Flag Jerusalem
Thanks Meter: 4,352
 
1,519 posts
Join Date:Joined: Nov 2011
More
Hey there bro A really nice tutorial, I miss you and all of XDA xD
The Following 3 Users Say Thank You to LegendK95 For This Useful Post: [ View ]
3rd June 2012, 08:47 PM   |  #3  
malavan's Avatar
Senior Member
Flag stockholm
Thanks Meter: 513
 
2,348 posts
Join Date:Joined: Jan 2009
More
where are you legend?
3rd June 2012, 09:53 PM   |  #4  
Mirko ddd's Avatar
OP Recognized Contributor / Recognized Developer
Flag Piazza Armerina
Thanks Meter: 4,730
 
1,453 posts
Join Date:Joined: Nov 2010
Donate to Me
More
Quote:
Originally Posted by LegendK95

Hey there bro A really nice tutorial, I miss you and all of XDA xD

Hello broooo hurry up, we have to work we have to work we have to work
Quote:
Originally Posted by malavan

where are you legend?

hello buddy, he is studying hard u.u in mid-june will be among us again
4th June 2012, 01:16 AM   |  #5  
Bologna's Avatar
Recognized Developer
Flag Bologna
Thanks Meter: 1,145
 
917 posts
Join Date:Joined: Mar 2010
Donate to Me
More
Great work mirko!

Very good stuff
Last edited by Bologna; 4th June 2012 at 01:18 AM.
The Following User Says Thank You to Bologna For This Useful Post: [ View ]
4th June 2012, 01:18 AM   |  #6  
Mirko ddd's Avatar
OP Recognized Contributor / Recognized Developer
Flag Piazza Armerina
Thanks Meter: 4,730
 
1,453 posts
Join Date:Joined: Nov 2010
Donate to Me
More
Quote:
Originally Posted by Bologna

Great work mirko! Thanks a lot!

thank u mate means much for me some your congrats
4th June 2012, 02:53 AM   |  #7  
Senior Member
Thanks Meter: 175
 
319 posts
Join Date:Joined: Apr 2011
Heyy,

Great tut! Thanks a lot!

I'm trying to get this to work on LP9

Button shows up correctly in settings, but I get a little compiling error of policy.jar.

The error I get is an undefined "goto_14" in line 3008.

There's 2 "goto_14" 's in LockPatternKeyguardView...

The one you pointed out and this seconde one in line 3008...

So I also changed the second one in "goto_1e" and after that the .dex compiles without errors...

Phone starts up with AOSP Lockscreen, but after that a bootloop...

Could you have a look at LP9's LockPatternKeyguardView.smali?

Here it is with the changes made to it, following exactly your tut:

http://dl.dropbox.com/u/25779832/SGS...uardView.smali

Thanks a lot in advance for looking into it!

Edit: Here it is zipped: http://dl.dropbox.com/u/25779832/SGS...yguardView.zip
Last edited by The Undertakerr; 4th June 2012 at 02:58 AM.
The Following User Says Thank You to The Undertakerr For This Useful Post: [ View ]
4th June 2012, 02:57 AM   |  #8  
Mirko ddd's Avatar
OP Recognized Contributor / Recognized Developer
Flag Piazza Armerina
Thanks Meter: 4,730
 
1,453 posts
Join Date:Joined: Nov 2010
Donate to Me
More
Quote:
Originally Posted by The Undertakerr

Heyy,

Great tut! Thanks a lot!

I'm trying to get this to work on LP9

Button shows up correctly in settings, but I get a little compiling error of policy.jar.

The error I get is an undefined "goto_14" in line 3008.

There's 2 "goto_14" 's in LockPatternKeyguardView...

The one you pointed out and this seconde one in line 3008...

So I also changed the second one in "goto_1e" and after that the .dex compiles without errors...

Phone starts up with AOSP Lockscreen, but after that a bootloop...

Could you have a look at LP9's LockPatternKeyguardView.smali?

Here it is with the changes made to it, following exactly your tut:

http://dl.dropbox.com/u/25779832/SGS...uardView.smali

Thanks a lot in advance for looking into it!

hello sure!
I told that mod was for LPF, probably there s some diff with LP9.
Let me watch into

PS: please upload your smali file, not a link with text :P
The Following User Says Thank You to Mirko ddd For This Useful Post: [ View ]
4th June 2012, 03:01 AM   |  #9  
Senior Member
Thanks Meter: 175
 
319 posts
Join Date:Joined: Apr 2011
Here it is my man, and give my greetings to Doctor Maroun!

http://dl.dropbox.com/u/25779832/SGS...yguardView.zip
4th June 2012, 03:11 AM   |  #10  
Mirko ddd's Avatar
OP Recognized Contributor / Recognized Developer
Flag Piazza Armerina
Thanks Meter: 4,730
 
1,453 posts
Join Date:Joined: Nov 2010
Donate to Me
More
Quote:
Originally Posted by The Undertakerr

Here it is my man, and give my greetings to Doctor Maroun!

http://dl.dropbox.com/u/25779832/SGS...yguardView.zip

I m sure he will be, he s a smart guy
please the unmodified one mate I didn t explained myself good

The Following User Says Thank You to Mirko ddd For This Useful Post: [ View ]
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes