#!/bin/bash
### BEGIN BOOT SCRIPT INFO
#Long-Name: Android emulator (release)
### END BOOT SCRIPT INFO
### BEGIN BOOT SCRIPT INSTALLATION DEFAULTS
#Launch-Mode: gui-and-terminal
### END BOOT SCRIPT INSTALLATION DEFAULTS
#
#Boot script for release version of Android emulator (with a single emulator
#version compatible with multiple Android versions; for the beta emulator
#versions that are specific to a particular Android version, use
#std_android_emu_beta_boot instead)
#
#Directories expected by this script:
#sdk/			SDK install directory (normally a symlink to
#			androidarm/SUPPORT/emulators/android-sdk-linux-<version>
#data/			emulator data directory
#data/config		SDK configuration directory
#data/emu_home		used as a pseudo-home directory; should contain a
#                       .android symlink to ../config
#data/sdk		used as a bind mount point for the SDK (should be empty)
#sdk_platforms/		contains SDK platform directories (this gets copied to
#			sdk/platforms in the temporary emulator directory)
#

. bootscriptfunctions.sh

CONFIGDIR="$PWD"

sdk_dir="`realpath sdk`"

if [ x"$_ANDROID_EMU_RUN_SHELL" != x ]
then
	EMU_CMD="$SHELL"
else
	EMU_CMD="./sdk/tools/emulator -avd default -shell -show-kernel"
fi

ANDROID_SDK_HOME=/mnt/emu_home faketree \
	--mount "$PWD/data:/mnt" \
	--mount "$sdk_dir:/mnt/sdk" \
	--mount "$PWD/sdk_platforms:/mnt/sdk/platforms" \
	--chdir /mnt \
	-- $EMU_CMD
