Skip to content

Android Server

What are you to do with two 1/2 working Google Pixel 5 phones? Mic is messed up in one, both have broken screens and you are sharing one display between the two devices. Do you recycle them? Sell them on a marketplace for pennies?

If you are a Linux junkie and have some Android know-how you think 🤔 headless Android servers in the rack.

Because regardless of what Reddit says, as long as you have a 1/2 functional screen for the initial setup you can 100% run Android headless and with help from tools like scrcpy you don't need displays.

Hardware

The Pixel phone is no slouch in performance! Besides imagination I don't see why we can't do something cool with all this compute.

Processors
    Qualcomm®5 Snapdragon™ 765G
    2.4 GHz + 2.2 GHz + 1.8 GHz, 64-bit Octa-Core
    Adreno 620

Memory
    8 GB LPDDR4x RAM

Storage
    128 GB storage

Ports
    USB Type-C® 3.1 Gen 1

Wireless
    Wi-Fi 2.4 GHz + 5 GHz 802.11a/b/g/n/ac 2x2 MIMO
    Bluetooth®11 5.0 + LE, A2DP (HD codecs: AptX, AptX HD, LDAC, AAC)

Dongle

Using a type-c dongle to split my power and data allows a fast charger to supply enough power, and a bog standard USB - Ethernet adapter.

usb to type-c dongle

Ethernet

Although WiFi is really stable with these devices I think I want to go Ethernet. I found some dongles that give me independent power in, and a separate USB for data. The TP-Link ue306 should do what I need and has great Linux support.

usb to ethernet dongle

Power

We don't want to leave the batteries plugged in 24/7 for obvious reasons 🔋 = 🔥☠️ at some point. Battery manufacturers of small devices have proven to be untrustworthy, and any powered battery in my house better be a tried and tested UPS to give me any sort of confidence the house won't burn down 😅

Smart Plug

I register each droidsrv phone with Home Assistant. I don't need access to the dashboard but the sensor monitoring pretty much solves that issue way better than scripting adb commands to get relevant data from the devices. For tablet devices around the house I have a smart plug toggle power based on the devices battery state 80% turn off / 20% turn on.

No Battery

If you want to remove the battery we need to do a bit of work. Is the method scalable? Can I use one battery PCB for multiple devices?

mobile phone battery PCB

  • You will need to cut the small battery management PCB from the battery

  • Solder 3 wire to the battery management board. (1 wire to battery [B+], and 2 wire to battery[B-])

  • Connect one of 2 wire that connected to battery [B-] terminal to a ground point of the pixel main PCB.

  • Supply power to the device with about 4.2V PSU


Quote from author of battery post:

I tried some ground points of the pixel main board. Some point will allow the phone power up but cannot pass the boot screen. The most easy and fully working ground point is the bolt that hold LCD cable.

battery PCB externally soldered to phone

OS

I opted to go LineageOS 21 Android 15 for the base system with F-Droid and privileged extensions flashed.

On When Powered

If we are running Android like a server we want the devices to turn on when power is restored because I'm not walking to the rack and pressing power on each phone. There are many ways to do this, but we are using Google phones and Google says to use fastboot.

  1. Boot into Download Mode
  2. fastboot devices
  3. fastboot oem off-mode-charge 0

adb over TCP

In order to start adb over TCP after boot without needing to plug a USB cable or navigate a broken screen to turn on wireless debugging, we need root. With newer version of Android and LineageOS its becoming harder to accomplish this. Currently this is working but an OTA update may break root.

  1. Download current Magisk .apk from here
  2. Make a copy of the .apk but rename it to .zip
  3. cp Magisk.*.apk magisk_sideload.zip
  4. Reboot into your recovery and install update via sideload
  5. adb -d sideload magisk_sideload.zip accept not valid signature
  6. Reboot
  7. Install the Magisk app adb install Magisk.*.apk

At this point I rebooted and tried to elevate my shell adb shell su

Check that your shell is root with the id command. Set system property to allow adb / TCP at boot with setprop persist.adb.tcp.port 5555

Note: This may all be possible with Termux and boot scripts starting adbd. Check out my blog post for the instructions on how to get that working. Open your script with the required shebang and you may only need to call the adbd package to start listening on boot.