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

[Source] Variable Size Pattern Lockscreen

OP Smasher816

3rd September 2012, 11:48 PM   |  #1  
Smasher816's Avatar
OP Senior Member
Flag Missouri
Thanks Meter: 166
 
390 posts
Join Date:Joined: Jan 2011
Donate to Me
More
For those who don't know, my pattern lockscreen modification has been merged into CyanogenMod 10.
This thread is designed to explain this modification so it can be enjoyed on more roms and devices.
I will also consider other lockscreen modification sugestions.

This addition is now in any CM10 based rom built after 09/01/2012 2:22
If you want to read about how or why I created this mod - continue reading post 1
If you want to implement this feature in your rom - skip to post 2
If you want to admire some screenshots - skip to post 3

Basic design process:
I finally learned how to compile android from source, so I figured I might as well start editing the source some.
Looking at my phone's lockscreen I thought, "Wouldn't it be cool if it was 5x5, it should be as easy as changing some 3s to 5s..."

I began with a lot of searches in the framworks/base folder.
I searched for the incorect pattern error message, found the localization file,
searched for the key, found the PatternUnlockScreen
and finally ended up with LockPatternView.java.

Any time I found 3 (or its variations) I replaced it with the variable PATTERN_SIZE.
3->PATTERN_SIZE, 2->PATTERN_SIZE-1, 9->PatternSize^2, etc

This allowed me to change the patterns appearance at compile time; however, it would only store a 3x3 pattern and could not be changed by a user.
These problems had me digging through LockPatternUtils and the android settings implementation.

Eventually I had a simi working setting (required restart) http://forum.xda-developers.com/show....php?t=1267420.
Later, school kept me busy and CM9 came out removing my changes.
With the release of CM10 I decided to recreate the modification from scratch, this time with everything working correctly.
Last edited by Smasher816; 4th September 2012 at 12:22 AM.
The Following 9 Users Say Thank You to Smasher816 For This Useful Post: [ View ]
3rd September 2012, 11:49 PM   |  #2  
Smasher816's Avatar
OP Senior Member
Flag Missouri
Thanks Meter: 166
 
390 posts
Join Date:Joined: Jan 2011
Donate to Me
More
Summary of required changes:
There are two modified projects
frameworks/base - http://review.cyanogenmod.com/#/c/20613/
packages/apps/Settings - http://review.cyanogenmod.com/#/c/20614/

Code:
Frameworks:
	LockPatternView.java:
		Replace '3' and its variations with a private static int 'PATTERN_SIZE' (must be static to be called from static functions). (This is the only modification required for a static sized pattern, everything else is for the settings implementation)
		Add functions to get and set 'PATTERN_SIZE' (changing size requires recreating a few variables). 
		Update 'Cell' class to alow size changes (recreate and initialize 'sCells' to the new size).
		Recreate '// Check for gaps in existing pattern' to support any size patterns and gaps. (This was a challenge to create my own optimized method to achieve this, if you have any improvements please let me know)
	LockPatternUtils.java:
		Replace '3' with a static int 'PATTERN_SIZE'
		Add functions to get, set, and update 'PATTERN_SIZE'
		Add get and set Integer functions to interface with the android settings
	ILockSettings.aidl:
		Add protypes for the get and set Integer functions
	LockSettingsService.java:
		Add functions to read and write Integers to the settings database
	Settings.java:
		Add keys for 'LOCK_PATTERN_SIZE' to the settings database
	PatternUnlockScreen.java:
		Read lockPatternSize from the utils and change the view's size to reflect it
		Update the utils PATTERN_SIZE before checking a pattern

Settings:
	AndroidManifest.xml:
		Add activity to choose the pattern size
	strings.xml:
		Add entries for the various sizes. (These could be localized; add more keys if you want to expand the size past 6x6)
	security_settings_pattern_size.xml: (New File)
		Add buttons for the various sizes (Can add more buttons for more sizes)
	ConfirmLockPatternSize:
		Make mLockPatternView's size respect the saved size 
	ChooseLockGeneric.java:
		Go strait to 'ChooseLockPatternSize.class'. It will forward to the tutorial or pattern choosing activities.
	ChooseLockPatternSize.java: (New File)
		Inflate the menu with new xml file
		Check which button was clicked. (This is what actually determines the 'PATTERN_SIZE' that will later be saved)
		Forward 'PATTERN_SIZE' in the intent to the next activity.
	ChooseLockPatternTutorial.java:
		Set the tutorial's mPatternView size to the one passed in the intent.
		Forward 'PATTERN_SIZE' to the next activity.
	ChooseLockPattern.java:
		Set mLockPatternView's size to the one passed in the intent (Don't save it until they have actually confirmed a pattern of the new size)
		Save the new PATTERN_SIZE with LockPatternUtils
All of the required code is contained in the two gerrit commits above.
Simply obtain the source for your rom and make the changes as needed.

Feel free to improve the source, add more sizes (fyi, 10x10 is almost unusable), or anything else (however, it would be nice to give me some credit if you use this code).
Post if you have any questions, I am also up for suggestions.
Last edited by Smasher816; 4th September 2012 at 12:01 AM.
The Following 4 Users Say Thank You to Smasher816 For This Useful Post: [ View ]
3rd September 2012, 11:50 PM   |  #3  
Smasher816's Avatar
OP Senior Member
Flag Missouri
Thanks Meter: 166
 
390 posts
Join Date:Joined: Jan 2011
Donate to Me
More
Screenshots: http://androtransfer.com/development/smasher816/media
See attached photos (larger inline photos coming soon)
Attached Thumbnails
Click image for larger version

Name:	Screenshot_2012-09-01-23-22-46.jpg
Views:	854
Size:	13.8 KB
ID:	1300523   Click image for larger version

Name:	Screenshot_2012-09-01-23-21-09.jpg
Views:	820
Size:	10.7 KB
ID:	1300524   Click image for larger version

Name:	Screenshot_2012-09-01-23-21-36.jpg
Views:	787
Size:	12.6 KB
ID:	1300525   Click image for larger version

Name:	Screenshot_2012-09-01-23-22-00.jpg
Views:	818
Size:	17.5 KB
ID:	1300526   Click image for larger version

Name:	Screenshot_2012-09-01-23-22-12.jpg
Views:	806
Size:	17.8 KB
ID:	1300528   Click image for larger version

Name:	Screenshot_2012-09-01-23-22-28.jpg
Views:	744
Size:	18.4 KB
ID:	1300529   Click image for larger version

Name:	Screenshot_2012-09-01-23-23-43.jpg
Views:	847
Size:	22.4 KB
ID:	1300530  
Last edited by Smasher816; 4th September 2012 at 12:16 AM.
The Following 2 Users Say Thank You to Smasher816 For This Useful Post: [ View ]
4th September 2012, 10:35 AM   |  #4  
BillGoss's Avatar
Senior Member
Flag Sydney
Thanks Meter: 842
 
1,570 posts
Join Date:Joined: Sep 2010
More
I saw this in the latest CM10 release for the Nexus 7. Loved it and am now hoping other CM10 derived ROMs will also implement this!

Sent from my Nexus 7
The Following User Says Thank You to BillGoss For This Useful Post: [ View ]
13th September 2012, 09:38 PM   |  #5  
lokeshsaini94's Avatar
Recognized Contributor / Themer
Flag Behind you!!!
Thanks Meter: 3,697
 
1,775 posts
Join Date:Joined: May 2012
Donate to Me
More
Only for jb???

Sent from my GT-S7500 using xda premium
21st October 2012, 02:46 PM   |  #6  
Junior Member
Thanks Meter: 2
 
9 posts
Join Date:Joined: Feb 2010
Pattern unlock coordinates in log
Hi, I just found out, that coordinates of unlock pattern are printed out to logcat.
Like that:
Code:
V/SMASHER816( 1656): (0, 0)
V/SMASHER816( 1656): (1, 0)
V/SMASHER816( 1656): (2, 0)
V/SMASHER816( 1656): (3, 0)
V/SMASHER816( 1656): (3, 1)
V/SMASHER816( 1656): (3, 2)
V/SMASHER816( 1656): (3, 3)
I think, it is not secure, so, it's better to remove logging of this stuff.
The Following 2 Users Say Thank You to nonsleepr For This Useful Post: [ View ]
24th October 2012, 03:24 PM   |  #7  
Junior Member
Thanks Meter: 0
 
9 posts
Join Date:Joined: Jan 2010
More
Quote:
Originally Posted by nonsleepr

Hi, I just found out, that coordinates of unlock pattern are printed out to logcat.
Like that:

Code:
V/SMASHER816( 1656): (0, 0)
V/SMASHER816( 1656): (1, 0)
V/SMASHER816( 1656): (2, 0)
V/SMASHER816( 1656): (3, 0)
V/SMASHER816( 1656): (3, 1)
V/SMASHER816( 1656): (3, 2)
V/SMASHER816( 1656): (3, 3)
I think, it is not secure, so, it's better to remove logging of this stuff.

Looks like the line that was logging this has been removed in cm10. Not sure what the OP's logic was on adding this in the first place?
Last edited by natediddy1120; 24th October 2012 at 03:30 PM.
22nd November 2012, 08:35 PM   |  #8  
ccbeam's Avatar
Member
Thanks Meter: 8
 
61 posts
Join Date:Joined: Jun 2008
More
Flashable zip possible?
I love this, but not every dev incorporates it.
Is it possible to make this code change into a flashable zip with 3, 4, or 5 as the options?

TIA
The Following User Says Thank You to ccbeam For This Useful Post: [ View ]
26th March 2013, 10:36 AM   |  #9  
FelixCited's Avatar
Member
Perth, Australia
Thanks Meter: 8
 
80 posts
Join Date:Joined: Dec 2011
More
Thumbs up
Quote:
Originally Posted by ccbeam

I love this, but not every dev incorporates it.
Is it possible to make this code change into a flashable zip with 3, 4, or 5 as the options?

TIA

Sorry if this has been already answered but I'd also like to know the outcome. A flashable zip would be perfect.

Seems like a great way to add more security. I have searched for this and cant find any other usable info on how to do it without compiling it into a rom which I have no idea about
10th September 2013, 08:35 AM   |  #10  
Junior Member
Thanks Meter: 1
 
16 posts
Join Date:Joined: Apr 2012
Great Idea
I wonder now why something so simple yet effective in means of improving the pattern locks level of security wouldnt have occurred to google in the first place. I suppose they figure the average end user lacks the memory recall to move beyond a max 3x3 grid pattern.Idk but I love it and am looking forward to incorporating into my own TW ROM.

Post Reply Subscribe to Thread

Tags
android, cyanogenmod, lockscreen, pattern, source
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes