To be honest, I have never really paid attention to VNC. I learned about VNC a few years ago, but I never had a use for it.

Recently, my Android device has been discontinued due to battery life issues, so I plan to keep it in a permanently plugged-in state (referring to charging).

For convenience, I directly installed Debian in Termux using a simple script.

One-click install Debian script: https://github.com/wahasa/Debian

One-click install Ubuntu script: https://github.com/MFDGaming/ubuntu-in-termux

However, I do not recommend using Ubuntu in Termux. Since Termux cannot use systemd, Ubuntu’s snapd cannot be used either. (But it seems there is a way if rooted.) Ubuntu is deeply tied to snap, and even if there is a way to remove snap, it can be quite troublesome. There is also very little optimization for arm64 processors in snap, so why not just use Debian directly?

For example, to install the Firefox browser through traditional deb in Ubuntu, you first need to use snap remove firefox to delete it, but… snap is completely unusable.

Phantom Process Killer

Starting from Android 12, there is a Phantom Process Killer mechanism that limits the number of background subprocesses for applications. Therefore, Termux can easily be killed, resulting in Process completed (signal 9). I used adb commands to disable this restriction.

ADB tool download link: https://developer.android.com/studio/releases/platform-tools

adb devices

adb shell "/system/bin/device_config set_sync_disabled_for_tests persistent"
adb shell "/system/bin/device_config put activity_manager max_phantom_processes 2147483647"
adb shell settings put global settings_enable_monitor_phantom_procs false

Another method is to find Feature flag in the developer settings and disable settings_enable_monitor_phantom_procs there. However, I don’t know why there is nothing in the feature flag on my phone.

Desktop Environment & VNC

To allow the VNC client to connect to Debian on the phone, a desktop environment must be installed first.

I used xfce, which can be installed directly using apt:

sudo apt install xfce4 xfce4-goodies

But you can also use @wahasa’s script, which also installs tigervnc and configures /.vnc/xstartup:

apt install wget -y ; wget https://raw.githubusercontent.com/wahasa/Debian/main/Desktop/de-xfce.sh ; chmod +x de-xfce.sh ; ./de-xfce.sh

Here, I used vnc-start to start the VNC Server, which can only listen on the local port and cannot be found on the local area network.

So I added a no localhost flag:

$ vncserver -localhost no

TightVNC

If you want to use TightVNC:

$ apt install tightvncserver

Delete Server: vncserver -kill :1

Change VNC connection password: vncpasswd

Then modify ~/.vnc/xstartup:

#!/bin/bash
xrdb $HOME/.Xresources
startxfce4 &

screenshot

More

You can also install gogs as a local Git server later.


Refs

https://docs.andronix.app/android-12/andronix-on-android-12-and-beyond