README 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. GPSd on Android/AOSP:
  2. ---------------------
  3. The files in this path, as well as the Android.bp in the path below,
  4. are used for building the GPSd client as a platform library for AOSP.
  5. Five components are currently implemented;
  6. gpsd executable,
  7. Shared library, libgps (builds libgps.so)
  8. Static library, libgps_static
  9. Test client, gps_test (builds executable gps_test)
  10. Android GNSS 1.1 HAL, (builds android.hardware.gnss@1.1-service.gpsd)
  11. Build instructions:
  12. -------------------
  13. 1) clone gpsd into your Android build tree at;
  14. platform/external/gpsd
  15. 2) initialize your build environment for your target device;
  16. cd platform/
  17. . build/envsetup.sh
  18. lunch
  19. 3) build the component;
  20. m libgps
  21. or
  22. m gps_test
  23. This will build the component and output it at;
  24. platform/out/target/product/<device name>/vendor/
  25. As a platform dependency:
  26. -------------------------
  27. You can add the components to your device's dependency list by adding
  28. it to the PRODUCT_PACKAGES variable in one of your device's makefiles.
  29. For example;
  30. PRODUCT_PACKAGES += libgps gps_test
  31. Following this, performing a full build for your device will
  32. incorporate the component(s) into the vendor partition image for
  33. your device.
  34. Note that for the HAL, you also have to include some additional
  35. components;
  36. PRODUCT_PACKAGES += android.hardware.gnss@1.1 \
  37. android.hardware.gnss@1.1-impl \
  38. android.hardware.gnss@1.1-service.gpsd
  39. Running gps_test:
  40. -----------------
  41. gps_test is an extremely simple test client that continually prints
  42. fix and SV details to the console.
  43. It accepts one parameter, which is the IP address or hostname of
  44. a running instance of GPSd.
  45. Building other components using libgps:
  46. ---------------------------------------
  47. gps_test is a good starting point for building other components using
  48. libgps. libgps can be added either as a shared object or static
  49. linked. For use as a shared object, add "libgps" to the list of
  50. shared_libs that your module depends on. For static, use
  51. "libgps_static" in the list of static_libs.
  52. GPSd:
  53. -----
  54. The only configuration needed for GPSd is to set a system property
  55. with the launch parameters to use. This should be appended to the
  56. PRODUCT_PROPERTY_OVERRIDES variable in an appropriate device specific
  57. makefile. This is a comma-separated list of parameters.
  58. For example (note that this is the default if unspecified);
  59. PRODUCT_PROPERTY_OVERRIDES += \
  60. service.gpsd.parameters=-Nn,-D2,/dev/ttyACM0,/dev/ttyACM1
  61. GNSS 1.1 HAL for Android:
  62. -------------------------
  63. This is the part that wraps everything together on Android. It makes
  64. it possible for location services on Android to be fed location data
  65. by gpsd.
  66. The HAL is able to operate with or without gpsd running on the same
  67. device. By default, the HAL will look to localhost:2947 for gpsd,
  68. however, it is possible to change both the host and port by setting
  69. the system properties "service.gpsd.host" and "service.gpsd.port"
  70. to reflect the hostname or ip address of the gpsd host, and the
  71. port number it is listening on.
  72. The HAL also has a special automotive mode that can be activated
  73. by setting the system property "service.gpsd.automotive" to any
  74. value. When the automotive mode is activated, the HAL will feed
  75. the location services with the last known fix coordinates until
  76. the first valid fix has been received. If the fix is later lost,
  77. it will correctly NOT continue to feed a fix. The updated fix will
  78. be stored in persistent system properties every 30 seconds while
  79. there is a valid fix.
  80. The purpose of automotive mode is to make it possible to immediately
  81. input a destination into navigation software without having to wait
  82. for a valid fix. A valid fix can take minutes to establish, even with
  83. a clear view of the sky, but worse, a fix can even be impossible if
  84. the vehicle is parked underground or in any structure that
  85. effectively blocks the signals. The consequence is that without
  86. automotive mode, it would be necessary to drive the vehicle from
  87. its current location to somewhere with a clear view of the sky,
  88. and then wait potentially several minutes for a valid fix before
  89. being able to enter a destination. With automotive mode, it is
  90. possible to immediately enter a destination, and begin driving.
  91. Once a fix has been established, the navigation software will
  92. update to the current location on the route.
  93. Note that in addition to including the components, it is also
  94. necessary to make adjustments to the device's selinux policy in
  95. order for the HAL to properly interact with the network. A typical
  96. policy file will be provided.
  97. VERY IMPORTANT: SEPOLICY!
  98. -------------------------
  99. In the old days prior to Android 8, it was possible to achieve full
  100. system functionality by simply disabling selinux enforcement. This
  101. is no longer enough with Android 8+, since the init process does
  102. its own selinux checks before it will even attempt to launch a daemon.
  103. And not only this, but it is also very important to enforce a certain
  104. degree of security. As such, appropriate policy for the GPSd process
  105. and the GNSS HAL are included, however, it is necessary for it to be
  106. included in the device configuration.
  107. Add the following to an appropriate device specific makefile;
  108. BOARD_SEPOLICY_DIRS += external/gpsd/android/sepolicy
  109. Putting it all together:
  110. ------------------------
  111. Adding the following to your device's makefile will build and install
  112. GPSd and its GNSS HAL:
  113. PRODUCT_PACKAGES += android.hardware.gnss@1.1 \
  114. android.hardware.gnss@1.1-impl \
  115. android.hardware.gnss@1.1-service.gpsd \
  116. gpsd
  117. PRODUCT_PROPERTY_OVERRIDES += \
  118. service.gpsd.parameters=-Nn,-G,/dev/ttyACM0
  119. BOARD_SEPOLICY_DIRS += external/gpsd/android/sepolicy
  120. Contact: Adam Serbinski <aserbinski@gmail.com>