Skip to content

Commit

Permalink
Log android system shutdown to param (commaai#23520)
Browse files Browse the repository at this point in the history
* Log android system shutdown to param

* comment

Co-authored-by: Comma Device <device@comma.ai>
  • Loading branch information
adeebshihadeh and Comma Device authored Jan 14, 2022
1 parent 8c53adf commit 610b99f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions release/files_common
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ selfdrive/hardware/base.py
selfdrive/hardware/hw.h
selfdrive/hardware/eon/__init__.py
selfdrive/hardware/eon/androidd.py
selfdrive/hardware/eon/shutdownd.py
selfdrive/hardware/eon/hardware.h
selfdrive/hardware/eon/hardware.py
selfdrive/hardware/eon/neos.py
Expand Down
1 change: 1 addition & 0 deletions selfdrive/common/params.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ std::unordered_map<std::string, uint32_t> keys = {
{"LastGPSPosition", PERSISTENT},
{"LastPeripheralPandaType", PERSISTENT},
{"LastPowerDropDetected", CLEAR_ON_MANAGER_START},
{"LastSystemShutdown", CLEAR_ON_MANAGER_START},
{"LastUpdateException", PERSISTENT},
{"LastUpdateTime", PERSISTENT},
{"LiveParameters", PERSISTENT},
Expand Down
27 changes: 27 additions & 0 deletions selfdrive/hardware/eon/shutdownd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env python3
import os
import time
import datetime

from common.params import Params
from selfdrive.hardware.eon.hardware import getprop
from selfdrive.swaglog import cloudlog

def main():
params = Params()
while True:
# 0 for shutdown, 1 for reboot
prop = getprop("sys.shutdown.requested")
if prop is not None and len(prop) > 0:
os.system("pkill -9 loggerd")
params.put("LastSystemShutdown", f"'{prop}' {datetime.datetime.now()}")
print("shutdown detected", repr(prop))

time.sleep(120)
cloudlog.error('shutdown false positive')
break

time.sleep(0.1)

if __name__ == "__main__":
main()
3 changes: 2 additions & 1 deletion selfdrive/manager/process_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os

from selfdrive.manager.process import PythonProcess, NativeProcess, DaemonProcess
from selfdrive.hardware import EON, TICI, PC
from selfdrive.manager.process import PythonProcess, NativeProcess, DaemonProcess

WEBCAM = os.getenv("USE_WEBCAM") is not None

Expand Down Expand Up @@ -40,6 +40,7 @@

# EON only
PythonProcess("rtshield", "selfdrive.rtshield", enabled=EON),
PythonProcess("shutdownd", "selfdrive.hardware.eon.shutdownd", enabled=EON),
PythonProcess("androidd", "selfdrive.hardware.eon.androidd", enabled=EON, persistent=True),
]

Expand Down

0 comments on commit 610b99f

Please sign in to comment.