Saturday, March 2, 2013

Some notes on development for Ubuntu phone

QML client library for the indicators:

  http://bazaar.launchpad.net/~phablet-team/indicators-client

Contacts:
  https://launchpad.net/qt-folks

Messaging (telepathy), onscreen keyboard (maliit), etc
  https://launchpad.net/phablet-extras

Friday, March 1, 2013

A little script to setup Ubuntu phone after flashing

#!/bin/bash

exec_with_adb() {
    adb shell chroot /data/ubuntu /usr/bin/env -i PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin "$@"
}

adb kill-server
sudo adb start-server
adb wait-for-device
adb root
adb wait-for-device
adb shell setprop sys.usb.config rndis,adb
adb wait-for-device

mkdir -p $HOME/downloads/phablet-pkg
wget -c http://ports.ubuntu.com/ubuntu-ports/pool/main/libe/libedit/libedit2_2.11-20080614-5ubuntu1_armhf.deb -P $HOME/downloads/phablet-pkg
wget -c http://ports.ubuntu.com/ubuntu-ports/pool/main/o/openssh/openssh-client_6.0p1-3ubuntu1_armhf.deb -P $HOME/downloads/phablet-pkg
wget -c http://ports.ubuntu.com/ubuntu-ports/pool/main/o/openssh/openssh-server_6.0p1-3ubuntu1_armhf.deb -P $HOME/downloads/phablet-pkg

for f in $HOME/downloads/phablet-pkg/*.deb; do adb push $f /data/ubuntu/; done
exec_with_adb dpkg -i openssh-server_6.0p1-3ubuntu1_armhf.deb openssh-client_6.0p1-3ubuntu1_armhf.deb libedit2_2.11-20080614-5ubuntu1_armhf.deb


echo "Setup sudo"
exec_with_adb sed -i 's/%admin.*ALL=(ALL) ALL/%admin ALL=(ALL) NOPASSWD: ALL/' /data/ubuntu/etc/sudoers

echo "Setup ssh keys"
TARGET_IP=127.0.0.1
USER_ID=32011
echo "install_ssh_key"
ssh-keygen -R $TARGET_IP
HOME_DIR=/data/ubuntu/home/phablet
adb push ~/.ssh/id_rsa.pub $HOME_DIR/.ssh/authorized_keys
adb shell chown $USER_ID:$USER_ID $HOME_DIR/.ssh
adb shell chown $USER_ID:$USER_ID $HOME_DIR/.ssh/authorized_keys
adb shell chmod 700 $HOME_DIR/.ssh
adb shell chmod 600 $HOME_DIR/.ssh/authorized_keys

echo "Setup your NetworkManager for reverse tethering, please"
read
sshphablet sudo dhclient usb0 -v
echo "Waiting for connectivity"
while true; do sshphablet ping google.com -c1 && break; done

cat > /tmp/sources.list << EOF
deb http://ppa.launchpad.net/canonical-qt5-edgers/qt5-proper/ubuntu quantal main
deb http://ppa.launchpad.net/phablet-team/ppa/ubuntu quantal main
deb-src http://ppa.launchpad.net/phablet-team/ppa/ubuntu quantal main
deb http://ports.ubuntu.com/ubuntu-ports/ quantal main restricted universe multiverse
deb http://ppa.launchpad.net/m-gehre/ppa/ubuntu quantal main
EOF

echo "Pushing sources.list"
adb push /tmp/sources.list /data/ubuntu/etc/apt/sources.list

echo "Updating keys"
exec_with_adb apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 5C5364B55E51A24C
exec_with_adb apt-key adv --keyserver keyserver.ubuntu.com --recv-keys D1106511179518B2
exec_with_adb apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EB93C836EDDD560E

echo "Running apt-get update"
exec_with_adb apt-get -y update

Screenshot on Android

Do get a screenshot, run in a shell:
  adb shell screencap -p /data/tmp.png
  adb pull /data/tmp.png

Enable reverse tethering on Nexus 4/Ubuntu phone


First we'll activate the usb-networking on the phone:
  adb root
  adb shell setprop sys.usb.config rndis,adb

Note: If you get "error: insufficient permissions for device" trying to adb after this line, this is probably due to an udev bug. You can workaround it by
  adb kill-server
  sudo adb start-server

Wait until NetworkManager on your computer shows the new connection. (It will say "disconnected" after some time). Edit the connection, and change under "IPv4 Settings" the method from "Automatic" to "Shared to other computers". Reconnect that connection in NetworkManager.

Then log into the phone via ssh (important!) and run

  dhclient usb0 -v

Now you can check on the phone, if it works
   ping google.com