Log with timing of system events (e,g, Flight Mode on/off) I would like to find out at what time my phone (running Android 8.0.0) was last switched into/out of Flight (Airplane) Mode. Ideally, this would be part of a longer log with the timestamps of the last N FlightMode events, alongside other system-related events.

I didn't find any quick solutions by searching this site and others. Is there an easy way to find out this information?
You can use adb for this. Run this command:

adb shell dumpsys activity broadcasts 


The output would be overwhelming, but you need to look for the string android.intent.action.AIRPLANE_MODE there. You can use grep or save the output into a file and then do the search.

Look for that string under Historical Broadcast Background. You would find the timestamp you're looking for. It could look like this:



Historical Broadcast background #345:
    BroadcastRecord{48eb128 u-1 android.intent.action.AIRPLANE_MODE} to user -1
    Intent { act=android.intent.action.AIRPLANE_MODE flg=0x10 (has extras) }
      extras: Bundle[{state=true}]
    caller=android 1298:system/1000 pid=1298 uid=1000
    enqueueClockTime=2019-01-10 00:00:01 dispatchClockTime=2019-01-10 00:00:01


You can also look under Historical Broadcasts summary (background).


#15: act=android.intent.action.AIRPLANE_MODE flg=0x10 (has extras)
    0 dispatch +1ms finish
    enq=2019-01-10 00:19:14 disp=2019-01-10 00:19:14 fin=2019-01-10 00:19:14
    extras: Bundle[{state=false}]


state=true means Airplane mode was activated. state=false means it was deactivated.

All of this may seem like a trouble, so I suggest you use an automation app to listen to the intent for Airplane mode and take an action for you for convenience. 

Both Tasker and MacroDroid should be able to help with this. In MacroDroid, 

Trigger: Intent Received First:


Action: android.intent.action.AIRPLANE_MODE


Intent Extra:


Extra name: state
Extra value to match: true




Actions: do what you want with that

Constraints: none

Save this. Now clone this, configure the trigger and change the value for state to false. So you would have triggers for both states of Airplane mode.