Android INJECT_EVENTS 权限 [英] Android INJECT_EVENTS permission

查看:49
本文介绍了Android INJECT_EVENTS 权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个应用程序,该应用程序将在后台运行一个服务,该服务能够将触摸屏事件注入到正在运行的任何活动中.我可以通过调用 Instrumentation.sendPointerSync(motionEvent); 将事件注入到属于我的应用程序的 Activity 中,但是如果我尝试在没有运行应用程序的活动的情况下执行此操作,则会收到权限错误说我没有 INJECT_EVENTS 权限.我已将此权限添加到我的清单中,如下所示:<uses-permission android:name="android.permission.INJECT_EVENTS"></uses-permission> 它仍然抛出相同的权限例外.经过一番搜索,我得到的答案是,为了获得 INJECT_EVENTS 权限,您的应用程序必须由与系统签名的签名相同的签名进行签名.然而,我不清楚这究竟意味着什么.我将不得不找到一个自定义 rom 构建它并使用与应用程序签名的相同签名对其进行签名.然后在我的设备上安装自定义 rom,然后安装我的应用程序,我将能够正确注入触摸事件?如果是这种情况,我最好从已经组合在一起的自定义 rom 开始,例如 从此页面 或者是我需要获取android项目的git副本并构建整个myslef的情况?无论哪种方式,有没有人知道您可以指点我的地方,让我朝着正确的方向工作以实现这一目标?

I am trying to create an application that will have a service running in the background that will be capable of injecting touch screen events into whatever activity is running. I am able to inject events into an Activity that is part of my application by calling Instrumentation.sendPointerSync(motionEvent); However if I try to do this without an activity from my application running I get a permission error saying that I don't have the INJECT_EVENTS permission. I've added this permission to my manifest like this: <uses-permission android:name="android.permission.INJECT_EVENTS"></uses-permission> Its still throwing the same permission exception though. After a bit of searching I've gotten the answer that in order to receive the INJECT_EVENTS permission your app must be signed by the same signature that the system is signed with. I am unclear however what exactly this means. I am going to have to find a custom rom build it and sign it with the same signature that the application is signed with. Then install the custom rom on my device, then install my app and I'll be able to inject the touch events correctly? If this is the case am I better off starting with a custom rom that is already put together, like one from this page Or is it a situation where I am going to need to grab a git copy of the android project and build the whole thing myslef? And either way does anyone know of a place you could point me that would get me working in the right direction to make this happen?

推荐答案

实际上,这在有 root 权限的设备上非常简单.我认为任何运行/system 的应用程序都可以访问它需要的任何权限.因此,只需将您的应用程序手动安装到/system(如此处所述 http://androidforums.com/droid-all-things-root/64603-installing-apk-system-app-directory.html ):

Actually, this is pretty simple on a rooted device. I think any app that is running off /system will get access to whatever permissions it requires. So simply manually install your App to /system (as described here http://androidforums.com/droid-all-things-root/64603-installing-apk-system-app-directory.html ):

在终端模拟器中执行以下命令,重新挂载/system目录为读/写,并将应用程序从SDCARD安装到/system/app目录:

Execute the following commands in the terminal emulator to remount the /system directory as read/write and to install the application into the /system/app directory from the SDCARD:

su
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
cp /sdcard/APP.apk /system/app

如果您更喜欢在计算机上使用 adb,请执行以下命令:

If you prefer to use adb from your computer, execute these commands:

adb remount
adb shell cp /sdcard/APP.apk /system/app

一些用户使用了来自 Google 市场的根浏览器来简化这个过程.

Several users have utilized root explorer from the Google marketplace to simplify this process.

或者,看看这个:如何用系统编译 Android 应用程序权限

这篇关于Android INJECT_EVENTS 权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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