Increase startForeground() timeout to 30 seconds.
Right now there is 10 seconds grace period from Context.startForegroudService() to Service.startForeground() call, afterwards we crash the app and thow ForegroundServiceDidNotStartInTimeException, at the same time generate ANR report. Make the startForegroundService() to startForeground() grace period configurable, increase the default value from 10 seconds to 30 seconds. This value can be changed by command "adb shell device_config put activity_manager service_start_foreground_timeout_ms 30000" After the 30 seconds service_start_foreground_timeout_ms and ForegroundServiceDidNotStartInTimeException, delay the ANR generation for another 10 seconds configurable by service_start_foreground_anr_delay_ms. This value can be changed by "adb shell device_config put activity_manager service_start_foreground_anr_delay_ms 10000". At the end of service_start_foreground_anr_delay_ms, if the app's process is still alive, the ANR report will be taken. Otherwise, there is no ANR report. Bug: 219514357 Test: adb shell device_config put activity_manager service_start_foreground_timeout_ms, adb shell device_config put activity_manager service_start_foreground_anr_delay_ms, Manual test, in test app, startForegroundService() but not call startForeground(), 30 seconds later, observe the ForegroundServiceDidNotStartInTimeException, 10 seconds later, try to take the ANR report. Change-Id: I5f30d0996bff23f8a302cedef01eaa31e6ff29ce
Loading
Please register or sign in to comment