android Qemu GPS 模組簡明分析

來源:互聯網
上載者:User

標籤:android

Android 的 gps module 是  gps.default.so 在system/lib/hw/ 目錄上, 一般提供gps功能的手機應該實現這個module和真實gps硬體互動

Qemu中gps就是要構造一個gps.default.so,  但這個so並不和真的硬體打交道,只是個類比介面,其代碼在sdk/emulator/gps/gps_qemu.c中


Qemu 容器外部實現了一個gps裝置,但這個裝置和 Android 互動只能通過管道,所以gps_qemu.c的功能就是同管道打交道,並提供Android需要的gps functions, 如下:

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外部GPS通過 QEMU_CHANNEL_NAME 管道給 gps module  發送資料, 格式 NMEA, 所以 gps module 有幾個函數負責 parse這些資料的


GPS模組有個要求,就是必須用它的 callback 來建立線程(gps_state_thread), 而將在的位置資訊回調只能在此線程中(gps_state_thread),這是因為framework 需要一個vm可見的java thread,  gps_state_thread 會被attach 到 vm 上了,從來回調 java 層函數

state->thread = callbacks->create_thread_cb( "gps_state_thread", gps_state_thread, state );

所以當QEMU_CHANNEL_NAME的位置資訊過來不能直接調用callback, 而要在 gps_state_thread 發送到 android framework
因此 gps.default.so 調用 epoll 函數監聽檔案fd, 實現在 gps_state_thread 中把 location 資訊送回

android Qemu GPS 模組簡明分析

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.