[Galaxy S II Original Android Development] Chainfire:
System Modified Status

The latest Samsung devices store "system modified ?" flags next to the "flash counter" and "current binary official ?" that Triangle Away traditionally resets.

It actually has this "system modified ?" flag twice. Once in the bootloader, once in Android itself. When resetting the flash counter, Triangle Away does attempt to reset the one stored in the bootloader (that you can see from Download mode), and disable it from being updated. However, whether or not this works is completely dependent on your device model and firmware version.

The flag in Android itself can be seen under Settings --> About Device --> Status --> Device Status. This one also affects whether or not the firmware will allow you to download and flash OTA updates, and may affect DRM apps and the allshare cast dongle.

Version 2.95 of Triangle Away introduced a "periodic system modified reset" option (enabled by default) that

may

help keep the bootloader system modified status as official. It has no effect on the system modified status under Settings and thus does not help with OTAs.

Version 2.50 of Triangle Away introduced a "allow tracker to run" option that can re-enable syscope if it was disabled by resetting the flash counter. After doing this and rebooting, in some cases this reverts to status under Settings to normal. However, in my personal experience this only works temporarily, and after a number of hours the status will revert to modified in both Settings as well as the bootloader, after which you will have to use Triangle Away to reset the status. This behavior is dependent on firmware, for some users this option works reliably. Alternatively, you can use the next option, which is more reliable, but less convenient.

Version 2.45 of Triangle Away introduced a "system modified workaround" option that tries to counter the flag in Android under Settings. This option is dependent on a fair number of factors:

- You must be running a stock Samsung ROM

- The SysScope package must be intact (if you removed it, it will likely not work)

- You must be using SuperSU as your root rights management app (Superuser is not supported)

- You must be using either the Play version of Triangle Away or have SuperSU Pro installed

A side-effect of this workaround is that root will be disabled for about five minutes after boot (yeah...). During that time, Triangle Away will display a notification. All your apps that launch at boot and do something that requires root will not be able to gain root access during this time. A well-coded root app should not care about this much, but unfortunately not all apps are coded that defensively, and app crashes may occur. When root access is restored, Triangle Away will re-launch the apps that are set to launch at boot and have been granted access in SuperSU, so these root apps may still initialize themselves properly.

Personally, I find this too annoying to use constantly, but due to being a developer, I reboot a lot. One way to use it would be to use the standard reset flash counter method that resets the bootloader value (and if you're lucky will keep the system status in the bootloader as "official" as well), and once in a while use the workaround patch when you want to check for OTAs and such only.

There are also some caveats:

- This workaround is incompatible with the reset function used when you reset the flash counter. As such, the "system modified" status flag in the bootloader may start updating again (resetting the counter itself will still work, though) if you enable the workaround. It will reflect the status you can see in Android. If you disable the workaround again, you are advised to reset the flash counter again afterwards.

- If your system is modified by other root tools, the "modified" status may still be triggered, regardless of this workaround

- I wanted to implement all this in a much cleaner way, but due to a bug in Samsung's modifications of the package manager, that method would often result in corrupted data and the inability to modify/(un)install any apps after the corruption occurs. Note that this corruption may still occur "naturally", and Triangle Away will inform of you of this problem if it occurs during enabling of the workaround. Unfortunately, there is no known solution to this issue other than wiping all your data (factory reset).

- I fully expect Samsung to prevent this patch from working in the near future, so use it while it's hot.

Note to developers:

In case your app uses a BOOT_COMPLETED receiver and has been granted access in SuperSU, it will receive a second BOOT_COMPLETED intent from Triangle Away once root access has been restored. The second intent will have an extra present named "eu.chainfire.triangleaway.BOOT_COMPLETED"