Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions doc/tools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tools
Android
-------

``tools/android/install_base.sh`` script installs Android command line tools
``tools/android/setup_host.sh`` script installs Android command line tools
for Linux and creates Android Virtual Devices (AVD).

The script creates ``android-sdk-linux`` directory under ``tools/android`` and
Expand All @@ -13,7 +13,7 @@ https://developer.android.com/tools/variables).

Your ``ANDROID_USER_HOME`` and ``ANDROID_EMULATOR_HOME`` environment variables
point to ``tools/android/android-sdk-linux/.android``. Hence, removing
``android-sdk-linux`` folder will clean all artefacts of ``install_base.sh``.
``android-sdk-linux`` folder will clean all artefacts of ``setup_host.sh``.

It fetches Android command line tools, then installs Android SDK
Platform-Tools, SDK Platform 31 (for Android 12) & 34 (for Android 14), and
Expand Down Expand Up @@ -93,7 +93,7 @@ tests for Android, Linux, LocalLinux, and QEMU targets.

The Dockerfile forks from ``Ubuntu-22.04``, installs required system packages,
checks out ``master`` branch of devlib, installs devlib, creates Android
virtual devices via ``tools/android/install_base.sh``, and QEMU images for
virtual devices via ``tools/android/setup_host.sh``, and QEMU images for
aarch64 and x86_84 architectures.

Version Android command line tools (``CMDLINE_VERSION``), buildroot
Expand Down
97 changes: 66 additions & 31 deletions tools/android/install_base.sh → tools/android/setup_host.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,26 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Forked from https://github.com/ARM-software/lisa/blob/main/install_base.sh
#

# Script to install Android SDK tools for LISA & devlib on an Ubuntu-like
# system and creates Android virtual devices.

# shellcheck disable=SC2317

if [[ -z ${ANDROID_HOME:-} ]]; then
ANDROID_HOME="$(dirname "${BASH_SOURCE[0]}")/android-sdk-linux"
export ANDROID_HOME
fi
export ANDROID_USER_HOME="${ANDROID_HOME}/.android"

ANDROID_CMDLINE_VERSION=${ANDROID_CMDLINE_VERSION:-"11076708"}

# Android SDK is picky on Java version, so we need to set JAVA_HOME manually.
# In most distributions, Java is installed under /usr/lib/jvm so use that.
# according to the distribution
ANDROID_SDK_JAVA_VERSION=17


# Read standard /etc/os-release file and extract the needed field lsb_release
# binary is not installed on all distro, but that file is found pretty much
# anywhere.
Expand Down Expand Up @@ -54,13 +68,15 @@ get_android_sdk_host_arch() {
echo "${arch}"
}

ANDROID_HOME="$(dirname "${0}")/android-sdk-linux"
export ANDROID_HOME
export ANDROID_USER_HOME="${ANDROID_HOME}/.android"
# No need for the whole SDK for this one
install_android_platform_tools() {
echo "Installing Android Platform Tools ..."

mkdir -p "${ANDROID_HOME}/cmdline-tools"
local url="https://dl.google.com/android/repository/platform-tools-latest-linux.zip"

ANDROID_CMDLINE_VERSION=${ANDROID_CMDLINE_VERSION:-"11076708"}
echo "Downloading Android Platform Tools from: ${url}"
wget -qO- "${url}" | bsdtar -xf- -C "${ANDROID_HOME}/"
}

cleanup_android_home() {
echo "Cleaning up Android SDK: ${ANDROID_HOME}"
Expand All @@ -85,15 +101,8 @@ install_android_sdk_manager() {
chmod +x -R "${ANDROID_HOME}/cmdline-tools/latest/bin"

yes | (call_android_sdkmanager --licenses || true)

echo "Creating the link to skins directory..."
readlink "${ANDROID_HOME}/skins" > /dev/null 2>&1 || ln -sf "../skins" "${ANDROID_HOME}/skins"
}

# Android SDK is picky on Java version, so we need to set JAVA_HOME manually.
# In most distributions, Java is installed under /usr/lib/jvm so use that.
# according to the distribution
ANDROID_SDK_JAVA_VERSION=17
find_java_home() {
_JAVA_BIN=$(find -L /usr/lib/jvm -path "*${ANDROID_SDK_JAVA_VERSION}*/bin/java" -not -path '*/jre/bin/*' -print -quit)
_JAVA_HOME=$(dirname "${_JAVA_BIN}")/../
Expand All @@ -115,15 +124,24 @@ call_android_avdmanager() {
call_android_sdk avdmanager "$@"
}

# Needs install_android_sdk_manager first
install_android_tools() {
local android_sdk_host_arch
android_sdk_host_arch=$(get_android_sdk_host_arch)
install_build_tools() {
yes | call_android_sdkmanager --verbose --channel=0 --install "build-tools;34.0.0"
}

install_platform_tools() {
yes | call_android_sdkmanager --verbose --channel=0 --install "platform-tools"
}

install_platforms() {
yes | call_android_sdkmanager --verbose --channel=0 --install "platforms;android-31"
yes | call_android_sdkmanager --verbose --channel=0 --install "platforms;android-33"
yes | call_android_sdkmanager --verbose --channel=0 --install "platforms;android-34"
}

install_system_images() {
local android_sdk_host_arch
android_sdk_host_arch=$(get_android_sdk_host_arch)

yes | call_android_sdkmanager --verbose --channel=0 --install "system-images;android-31;google_apis;${android_sdk_host_arch}"
yes | call_android_sdkmanager --verbose --channel=0 --install "system-images;android-33;android-desktop;${android_sdk_host_arch}"
yes | call_android_sdkmanager --verbose --channel=0 --install "system-images;android-34;google_apis;${android_sdk_host_arch}"
Expand All @@ -136,15 +154,15 @@ create_android_vds() {
local vd_name
vd_name="devlib-p6-12"
echo "Creating virtual device \"${vd_name}\" (Pixel 6 - Android 12)..."
echo no | call_android_avdmanager -s create avd -n "${vd_name}" -k "system-images;android-31;google_apis;${android_sdk_host_arch}" --skin pixel_6 -b "${android_sdk_host_arch}" -f
echo no | call_android_avdmanager -s create avd -n "${vd_name}" -k "system-images;android-31;google_apis;${android_sdk_host_arch}" -b "${android_sdk_host_arch}" -f

vd_name="devlib-p6-14"
echo "Creating virtual device \"${vd_name}\" (Pixel 6 - Android 14)..."
echo no | call_android_avdmanager -s create avd -n "${vd_name}" -k "system-images;android-34;google_apis;${android_sdk_host_arch}" --skin pixel_6 -b "${android_sdk_host_arch}" -f
echo no | call_android_avdmanager -s create avd -n "${vd_name}" -k "system-images;android-34;google_apis;${android_sdk_host_arch}" -b "${android_sdk_host_arch}" -f

vd_name="devlib-chromeos"
echo "Creating virtual device \"${vd_name}\" (ChromeOS - Android 13, Pixel tablet)..."
echo no | call_android_avdmanager -s create avd -n "${vd_name}" -k "system-images;android-33;android-desktop;${android_sdk_host_arch}" --skin pixel_tablet -b "${android_sdk_host_arch}" -f
echo no | call_android_avdmanager -s create avd -n "${vd_name}" -k "system-images;android-33;android-desktop;${android_sdk_host_arch}" -b "${android_sdk_host_arch}" -f
}

install_apt() {
Expand All @@ -171,15 +189,16 @@ install_pacman() {
apt_packages=(
cpu-checker
libarchive-tools
wget
unzip
qemu-user-static
wget
)

# pacman-based distributions like Archlinux or its derivatives
pacman_packages=(
coreutils
libarchive
qemu-user-static
wget
)

# Detection based on the package-manager, so that it works on derivatives of
Expand All @@ -198,9 +217,7 @@ fi

if [[ -n "${package_manager}" ]] && ! test_os_release NAME "${expected_distro}"; then
unsupported_distro=1
echo
echo "INFO: the distribution seems based on ${package_manager} but is not ${expected_distro}, some package names might not be right"
echo
echo -e "\nINFO: the distribution seems based on ${package_manager} but is not ${expected_distro}, some package names might not be right\n"
else
unsupported_distro=0
fi
Expand Down Expand Up @@ -239,22 +256,34 @@ for arg in "${args[@]}"; do
handled=1
;;&

# Not part of --install-all since that is already satisfied by
# --install-android-tools The advantage of that method is that it does not
# require the Java JDK/JRE to be installed, and is a bit quicker. However,
# it will not provide the build-tools which are needed by devlib.
"--install-android-platform-tools")
install_functions+=(install_android_platform_tools)
handled=1
;;&

"--install-android-tools" | "--install-all")
install_functions+=(
find_java_home
install_android_sdk_manager
install_android_tools
install_build_tools
install_platform_tools
)
apt_packages+=(openjdk-"${ANDROID_SDK_JAVA_VERSION}"-jre openjdk-"${ANDROID_SDK_JAVA_VERSION}"-jdk)
pacman_packages+=(jre"${ANDROID_SDK_JAVA_VERSION}"-openjdk jdk"${ANDROID_SDK_JAVA_VERSION}"-openjdk)
handled=1;
handled=1
;;&

"--create-avds" | "--install-all")
install_functions+=(
find_java_home
install_android_sdk_manager
install_android_tools
install_platform_tools
install_platforms
install_system_images
create_android_vds
)
handled=1
Expand Down Expand Up @@ -286,14 +315,20 @@ ordered_functions=(
# cleanup must be done BEFORE installing
cleanup_android_home
install_android_sdk_manager
install_android_tools
install_android_platform_tools
install_build_tools
install_platform_tools
install_platforms
install_system_images
create_android_vds
)

# Remove duplicates in the list
# shellcheck disable=SC2207
install_functions=($(echo "${install_functions[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '))

mkdir -p "${ANDROID_HOME}/cmdline-tools"

# Call all the hooks in the order of available_functions
ret=0
for f in "${ordered_functions[@]}"; do
Expand Down
Binary file removed tools/android/skins/pixel_6/back.webp
Binary file not shown.
36 changes: 0 additions & 36 deletions tools/android/skins/pixel_6/layout

This file was deleted.

Binary file removed tools/android/skins/pixel_6/mask.webp
Binary file not shown.
Binary file removed tools/android/skins/pixel_tablet/back.webp
Binary file not shown.
35 changes: 0 additions & 35 deletions tools/android/skins/pixel_tablet/layout

This file was deleted.

Binary file removed tools/android/skins/pixel_tablet/mask.webp
Binary file not shown.
6 changes: 3 additions & 3 deletions tools/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

FROM ubuntu:22.04

ENV DEBIAN_FRONTEND noninteractive
ENV DEBIAN_FRONTEND=noninteractive

ENV DEVLIB_REF master
ENV DEVLIB_REF=master

RUN apt-get update && \
apt-get install -y --no-install-recommends \
Expand Down Expand Up @@ -66,7 +66,7 @@ RUN cd /devlib && \
# Set ANDROID_CMDLINE_VERSION environment variable if you want to use a
# specific version of Android command line tools rather than default
# which is ``11076708`` as of writing this comment.
RUN cd /devlib/tools/android && ./install_base.sh
RUN cd /devlib/tools/android && ./setup_host.sh

# Set BUILDROOT_VERSION environment variable if you want to use a specific
# branch of buildroot rather than default which is ``2023.11.1`` as of
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ echo "Waiting 30 seconds for Android virtual devices to finish boot up..."
sleep 30

cd /devlib
cp -f tools/docker/target_configs.yaml tests/
cp -f tools/docker/test_config.yml tests/
python3 -m pytest --log-cli-level DEBUG ./tests/test_target.py
File renamed without changes.