BlackBerry Key2

1: Installing platform tools

On Linux install the 'android-tools' package.

On Windows and macOS download the command-line tools from https://developer.android.com/tools/releases/platform-tools and extract the downloaded .zip file.

2: Install the magisk app

NOTE: If you already have magisk installed skip to step 5.

Download the magisk app from the magisk github repo, you need 'Magisk-{version.number}.apk'.

3: Patching boot.img

3.1: Downloading boot.img

If you're using Krab-Ubica's LineageOS build skip this section and use the boot.img file included with it

Download the latest LineageOS OTA update. Link to current version

Once the download completes extract the downloaded .zip file.

Inside of the folder you extracted the zip file to there will be a boot.img file, move this file to your phone. If you do not know how follow steps 3.2 or 3.3.

3.2: Using USB file transfer

Requirments: You have a computer running windows or linux. In 'Trust' settings 'Restrict USB' does NOT block all connections.

NOTE: macOS does not have the ability to connect to MTP storage device so follow section 3.3 instead if you use macOS.

Plug your phone into your computer.

Open the settings app. Go into Connected devices, USB. If there is no USB menu option unplug and replug your phone from your computer and if this still does not fix this use a different cable.

Set 'Use USB for' to 'File Transfer'

Your phone now should be seen as a usb storage device inside you file manager, copy your boot.img file somewhere on your phone.

NOTE: If you unplug your phone this setting will not be saved for the next time it's pluged in to a computer.

3.3: Using wireless file transfer via localsend

See https://github.com/localsend/localsend

Transfer boot.img to your device

3.4: Patching boot.img

Open the magisk app

To the right of the of where it has the magisk logo and says magisk press the install text.

Set the method to 'Select and patch a file'

A file manager window should open, find where you copied your boot.img file and tap on it

Press the 'LET'S GO' text.

Once the text 'All done!' is printed close the magisk app.

Copy the magisk_patched-{random_text}.img file in your phone's downloads folder to your computer.

4: Flashing magisk

Power off your phone.

Once you phone is fully powered off hold the power and volume down buttons until the bootloader is shown.

Connect your phone to your computer

Open a terminal window. If you don't know how see section 4.1.

(Windows, macOS): Enter the folder you extracted platfrom tools to (skip if you followed section 4.1)

NOTE: on windows instead of fastboot use .\fastboot.exe. on macOS instead of fastboot use ./fastboot.

Run fastboot devices in your teminal

If no devices are printed use a differnet cable.

(Linux): If you get a user needs to be in plugdev group error run fastboot as root.

(macOS): If you get a permission denied: ./fastboot error run chmod +x fastboot.

Run fastboot flash boot path/to/magisk_patched-{random_text}.img If you don't know the path to your magisk_patched-{random_text}.img file drag it from a file manager window into the terminal window.

Run fastboot reboot in your terminal.

Close your terminal window.

Continue to section 5.

4.1: Opening a terminal

Windows: Press the Windows and R keys at the same time, type cmd into the window that opened then press enter.

macOS: Type 'terminal' into spotlight and hit enter. If you don't know to open spotlight read this apple help page.

Inside the now open terminal window 'cd' then press the spacebar

Open a file manager window (on macOS this is finder, on windows this is explorer) go to where you extracted platform tools to and drag that folder into the terminal window then press enter.

Go back to following section 4

5: Installing integrity box

Download Integrity-Box from here, you need '{version}-Integrity-Box-{DD}-{MM}-{YYYY}.zip'.

Download ReZygisk from here, you need 'ReZygisk-{version}-release.zip'.

Download TEESimulator from here, you need 'TEESimulator-{version}-Release.zip'.

Open the magisk application.

Enter the modules tab by clicking on the puzzle piece icon in the bottom bar.

Press the button at the top of the screen that says 'Install from storage' it will open a file browser, open one of the downloaded zip files.

Once the restart button appears press the back key. DO NOT PRESS RESTART.

Repeat the previous to instructions until you have installed all 3 downloaded zip files.

Reboot device.

Open the magisk app and go into the modules tab.

On the card for .Integrity Box tap the 'Action' text.

Press the 'Close' button once it appears

6: Post install configuration

(Optional) Install the KsuWebUIStandalone app to be able to use the Intgerity box configuration ui.

In the magisk app tap on the cog icon in the top right corner

Enable 'Enfore DenyList'

(Optional) Tap 'Configure DenyList' and tick the checkboxes for apps you want to hide magisk from. (eg. google messages, google wallet)

Set 'Superuser access' to 'Apps only'

Set 'Mount namespace mode' to 'Isolated namespace'

(Optional) Set 'Automatic respose' to 'Deny'

In magisk's 'Superuser' tab enable the toggle for apps you want to have superuser access. (eg. Key Mapper, KsuWebUI, Aurora Store, Shizuku, Droidify, etc)

NOTE: The offical F-Droid app does not support rooted/automatic app insallation so I recommend switching to the Droid-fiy client.

1: Prerequisites

Have ADB and fastboot installed

Your device's bootloader is unlocked as shown in Bochenek's guide.

NOTE: If you don't know the path of a file you can drag it from your filemanager into a terminal window

2: Backing up data with seedvault

NOTE: This section is *completely* optional

Open settings and go into system: backup: Seedvault backup

If you haved logged into google account on the device you will need to set the backup provider to seedvault

Go thru the prompts to setup seedvault

MAKE SURE TO WRITE DOWN YOUR BACKUP KEYS YOU WILL NEED THEM LATER

Enable the 'Backup my apps' option

Press the three dots icon the right corner and select 'Backup Now' option

DO NOT set the backup location to you internal storage as it will be wiped when flashing the rom. I recommend using a usb drive or an SD card.

Proceed to step 3 one your backup has finished

NOTE: Make sure to manually backup your pictures and DCIM folders as these are not covered by seedvault

3: Flashing the rom

WARNING: THIS WILL DELETE ALL DATA STORED ON THE DEVICE

Download the Crab-Ubica rom build from here then extract the downloaded zip file

Power off you device then hold volume down and power until the bootloader menu is shown

Run fastboot -w

Run the following commands fastboot flash recovery /path/to/recovery.img,fastboot flash system /path/to/system.img,fastboot flash vendor /path/to/vendor.img

If you want google services follow section 3.1 then come back to this step.

Run fastboot flash boot /path/to/boot.img

Once all the files are flashed run fastboot reboot

OPTIONAL: install either Krab-Ubica's keyboard or Hazem's updated blackberry keyboard build.

3.1: Flashing gapps

Run fastboot flash boot /path/to/recovery.img reboot

Once the recovery menu appears go into 'Apply update', 'Apply update from adb'

Run adb sideload /path/to/gapps.zip once the signature verification failed message appears select yes

Once that finishes select 'Factory reset' then 'Format data / factory reset'

Select 'Advanced' then 'Reboot to bootloader'

3.2: Restoring backup

In the oobe continue setup until you get restore apps and data section

Select next select the storage media you backed up to (if you backed up to a usb drive plug that in now)

Wait unitl it finds your backup

Input you 12 word code you wrote down earlier

NOTE: if you did NOT write it down you will not be able to restore your backup

Select the latest backup

Unselect any google services (eg: 'Digital Wellbeing', 'Google Play Store', 'Speech Recogtinion and Synthsis from Google', 'Google Play Services', 'Google' etc)

If you rooted your phone uncheck the root app you used (eg: magisk, apatch)

Press the 'Restore backup' button

Wait for restore to finish, it will take a while

Once the 'Next' button turns blue press it

Once the 'Finish' button turns blue press it

Select reuse backup and skip restoring files

Continue oobe as normal

1: Prerequsites

You have ADB and fastboot installed

You are running an older version of the rom

NOTE: acording to Krab-Ubica downgrading is possible if the rom is signed with the same signature.

2: Updating the rom

Download the latest version posted on discord, currently that's 1.2A

If your phone is rooted patch the boot.img file included with the new build

Power off you device then hold volume down and power until the bootloader menu is shown

Run the following commands fastboot flash recovery /path/to/recovery.img,fastboot flash system /path/to/system.img,fastboot flash vendor /path/to/vendor.img

If you want google services follow section 2.1 then come back to this step.

Run fastboot flash boot /path/to/boot.img if your phone is rooted use your patched file instead

Run fastboot reboot

2.1: Flashing gapps

Run fastboot flash boot /path/to/recovery.img reboot

Once the recovery menu appears go into 'Apply update', 'Apply update from adb'

Run adb sideload /path/to/gapps.zip once the signature verification failed message appears select yes

Select 'Advanced' then 'Reboot to bootloader'