定制适合的Andr​​oid应用程序:自动更新和永远在线的? [英] Custom-fit Android app: auto-update and always-on?

查看:154
本文介绍了定制适合的Andr​​oid应用程序:自动更新和永远在线的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开发通常会被认为是恶意软件的应用程序,但客户的需求是非常具体和逻辑。我们有大约50-100被囫囵吞下,插入,和应用程序应该通过TCP发送一些传感器数据到远程服务器cheapset Android手机。这听起来很简单,但有两个功能,我挣扎(因为我不是一个有经验的Andr​​oid开发,并且从来没有根植电话):

I'm trying to develop an app that would normally be considered to be malware, but the customer's demands are very specific and logical. We have around 50-100 cheapset Android phones that are bolted down, plugged in, and the app is supposed to send some of the sensor data via tcp to a remote server. It sounds simple enough, but there are two features that I struggle with (since I'm not an experienced Android developer, and have never rooted a phone):

1的应用程序应始终打开。如果它崩溃,服务器应该得到的错误报告(堆栈跟踪),以及应用程序应该在10分钟后放弃之前重新启动一次。此外,操作系统理论上可以杀死应用程序(虽然我尽我所能去减少内存使用)。我想以某种方式处理这一点。

#1 The app should be always on. If it crashes, server should get the error report (stack trace), and the app should be restarted after 10 minutes one more time before giving up. Also, the OS could theoretically kill the app (although I did my best to minimize the memory usage). I'd like to somehow handle that as well.

#2那将是巨大的,如果该应用程序可以被远程更新或自动更新,任何没有用户交互(因为没有传统的用户)。

#2 It would be great if the app could be remotely updated, or auto-updated, with no user interaction whatsoever (since there is no conventional user).

要实现#1,我看比根的电话没有其他解决办法(AlarmsManager似乎没有工作,如我所料,添加其他应用程序,以照顾第一个就觉得错的)。是否有什么我失踪?

To implement #1, I see no other solution than to root the phone (AlarmsManager doesn't seem to work as I expected, and adding another application to take care of the first one just feels wrong). Is there anything I'm missing?

我不知道如何处理实现的功能#2可言。如果我把应用程序市场,并勾选保持这个应用程序始终保持最新状态复选框进行安装时,将这项工作?我担心,服务运行时不会发生自动更新,即使它没有,该操作系统将不安装此更新(除非功能#1实现)后,重新启动该服务。如果我编程下载最新的.apk文件并打开它,我仍然需要用户点击安装按钮。我甚至在考虑实施一些脚本语言的更新的部分。

I don't know how to approach implementing feature #2 at all. If I put the app on the market and check the "keep this application always up to date" checkbox while installing it, will that work? I fear that the auto-update would not occur while the service is running, and even if it did, that the OS would not restart the service after installing the update (unless feature #1 is implemented). If I programatically download the latest .apk and open it, I still need the user to click the "Install" button. I'm even considering implementing the updateable part in some scripting language.

有Android的API的限制范围内解决这些问题呢?

Is there a solution to these problems within the limits of Android API?

编辑:谢谢大家的答案,你非常有帮助。似乎只有这样,才能让Android的行为作为一个非用户的硬件是铲除它。这是做无声的自动更新的唯一途径。始终在随后通过启用的cron来实现(AlarmManager显然不触发事件的情况下通过碰撞终止服务的,但它可以被其他琐碎的,非crashable服务,以保持第一个运行)。

Thank you all for your answers, you've been very helpful. It seems that the only way to make Android behave as a non-user piece of hardware is to root it. That's the only way to do silent auto-updates. Always on can then be implemented by enabling cron (AlarmManager apparently doesn't fire the event in case of service termination via crash, but it could be used by another trivial, non-crashable service to keep the first one running).

推荐答案

有关#1,你可以使用前台服务。我不知道你是怎么经常需要获得传感器数据,但有什么用AlarmManager问题?我不知道怎样生根能帮助#1虽然。你真的不能做#2没有生根或建立你的固件。如果您安装的应用程序作为一个系统应用程序(在 /系统/应用程序),您可以使用一个隐藏的 PackageManager 默默地安装新的版本。利用市场/播放自动更新应该工作,但是你没有办法控制的更新时间表。而且,是的,它不会重新启动服务,但如果您使用AlaramManager,这不应该是一个问题。

For #1 you can use an foreground service. I don't know how often you need to get sensor data, but what's the problem with AlarmManager? I don't see how rooting could help with #1 though. You can't really do #2 without rooting or building your firmware. If you install your app as a system app (in /system/app) you can use a hidden PackageManager to silently install the new version. Using Market/Play autoupdate should work as well, but you have no way to control the update schedule. And, yes, it won't restart your service, but if you use AlaramManager, this shouldn't be a issue.

总而言之,股票Android是不是完全是一个嵌入式系统,让您完全控制,所以这取决于你有多少时间/精力都愿意花钱,你可能要有点自定义(或者找一个定制ROM,获取接近您的要求)。

All in all, stock Android is not exactly an embedded system that gives you full control, so depending on how much time/effort you are willing to spend, you might want to customize it somewhat (or find a custom ROM that gets close to your requirements).

这篇关于定制适合的Andr​​oid应用程序:自动更新和永远在线的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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