没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
Application
Application Framework
JNI
HAL
SystemServer.java
location = new LocationManagerService(context);
Location Application
the thread will call initialize()
private void initialize() {
…
loadProviders() ;
...
LocationManagerService.java
void systemReady() { //start the location thread
Thread thread = new Thread(null, this,
"LocationManagerService");
thread.start();
}
in loadProviders call _loadProvidersLocked();
/*in _loadProvidersLocked we get the GpsInterface*/
GpsLocationProvider.isSupported();
public static boolean isSupported() {
/* invoke the native method to get the GpsInterface */
return native_is_supported();
}
static JNINativeMethod sMethods[] = {
...
{"native_is_supported", "()Z", (void*)android_location_GpsLocationProvider_is_supported},
…
}
static jboolean android_location_GpsLocationProvider_is_supported(JNIEnv* env, jclass clazz) {
return (sGpsInterface != NULL || get_gps_interface() != NULL);
}
static const GpsInterface* get_gps_interface() {
err = hw_get_module(GPS_HARDWARE_MODULE_ID, (hw_module_t const**)&module);
…
err = module->methods->open(module, GPS_HARDWARE_MODULE_ID, &device);
...
gps_device_t* gps_device = (gps_device_t *)device;
interface = gps_device->get_gps_interface(gps_device)
return interface;
}
int hw_get_module(const char *id, const struct hw_module_t **module)
{
…
/*get the share lib path*/
snprintf(path, sizeof(path), "%s/%s.%s.so",
HAL_LIBRARY_PATH1, id, prop);
…
status = load(id, path, module); //load the share lib and get the struct hw_module_t module
}
static int load(const char *id, const char *path, const struct hw_module_t **pHmi)
{
handle = dlopen(path, RTLD_NOW); //open the share lib dynamically
...
const char *sym = HAL_MODULE_INFO_SYM_AS_STR;
hmi = (struct hw_module_t *)dlsym(handle, sym); //get the struct hw_module_t address
...
*pHmi = hmi;
...
}
GpsLocationProvider.java
com_android_server_location_GpsLocationProvier.cpp
hardware.c
const struct hw_module_t HAL_MODULE_INFO_SYM = {
...
.methods = &hw_module_methods,
};
static struct hw_module_methods_t hw_module_methods = {
.open = open_gps
};
static int open_gps(const struct hw_module_t* module, char const* name,
struct hw_device_t** device)
{
struct gps_device_t *gps_device = malloc(sizeof(struct gps_device_t));
if (gps_device)
{
...
gps_device->get_gps_interface = gps_get_hardware_interface;
*device = (struct hw_device_t*)gps_device;
return 0;
}
return 1;
}
const GpsInterface* gps_get_hardware_interface(struct gps_device_t* dev)
{
/*we focus on and need to realize the interface*/
return &_GpsInterface;
}
jshazk1989
- 粉丝: 61
- 资源: 19
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
前往页