Keyguard rewrite

Change-Id: I7220f8a28a0b3fec387e84362298d19904329467