[OnePlus 5 ROMs, Kernels, Recoveries, & Other Devel] robertogl:
Boot with locked bootloader

Following the next points, you will be able to boot this ROM with the locked bootloader on OnePlus 5. This will grant the security of your own data, as no one will be able to flash any new image without first deleting everything from the data partition: this is because unlocking the bootloader again requires to format the data partition.

If the data are encrypted (if you are using a PIN or the fingerprint to unlock your device), your data are safe.

Also, no more wait time or 'you have unlocked the bootloader' screen at boot :)

Be aware that in this 'beta' version, I'm still using AOSP keys, that are actually publicly available.

ATTENTION: ALL THE DATA ON THE DEVICE WILL BE LOST FOLLOWING THIS PROCEDURE

The following link contains different useful files:

https://androidfilehost.com/?w=files&flid=320711

a signed twrp image: signed_twrp.zip Thanks @codeworkx for the actual TWRP recovery!

a signed boot image with Magisk preinstalled: signed_magisk_boot_[date].img

a 'persist twrp' recovery zip: persist_twrp.zip

Download the signed TWRP image signed_twrp.zip

Enter in fastboot mode. There are two ways, select the one you prefer:

from adb, run the command 'adb reboot bootloader'

or power on the device pressing the power up button and the power button at the same time

Run the following command to flash the signed recovery:

fastboot flash recovery signed_twrp.img

Using the volume buttons, select 'RECOVERY' and using the power button boot into recovery.

This TWRP version does not support decrypting data if a numeric PIN is used, but this is not an issue. If asked for a PIN, just 'cancel' the dialog to get into the TWRP main screen.

From adb, push the OTA file and the GAPPS file:

adb push aosp_cheeseburger-ota-user-20201121.zip /data/update.zip

adb push FlameGApps-11.0-basic-arm64-20201024-ALPHA-10.zip /data/gapps.zip

(any gapps package should work, but I've only tested this)

adb push signed_magisk_boot_[date].img /data/magisk.img (only if you need Magisk)

adb push persist_twrp.zip /data/persist_twrp.zip (only if you want to persist the TWRP recovery after boot)

From the TWRP interface, select 'Install' and flash first the 'update.zip' file and secondly the 'gapps.zip' file.

If you want to persist the TWRP recovery, flash also the 'persist_twrp.zip' file.

If you need magisk, from the TWRP interface select 'Install Image' and install also the magisk.img file in the boot partition.

From the TWRP interface, reboot into fastboot (bootloader) mode again.

Run the command (ATTENTION: ALL THE DATA ON THE DEVICE WILL BE DELETED):

fastboot oem lock

Confirm the lock operation on the device's screen.

After the reboot, the device will probably boot again into the TWRP recovery: in this case, clear all the data from /data and restart the device (Wipe -> Format Data). Android will boot with the locked bootloader.

Important note: the device will now boot only signed image. DO NOT change boot.img without first check if it is signed. The images provided in this thread all are signed using AOSP keys.

If you are using Magisk, DO NOT UPDATE MAGISK after this installation. You can only update the Magisk Manager. At first boot, open the Magisk Manager and follow the instructions on screen.

If you don't flash the persist_twrp.zip archive, Android will replace the recovery at every boot with the stock signed recovery*. This stock recovery only flashes signed images (the OTAs from this thread are all signed), so if you need the TWRP, you have to use ADB sideload to flash the signed TWRP.

I've uploaded here a signed zip that can flash the signed TWRP while using the locked bootloader:

https://androidfilehost.com/?w=files&flid=320711

(signed_twrp.zip)

enter into recovery (with the physical buttons or with 'adb reboot recovery')

Press and hold the Power button. While holding the Power button press the Volume Up button then release the Volume Up button then the Power button to get into the Recovery UI

select 'apply update from ADB'

connect the phone and the pc, and from the pc run:

adb sideload twrp_signed.zip

reboot the phone selecting the 'reboot system now' from the recovery. Immediately after confirming the reboot, press the volume up button and keep it pressed until the boot mode is requested: select 'Recovery mode' and the phone will boot into the signed TWRP recovery. If the phone does not reboot, press the power button and after one second press the volume button keeping both buttons pressed until the device boots again.

Remember that, if you boot Android, you will lose the TWRP again.

How to update via TWRP

TWRP cannot decrypt the data partition using this ROM if you are using a PIN (it works fine using a pattern, for example).

To update the ROM:

- enter into TWRP recovery

- push the .zip update via adb:

$ adb push update.zip /data/

- from the TWRP recovery, select 'Install' e select the zip as /data/update.zip

If you need the TWRP recovery to be persisted, flash also the persis_twrp.zip archive again.

If you have a locked bootloader and you are using Magisk, flash the boot image with Magisk preinstalled again.

Notification LED control (BETA)

The ROM has an integrated Led Manager. It can be enabled from the SettingsExtra preinstalled app.

When enabled, the Android LED API will not work anymore: the colors

indicated in any application will not work: the only way to turn on the

LED is to use SettingsExtra.

Note that no error will be generated when a third party will try to turn

on the LED: the LED will simply not work.

The Led colors, blinking effect and filters are configurable, but there is no UI available.

The configuration can be injected using a text file, for example:

com.example.myapplication,,00FFFF,
com.example.myapplication,display,FFFF00,blink,500,5000
com.example.myapplication,test,0000FF,blink,500,500
android,debugging,FF00FF,blink,500,5000

The file should contains only lines with that structure, it should be named SettingsExtraLedConfiguration.conf, and it should be push as:

adb push SettingsExtraLedConfiguration.conf /sdcard/

You can also generate the file directly on the phone, but it could be a bit difficult as the file needs to be formatted correctly.

The rules are:

- colors are in hexadecimal, and they can be generated here (any website will work fine): https://htmlcolorcodes.com/

- the structure of every line is:

application package name, string, color, blink?, milliseconds ON, milliseconds OFF

where:

- application package name: the application package name, for example com.whatsapp for Whatsapp or com.android.settings for the Android Settings. You can use simple 'android' for the SystemUI notification (for example for the USB debugging notification)

- string: a word or a phrase to match the title of the notification. For example, setting as application package name 'com.whatsapp' and as string 'Name Surnane', this rules will only apply to notifications including the text 'Name Surname' in the notification title. Useful to filter for particular contact, for example. It is case insensitive. Leave this field empty to assign the same color to all the notifications from the indicated application.

- color: the hexadecimal color of the led

- bling: use the work 'blink' if you want the led to blink. Leave this empty, and not include the milliseconds parameters if you want the led to be always on

- milliseconds ON: integer value to indicate how much the led should stay on

- milliseconds OFF: integer value to indicate how much the led should stay off

The led is hardcoded to be yellow while the phone is charging and green when the phone is charging but with 100% battery.

The priorities are:

- the charging led colors have the lowest priority -> if a notification with a color is present, the charging status will not be shown

- if multiple notifications are present, the latest notification color is shown

- when one notification goes away, the color of the latest notification appeared will be shown

- the rule with a string indicated has priority over a rule for the same app but without matching string.

When the Led Manager is enabled from SettingsExtra, it is already working but I suggest a reboot so that the application can get all the notifications from the boot.

When the configuration file is updated, restart the manager from SettingsExtra (turn the LED manager option off and on again) or reboot the phone to load the new rules.

*as clarification, with 'stock recovery' the stock recovery from this ROM is intendend (not the Oxygen OS recovery).