Consider this scenario: You got yourself a Nexus device, unlocked its bootloader, flashed a custom recovery and used it to root your phone and mods for your stock ROM (or flashed a custom ROM), configured your device the way you want, enabled lockscreen security of your choice, and finally, disabled USB debugging, reflashed the stock recovery and locked the bootloader again so that in the event of your device getting stolen, the thief may not be able to get access to your data because they would need to unlock the bootloader to flash a custom recovery and install a ROM or take a backup, and unlocking the bootloader will wipe the device. That sounds all swell, up to the point where you yourself need to flash something else. This will require you to take a backup of your apps and settings using something like Titanium Backup, followed by copying everything over to your computer. What if things were easier, and you could simply unlock your bootloader from within Android without having to wipe data, and then use a custom recovery to flash whatever you want before manually relocking the bootloader? Fortunately, you can.
XDA Senior Member segv11 has developed BootUnlocker – a tool for rooted Nexus devices that lets you unlock and relock your bootloader from within Android. It achieves this by directly modifying the entry on your param (or /misc) partition that represents the bootloader’s lock state. So, while you can get into Android after unlocking the lockscreen and use the tool to lock/unlock the bootloader at will without data loss, no one else will be able to bypass the lockscreen security and use the app for the purpose, and if they try to unlock the bootloader using fastboot, all your data will be securely wiped.
Needless to say, in order to use the tool like this, your device must be rooted. It will work regardless of whether you rooted it after unlocking the bootloader in the first place, or just used some toolkit or exploit for rooting without unlocking the bootloader.
Using BootUnlocker is simple – just launch the app and it will ask you for root permissions that you should grant. Next, it will tell you the current lock state of the device on top, followed by buttons labeled Lock and Unlock that do exactly what they say. Just tap the required option and the bootloader will be locked or unlocked instantly, without even requiring a reboot.
BootUnlocker is an open-source application and can be installed for free from Google Play. To follow its development, head over to its XDA thread linked below.