App that survives a factory reset My problem is theoretical at this moment. I am investigating if it is possible or not, before spending hours on it.


I have a rooted phone.
I want to add an entry to the IPTABLES on startup.
If the phone is factory reset, I still want the entry to be added to IPTABLES.


My thought so far are:


Altering the boot image and making the init.rc permanent, but I think that is to scary and risky.
Create an app (apk) that is installed in /system/app that runs the ITPABLES command.


What are my chances of succeeding with number 2?

To run IPTABLES the apk needs root, the phone is rooted, but does the app have root access just because it is in /system/app?
Normal apps trigger SuperSU to grant the app root, but I want it to do the IPTABLES thing without any popups. All unattended.
Your chances for #2 are pretty good – though there might be some caveats. To figure which those are, let's take a look of what a factory-reset does. It...


wipes /data
wipes /cache
wipes the dalvik cache (usually implicitly, as in most cases this resides in /data; I guess with Lollipop it will do the same for ART).


So you see, /system remains untouched. With your app installed in /system/app, it will survice a factory-reset. But its data might not, as /data gets wiped. Which means, all required settings need to be part of the app itself, or of its "default settings" which get deployed on first initalization.

For the second part: That's better asked at a development site (which we are not). Basically, no app gets root access by default AFAIK. They get access to everything their permissions allows (and yes, there are permissions which can be granted to system apps which are not available to "user-space apps") – but for root access, you've got to ask su, which should trigger the corresponding superuser app.

PS: As for the SuperSU popup, you will have to live with that for the first call, I'm afraid.