diff options
author | Aditya Wasan <adityawasan55@gmail.com> | 2021-08-17 04:14:43 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-17 04:14:43 +0530 |
commit | b7abd561f561af451ec717746e198a8686d10868 (patch) | |
tree | 16af9397d205d6501624ba4e98389e21764d9dd3 /scripts | |
parent | 9982562dc4e1ab4dbd058cf9d3c3c46fc598dec8 (diff) |
Add `KeyPair` and `KeyManager` to manage keys in the app (#1487)
Co-authored-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/boot-emulator.sh | 29 | ||||
-rwxr-xr-x | scripts/setup-environment.sh | 42 |
2 files changed, 71 insertions, 0 deletions
diff --git a/scripts/boot-emulator.sh b/scripts/boot-emulator.sh new file mode 100755 index 00000000..abd73efa --- /dev/null +++ b/scripts/boot-emulator.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +# Boots an emulator that exactly matches the one in our CI. It is recommended +# to use this as the target device for android tests. + +set -euo pipefail + +[ -n "${ANDROID_SDK_ROOT:-}" ] || { + echo "ANDROID_SDK_ROOT must be set to use this script" + exit + 1 +} +[ -n "${ANDROID_API_LEVEL:-}" ] || { echo "ANDROID_API_LEVEL not defined; defaulting to 30"; } + +API_LEVEL="${ANDROID_API_LEVEL:-30}" + +echo no | "${ANDROID_SDK_ROOT}"/cmdline-tools/latest/bin/avdmanager create avd \ + --force \ + -n "Pixel_XL_API_${API_LEVEL}" \ + --abi 'google_apis/x86' \ + --package "system-images;android-${API_LEVEL};google_apis;x86" \ + --device 'pixel_xl' + +"${ANDROID_SDK_ROOT}"/emulator/emulator \ + -avd "Pixel_XL_API_${API_LEVEL}" \ + -no-window \ + -gpu swiftshader_indirect \ + -noaudio \ + -no-boot-anim diff --git a/scripts/setup-environment.sh b/scripts/setup-environment.sh new file mode 100755 index 00000000..30dd0c19 --- /dev/null +++ b/scripts/setup-environment.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +# Installs the latest command line tools and sets up the necessary packages for an Android emulator +# for API level $ANDROID_API_LEVEL, or API 30 if unspecified. + +set -euo pipefail + +CMDLINE_TOOLS_URL_MAC="https://dl.google.com/android/repository/commandlinetools-mac-7583922_latest.zip" +CMDLINE_TOOLS_URL_LINUX="https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip" + +[ -n "${ANDROID_SDK_ROOT:-}" ] || { + echo "ANDROID_SDK_ROOT must be set to use this script" + exit + 1 +} + +if [ "$(uname)" == "Linux" ]; then + wget "${CMDLINE_TOOLS_URL_LINUX}" -O /tmp/tools.zip -o /dev/null +elif [ "$(uname)" == "Darwin" ]; then + wget "${CMDLINE_TOOLS_URL_MAC}" -O /tmp/tools.zip -o /dev/null +else + echo "This script only works on Linux and Mac" + exit 1 +fi + +[ -n "${ANDROID_API_LEVEL:-}" ] || { echo "ANDROID_API_LEVEL not defined; defaulting to 30"; } + +API_LEVEL="${ANDROID_API_LEVEL:-30}" + +unzip -qo /tmp/tools.zip -d "${ANDROID_SDK_ROOT}/latest" +mkdir -p "${ANDROID_SDK_ROOT}/cmdline-tools" +if [ -d "${ANDROID_SDK_ROOT}/cmdline-tools" ]; then + rm -rf "${ANDROID_SDK_ROOT}/cmdline-tools" +fi +mkdir -p "${ANDROID_SDK_ROOT}/cmdline-tools" +mv -v "${ANDROID_SDK_ROOT}/latest/cmdline-tools" "${ANDROID_SDK_ROOT}/cmdline-tools/latest" + +export PATH="${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin:${PATH}" + +sdkmanager --install 'build-tools;30.0.3' platform-tools "platforms;android-${API_LEVEL}" +sdkmanager --install emulator +sdkmanager --install "system-images;android-${API_LEVEL};google_apis;x86" |