Q:

Does android keep a log of when it starts?

I'm making a parental control/accountability app for android. It consists of a monitoring service that runs in the background and starts when the phone is booted.
Unfortunately, I have found that when android is started in "Safe Mode", services are not started automatically, and because of this my app has a serious flaw.
While in safe mode, the web and other apps can be started without my monitoring service running.
I thought that if it isn't possible to monitor app activity while in safe mode, maybe I could at least have my app detect if the phone was previously in safe mode. Then it could maybe alert the parent or accountability partner?
Does Android keep any log of this? Or any boot log in general?  I'm very open to suggestions and alternatives.

A:

I think you have caught yourself out, in short, nothing you can do!
Have a look at this source that explains why, specifically in this section:
System Partition and Safe Mode

The system partition contains Android's kernel as well as the
operating system libraries, application runtime, application
framework, and applications. This partition is set to read-only. When
a user boots the device into Safe Mode, only core Android applications
are available. This ensures that the user can boot their phone into an
environment that is free of third-party software.

Keywords is free of third-party software
Edit:
When Android boots up, it keeps a cache of the logcat, in a temporary buffer that is reserved found in /dev/log. That buffer gets recycled when it hits the threshold, obviously, the bigger the threshold, the slower Android gets with the continual spamming into the logcat buffer hence kept to minimum - iirc, its around 64K:
#define DEFAULT_LOG_ROTATE_SIZE_KBYTES 16
#define DEFAULT_MAX_ROTATED_LOGS 4

Source: system/core/logcat/logcat.cpp
Do not ask how many lines that can be, as to each and to every app, its different. Not alone that, the logcat disappears upon reboot!

A:

Not the best answer but maybe the information will be some what useful.
The only method I'm aware of that contains a log produced by the system after a reboot is /proc/last_kmsg.
Whether or not the kernel keeps this log file after a reboot, depends on settings provided during kernel compilation.
My experience has shown that some stock devices (HTC) have this logging enabled and others do not. I haven't seen a consistent pattern.

