[gRPC] Add java example

This showcases how you would use gRPC from java with gradle.

$ gradle run

will list the snapshots.

Change-Id: I6565657d01695c6734749454ac1b164732d99707
13 files changed
tree: 3734aaf181c4f1546ee50fad1019c346d7808a4f
  1. .vscode/
  2. accel/
  3. android/
  4. android-qemu2-glue/
  5. audio/
  6. backends/
  7. block/
  8. bsd-user/
  9. chardev/
  10. contrib/
  11. crypto/
  12. default-configs/
  13. disas/
  14. docs/
  15. fpu/
  16. fsdev/
  17. gdb-xml/
  18. hw/
  19. include/
  20. io/
  21. libdecnumber/
  22. linux-headers/
  23. linux-user/
  24. migration/
  25. nbd/
  26. net/
  27. pc-bios/
  28. po/
  29. qapi/
  30. qemu2-auto-generated/
  31. qga/
  32. qobject/
  33. qom/
  34. replay/
  35. roms/
  36. scripts/
  37. scsi/
  38. slirp/
  39. stubs/
  40. target/
  41. tcg/
  42. tests/
  43. trace/
  44. ui/
  45. util/
  46. .clang-tidy
  47. .dir-locals.el
  48. .editorconfig
  49. .exrc
  50. .gdbinit
  51. .gitignore
  52. .gitmodules
  53. .gitpublish
  54. .mailmap
  55. .shippable.yml
  56. .travis.yml
  57. android-info.txt
  58. arch_init.c
  59. balloon.c
  60. block.c
  61. blockdev-nbd.c
  62. blockdev.c
  63. blockjob.c
  64. bootdevice.c
  65. bt-host.c
  66. bt-vhci.c
  67. build.gradle
  68. Changelog
  69. cmake-format.json
  70. cmake-main.darwin-x86_64.inc
  71. cmake-main.linux-x86_64.inc
  72. cmake-main.windows-x86.inc
  73. cmake-main.windows-x86_64.inc
  74. cmake-main.windows_msvc-x86_64.inc
  75. CMakeLists.txt
  77. configure
  81. cpus-common.c
  82. cpus.c
  83. device-hotplug.c
  84. device_tree.c
  85. disas.c
  86. dma-helpers.c
  87. dummy.c
  88. dump.c
  89. exec.c
  90. gdbstub.c
  91. GNUmakefile
  93. hmp-commands-info.hx
  94. hmp-commands.hx
  95. hmp.c
  96. hmp.h
  97. hvf-stub.c
  98. ioport.c
  99. iothread.c
  100. LICENSE
  101. mac.source.properties
  103. Makefile
  104. Makefile.objs
  105. Makefile.target
  106. memory.c
  107. memory_ldst.inc.c
  108. memory_mapping.c
  109. module-common.c
  111. monitor.c
  112. NOTICE
  113. numa.c
  114. os-posix.c
  115. os-win32.c
  116. qdev-monitor.c
  117. qdict-test-data.txt
  118. qemu-bridge-helper.c
  119. qemu-char.c
  120. qemu-doc.texi
  121. qemu-ga.texi
  122. qemu-img-cmds.hx
  123. qemu-img.c
  124. qemu-img.texi
  125. qemu-io-cmds.c
  126. qemu-io.c
  127. qemu-keymap.c
  128. qemu-nbd.c
  129. qemu-nbd.texi
  130. qemu-option-trace.texi
  131. qemu-options-wrapper.h
  132. qemu-options.def
  133. qemu-options.h
  134. qemu-options.hx
  135. qemu-seccomp.c
  136. qemu-tech.texi
  137. qemu-test.cmake
  138. qemu-version.h.in
  139. qemu.nsi
  140. qemu.sasl
  142. qmp.c
  143. qtest.c
  144. README
  145. README.md
  146. replication.c
  147. replication.h
  148. rules.mak
  149. source.properties
  150. thunk.c
  151. tpm.c
  152. trace-events
  153. version.rc
  154. vl.c
  155. whpx-stub.c
  156. win.source.properties

Welcome to the Android Emulator

This document gives you some background on the emulator and outlines how you can start hacking and contributing to the emulator!

Just get me started with development!

Make sure to install Android Studio and the associated SDKs. Do not forget to install the official emulator and create a few android virtual devices. Next follow the instructions for the platform you would like to work on:

We use the Repo tool to manage working accross multiple branches.

About the Emulator

The Android Emulator simulates Android devices on your computer so that you can test your application on a variety of devices and Android API levels without needing to have each physical device.

The emulator provides almost all of the capabilities of a real Android device. You can simulate incoming phone calls and text messages, specify the location of the device, simulate different network speeds, simulate rotation and other hardware sensors, access the Google Play Store, and much more.

Testing your app on the emulator is in some ways faster and easier than doing so on a physical device. For example, you can transfer data faster to the emulator than to a device connected over USB.

The emulator comes with predefined configurations for various Android phone, tablet, Wear OS, and Android TV devices.

Recommended Reading

The following is a list of concepts that are important. Please read these links and any other links you can find. If you find a link that you think does a better job at explaining the concept, please add it here:

QEMU is an open source competitor to VMware Workstation, VirtualBox, HyperV. It is focused on Linux server virtualization on Linux servers. While QEMU does support booting other OS’s, we don’t use that functionality since Android is Linux.

The Android Emulator is downstream from the QEMU emulator. It adds support for booting Android devices, emulates typical Android hardware (OpenGL, GPS, GSM, Sensors) and a GUI interface. The android emulator extends qemu in various ways.

For an overview of Qemu see:

The QEMU emulator leverages technologies like hardware Hypervisors KVM (Linux) and HAXM (Windows/Mac)

https://en.wikipedia.org/wiki/Hypervisor https://en.wikipedia.org/wiki/Kernel-based_Virtual_Machine

The QEMU emulator supports both guest images that require full virtualization and guest images that require paravirtualization technologies like virtio

The emulator passes a device tree blob to a guest kernel to describe the guest hardware

When running a non-x86 image on an x86 host, QEMU will JIT the non-x86 code into x86 code. See this lectutre for more. The MMU (page table hardware) is emulated in software, which is unfortunately slow.

You will need to build Android kernels and system images that the emulator will run. The easiest way to obtain these is to make use of the publicly released images. You can find more details here.

Building the Emulator

The emulator uses Cmake as a meta build generator, and all the necessary compilers and toolchains are included in the repository. Make sure you have read the section above as the requirements to succesfully build vary slightly from platform to platform.

In general you can run the following script:


For incremental builds you can use ninja. For example

ninja -C objs

Contributing code

The emulator uses a coding style derived from the Chromium style. We use the repo tool to submit pathces. The usual workflow is roughly as follows:

    repy sync # Pulls in all the changes accross all branches.
    repo start my_awesome_feature

This will create a git branch called my_awesome_feature. You can now work on your patch.

Once you have written a patch you can send it out for code review. We use gerrit for code reviews.

Use the repo tool to upload or update a CL:

    repo upload --cbr --re=”blah@google.com,foo@google.com,bar@google.com
  • “--cbr” means “upload the current branch”,
  • “--re” supplies the initial reviewers list

Add “-t” switch to use the current git branch as a review topic (topic groups CLs together and only allows them to be submitted when all got +2/+verified)

The repo tool will provide you with a url where you can find your change.

Code Reviews

Make sure to check the CL against our coding style: coding style. Coding style isn’t frozen: just edit it in our repository and create a code review to propose a change.

Some good articles on code reviewing, especially when it comes to google:

Below are some short notes relevant to the emulator.

Keep in mind that all of the code reviews are open source and visible to everyone!. In other words, be nice and and provide actionable constructive feedback.

  • C++ over C for all new code. Always.

  • After uploading a CL for review, author should “+1” it when they think it’s ready for reviewing. A CL without author’s “+1” is a “work in progress” and other reviewers may ignore it..

  • Prefer not to send a WIP CL to reviewers and only add them when it’s in a reviewable state. If you realized that you added reviewers too soon, just remove them - “x” button in the browser UI for each reviewer actually works.

  • Avoid large CLs. There are always exceptions, use your best judgement to improve code clarity and to help other maintainers in the future.

    Split the changes into smaller isolated chunks and submit those as a single topic If you touch multiple components, that’s a good way to split the CL.

    Changes into any QEMU files must be in their own CL - otherwise rebasing into the new version becomes 10x more painful.

  • “-2” is sticky, it remains there until the very same reviewer removes it. If you “-2”-ed someone, it’s always a good thing to communicate to them about the follow-up

  • Abandon the CLs you don’t need anymore

  • Tests: when reviewing the code, make sure there’s a test or a really good reason for its absence

Merging downstream Qemu

Merging changes from the qemu branch should be done on the emu-master-qemu branch. You will need to this on a linux machine as qemu development happens in a linux environment. Once you have obtained this branch you can add the remote qemu repository as follows:

cd emu-master-qemu/external/qemu
git remote add qemu https://git.qemu.org/git/qemu.git
git fetch qemu

Now you can start merging in changes:

git merge master

Be smart, merge only a few commits at a time

Next you should try to build qemu standalone:

    ./android/scripts/unix/build-qemu-android.sh  --verbose --verbose --build-dir=$HOME/qemu-build  &&
    cd $HOME/qemu-build/build-linux-x86_64 &&
    source env.sh &&
    cd qemu-android &&

Now you are ready for building, testing, and merging the next set. You could have a look at this script to automate this slightly.