Skip to content

Commit f8604ae

Browse files
committed
tools/android: Address review comments on PR#668
PR#668: #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>
1 parent eedbf43 commit f8604ae

File tree

2 files changed

+29
-23
lines changed

2 files changed

+29
-23
lines changed

tools/android/install_base.sh

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,18 @@ test_os_release() {
4242
fi
4343
}
4444

45-
function set_host_arch
45+
function get_android_sdk_host_arch
4646
{
47-
# Google ABI type for Arm platforms
48-
HOST_ARCH="arm64-v8a"
49-
50-
local machine
51-
machine=$(uname -m)
52-
if [[ "${machine}" == "x86"* ]]; then
53-
HOST_ARCH=${machine}
54-
fi
47+
# Default to Google ABI type for Arm platforms
48+
local arch="arm64-v8a"
49+
local machine
50+
51+
machine=$(uname -m)
52+
if [[ "${machine}" == "x86"* ]]; then
53+
arch=${machine}
54+
fi
55+
56+
echo "${arch}"
5557
}
5658

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

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

63-
CMDLINE_VERSION=${CMDLINE_VERSION:-"11076708"}
65+
ANDROID_CMDLINE_VERSION=${ANDROID_CMDLINE_VERSION:-"11076708"}
6466

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

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

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

118120
# Needs install_android_sdk_manager first
119121
install_android_tools() {
122+
local android_sdk_host_arch
123+
124+
android_sdk_host_arch=$(get_android_sdk_host_arch)
125+
120126
yes | call_android_sdkmanager --verbose --channel=0 --install "platform-tools"
121127
yes | call_android_sdkmanager --verbose --channel=0 --install "platforms;android-31"
122128
yes | call_android_sdkmanager --verbose --channel=0 --install "platforms;android-33"
123129
yes | call_android_sdkmanager --verbose --channel=0 --install "platforms;android-34"
124-
yes | call_android_sdkmanager --verbose --channel=0 --install "system-images;android-31;google_apis;${HOST_ARCH}"
125-
yes | call_android_sdkmanager --verbose --channel=0 --install "system-images;android-33;android-desktop;${HOST_ARCH}"
126-
yes | call_android_sdkmanager --verbose --channel=0 --install "system-images;android-34;google_apis;${HOST_ARCH}"
130+
yes | call_android_sdkmanager --verbose --channel=0 --install "system-images;android-31;google_apis;${android_sdk_host_arch}"
131+
yes | call_android_sdkmanager --verbose --channel=0 --install "system-images;android-33;android-desktop;${android_sdk_host_arch}"
132+
yes | call_android_sdkmanager --verbose --channel=0 --install "system-images;android-34;google_apis;${android_sdk_host_arch}"
127133
}
128134

129135
create_android_vds() {
136+
local android_sdk_host_arch
130137
local vd_name
131138

139+
android_sdk_host_arch=$(get_android_sdk_host_arch)
140+
132141
vd_name="devlib-p6-12"
133142
echo "Creating virtual device \"${vd_name}\" (Pixel 6 - Android 12)..."
134-
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
143+
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
135144

136145
vd_name="devlib-p6-14"
137146
echo "Creating virtual device \"${vd_name}\" (Pixel 6 - Android 14)..."
138-
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
147+
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
139148

140149
vd_name="devlib-chromeos"
141150
echo "Creating virtual device \"${vd_name}\" (ChromeOS - Android 13, Pixel tablet)..."
142-
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
151+
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
143152
}
144153

145154
install_apt() {
@@ -183,7 +192,6 @@ if which apt-get &>/dev/null; then
183192
install_functions+=(install_apt)
184193
package_manager='apt-get'
185194
expected_distro="Ubuntu"
186-
187195
elif which pacman &>/dev/null; then
188196
install_functions+=(install_pacman)
189197
package_manager="pacman"
@@ -223,8 +231,6 @@ else
223231
args=("$@")
224232
fi
225233

226-
set_host_arch
227-
228234
# Use conditional fall-through ;;& to all matching all branches with
229235
# --install-all
230236
for arg in "${args[@]}"; do

tools/docker/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ RUN cd /devlib && \
6363
pip install --upgrade pip setuptools wheel && \
6464
pip install .[full]
6565

66-
# Set CMDLINE_VERSION environment variable if you want to use a specific
67-
# version of Android command line tools rather than default which is
68-
# ``11076708`` as of writing this comment.
66+
# Set ANDROID_CMDLINE_VERSION environment variable if you want to use a
67+
# specific version of Android command line tools rather than default
68+
# which is ``11076708`` as of writing this comment.
6969
RUN cd /devlib/tools/android && ./install_base.sh
7070

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

0 commit comments

Comments
 (0)