NOTE, THIS DOESN’T WORK FOR ME :(
I was not able to get this to work. Something about compiling the required apps mentioned in the instructions below. Adding the patches worked fine. I compiled source verified install worked on phone. Then I compiled source with patches added, and verified it worked on the phone.
As soon as I compiled in the SolidHal apps (PRODUCT_PACKAGES += GmsCore GsfProxy FakeStore FDroid FDroidPrivilegedExtension auroraservices) per the instructions below. Not sure what’s wrong here but above my skillset.
Recently I upgraded the deck in my truck to a fancy one with a screen, and, Android Auto. Being the privacy nerd I am, I use GrapheneOS on my phone, which, doesn’t work with Android Auto (obviously).
I found some random posts on Reddit, CalyxOS forums and more of others trying to get it working, and some people were successful so I thought I’d give it a try.
Unfortunately, I was not able to get it working :(
However, I thought I’d document the steps incase I decide to come back to it, and, maybe someone else with more time than me can get this working!
This assumes you are using Ubuntu 22 LTS. I am using a Pixel 5a (barbet) for this tutorial.
Here’s what you need to do to get started.
Prerequest software setup
First you’re going to need to make sure all your basics are setup and ready (I found out the hard way an hour into compiling I was missing things, three times!). Do this first to make sure you’re ready to go. This assumes you’re logged in as a user account, not, root directly.
Also, make sure you have around 500GB free on your hard drive, this takes some space.
$ sudo apt-get update $ sudo apt-get upgrade $ sudo apt-get install bison openssl libssl-dev gnupg2 simg2img signify-openbsd libncurses5 zip openjdk-18-jdk-headless $ sudo ln -s /usr/bin/signify-openbsd /usr/bin/signify $ sudo snap remove git-repo $ sudo apt-get install repo $ sudo apt-get remove cmdtest $ sudo apt-get remove yarn $ sudo curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - $ sudo echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list $ sudo sudo apt-get update $ sudo apt-get install yarn -y $ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash $ nvm install 18.4.0 $ curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash - $ pip install -Iv protobuf==3.20.1 $ sudo ln -s /home/$LOGUSER/.nvm/versions/node/v18.4.0/bin/node /usr/bin/node $ sudo apt autoremove
I also had to re-run the last few as root, for later in the instructions. Note the only difference here is ‘sudo’ which will install it as root, not, the user account you’re logged in under.
$ sudo curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash $ sudo nvm install 18.4.0 $ sudo curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash - $ sudo pip install -Iv protobuf==3.20.1
Make sure git is setup;
$ git config --global user.email "firstname.lastname@example.org" $ git config --global user.name "some name"
Get the Android developer tools just to make sure everything is good with your connection, this probably isnt’ needed, but i like to be cautious. Unplug your phone from computer if it’s plugged in.
$ sudo usermod -aG plugdev $LOGNAME $ sudo apt-get install android-sdk-platform-tools-common $ cd ~ && mkdir sdk $ wget https://developer.android.com/studio/releases/platform-tools/platform-tools_r33.0.2-linux.zip $ mv platform-tools_r33.0.2-linux.zip ./sdk $ cd sdk $ unzip platform-tools_r33.0.2-linux.zip $ cd ~/sdk/platform-tools
Now plug your phone in
$ ./adb devices
should show you
$ ~/sdk/platform-tools$ ./adb devices List of devices attached XXYY123456BBAA device
Now, we just need to add the SDK path to our login. This assumes you’re using bash as a shell (zsh will be the same though just in .zshrc);
$ nano .bashrc
and paste this at the bottom of the file changing user to your user.
now exit and save your file. you can now log out and log back in, or, run ;
$ source .bashrc
to enable your changes.
Start the GrapheneOS compiling
This is where we start the compiling process of the GrapheneOS Android OS for your phone. This portion takes quite some time (around 200gb of files are downloaded).
$ cd ~
Sync the repository of the latest Graphene release. For me this was 220605.009.A1.2022062200. Yours may change, please see the Releases Page.
$ mkdir grapheneos-SQ3A.220605.009.A1.2022062200_modified $ cd grapheneos-SQ3A.220605.009.A1.2022062200_modified $ repo init -u https://github.com/GrapheneOS/platform_manifest.git -b refs/tags/SQ3A.220605.009.A1.2022062200 $ sudo cp ~/grapheneos-SQ3A.220605.009.A1.2022062200/.repo/repo/repo /usr/bin/repo $ repo init -u https://github.com/GrapheneOS/platform_manifest.git -b refs/tags/SQ3A.220605.009.A1.2022062200
$ gpg --recv-keys 65EEFE022108E2B708CBFCF7F9E712E59AF5F22A $ cd .repo/manifests $ git verify-tag $(git describe) $ cd ../..
Now, we sync the source. On Starlink this took approximately 2 hours (around 150ish GB).
$ repo sync -j16
Now we build the kernel.
$ cd ./kernel/google/barbet/ $ git submodule sync $ git submodule update --init --recursive $ ./build.sh barbet $ cd ../../..
Now we build AAPT.
$ cd vendor/adevtool/ && yarn install && cd ../.. $ source script/envsetup.sh $ m aapt2
Now we can start the rest of the setup. This will download the sources and put everything where it needs to be to modify, and build the OS.
$ vendor/adevtool/bin/run download vendor/adevtool/dl/ -d barbet -b SQ3A.220605.009.A1 -t factory ota $ sudo vendor/adevtool/bin/run generate-all vendor/adevtool/config/barbet.yml -c vendor/state/barbet.json -s vendor/adevtool/dl/barbet-sq3a.220605.009.a1-*.zip $ sudo chown -R $(logname):$(logname) vendor/google_devices $ vendor/adevtool/bin/run ota-firmware vendor/adevtool/config/barbet.yml -f vendor/adevtool/dl/barbet-ota-sq3a.220605.009.a1-*.zip
Now we want to go ahead and download the patches, and additional apps we’ll be trying to use.
$ mkdir solidhal $ cd solidhal $ git clone https://github.com/SolidHal/android_prebuilts_solidhal.git . $ cd ~ $ git clone https://github.com/SolidHal/Build-GrapheneOS-Microg-AndroidAuto-Oriole-Raven.git
Now we want to apply the patches found in the SolidHal repo. First we’re going to setup the base system.
$ nano build/target/product/base_system.mk
PRODUCT_PACKAGES += GmsCore GsfProxy FakeStore FDroid FDroidPrivilegedExtension auroraservices
Exit and save the file. Now let’s apply some patches.
$ cd frameworks/base $ git am ~/Build-GrapheneOS-Microg-AndroidAuto-Oriole-Raven/patches/sig_spoofing/android_frameworks_base-S.patch Applying: Add support for app signature spoofing $ git am ~/Build-GrapheneOS-Microg-AndroidAuto-Oriole-Raven/patches/android-auto-12.patch Applying: Allow required Android Auto permissions
$ cd ../../packages/modules/Permission $ git am ~/Build-GrapheneOS-Microg-AndroidAuto-Oriole-Raven/patches/sig_spoofing/permissionControllerPatch.patch Applying: Utils: add FAKE_PACKAGE_SIGNATURE to platform permissions
Then. This patch wasn’t able to install for me, so I had to manually edit it.
$ cd ../../../device/google/barbet/barbet/overlay/frameworks/base/core/res/res/values/ $ nano config.xml
add in this before the closing resources tag at the bottom
<!-- Force-enable the location overlays --> <bool name="config_enableNetworkLocationOverlay" translatable="false">true</bool> <bool name="config_enableFusedLocationOverlay" translatable="false">true</bool>
Now, our patches are applied. And we can start the build.
$ source script/envsetup.sh $ sudo chown -R $USER:$USER vendor/adevtool/dl/* $ choosecombo release barbet user
Generate our keys for this test compile;
$ mkdir -p keys/barbet $ cd keys/barbet $ ../../development/tools/make_key releasekey '/CN=GrapheneTest/' $ ../../development/tools/make_key platform '/CN=GrapheneTest/' $ ../../development/tools/make_key shared '/CN=GrapheneTest/' $ ../../development/tools/make_key media '/CN=GrapheneTest/' $ ../../development/tools/make_key networkstack '/CN=GrapheneTest/' $ openssl genrsa 4096 | openssl pkcs8 -topk8 -scrypt -out avb.pem $ ../../external/avb/avbtool extract_public_key --key avb.pem --output avb_pkmd.bin $ cd ../.. $ signify -G -n -p keys/barbet/factory.pub -s keys/barbet/factory.sec
Build Target files, OTA package, Release. This will take a while depending on your hardware.
$ m target-files-package $ m otatools-package $ script/release.sh barbet
Now, what I did here which is optional but highly recommended. I found a USB C -> USB A hub and 128gb Flash drive I happened to have. Then I formatted the drive, and plugged the reader and drive into my phone which then gave me the option to select it as a backup device. To do this, just format your USB (I used
Fat32), then plug it into the phone and when you go to
settings -> system -> backups you should now see your usb drive listed. Select it, select what you want to backup and press submit. Wait until it’s backed up before proceeding!
Once your backup is completed, or not, up to you, contiunue with actually flashing your phone with your build! Reboot the phone into bootloader -
turn the phone off, then hold the volume down button while the phone boots up. This should present you with the bootloader screen. First we’re going to want to unlock it (note: I was already on GrapheneOS so it was already unlocked, if you’re doing this from stock, unlocking your phone’s bootloader first!)
$ fastboot flashing unlock
Now your phone is ready to be flashed!
$ cd out/release-barbet-2022062600 $ unzip barbet-factory-2022062600.zip $ cd barbet-factory-2022062600 $ ./flash-all.sh
This process is going to take a while. Do not unplug your phone or you’ll probably brick it. Just let everything happen and watch the console output as it’s going.
Once it’s done, your phone will reboot back to the fastboot screen, so run this;
$ fastboot flashing lock
The phone will reboot now and you should see your bootloader showing as ’locked’ in green. Press the ‘power’ button to start the boot process and see if this worked.
If it does work, and you’re back into your phone, this is how you continue.
- open microg, give it all the permissions
- install some location backends into microg
- install the AndroidAuto app from aurora store
- install the Gapp stub and speech services stubs from https://github.com/SolidHal/android-auto-stub
- open AndroidAuto once, give it all the permissions
- in settings, also give AndroidAuto permission to detect nearby devices (needed for bluetooth)
- The first time you setup AA with a car’s headunit you usually need to reboot, when you first plug in it’ll mention there’s no apps that can handle the device, once you reboot AA should be available.
Hopefully you can get it working, I spent the better part of a week on this and could never figure it out!
Reverting to factory google images if you want
GrapheneOS Build instructions from here;
GrapheneOS install documentation;
Graphene OSReleases page;
Android Prebuilts by SolidHal;
Android Auto for GrapheneOS Patches;