如何通过应用程序ID确定iOS上哪些应用程序是后台应用程序和哪些应用程序是前台应用程序
使用此问题,我可以获得 iOS 设备上运行的应用程序列表。 我知道 PID 并且可以访问它们的 kinfo_proc
结构。 如何确定哪些是前台进程,哪些是后台进程(假设我的应用程序是后台)?
我试图通过 kp_proc.p_priority
根据 kinfo_proc
中的信息(参见第一个链接)找到这一点,但看起来无法推断背景/前景状态从优先级。
我并不真正关心这是否适用于 AppStore Review,但我更喜欢一种无需越狱即可工作的方法(即私有 API 可以,但哪些?)。我希望它至少在 iOS 5 上工作
我考虑编写一个简单的 MobileSubstrate
扩展,将其注入到所有应用程序中,然后挂钩每个人的 applicationDidBecomeActive
,但这需要越狱,并且是太具有侵略性了。
Using the method described in this question, I can get a list of apps running on an iOS device.
I know PIDs and have access to their kinfo_proc
structures.
How can I determine which are foreground processes and which are background (assuming my app is background)?
I tried to find this out base on information in kinfo_proc
(see 1st link), via kp_proc.p_priority
, but it looks like it is not possible to infer background/foreground state from priority.
I don't really care if this works correctly for AppStore Review but I would prefer a method that will work without a jailbreak(i.e. Private APIs are ok but which ones?). I want this to work at least on iOS 5
I considered writing a simple MobileSubstrate
extension, injecting it into all apps and just hook everyone's applicationDidBecomeActive
, but this requires a jailbreak and is too invasive.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
嗯,看起来模拟器中 SpringBoardServices 二进制文件上 nm 和 IDA 的一些用法帮助了我。
以下代码适用于在 iPod Touch 4、iPhone 4 和 iPad1 WiFi(所有非 JB)上运行的 iOS 5.0.1
当然,你永远不应该尝试将其提交到 AppStore
当然,第二个循环并不是绝对必要的,但我需要非本地化的名称和名称。 PID 也是如此。
Well, looks like some usage of nm and IDA on SpringBoardServices binary from simulator helped me on this.
Following code works on iOS 5.0.1 running on iPod Touch 4, iPhone 4 and iPad1 WiFi(all non-JB)
Of course you should never try to submit that to AppStore
Of course 2nd loop is not strictly necessary but I needed non-localized names & PIDs too.
很好的答案!但是您的代码中有一个小拼写错误,应该是:
首先确保定义了 SBSERVPATH 并包含正确的头文件:
然后首先找到正确的 SB 端口:
然后找到活动的应用程序:
Great answer! But there is a small typo in your code, it should be:
First make sure that SBSERVPATH is defined and the correct header files are included:
Then first find the correct SB port:
And then find the active app:
这对我来说适用于所有 IOS 设备:
This is what works for me on all IOS devices: