安卓:添加应用程序到固件,使用WRITE_SECURE_SETTINGS [英] Android: Add app to firmware, use WRITE_SECURE_SETTINGS

查看:318
本文介绍了安卓:添加应用程序到固件,使用WRITE_SECURE_SETTINGS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试着写一个应用程序,可以打开和关闭我的移动数据连接。 已经得到了源和建立了自己的SDK,在这里我删除了@hide语句这样我就可以使用相应的功能

I'm trying to write an app that can turn my mobile data connection on and off. Already got the source and built my own sdk, where I removed the @hide statements so I can use the relevant function

cm = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
cm.setMobileDataEnabled(true);

也发现我需要哪些权限,特别是WRITE_SECURE_SETTINGS,这是唯一可用的系统应用程序。我读adamk的<一个href="http://stackoverflow.com/questions/3476600/why-are-these-permissions-being-refused/3477237#3477237">comment现在需要知道如何做什么,他建议(应用程序添加到系统或平台密钥签名)。

Also found out which permissions I need, in particular WRITE_SECURE_SETTINGS, which is only available to system apps. I read adamk's comment and now need to know how to do what he suggested (add the app to system or sign it with the platform key).

起初我想这样做是在模拟器只,然后在我的手机(其根源,并使用自定义ROM)。 我试图将其推到系统目录上的仿真器:

At first I would like to do that on the emulator only, and then on my phone (which is rooted and using a custom ROM). I tried pushing it to the system directory on the emulator:

adb remount
adb push app.apk /system/app/
adb sync

没有工作,该应用程序没有被发现和安装。

which did not work, the app was not found and installed.

我是怎么忘了?如何正确的方式做到这一点?

What did I forget? How is the proper way to do this?

推荐答案

于是,我终于发现了问题并解决它。 我其实相当接近:

So, I finally found the problem and solved it. I was actually quite close:

adb remount
adb push app.apk /system/app/

这是做在模拟器上(不需要亚行同步)的正确方法。我看着logcat的,并且发现了您需要登录您的.apk文件,以便系统不会拒绝它,即使不添加任何的有效性在这种情况下。 如果你把一个签名的apk这样一来,它会得到所需要的权限和预期的工作 - 在我的情况下,打开了移动数据连接和断开。 对于部分手机(使用ClockworkMod): 开机进入恢复模式,挂载/系统文件夹,并启用USB存储。然后,继续以同样的方式与模拟器,重启手机,你是好去。 希望这可以帮助别人谁遇到同样的问题。

This is the correct way to do it on the emulator (no adb sync needed). I watched the logcat, and found out that you need to sign your .apk file so the system does not reject it, even if that does not add any validity in this case. If you push a signed .apk this way, it will get the needed permissions and work as expected — in my case, turning the mobile data connection on and off. For the phone part (using ClockworkMod): Boot into recovery mode, mount the /system folder and enable USB storage. Then proceed in the same way as with the emulator, reboot the phone, and you are good to go. Hope this helps someone who encounters the same problem.

这篇关于安卓:添加应用程序到固件,使用WRITE_SECURE_SETTINGS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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