Skip to content

Commit

Permalink
chore: use external script to write entitlements
Browse files Browse the repository at this point in the history
  • Loading branch information
siepra committed May 8, 2024
1 parent 33d70e0 commit 2534168
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 17 deletions.
23 changes: 23 additions & 0 deletions .github/scripts/write_entitlements.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
set -e

# Modified from:
# https://stackoverflow.com/questions/67264212/android-emulator-crash-when-start-hvf-error-hv-error

original_dir=$(pwd)
target_dir=~/Library/Android/sdk/emulator/qemu/darwin-aarch64
file_path=entitlements.xml

xml_content='<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.hypervisor</key>
<true/>
</dict>
</plist>'

cd "$target_dir"
echo "$xml_content" > "$file_path"
codesign -s - --entitlements entitlements.xml --force ./qemu-system-aarch64
cd "$original_dir"
37 changes: 20 additions & 17 deletions .github/workflows/e2e-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,26 @@ jobs:
git lfs pull
# see: https://stackoverflow.com/questions/67264212/android-emulator-crash-when-start-hvf-error-hv-error
- name: Create qemu entitlements
run: |
{
echo '<?xml version="1.0" encoding="UTF-8"?>'
echo '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">'
echo '<plist version="1.0">'
echo '<dict>'
echo ' <key>com.apple.security.hypervisor</key>'
echo ' <true/>'
echo '</dict>'
echo '</plist>'
} >> $ANDROID_HOME/emulator/qemu/darwin-aarch64/entitlements.xml
- name: Re-sign qemu binary
run: |
cd $ANDROID_HOME/emulator/qemu/darwin-aarch64
codesign -s - --entitlements entitlements.xml --force qemu-system-aarch64 --verbose
# - name: Create qemu entitlements
# run: |
# {
# echo '<?xml version="1.0" encoding="UTF-8"?>'
# echo '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">'
# echo '<plist version="1.0">'
# echo '<dict>'
# echo ' <key>com.apple.security.hypervisor</key>'
# echo ' <true/>'
# echo '</dict>'
# echo '</plist>'
# } >> $ANDROID_HOME/emulator/qemu/darwin-aarch64/entitlements.xml

# - name: Re-sign qemu binary
# run: |
# cd $ANDROID_HOME/emulator/qemu/darwin-aarch64
# codesign -s - --entitlements entitlements.xml --force qemu-system-aarch64 --verbose

- name: Write entitlements
run: ./scripts/write_entitlements.sh

- name: Install SDK image
run: yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install 'system-images;android-34;google_apis;arm64-v8a'
Expand Down

0 comments on commit 2534168

Please sign in to comment.