Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,780,165 Members 38,373 Now Online
XDA Developers Android and Mobile Development Forum

[Source] Variable Size Pattern Lockscreen

Tip us?
 
Smasher816
Old
(Last edited by Smasher816; 3rd September 2012 at 11:22 PM.)
#1  
Smasher816's Avatar
Senior Member - OP
Thanks Meter 166
Posts: 389
Join Date: Jan 2011
Location: Missouri

 
DONATE TO ME
Info 2 [Source] Variable Size Pattern Lockscreen

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.
and remember use the THANKS button

Retired: Samsung Captivate
Current: Samsung Galaxy S III

Glitch Updater App (Developed by yours truly)
The Following 9 Users Say Thank You to Smasher816 For This Useful Post: [ Click to Expand ]
 
Smasher816
Old
(Last edited by Smasher816; 3rd September 2012 at 11:01 PM.)
#2  
Smasher816's Avatar
Senior Member - OP
Thanks Meter 166
Posts: 389
Join Date: Jan 2011
Location: Missouri

 
DONATE TO ME
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.
and remember use the THANKS button

Retired: Samsung Captivate
Current: Samsung Galaxy S III

Glitch Updater App (Developed by yours truly)
The Following 4 Users Say Thank You to Smasher816 For This Useful Post: [ Click to Expand ]
 
Smasher816
Old
(Last edited by Smasher816; 3rd September 2012 at 11:16 PM.)
#3  
Smasher816's Avatar
Senior Member - OP
Thanks Meter 166
Posts: 389
Join Date: Jan 2011
Location: Missouri

 
DONATE TO ME
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:	836
Size:	13.8 KB
ID:	1300523   Click image for larger version

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

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

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

Name:	Screenshot_2012-09-01-23-22-12.jpg
Views:	787
Size:	17.8 KB
ID:	1300528  

Click image for larger version

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

Name:	Screenshot_2012-09-01-23-23-43.jpg
Views:	827
Size:	22.4 KB
ID:	1300530  
and remember use the THANKS button

Retired: Samsung Captivate
Current: Samsung Galaxy S III

Glitch Updater App (Developed by yours truly)
The Following 2 Users Say Thank You to Smasher816 For This Useful Post: [ Click to Expand ]
 
BillGoss
Old
#4  
BillGoss's Avatar
Senior Member
Thanks Meter 815
Posts: 1,524
Join Date: Sep 2010
Location: Sydney
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: [ Click to Expand ]
 
lokeshsaini94
Old
#5  
lokeshsaini94's Avatar
Recognized Contributor / Themer
Thanks Meter 3,645
Posts: 1,776
Join Date: May 2012
Location: Behind you!!!

 
DONATE TO ME
Only for jb???

Sent from my GT-S7500 using xda premium

lokeshsaini94's Theming Hub
MY WORK <= click here
TEAM GFX BANDITS - you request, we design.
I WON'T REPLY TO ANY DEVELOPMENT RELATED QUESTIONS WITH PM...
 
nonsleepr
Old
#6  
Junior Member
Thanks Meter 2
Posts: 9
Join Date: Feb 2010
Default 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: [ Click to Expand ]
 
natediddy1120
Old
(Last edited by natediddy1120; 24th October 2012 at 02:30 PM.)
#7  
Junior Member
Thanks Meter 0
Posts: 9
Join Date: Jan 2010
Quote:
Originally Posted by nonsleepr View Post
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?
 
ccbeam
Old
#8  
ccbeam's Avatar
Member
Thanks Meter 8
Posts: 59
Join Date: Jun 2008
Default 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: [ Click to Expand ]
 
FelixCited
Old
#9  
FelixCited's Avatar
Member
Thanks Meter 8
Posts: 80
Join Date: Dec 2011
Location: Perth, Australia
Quote:
Originally Posted by ccbeam View Post
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
 
3ncrypt3d
Old
#10  
Junior Member
Thanks Meter 1
Posts: 16
Join Date: Apr 2012
Default 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.

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

Advanced Search
Display Modes