ubports / ubuntu-touch

Ubuntu Touch's issue inbox is now migrated to GitLab.
https://gitlab.com/ubports/ubuntu-touch
1.28k stars 110 forks source link

Anbox Installation on Nexus 7 2013 (deb) #1565

Open hesoyamhh opened 4 years ago

hesoyamhh commented 4 years ago

Hi Team,

Thank you for maintaining Ubuntu Touch. I am planning to install it on my Nexus 7 (2013) (deb) and according to documentation, only selected devices are compatible with Anbox for running Android Apps. (https://docs.ubports.com/en/latest/userguide/dailyuse/anbox.html)

Can you please let me know the possibility of making patched boot img for 'deb' or instructions for creating patched boot image so that I can try by my own (If there are pre-defined steps) ?

UniversalSuperBox commented 4 years ago

Hi @hesoyamhh,

I had to go on a bit of a hunt to find the appropriate steps for you here. This is by no means an easy project, but it is one that I'd like to help you with.

Our current distribution of the deb device was taken wholesale from before 2017 when Canonical dropped the project and redistributed. This includes the kernel and Android container image. Unfortunately, the original repositories which hosted this code have gone offline. Fortunately, I took a backup for exactly this purpose.

I was pretty sure that the kernel was the same for flo and deb, and that has now been confirmed as the case by the device/asus/deb/ tree from Canonical: https://github.com/ubports-android/aosp_device_asus_deb

This means that https://github.com/ubports/ubuntu_kernel_xenial/tree/flo is your best chance for getting this working. Building and flashing this kernel using the instructions provided at the top of the README will be the first step. Then take your boot.img, you can find it inside the current device tarball (.tar.xz download link to current deb device tarball), and repack it with your new kernel using abootimg for flashing. See "Extract boot.img content" and "Repack boot.img" on Android boot.img manipulation. Then you can flash your new boot image with Fastboot.

If that works, you can then add the following two commits to add and enable the Anbox binder. Build the kernel again, repack the boot image, flash it, and see if the device boots. Then, try installing Anbox.

https://github.com/ubports/android_kernel_lge_hammerhead/commit/d72ff7f655ac64ba94c485098817ededf1949608 https://github.com/ubports/android_kernel_lge_hammerhead/commit/b2a8b31816bdbf227446bc0ffeb24870297ef93e

We can take our next steps from there.

I'm a little concerned that the current tip of the flo branch isn't actually the code running on the deb device right now. The deb kernel may predate the current flo branch, meaning your build won't work correctly. Please let me know how you get on with these builds and where I might be of assistance.

hesoyamhh commented 4 years ago

Sorry but I don't know anything about this. I only know how to install recovery and flash Custom ROMs.

ameyagokhale commented 4 years ago

Let me try to take this up.

Thanks @UniversalSuperBox for this info.

I am preparing modified boot.img in the given flow:

  1. Clone ubuntu flo kernel, merge the given 2 commits and then build the zImage
  2. Download deb device tarball, extract boot.img, use abootimg to extract and then replace the zImage built in step 1 and create modified boot.img.

In parallel, I will be installing Ubuntu Touch on my N7 2013 (deb) using the installer and once that is done and I am able to boot into ubuntu, I will flash the modified boot.img and check whether I am able to boot inti ubuntu-touch again and if yes, then execute commands to install Anbox.

Does this seem correct ?

ameyagokhale commented 4 years ago

@UniversalSuperBox Update

Was able to create modified boot.img with commits to add and enable the Anbox binder: ut_boot_anbox_deb.img

Was also able to flash using fastboot flash boot ut_boot_anbox_deb.img and successfully booted into Ubuntu Touch.

Was facing some issues with storage in /var and so created symlink for apt directory in userdata.

mkdir -p /userdata/var/cache/ 
mv /var/cache/apt/ /userdata/var/cache/  
ln -s /userdata/var/cache/apt/ /var/cache/apt

And then, was able to update using sudo apt update && sudo apt upgrade Also, Installed sudo apt install anbox-ubuntu-touch android-tools-adb

Followed anbox installation but received:

root@ubuntu-phablet:/var/cache# anbox-tool install  
deb is not supported (yet)

What needs to be done so that Anbox can support deb ?

ameyagokhale commented 4 years ago

@UniversalSuperBox Modified Kernel code for Anbox: https://github.com/ameyagokhale/ubuntu_kernel_xenial/tree/flo

UniversalSuperBox commented 4 years ago

Hi @ameyagokhale, this is awesome!

I've added flo and deb to https://cdimage.ubports.com/anbox-images/devices.json so they can correctly retrieve the Android image. Now you should be able to use anbox-tool install again.

ameyagokhale commented 4 years ago

@UniversalSuperBox My N7 was able to download anbox img but installation failed for 64binder.img

phablet@ubuntu-phablet:~$ anbox-tool install
/home/phablet/anbox 100%[===================>] 207.16M  4.32MB/s    in 45s
start: Job failed to start
start: Unknown job: anbox-session

^CTraceback (most recent call last):
  File "/usr/bin/anbox-tool", line 329, in <module>
    enable()
  File "/usr/bin/anbox-tool", line 192, in enable
    waitForAnbox()
  File "/usr/bin/anbox-tool", line 180, in waitForAnbox
    time.sleep(1)
KeyboardInterrupt

phablet@ubuntu-phablet:~/anbox-data$ anbox-tool status
Kernel: OK
System: OK
Enabled: YES
Running: NO
ameyagokhale commented 4 years ago

Opened new issue in anbox project: https://github.com/ubports/anbox/issues/42