disclaimer: This has not been tested by anyone but me. This has had zero oversight and should not be treated as official in any capacity. No warranty, express or implied.
LICENSE CC0 public domain https://creativecommons.org/publicdomain/zero/1.0/
flowchart TD
Start((Start))
Start --> Disco
Disco(((Working and fully locked)))
Disco -->|From developer options, enable OEM unlock| EnableUnlock
EnableUnlock(Device can be unlocked with fastboot commands)
EnableUnlock -->|fastboot flashing unlock| FastbootUnlock
FastbootUnlock(Unlocked noncritical)
FastbootUnlock -->|fastboot flashing unlock_critical| FastbootUnlockC
FastbootUnlockC(Unlocked critical. Device can be flashed.)
FastbootUnlockC -->|./your_flash_script.sh| FlashInProgress
FlashInProgress{{Device flashing. Pay attention. At the end, hold Volume Down to prevent booting into the flashed OS.}}
FlashInProgress -->|I held Volume Down to avoid OS boot| OSBootAvoided1
FlashInProgress -->|I didn't hold Volume Down and it attempted to boot the OS| OSBootAttemptNoLocks
OSBootAvoided1(OS has not had a chance to disable unlocking)
OSBootAvoided1 --> SafetyCheck1
SafetyCheck1{{fastboot flashing get_unlock_ability}}
SafetyCheck1 -->|Returned 1| SafetyCheck1Passed
SafetyCheck1 -->|Returned 0| NothingLockedRetry
SafetyCheck1Passed{{Proceed if you want to lock}}
SafetyCheck1Passed -->|fastboot flashing lock_critical| LockedCritical
SafetyCheck1Passed -->|don't lock, just boot to the OS| OSBootAttemptNoLocks
LockedCritical{{Critical locked. Pay attention. After you confirm the lock, hold Volume Down to prevent booting into the flashed OS.}}
LockedCritical -->|I held Volume Down to avoid OS boot| SafetyCheck2{{fastboot flashing get_unlock_ability}}
LockedCritical -->|I didn't hold Volume Down and it attempted to boot the OS| OSBootAttemptLockedCritical
SafetyCheck2{{fastboot flashing get_unlock_ability}}
SafetyCheck2 -->|Returned 1| SafetyCheck2Passed
SafetyCheck2 -->|Returned 0| Unknown1(I bet your device booted to the OS and you tried to resume from here anyway. You should retry.)
SafetyCheck2Passed{{ Proceed if you want to finish locking }}
SafetyCheck2Passed -->|fastboot flashing lock| LockedBoth
LockedBoth(Your device is locked and able to be unlocked. If you make it into the OS now, you should be golden. If you don't, you should be able to retry.)
LockedBoth --> OSBootAttemptLockedBoth
OSBootAttemptLockedBoth{{Did it boot the OS?}}
OSBootAttemptLockedBoth -->|It failed to boot with a red error| NoBoot2(todo)
OSBootAttemptLockedBoth -->|It booted to the OS!!!| Disco
Unknown1 -->|Boot into the OS again| UseItInsecure
%% OEMLocked(OS boot has set get_unlock_ability to 0)
NothingLockedRetry(Because you didn't lock anything, you should be able to retry.)
NothingLockedRetry --> FlashWithPrevious
OSBootAttemptNoLocks{{Did it boot the OS?}}
OSBootAttemptNoLocks -->|It failed to boot with a red error| NothingLockedRetry
OSBootAttemptNoLocks -->|It booted to the OS| UseItInsecure
OSBootAttemptLockedCritical{{Did it boot the OS?}}
OSBootAttemptLockedCritical -->|It failed to boot with a red error| NoBoot2(todo)
OSBootAttemptLockedCritical -->|It booted to the OS| UseItInsecure
NoBoot2(Because you didn't make it into the OS, you should be able to retry.)
NoBoot2 --> FlashWithPrevious
FlashWithPrevious(You should flash with the OS that the device last successfully booted with, not the one you just tried.)
FlashWithPrevious -->|Reboot to fastboot by powering it off and holding Volume Down during power on| EnableUnlock
UseItInsecure(You can use the device, but if your goal is to lock the bootloader you must start over. Do not attempt to lock anything from here without starting over.)
UseItInsecure -->|From developer options, enable OEM unlock| EnableUnlock