Anbox:容器中的 Android,anboxandroid


Anbox 實現分析 3:會話管理器與容器管理器的通信

 

 

 

Anbox源碼分析

https://blog.csdn.net/qq_36383272/category_9934190.html

 

Anbox 實現分析之 I/O 模型

https://blog.csdn.net/tq08g2z/article/details/79037764?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-1.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-1.control

 

 

Anbox

Anbox is a container-based approach to boot a full Android system on a regular GNU/Linux system like Ubuntu. In other words: Anbox will let you run Android on your Linux system without the slowness of virtualization.

Overview

Anbox uses Linux namespaces (user, pid, uts, net, mount, ipc) to run a full Android system in a container and provide Android applications on any GNU/Linux-based platform.

The Android inside the container has no direct access to any hardware. All hardware access is going through the anbox daemon on the host. We're reusing what Android implemented within the QEMU-based emulator for OpenGL ES accelerated rendering. The Android system inside the container uses different pipes to communicate with the host system and sends all hardware access commands through these.

For more details have a look at the following documentation pages:

Anbox is currently suited for the desktop use case but can be used on mobile operating systems like Ubuntu Touch, Sailfish OS or Lune OS too. However as the mapping of Android applications is currently desktop specific this needs additional work to supported stacked window user interfaces too.

The Android runtime environment ships with a minimal customized Android system image based on the Android Open Source Project. The used image is currently based on Android 7.1.1

Installation

See our installation instructions for details.

Supported Linux Distributions

At the moment we officially support the following Linux distributions:

  • Ubuntu 16.04 (xenial)
  • Ubuntu 18.04 (bionic)

However all other distributions supporting snap packages should work as well as long as they provide the mandatory kernel modules (see kernel/).

Install and Run Android Applications

TBD

Build from source

Requirements

To build the Anbox runtime itself there is nothing special to know. We're using cmake as build system. A few build dependencies need to be present on your host system:

  • libdbus
  • google-mock
  • google-test
  • libboost
  • libboost-filesystem
  • libboost-log
  • libboost-iostreams
  • libboost-program-options
  • libboost-system
  • libboost-test
  • libboost-thread
  • libcap
  • libsystemd
  • mesa (libegl1, libgles2)
  • libglm
  • libsdl2
  • libprotobuf
  • protobuf-compiler
  • python2
  • lxc (>= 3.0)

On an Ubuntu system you can install all build dependencies with the following command:

$ sudo apt install build-essential cmake cmake-data debhelper dbus google-mock \ libboost-dev libboost-filesystem-dev libboost-log-dev libboost-iostreams-dev \ libboost-program-options-dev libboost-system-dev libboost-test-dev \ libboost-thread-dev libcap-dev libsystemd-dev libegl1-mesa-dev \ libgles2-mesa-dev libglm-dev libgtest-dev liblxc1 \ libproperties-cpp-dev libprotobuf-dev libsdl2-dev libsdl2-image-dev lxc-dev \ pkg-config protobuf-compiler python-minimal 

We recommend Ubuntu 18.04 (bionic) with GCC 7.x as your build environment.

Build

Afterwards you can build Anbox with

$ git clone https://github.com/anbox/anbox.git $ cd anbox $ mkdir build $ cd build $ cmake .. $ make 

A simple

$ sudo make install

will install the necessary bits into your system.

If you want to build the anbox snap instead you can do this with the following steps:

$ mkdir android-images
$ cp /path/to/android.img android-images/android.img
$ snapcraft

The result will be a .snap file you can install on a system supporting snaps

$ snap install --dangerous --devmode anbox_1_amd64.snap 

Run Anbox

Running Anbox from a local build requires a few more things you need to know about. Please have a look at the "Runtime Setup" documentation.

Documentation

You will find additional documentation for Anbox in the docs subdirectory of the project source.

Interesting things to have a look at

Reporting bugs

If you have found an issue with Anbox, please file a bug.

Get in Touch

If you want to get in contact with the developers please feel free to join the #anbox IRC channel on Freenode.

Copyright and Licensing

Anbox reuses code from other projects like the Android QEMU emulator. These projects are available in the external/ subdirectory with the licensing terms included.

The Anbox source itself, if not stated differently in the relevant source files, is licensed under the terms of the GPLv3 license.

 

 

 

Anbox 以基於容器的方式,在像 Ubuntu 這樣的常規的 GNU Linux 系統上啟動一個完整的 Android 系統。

概述

Anbox 使用 Linux 命名空間(user、pid、uts、net、mount、ipc)來在容器中運行完整的 Android 系統,並在任何基於 GNU Linux 平台上提供 Android 應用。

容器內的 Android 無法直接訪問任何硬件。所有硬件訪問都通過主機上的 anbox 守護進程進行。我們重用基於 QEMU 的模擬器實現的 Android 中的 GL、ES 加速渲染。容器內的 Android 系統使用不同的管道與主機系統通信,並通過它發送所有硬件訪問命令。

有關更多詳細信息,請參考下文檔:

  • Android 硬件 OpenGL ES 仿真設計概述
  • Android QEMU 快速管道
  • Android 的 “qemud” 復用守護進程
  • Android qemud 服務

Anbox 目前適合桌面使用,但也用在移動操作系統上,如 Ubuntu Touch、Sailfish OS 或 Lune OS。然而,由於 Android 程序的映射目前只針對桌面環境,因此還需要額外的工作來支持其他的用戶界面。

Android 運行時環境帶有一個基於 Android 開源項目鏡像的最小自定義 Android 系統。所使用的鏡像目前基於 Android 7.1.1。

安裝

目前,安裝過程包括一些添加額外組件到系統的步驟。包括:

  • 啟用用於 binder 和 ashmen 的非發行的樹外內核模塊。
  • 使用 udev 規則為 /dev/binder 和 /dev/ashmem 設置正確權限。
  • 能夠啟動 Anbox 會話管理器作為用戶會話的一個啟動任務。

為了使這個過程盡可能簡單,我們將必要的步驟綁定在一個 snap(見 https://snapcraft.io ) 中,稱之為 “anbox-installer”。這個安裝程序會執行所有必要的步驟。你可以在所有支持 snap 的系統運行下面的命令安裝它。

$ snap install --classic anbox-installer

另外你可以通過下面的命令下載安裝腳本。

$ wget https://raw.githubusercontent.com/anbox/anbox-installer/master/installer.sh -O anbox-installer

請注意,我們還不支持除所有 Linux 發行版。請查看下面的章節了解支持的發行版。

運行下面的命令進行安裝。

$ anbox-installer

它會引導你完成安裝過程。

注意: Anbox 目前處於 pre-alpha 開發狀態。不要指望它具有生產環境你需要的所有功能。你肯定會遇到錯誤和崩潰。如果你遇到了,請不要猶豫並報告它們!

注意: Anbox snap 目前 完全沒有約束,因此它只能從邊緣渠道獲取。正確的約束是我們想要在未來實現的,但由於 Anbox 的性質和復雜性,這不是一個簡單的任務。

已支持的 Linux 發行版

目前我們官方支持下面的 Linux 發行版:

  • Ubuntu 16.04 (xenial)

未測試但可能支持的:

  • Ubuntu 14.04 (trusty)
  • Ubuntu 16.10 (yakkety)
  • Ubuntu 17.04 (zesty)

安裝並運行 Android 程序

從源碼構建

要構建 Anbox 運行時不需要特別了解什么,我們使用 cmake 作為構建系統。你的主機系統中應已有下面這些構建依賴:

  • libdbus
  • google-mock
  • google-test
  • libboost
  • libboost-filesystem
  • libboost-log
  • libboost-iostreams
  • libboost-program-options
  • libboost-system
  • libboost-test
  • libboost-thread
  • libcap
  • libdbus-cpp
  • mesa (libegl1, libgles2)
  • glib-2.0
  • libsdl2
  • libprotobuf
  • protobuf-compiler
  • lxc

在 Ubuntu 系統中你可以用下面的命令安裝所有的依賴:

$ sudo apt install build-essential cmake cmake-data debhelper dbus \
google-mock libboost-dev libboost-filesystem-dev libboost-log-dev \
libboost-iostreams-dev libboost-program-options-dev libboost-system-dev \
libboost-test-dev libboost-thread-dev libcap-dev libdbus-1-dev \
libdbus-cpp-dev libegl1-mesa-dev libgles2-mesa-dev libglib2.0-dev \
libglm-dev libgtest-dev liblxc1 libproperties-cpp-dev libprotobuf-dev \
libsdl2-dev lxc-dev pkg-config protobuf-compiler

之后用下面的命令構建 Anbox:

$ mkdir build
$ cd build
$ cmake ..
$ make

一個簡單的命令會將必要的二進制安裝到你的系統中,如下。

$ make install

如果你想要構建 anbox snap,你可以按照下面的步驟:

$ mkdir android-images
$ cp /path/to/android.img android-images/android.img
$ snapcraft

結果會有一個 .snap 文件,你可以在支持 snap 的系統上安裝。

$ snap install --dangerous --devmode anbox_1_amd64.snap

運行 Anbox

要從本地構建運行 Anbox ,你需要了解更多一點。請參考“運行時步驟”文檔。

文檔

在項目源代碼的子目錄下,你可以找到額外的關於 Anbox 的文檔。

有興趣可以看下:

  • 運行時步驟
  • 構建 Android 鏡像

報告 bug

如果你發現了一個 Anbox 問題,請提交 bug。

取得聯系

如果你想要與開發者聯系,你可以在 FreeNode 中加入 #anbox 的 IRC 頻道。

版權與許可

Anbox 重用了像 Android QEMU 模擬器這樣的其他項目的代碼。這些項目可在外部/帶有許可聲明的子目錄中得到。

anbox 源碼本身,如果沒有在相關源碼中聲明其他的許可,默認是 GPLv3 許可。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM