Monday, November 10, 2014

The internals of running Fedora22 in a large screen phone.

All the internals are included in my Fedora...21-6.tar.gz and no need to do it if you just extract my Fedora...22-6.tar.gz .

Stop process killer

If you replace the adjusting of process killing priorities in starts.sh with below one line,
echo '0,0,0,0,0,0' > /sys/module/lowmemorykiller/parameters/minfree
, your desktop mate will not be killed when you switch to android. But with my 2g memory with android 5.1 , I often run out of memory with just 3 apps, like a browser and a map and a music player and the system freezes requiring reset.

Run X with mate session


Put a am start -n com.package.name/com.package.name.ActivityName
in /data/local/fedora/startx.sh .  ActivityName is often “MainActivity”. This is needed because the Startup app often can’t time the startup sequence and the XSDL X app needs time before accepting mate session. startx.sh can also periodically set XSDL priority to -17 to prevent app closing by android system. This is already included in my Fedora22...5.tar.gz,
# cat /mnt/tmp/bin/android-startx.sh
#!/system/bin/sh
am start -n x.org.server/x.org.server.MainActivity
# the 3 minute sleep allows the android's process killer to kill off
# unused apps before we enter the Desktop mode when 000000 cancels
# all killings.
sleep 180
echo '0,0,0,0,0,0' > /sys/module/lowmemorykiller/parameters/minfree

Chroot enter the PC operating system

# cat /mnt/tmp/bin/android-enter-chroot-fedora.sh
#!/system/bin/sh
export fedora="/data/local/chroots/fedora"
/system/xbin/busybox mount -t proc proc $fedora/proc
/system/xbin/busybox mount --bind /sys $fedora/sys
/system/xbin/busybox mount --bind /dev $fedora/dev
/system/xbin/busybox mount -t devpts devpts $fedora/dev/pts
#/system/xbin/busybox mount --bind /storage/sdcard1 $fedora/root/SDCard
export TERM=vt100
export HOME=/root
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin:.
export SHELL=/usr/bin/bash
export EDITOR=vi
if [ ! -d /dev/shm ] ; then /system/xbin/busybox mkdir /dev/shm ; fi
/system/xbin/busybox chroot $fedora $SHELL -l



Run Mate' desktop

At chroot entering the PC operating system, which includes login, the root account's bash init script is responsible to invoke mate-session .
[root@android01 ~]# tail .bash_profile
if ! test -d /dev/shm ; then mkdir /dev/shm ; fi
export HOSTNAME=android01
hostname android01
export DISPLAY=:0
if test -z "`pidof sshd`" ; then /usr/sbin/sshd; fi
if test -z "`pidof mate-session`" ; then mate-session & fi 2>/dev/null
if test -z "`pidof Xvnc`" ; then vncserver -geometry 1920x1080 -localhost ; fi
[root@android01 ~]#

Development work 

For smooth terminal without "Queue background data", disable Xperia's Settings->Power Management->Queue background data, disable the Settings->WiFi->Settings-> Advanced->WiFi optimization to save power.
You can't edit source code through WIFI to the phone when vim's key strokes are delayed and come in bursts. Disable the queuing option is a must.

Flash player and chromium browser

Archlinux generously gives out builds at http://us.mirror.archlinuxarm.org/armv7h . And I donated to it multiple times. I have also subscribed to RedHat enterprise for 1 year, which the payout should reach Fedora developers.

 More internal works 

The source image we receive from redhat is often a dd image dump of a working fedora arm installation, and we are expected to be able to mount the filesystem inside the dd raw image when the raw image is burned to a USB flash. In an android phone, the mouting utility may or may not be able to mount ext4 or other file systems due to pared down phone kernel. So, we need to mount it with a desktop pc linux. With a desktop pc, we don't need to burn USB, and we can just mount with offset to the root partition of the raw image. To figure out the offset, use fdisk to look at the raw image. The starting block number of the root partition times the number of bytes per block is the offset.  For example,
mount -o offset=4096 Fedora-sda.raw /tmp/chroots/fedora 
, assuming root partition starts at block 8, and block size is 512.

No comments:

Post a Comment