[Galaxy S III Android Development] JustArchi:
Know Your ArchiDroid

ArchiDroid is not only a rom. It's not only a baked android with third-party apps, modifications and tweaks. ArchiDroid is an universal backend which improves rom by many built-in functions.

Let me tell you a story. During developing first version of ArchiDroid 2.0 I experienced many problems, which were not that easy to solve. First of all - apps data. Trust me or not but you can't simply extract data, put it in /data/data after install and hope that it works. CyanogenMod will detect such injection, report inconsistent of data and wipe everything attached to that. Okay so... How I should provide you with my boeffla preset? CoolTool settings? STweaks profile? If I put my data during flashing it'll get wiped. If I put my data and deny wiping it then CM will report inconsistent of data to user and work unstable. Yes guys, it's impossible to do so without a trick or without recompiling whole rom.

This was the first reason why I started implementing something, what I call today "ArchiDroid Backend" or "ArchiDroid" in general. I knew that I can't simply trust CyanogenMod and I *need* something independent, something which will allow me to get exact result without relying on CyanogenMod. And this is how ArchiDroid Backend was born.

ArchiDroid Backend contains basicly two main parts. Executable part, located in /system/etc/init.d, and Local part, located in /data/media/0/ArchiDroid. Take a look at probably most important thing - ArchiDroid_RunOnce. Yes, this is the core of my backend, this is the script being executed every time on the first boot of your ArchiDroid. Take a closer look how it works. First of all it detects if you selected either Install or Update mode during flashing. If you selected Install mode it firstly counts how many apps need our data, then it moves to "Semaphore" part which loops itself every 2 seconds. Yes, this is the reason why you can see my cute ArchiDroid Loading banner in logcat :). But that's not a main part of semaphore. ArchiDroid checks every 2 seconds if null data of our app has been already placed by CyanogenMod. If CM finished managing data for our app then ArchiDroid overwrites data with our preset, thus making both CyanogenMod happy (yay, data is stable!) and ArchiDroid (yay, you have my preset!). Additionally it waits for database to get populated and then updates some variables according to my taste. Yes, this is why you have advanced reboot, install non market apps, 0.5x animation and many more things enabled by default :). However if you selected Update mode, fine. RunOnce won't do anything, as it already finished during first install mode and we don't want to *force* you by overwriting everything to my liking :). After required modifications we're waiting for system to fully load and then to apply our changes we need at least a soft reboot, which RunOnce of course performs. Yes, this is the reason why you nearly always gets this little lag with the first boot, as it's not lag but just soft reboot done by RunOnce. After soft reboot RunOnce automatically removes itself as there's nothing else to do. So yeah you've just met RunOnce guy. Shy little script which fixes everything you'd need while keeping CyanogenMod happy.

Right behind RunOnce there is an Init script. Basicly this script doesn't do anything special right now, just some basic stuff like showing banner and managing required soft/hard reboots. This will probably be extended in the future but as for now I don't need anything else being run on every boot through Init.

Behind Init there is one more guy, PermFix. This little guy works in backrground after your first boot, fixing permissions and owners and deleting itself after finish. Completely transparent process.

This was the executable part, now local part.

Local part is basicly ArchiDroid folder, which is required by executable part and also provides you with some useful features. First of all you can find your efs backup in "Backups" folder, in case you'd like to copy it to your PC or make another copy. You can also find "Scripts" folder with little useful scripts, again, written from scratch by me. These scripts are very useful if you know how to use them. Lastly ArchiDroid stores some temporary backend informations being used by executable part, for example after first flash there appears FIRSTBOOT folder, which is needed by RunOnce to access presets and other apps data.

You won't find anything like that in any other rom because my backend has been written from scratch by me, mostly because as you can see I needed such feature to make you happy. In the same time I didn't want to recompile whole CyanogenMod, because it's not a solution. It's much better to implement my own independent part of ROM, which acts the way I like it.

Please keep in mind that it's not anything cutting-edge or very advanced. It's rather small, simple, but very useful and trust me or not but it took me at least over a dozen of hours to make it work the way I like it. I'm very proud of my backend because I'm easily able to add new features, backend is universal, clean and mostly important - it in fact works :).

;)