iphone 以编程方式重新启动

发布于 2024-11-16 12:19:11 字数 179 浏览 3 评论 0原文

我有代码

system("reboot") 

reboot 命令在终端中工作,但即使我以 root 身份运行应用程序,操作仍然被拒绝。有没有人找到任何有效的方法,或者可以解释一下SBSetting重启,这让我很好奇?

I have code

system("reboot") 

The reboot command works in the terminal, but even if I run the app as root, the operation is still denied. Has anyone found any way that works, or can explain a bit about SBSetting's reboot, which makes me curious?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

颜漓半夏 2024-11-23 12:19:11

我终于找到了一种无需 root 即可以编程方式重新启动 iOS 设备的方法!!!!
用于重新启动 iOS 设备的命令行工具称为 libimobiledevice:

http://krypted.com/mac-os-x/use-libimobiledevice-to-view-ios-logs/

这确实令人惊叹。我在安装时遇到的一个障碍是尝试安装这一行:

brew install -v --devel --fresh automake autoconf libtool wget libimobiledevice

但是我通过运行这一行解决了安装问题:

brew install -v --fresh automake autoconf libtool wget libimobiledevice

遇到这个问题后,我按照其余的说明进行操作,瞧!

大多数命令都可以在此页面上找到:
http://krypted.com/uncategorized/command-line-ios-device- management/

重启iOS设备的神奇命令是:

idevicediagnostics restart

这个工具真正神奇的地方不仅在于重启iOS设备,还可以使用以下命令将iOS设备日志输出到mac的终端应用程序:

idevicesyslog

I have finally found a way to programmatically restart an iOS device without rooting a device!!!!
The command line tool to restart an iOS device is called libimobiledevice:

http://krypted.com/mac-os-x/use-libimobiledevice-to-view-ios-logs/

It is truly amazing. One snag I ran into while installing was trying to install this line:

brew install -v --devel --fresh automake autoconf libtool wget libimobiledevice

However I got around the install problem by running this line:

brew install -v --fresh automake autoconf libtool wget libimobiledevice

After that problem, I followed the rest of the instructions and voila!

Most of the commands can be found on this page:
http://krypted.com/uncategorized/command-line-ios-device-management/

The magic command that restarts the iOS device is:

idevicediagnostics restart

What is truly amazing about this tool is not only restarting an iOS device but also outputting iOS device logs to mac's terminal app using the following command:

idevicesyslog
莫多说 2024-11-23 12:19:11

我想出了一个办法,虽然有点复杂。问题是,即使您将应用程序设置为以 root 身份运行,当您进行 system() 调用时,您显然仍然仅限于用户移动< /strong> 特权。由于移动无法(成功)调用重新启动,因此这不起作用。

我解决这个问题的方法是利用 SBSettings 支持的新功能。 SSBettings 有一个运行的特权守护进程。它允许您插入自己的命令,只需编写脚本(或其他可执行文件)并将其转储到适当的目录(/var/mobile/Library/SBSettings/Commands)即可。重新启动 sbsettingsd 进程后,您可以通过发布通知来让它运行您的脚本。 命名脚本

com.mycompany.reboot

如果您在应用程序中

#import <notify.h>

notify_post("com.mycompany.reboot");

,则可以执行以下代码:然后,将 com.mycompany.reboot 制作为一个简单的 shell 脚本,如下所示:

#!/bin/sh
reboot

并确保在 com.mycompany.reboot 上执行 chmod 755。 mycompany.reboot 脚本。可以在此处找到此 SB​​Settings 命令功能的完整详细信息:

http://thebigboss.org/guides/ sbsettings-toggle-spec(请参阅调用外部函数和脚本 ...)

无论如何,它确实要求您的应用程序依赖于 SSBettings,但是它是一个免费的应用程序,大多数用户可能都想拥有它。目前,它通过 notify_post() 以编程方式实现了重新启动(或任何其他需要 root 访问权限)的目标。

I figured out a way to do it, although it's a bit convoluted. The problem is that even if you setup your app to run as root, when you make system() calls, you're apparently still limited to user mobile privileges. Since mobile cannot call reboot (successfully), this doesn't work.

The way I got around this problem is to take advantage of a new feature that SBSettings supports. SBSettings has a privileged daemon process that runs. It allows you to plug in your own commands, by simply writing a script (or other executable) and dumping it in the appropriate directory (/var/mobile/Library/SBSettings/Commands). Once you then restart the sbsettingsd process, you can get it to run your script by posting a notification. If you name your script

com.mycompany.reboot

then from within your app, you can execute this code:

#import <notify.h>

notify_post("com.mycompany.reboot");

Then, you make com.mycompany.reboot a simple shell script like this:

#!/bin/sh
reboot

And make sure to chmod 755 on your com.mycompany.reboot script. The full details of this SBSettings command feature can be found here:

http://thebigboss.org/guides/sbsettings-toggle-spec (see Calling External Functions and Scripts ...)

Anyway, it does require your app to depend on SBSettings, but it's a free app, and most users would probably want to have it anyway. For now, it accomplishes the goal of rebooting (or anything else that requires root access) programmatically, via notify_post().

樱娆 2024-11-23 12:19:11

这个答案可能对某些人来说有点老套,但我还没有找到更好的解决方案来重新启动尚未越狱的 iOS 设备,所以这是我的答案:

为了从命令行重新启动设备,我做了一些准备工作:

  • 连接设备到计算机
  • 将 iTunes 快捷方式添加到扩展坞
  • 选择聚光灯并搜索名为 Automator 的应用程序[必须安装 Xcode 才能启动 Automator!]
  • 当 Automator 启动时,选择应用程序选项
  • 选择录制按钮开始记录以下操作
  • 选择iTunes 快捷方式
  • 从设备选项中选择您的设备
  • 选择恢复备份...按钮
  • 选择恢复按钮
  • 选择 Automator 应用程序上的停止按钮以停止录制。
  • 在 Automator 应用程序中,从顶部栏中选择“文件”,然后将新录制的应用程序保存到您选择的位置。

此时,您拥有一个将执行上述步骤的应用程序文件。我倾向于让 iTunes 保持打开状态,因为它始终会连接 iOS 设备并准备好进行访问。当 iTunes 关闭并重新启动时,设备需要一些时间才能与 iTunes 完全连接,这往往会破坏 Automator 应用程序的流程。

此时,我可以进入终端,转到应用程序文件的位置并运行以下命令[示例]:

open automator.app
(将 'automator.app' 替换为您的文件名)

如果您像我一样并且在 jenkins 中运行此命令,则需要运行以下命令:

  1. open [location ]/[your_app_name.app]
  2. sleep 30

由于某种原因,自动化应用程序需要睡眠时间来完成所有记录的操作。

另外,我确信您也可以编写一个 applescript 来完成所有这些操作,但我讨厌 applescript 并采取了简单的方法!

This answer might feel hacky to some but I have not found a better solution on how to restart an iOS device that has not been jailbroken so here goes my answer:

In order to restart a device from the command line I do some prep work:

  • Connect device to computer
  • Add iTunes shortcut to your dock
  • Select spotlight and search for an application called Automator [must have Xcode installed in order to launch Automator!]
  • When Automator launches, select the Application option
  • Select the record button to start recording following actions
  • Select the iTunes shortcut
  • Select your device from the Device options
  • Select the Restore Backup... button
  • Select the Restore button
  • Select the stop button on the Automator app to stop recording.
  • From the Automator application, select File from the top bar and Save your newly recorded app to a location of your choosing

At this point you have an app file that will execute the steps mentioned above. I tend to leave iTunes open as it will always have the iOS device hooked up and ready to be accessed. When iTunes is closed and relaunched, the device takes time to fully connect with iTunes and this tends to break the flow of the Automator app.

At this point I can go into a terminal, go to the location of the app file and run the following command [EXAMPLE]:

open automator.app
(replace 'automator.app' with the name of your file)

If you are like me and your are running this command in jenkins, you will need to run the following commands:

  1. open [location]/[your_app_name.app]
  2. sleep 30

For some reason, the automator app needs the sleep time to complete all the recorded actions.

Also, I am sure you can also write an applescript to do all of this but I hate applescript and took the easy way out!

固执像三岁 2024-11-23 12:19:11

如果应用程序在其沙箱中运行,则这是不可能的。在越狱的手机上,您也许能够执行重新启动 shell 命令。

This is not possible if the app is running in its sandbox. on a jailbroken phone you might be able to execute the reboot shell command.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文