假的GPS的运行Android虚拟箱 [英] fake gps for android running in virtual-box

查看:275
本文介绍了假的GPS的运行Android虚拟箱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试虚拟化的GPS设备在运行Android虚拟盒。我想,以方便在Android中使用GPS设备,或得到一个假的GPS定位一些如何运行的应用程序。我已经开始寻找Android模拟器源$ C ​​$ C,但同时,任何人有任何好的地方开始。

I am trying to virtualize GPS device in android running in virtual-box. I want to facilitate an app running in android to use the gps device or get a fake gps location some how. I have started looking at the android emulator source code but meanwhile, any one has any good place to start with.

[更新]

要使它有点更清晰,整个应用程序栈将一些东西一样:

To make it a bit more clear, the whole application stack would be some thing like:

Android app (with gps functionality) to be tested ----> (developed by end user)

Android virtual machine ----> (Guest OS)

virtual box ----> 

Microsoft Windows ---> Host OS 

现在,我非常希望有我的应用程序(如亚行 DDMS )从那里在Windows中运行用户可以设置一些协调GPS设备值(在没有实际的GPS,否则虚拟化现有的GPS)。这些坐标是提供给Android应用程序。基本上,这是一样的,通过虚拟盒运行的机器人图像提供现有的Andr​​oid模拟器(使用DDMS)的功能。

Now, Ideally I would like to have my application (like adb or ddms) running in Windows from where the user can set some coordinate values for gps device (in absence of actual GPS, else virtualize the existing GPS) . These coordinates would be available to the android app. Basically, this is same as providing the functionality of existing android emulator (using ddms) through virtual-box running an android image.

我不运行Android模拟器,我没有使用Eclipse。 :(
[更新完]

I am NOT running android emulator and I am not using eclipse. :( [UPDATE ENDS]

谢谢,
维克拉姆。

Thanks, Vikram.

推荐答案

这是我如何做的(以及如何Android软件开发包(VBOX上运行)的作品的简要概述)。

This is how I did it (and a brief overview of how android stack (running on vbox) works).

具有GPS功能的Andr​​oid应用程序,注册一些回调与用户模式共享库的基础实现(通常libgps.so或libhardware_legacy.so)使用JNI接口(如出口框架/基/核心/jni/android_location_GpsLocationProvider.cpp

An Android app having GPS functionality, registers some callbacks with the underlying implementation of user mode shared lib (typically libgps.so or libhardware_legacy.so) using JNI interfaces (as exported in frameworks/base/core/jni/android_location_GpsLocationProvider.cpp)

这些注册的回调是负责通知GPS定位(或GPS定位的变化)的应用程序。

These registered callbacks are responsible for notifying GPS fix (or change in gps location) to the app.

下面是一个简单的图片展示呼叫流程Android的 - >垂直框 - >视窗

现在完成这个流程中,需要以下步骤:

Now to complete this flow, following steps were required:


  1. 我创建了自己的 libgps.so 出口 gps_get_interface (中声明的函数 gps.h ),用于通过JNI接口。与GPS支持的应用程序获取最新的坐标,从这个libgps.so,这实际上是由GpsLocationProvider服务动态加载返回。

  1. I created my own libgps.so exporting the function gps_get_interface (declared in gps.h), which is used by JNI interface. An app with gps support gets the latest coordinates returned from this libgps.so, which is actually loaded dynamically by the GpsLocationProvider service.

使用VBOX头和含例程连接,断开连接,并发送功能请求主机服务,在主机操作系统上运行再创建一个共享对象。这些是pre-定义的ioctl号码简单的ioctl()调用(如:VBOX_GUEST_IOCTL_HGCM_CONNECT等)

Create one more shared object using Vbox headers and containing routines to connect, disconnect, and send function request to the host service, running in host OS. These are simple ioctl calls with pre-defined ioctl-numbers (eg: VBOX_GUEST_IOCTL_HGCM_CONNECT etc).

创建主机服务(这实际上是一个DLL,由垂直框主机服务加载)具有可以处理来自HGCM传递的参数调用和返回所需的数据在共享对象在步骤2中了解到创建的格式。

Create a host service (which actually is a DLL, loaded by VBox Host Service) with can handle the parameters passed from HGCM calls and return the required data in a format that the shared object created in step 2 understands.

现在送假/伪位置返回到一个应用程序内 Android的虚拟机上运行,你只需要通知主机服务,剩下的就是传送回垂直框附加 - > libgps.so - > GpsLocationProvider服务 - >终于到了应用与GPS支持

Now to send any fake/dummy location back to an app running inside Android VM, you just need to notify the host service, and the rest is communicated back to VBox Additions -> libgps.so -> GpsLocationProvider service -> and finally to the App with GPS Support.

希望这将有助于有人尝试一些类似的东西或者帮助某一个了解如何栈Android版。

Hope this will help some one trying some thing similar or help some one understanding how android stack works.

请注意:编译hgcm code和与Android LIB连接起来,也有点复杂,因为在android的libc中实现(和其他一些库也一样)的功能数量有限。为了避免这一切,你可以直接打开设备(的/ dev / vboxguest)和发布,是已知的VBOX和你的主机服务的格式上它控制调用。

NOTE: Compiling the hgcm code and linking it with android lib is also a bit complicated because of the limited number of functions implemented in android libc (and some other libs as well). To avoid this all, you can directly open the device (/dev/vboxguest) and issue ioctl calls on it in the format that is known to vbox and your host service.

这篇关于假的GPS的运行Android虚拟箱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆