Android GPS如何工作?

时间:2011-07-18 11:08:55

标签: android gps

我想更好地理解GPS在Android中的工作方式,我想要包含一些跟踪它并修改其行为的痕迹。在GpsLocationProvider.java中,我找到了方法:

 private native boolean native_init();
private native void native_disable();
private native void native_cleanup();
private native boolean native_start(int positionMode, boolean singleFix, int fixInterval);
private native boolean native_stop();
private native void native_set_fix_frequency(int fixFrequency);
private native void native_delete_aiding_data(int flags);
private native void native_wait_for_event();
// returns number of SVs
// mask[0] is ephemeris mask and mask[1] is almanac mask
private native int native_read_sv_status(int[] svs, float[] snrs,
        float[] elevations, float[] azimuths, int[] masks);
private native int native_read_nmea(int index, byte[] buffer, int bufferSize);
private native void native_inject_location(double latitude, double longitude, float accuracy);

// XTRA Support
private native void native_inject_time(long time, long timeReference, int uncertainty);
private native boolean native_supports_xtra();
private native boolean native_inject_xtra_data(byte[] data, int length);

// DEBUG Support
private native String native_get_internal_state();

// AGPS Support
private native void native_agps_data_conn_open(String apn);
private native void native_agps_data_conn_closed();
private native void native_agps_data_conn_failed();
private native void native_set_agps_server(int type, String hostname, int port);

// Network-initiated (NI) Support
private native void native_send_ni_response(int notificationId, int userResponse);

但是,我想看看他们做了多少详细的事情。它们在哪里实施?我已经找到了GPS的高通驱动程序,但我想在抽象硬件问题(HAL层?)之间缺少一层。

1 个答案:

答案 0 :(得分:1)

我希望您知道这些应该在JNI层映射到相应的GPS供应商API。当你说这些是作为HAL层的一部分实现时,你是对的。 HAL层将成为GPS芯片组供应商代码的一部分。

既然你谈到了高通,我可以告诉你,高通公司肯定有HAL层。如果您有源,可以检查它们的引擎部件。但它有版权和因此,我无法向您提供实现本机API的源代码。