Many people, myself included, struggle with turning the lock function of a phone off and on at various times based upon conditions. I have seen many threads with suggestions, some of which helped, some which did not. On my older phone, with Gingerbread, I had it working, but not exactly the way I wanted. On my new phone, with ICS, it didn't work at all, so I was forced to try and figure it out again.
This profile uses a plug-in, Secure Settings, and a 3rd party app, WidgetLocker.
I have come up with what I believe to be a reliable method of using Secure Settings to turn off keyguard and pin, and to reactivate it when necessary. The key is to do both keyguard and pin/password. This method works on ICS, and expects a pin, but I believe password would work just as well. Other methods, perhaps not. This device is NOT rooted. I start by setting or clearing a variable in various profiles depending on whether or not I want the screen to be locked. The profile below then triggers based on the variable being set or not, and not a specific value in that variable.
I also use Widgetlocker, which is also enabled/disabled by this profile.
Profile: KeyGuardOff (75)
State: Variable Value [ Name:%KEYGUARDOFF Op:Is Set Value:* ]
Enter: KeyGuardOff Enter (76)
Abort Existing Task
A1: Secure Settings [ Configuration:Screen & Keyboard Lights On
5 Seconds Package:com.intangibleobject.securesettings.plugin Name:Secure Settings ]
A2: Secure Settings [ Configuration:Clear Password Package:com.intangibleobject.securesettings.plugin Name:Secure Settings ]
A3: Secure Settings [ Configuration:Keyguard Disabled Package:com.intangibleobject.securesettings.plugin Name:Secure Settings ]
A4: Wait [ MS:0 Seconds:5 Minutes:0 Hours:0 Days:0 ]
A5: WidgetLocker [ Cmd:Disable ]
Exit: KeyGuardOff Exit (77)
Abort Existing Task
A1: Wait [ MS:0 Seconds:0 Minutes:1 Hours:0 Days:0 ]
A2: Stop [ With Error:Off ] If [ %PACTIVE ~ *,keyguardoff,* ]
A3: Secure Settings [ Configuration:Screen & Keyboard Lights On
5 Seconds Package:com.intangibleobject.securesettings.plugin Name:Secure Settings ]
A4: Secure Settings [ Configuration:Keyguard Enabled Package:com.intangibleobject.securesettings.plugin Name:Secure Settings ]
A5: Secure Settings [ Configuration:Set Pin Package:com.intangibleobject.securesettings.plugin Name:Secure Settings ]
A6: Wait [ MS:0 Seconds:5 Minutes:0 Hours:0 Days:0 ]
A7: WidgetLocker [ Cmd:Enable ]