XZ-premium

Sony is one of the few companies that actually take the OHA seriously and while various other companies tend to shy away from releasing device trees and libraries, Sony takes it all a step further with their Open Devices Program

The inclusion of XZ Premium to Sonyโ€™s Open Devices program enables you to build and flash any flavour of Android on your device. It must be noted that the software is meant for developers and โ€˜flashaholicsโ€™ and can be unstable due to its early stage implementation.

Building an AOSP ROM

Given below is a detailed set of instructionsย in case anyone is interested in building an AOSP ROM for the device

Prerequisites

This guide assumes you run Ubuntu, but it should work in a similar way on any Linux-based system. To useย these instructions, you should be familiar with Android development. Follow the steps below to build Android Nougat on an unlocked Xperia device.

  1. Prepare Your Java Environment
    In a terminal window, enter the following commands:
    sudo apt-get purge openjdk-\* icedtea-\* icedtea6-\*
    sudo apt-get update
    sudo apt-get install openjdk-8-jdk
    java -version
  2. Install the necessary tools to make an Android build
    In a terminal window, enter the following commands, all at once:
    sudo apt-get install bison g++-multilib git gperf libxml2-utils make zlib1g-dev:i386 zip
  3. Download Repo tool and set PATH
    In a terminal window, enter the following commands to download and install Repo, and set the right access rules for it:
    mkdir ~/bin
    curl https://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
    chmod a+x ~/bin/repo

    Open the bashrc file included in the repo tool:

    sudo nano ~/.bashrc

    To set the right path for your local bin folder, paste the following code to a new line at the very bottom of the bashrc file, and then save the file using Ctrl+X:

    export PATH=~/bin:$PATH

    Reload bash variables to include the new path:

    source ~/.bashrc
  4. Initialise the AOSP tree
    In a terminal window, enter the following commands:
    mkdir ~/android
    cd ~/android
    repo init -u https://android.googlesource.com/platform/manifest -b android-7.1.2_r17

    Clone the local_manifests from GitHub using the following commands

    cd .repo
    git clone https://github.com/sonyxperiadev/local_manifests
    cd local_manifests
    git checkout n-mr1_4.4
    cd ../..

    To download the code into the device repos created above, run the command

    repo sync
  5. Add necessary patches from the AOSP upstream branch
    In a terminal window, enter:
    cd external/toybox
    git fetch https://android.googlesource.com/platform/external/toybox refs/changes/74/265074/1 && git cherry-pick FETCH_HEAD
    git cherry-pick d3e8dd1bf56afc2277960472a46907d419e4b3da
    git cherry-pick 1c028ca33dc059a9d8f18daafcd77b5950268f41
    git cherry-pick cb49c305e3c78179b19d6f174ae73309544292b8
    cd ../libnfc-nci
    git fetch https://android.googlesource.com/platform/external/libnfc-nci refs/changes/52/371052/1 && git cherry-pick FETCH_HEAD
    cd ../../hardware/qcom/bt
    git fetch https://android.googlesource.com/platform/hardware/qcom/bt refs/changes/99/422499/1 && git cherry-pick FETCH_HEAD
    git fetch https://android.googlesource.com/platform/hardware/qcom/bt refs/changes/00/422500/1 && git cherry-pick FETCH_HEAD
    cd ../audio
    git fetch https://android.googlesource.com/platform/hardware/qcom/audio refs/changes/91/294291/1 && git cherry-pick FETCH_HEAD
    git fetch https://android.googlesource.com/platform/hardware/qcom/audio refs/changes/35/274235/9 && git cherry-pick FETCH_HEAD
    git fetch https://android.googlesource.com/platform/hardware/qcom/audio refs/changes/86/333386/1 && git cherry-pick FETCH_HEAD
    cd ../media
    git fetch https://android.googlesource.com/platform/hardware/qcom/media refs/changes/39/422439/1 && git cherry-pick FETCH_HEAD
    git fetch https://android.googlesource.com/platform/hardware/qcom/media refs/changes/79/422379/1 && git cherry-pick FETCH_HEAD
    cd ../../../system/core
    git fetch https://android.googlesource.com/platform/system/core refs/changes/52/269652/1 && git cherry-pick FETCH_HEAD
    git fetch https://android.googlesource.com/platform/system/core refs/changes/12/373812/1 && git cherry-pick FETCH_HEAD
    cd ../../packages/apps/Music
    git cherry-pick 6036ce6127022880a3d9c99bd15db4c968f3e6a3
    cd ../../../frameworks/av
    git fetch https://android.googlesource.com/platform/frameworks/av refs/changes/92/384692/2 && git cherry-pick FETCH_HEAD
    cd ../../
  6. Build AOSP images that can be flashed
    Enter the following commands:
    source build/envsetup.sh && lunch
    make โ€“j
  7. Flash AOSP image to your device
    On your device: Connect the device to your computer in Fastboot mode, by pressing volume up while inserting the USB cable. When the device is in Fastboot mode, the LED on the device will be illuminated in blue.
    On your computer: Flash the boot, system and userdata images by entering the following commands in a terminal window:
    fastboot โ€“S 256M flash boot out/target/product//boot.img
    fastboot โ€“S 256M flash system out/target/product//system.img
    fastboot โ€“S 256M flash userdata out/target/product//userdata.img

If all steps are followed correctly, your device should now be running an AOSP Nougat 7.1 build.


Sarang Avatar


Leave a Reply