Thursday, June 24, 2010

Research: How to launch iOS app upon device startup

I have long been interested in the deep innerworkings of the iPhone (now iOS). I have gotten into iOS development, and poked into the process of jailbreaking and the filesystem of iDevices.

Today I was given a task to research the possibility of launching an app when the iDevice boots. I know that it is possible, since certain jailbreak apps/ processes are loaded upon startup. My digging led me to learn about daemons and how they work. This is incredibly useful to me in my quest to understand under the hood of iOS. Here are the results from my research.
  • The device will have to be jailbroken in order to have access to the filesystem. I recommend Pwnage. It takes a lot longer than Spirit, but is more secure.
    • With Spirit, you simply plug in your iPhone, open the Spirit app, press a button, and you're jailbroken. Spirit is what's called a "untethered userland jailbreak." Which means it exploits a hack in user (rather than kernel) mode in the UNIX filesystem. It therefore does not require iTunes to reboot the device and perform low-level tasks. Apple usually fills these holes in the minor updates (i.e. 3.1.x).
    • The Pwnage Tool,  builds a custom .ipsw file from an official copy. After that process is complete, you restore it to the device using iTunes. This is my preferred method. It takes about 30 minutes (maybe more), but some Pwnage jailbreaks will persist through software updates.There are Pwnage jailbreaks for 3.2 and 4.0 software already.
  • Here is a list of iOS daemons. Depending on the functionality of the app, we can delete many of these in order to clear up some overhead RAM.
  • We will have to create a daemon to launch our app. This tutorial goes into it as well as this one. The .plist will obviously have to be customized, but these two just prove that it is possible.
  • Overriding the home button is the other issue I'm researching. In addition to SBSSettings, there are other apps which allow you to associate user interactions on the screen (swipe, pinch, touching the volume display, etc) with system actions (e.g opening apps, toggling settings). More research is needed on this, but I do believe it is a feasible task.
This stuff is VERY interesting to me. I'm glad that I'm finally starting to get somewhere in my quest to understand what's happening in the system itself.

Too bad I just decided today that I want an iPhone 4. I'm almost sure they're all gone now.