androidenv/emulate-app: rename androidsdkComposition -> sdk
This greatly improves readability by shortening some of the overlong lines.
This commit is contained in:
parent
4daca65fe3
commit
2ec43d3509
@ -15,7 +15,7 @@ let
|
|||||||
abiVersions = [ abiVersion ];
|
abiVersions = [ abiVersion ];
|
||||||
} // sdkExtraArgs;
|
} // sdkExtraArgs;
|
||||||
|
|
||||||
androidsdkComposition = (composeAndroidPackages sdkArgs).androidsdk;
|
sdk = (composeAndroidPackages sdkArgs).androidsdk;
|
||||||
in
|
in
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
inherit name;
|
inherit name;
|
||||||
@ -41,7 +41,7 @@ stdenv.mkDerivation {
|
|||||||
''}
|
''}
|
||||||
|
|
||||||
# We need to specify the location of the Android SDK root folder
|
# We need to specify the location of the Android SDK root folder
|
||||||
export ANDROID_SDK_ROOT=${androidsdkComposition}/libexec/android-sdk
|
export ANDROID_SDK_ROOT=${sdk}/libexec/android-sdk
|
||||||
|
|
||||||
# We have to look for a free TCP port
|
# We have to look for a free TCP port
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ stdenv.mkDerivation {
|
|||||||
|
|
||||||
for i in $(seq 5554 2 5584)
|
for i in $(seq 5554 2 5584)
|
||||||
do
|
do
|
||||||
if [ -z "$(${androidsdkComposition}/libexec/android-sdk/platform-tools/adb devices | grep emulator-$i)" ]
|
if [ -z "$(${sdk}/libexec/android-sdk/platform-tools/adb devices | grep emulator-$i)" ]
|
||||||
then
|
then
|
||||||
port=$i
|
port=$i
|
||||||
break
|
break
|
||||||
@ -67,12 +67,12 @@ stdenv.mkDerivation {
|
|||||||
export ANDROID_SERIAL="emulator-$port"
|
export ANDROID_SERIAL="emulator-$port"
|
||||||
|
|
||||||
# Create a virtual android device for testing if it does not exists
|
# Create a virtual android device for testing if it does not exists
|
||||||
${androidsdkComposition}/libexec/android-sdk/tools/android list targets
|
${sdk}/libexec/android-sdk/tools/android list targets
|
||||||
|
|
||||||
if [ "$(${androidsdkComposition}/libexec/android-sdk/tools/android list avd | grep 'Name: device')" = "" ]
|
if [ "$(${sdk}/libexec/android-sdk/tools/android list avd | grep 'Name: device')" = "" ]
|
||||||
then
|
then
|
||||||
# Create a virtual android device
|
# Create a virtual android device
|
||||||
yes "" | ${androidsdkComposition}/libexec/android-sdk/tools/android create avd -n device -t 1 --abi ${systemImageType}/${abiVersion} $NIX_ANDROID_AVD_FLAGS
|
yes "" | ${sdk}/libexec/android-sdk/tools/android create avd -n device -t 1 --abi ${systemImageType}/${abiVersion} $NIX_ANDROID_AVD_FLAGS
|
||||||
|
|
||||||
${stdenv.lib.optionalString enableGPU ''
|
${stdenv.lib.optionalString enableGPU ''
|
||||||
# Enable GPU acceleration
|
# Enable GPU acceleration
|
||||||
@ -85,23 +85,23 @@ stdenv.mkDerivation {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Launch the emulator
|
# Launch the emulator
|
||||||
${androidsdkComposition}/libexec/android-sdk/emulator/emulator -avd device -no-boot-anim -port $port $NIX_ANDROID_EMULATOR_FLAGS &
|
${sdk}/libexec/android-sdk/emulator/emulator -avd device -no-boot-anim -port $port $NIX_ANDROID_EMULATOR_FLAGS &
|
||||||
|
|
||||||
# Wait until the device has completely booted
|
# Wait until the device has completely booted
|
||||||
echo "Waiting until the emulator has booted the device and the package manager is ready..." >&2
|
echo "Waiting until the emulator has booted the device and the package manager is ready..." >&2
|
||||||
|
|
||||||
${androidsdkComposition}/libexec/android-sdk/platform-tools/adb -s emulator-$port wait-for-device
|
${sdk}/libexec/android-sdk/platform-tools/adb -s emulator-$port wait-for-device
|
||||||
|
|
||||||
echo "Device state has been reached" >&2
|
echo "Device state has been reached" >&2
|
||||||
|
|
||||||
while [ -z "$(${androidsdkComposition}/libexec/android-sdk/platform-tools/adb -s emulator-$port shell getprop dev.bootcomplete | grep 1)" ]
|
while [ -z "$(${sdk}/libexec/android-sdk/platform-tools/adb -s emulator-$port shell getprop dev.bootcomplete | grep 1)" ]
|
||||||
do
|
do
|
||||||
sleep 5
|
sleep 5
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "dev.bootcomplete property is 1" >&2
|
echo "dev.bootcomplete property is 1" >&2
|
||||||
|
|
||||||
#while [ -z "$(${androidsdkComposition}/libexec/android-sdk/platform-tools/adb -s emulator-$port shell getprop sys.boot_completed | grep 1)" ]
|
#while [ -z "$(${sdk}/libexec/android-sdk/platform-tools/adb -s emulator-$port shell getprop sys.boot_completed | grep 1)" ]
|
||||||
#do
|
#do
|
||||||
#sleep 5
|
#sleep 5
|
||||||
#done
|
#done
|
||||||
@ -113,7 +113,7 @@ stdenv.mkDerivation {
|
|||||||
${stdenv.lib.optionalString (app != null) ''
|
${stdenv.lib.optionalString (app != null) ''
|
||||||
# Install the App through the debugger, if it has not been installed yet
|
# Install the App through the debugger, if it has not been installed yet
|
||||||
|
|
||||||
if [ -z "${package}" ] || [ "$(${androidsdkComposition}/libexec/android-sdk/platform-tools/adb -s emulator-$port shell pm list packages | grep package:${package})" = "" ]
|
if [ -z "${package}" ] || [ "$(${sdk}/libexec/android-sdk/platform-tools/adb -s emulator-$port shell pm list packages | grep package:${package})" = "" ]
|
||||||
then
|
then
|
||||||
if [ -d "${app}" ]
|
if [ -d "${app}" ]
|
||||||
then
|
then
|
||||||
@ -122,12 +122,12 @@ stdenv.mkDerivation {
|
|||||||
appPath="${app}"
|
appPath="${app}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
${androidsdkComposition}/libexec/android-sdk/platform-tools/adb -s emulator-$port install "$appPath"
|
${sdk}/libexec/android-sdk/platform-tools/adb -s emulator-$port install "$appPath"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Start the application
|
# Start the application
|
||||||
${stdenv.lib.optionalString (package != null && activity != null) ''
|
${stdenv.lib.optionalString (package != null && activity != null) ''
|
||||||
${androidsdkComposition}/libexec/android-sdk/platform-tools/adb -s emulator-$port shell am start -a android.intent.action.MAIN -n ${package}/${activity}
|
${sdk}/libexec/android-sdk/platform-tools/adb -s emulator-$port shell am start -a android.intent.action.MAIN -n ${package}/${activity}
|
||||||
''}
|
''}
|
||||||
''}
|
''}
|
||||||
EOF
|
EOF
|
||||||
|
Loading…
x
Reference in New Issue
Block a user