Skip to content

Commit

Permalink
tools/android: Address review comments on PR#668
Browse files Browse the repository at this point in the history
PR#668: ARM-software#668

- Fix mixed tab-space white-spacing issues
- s/CMDLINE_VERSION/ANDROID_CMDLINE_VERSION/ to be more precise
- s/set_host_arch/get_android_sdk_host_arch/ because the global variable
  for Android host architecture is removed now

Signed-off-by: Metin Kaya <metin.kaya@arm.com>
  • Loading branch information
metin-arm committed Mar 28, 2024
1 parent 29610d3 commit a3cdf78
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 23 deletions.
46 changes: 26 additions & 20 deletions tools/android/install_base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,18 @@ test_os_release() {
fi
}

function set_host_arch
function get_android_sdk_host_arch
{
# Google ABI type for Arm platforms
HOST_ARCH="arm64-v8a"

local machine
machine=$(uname -m)
if [[ "${machine}" == "x86"* ]]; then
HOST_ARCH=${machine}
fi
# Default to Google ABI type for Arm platforms
local arch="arm64-v8a"
local machine

machine=$(uname -m)
if [[ "${machine}" == "x86"* ]]; then
arch=${machine}
fi

echo "${arch}"
}

ANDROID_HOME="$(dirname "${0}")/android-sdk-linux"
Expand All @@ -60,7 +62,7 @@ export ANDROID_USER_HOME="${ANDROID_HOME}/.android"

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

CMDLINE_VERSION=${CMDLINE_VERSION:-"11076708"}
ANDROID_CMDLINE_VERSION=${ANDROID_CMDLINE_VERSION:-"11076708"}

cleanup_android_home() {
echo "Cleaning up Android SDK: ${ANDROID_HOME}"
Expand All @@ -72,7 +74,7 @@ install_android_sdk_manager() {
echo "Installing Android SDK manager ..."

# URL taken from "Command line tools only": https://developer.android.com/studio
local url="https://dl.google.com/android/repository/commandlinetools-linux-${CMDLINE_VERSION}_latest.zip"
local url="https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_CMDLINE_VERSION}_latest.zip"

echo "Downloading Android SDK manager from: $url"
wget -qO- "${url}" | bsdtar -xf- -C "${ANDROID_HOME}/cmdline-tools"
Expand Down Expand Up @@ -117,29 +119,36 @@ call_android_avdmanager() {

# Needs install_android_sdk_manager first
install_android_tools() {
local android_sdk_host_arch

android_sdk_host_arch=$(get_android_sdk_host_arch)

yes | call_android_sdkmanager --verbose --channel=0 --install "platform-tools"
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"
yes | call_android_sdkmanager --verbose --channel=0 --install "system-images;android-31;google_apis;${HOST_ARCH}"
yes | call_android_sdkmanager --verbose --channel=0 --install "system-images;android-33;android-desktop;${HOST_ARCH}"
yes | call_android_sdkmanager --verbose --channel=0 --install "system-images;android-34;google_apis;${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}"
}

create_android_vds() {
local android_sdk_host_arch
local vd_name

android_sdk_host_arch=$(get_android_sdk_host_arch)

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;${HOST_ARCH}" --skin pixel_6 -b "${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}" --skin pixel_6 -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;${HOST_ARCH}" --skin pixel_6 -b "${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}" --skin pixel_6 -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;${HOST_ARCH}" --skin pixel_tablet -b "${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}" --skin pixel_tablet -b "${android_sdk_host_arch}" -f
}

install_apt() {
Expand Down Expand Up @@ -183,7 +192,6 @@ if which apt-get &>/dev/null; then
install_functions+=(install_apt)
package_manager='apt-get'
expected_distro="Ubuntu"

elif which pacman &>/dev/null; then
install_functions+=(install_pacman)
package_manager="pacman"
Expand Down Expand Up @@ -223,8 +231,6 @@ else
args=("$@")
fi

set_host_arch

# Use conditional fall-through ;;& to all matching all branches with
# --install-all
for arg in "${args[@]}"; do
Expand Down
6 changes: 3 additions & 3 deletions tools/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ RUN apt-get -y autoremove && \
RUN git clone -b ${DEVLIB_REF} -v https://github.com/ARM-software/devlib.git /devlib
RUN cd /devlib && pip install .[full]

# Set 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.
# 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

# Set BUILDROOT_VERSION environment variable if you want to use a specific
Expand Down

0 comments on commit a3cdf78

Please sign in to comment.