Simple Analysis of android Qemu GPS module

Source: Internet
Author: User

Simple Analysis of android Qemu GPS module

The gps module of Android is gps. default. so on the system/lib/hw/directory. Generally, the mobile phone that provides the gps function should implement the interaction between this module and the real gps hardware.

In Qemu, gps is to construct a gps. default. so, but this so does not deal with real hardware. It is just a simulated interface, and its code is in sdk/emulator/gps/gps_qemu.c.


A gps device is implemented outside the Qemu container, but this device can only interact with Android through pipelines. Therefore, the gps_qemu.c function is to deal with pipelines and provide gps functions required by Android, as shown below:

Static const GpsInterface qemuGpsInterface = {

    sizeof(GpsInterface),    qemu_gps_init,    qemu_gps_start,    qemu_gps_stop,    qemu_gps_cleanup,    qemu_gps_inject_time,    qemu_gps_inject_location,    qemu_gps_delete_aiding_data,    qemu_gps_set_position_mode,    qemu_gps_get_extension,};

Qemu external GPS sends data to the gps module through the QEMU_CHANNEL_NAME pipe in the NMEA format. Therefore, the gps module has several functions responsible for parse data.


The GPS module has a requirement that its callback must be used to create a thread (gps_state_thread), while the location information callback can only be in this thread (gps_state_thread ), this is because the framework requires a java thread visible to the vm, and gps_state_thread will be attach to the vm, And the java layer function will be called back from time to time.

state->thread = callbacks->create_thread_cb( "gps_state_thread", gps_state_thread, state );
 
Therefore, when the location information of QEMU_CHANNEL_NAME is returned, callback cannot be called directly. Instead, it must be sent to the android framework at gps_state_thread.
Therefore, gps. default. so calls the epoll function to listen to the file fd, so that location information is returned in gps_state_thread.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.