Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 45f4b4aa authored by Makoto Onuki's avatar Makoto Onuki
Browse files

ForegroundServiceDidNotStartInTimeException now has...

an inner exception that captures the stacktrace where
Context.startForegroundService() was called last time,
from the same process.

Bug: 124137635
Test: Manual test with a tesapp. 1: when startForegroundService() is called by
the same process:
```
11-17 17:00:12.483 10241  9545  9545 E AndroidRuntime: FATAL EXCEPTION: main
11-17 17:00:12.483 10241  9545  9545 E AndroidRuntime: Process: com.google.omakoto.testapp, PID: 9545
11-17 17:00:12.483 10241  9545  9545 E AndroidRuntime: android.app.RemoteServiceException$ForegroundServiceDidNotStartInTimeException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{e7674af u0 com.google.omakoto.testapp/.MyFgs3}
11-17 17:00:12.483 10241  9545  9545 E AndroidRuntime: 	at android.app.ActivityThread.generateForegroundServiceDidNotStartInTimeException(ActivityThread.java:1965)
11-17 17:00:12.483 10241  9545  9545 E AndroidRuntime: 	at android.app.ActivityThread.throwRemoteServiceException(ActivityThread.java:1934)
11-17 17:00:12.483 10241  9545  9545 E AndroidRuntime: 	at android.app.ActivityThread.access$2700(ActivityThread.java:255)
11-17 17:00:12.483 10241  9545  9545 E AndroidRuntime: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2190)
11-17 17:00:12.483 10241  9545  9545 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:106)
11-17 17:00:12.483 10241  9545  9545 E AndroidRuntime: 	at android.os.Looper.loopOnce(Looper.java:201)
11-17 17:00:12.483 10241  9545  9545 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:288)
11-17 17:00:12.483 10241  9545  9545 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:7839)
11-17 17:00:12.483 10241  9545  9545 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
11-17 17:00:12.483 10241  9545  9545 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
11-17 17:00:12.483 10241  9545  9545 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
11-17 17:00:12.483 10241  9545  9545 E AndroidRuntime: Caused by: android.app.StackTrace: Last startServiceCommon() call for this service was made here
11-17 17:00:12.483 10241  9545  9545 E AndroidRuntime: 	at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1868)
11-17 17:00:12.483 10241  9545  9545 E AndroidRuntime: 	at android.app.ContextImpl.startForegroundService(ContextImpl.java:1823)
11-17 17:00:12.483 10241  9545  9545 E AndroidRuntime: 	at android.content.ContextWrapper.startForegroundService(ContextWrapper.java:779)
11-17 17:00:12.483 10241  9545  9545 E AndroidRuntime: 	at android.content.ContextWrapper.startForegroundService(ContextWrapper.java:779)
11-17 17:00:12.483 10241  9545  9545 E AndroidRuntime: 	at com.google.omakoto.testapp.MyReceiver.onReceive(MyReceiver.java:53)
11-17 17:00:12.483 10241  9545  9545 E AndroidRuntime: 	at android.app.ActivityThread.handleReceiver(ActivityThread.java:4345)
11-17 17:00:12.483 10241  9545  9545 E AndroidRuntime: 	at android.app.ActivityThread.access$1600(ActivityThread.java:255)
11-17 17:00:12.483 10241  9545  9545 E AndroidRuntime: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2102)
11-17 17:00:12.483 10241  9545  9545 E AndroidRuntime: 	... 7 more
```

Test: Manual test with a tesapp. 1: when startForegroundService() is called by
another process:
```
11-17 16:59:34.456 10241  9432  9432 E AndroidRuntime: FATAL EXCEPTION: main
11-17 16:59:34.456 10241  9432  9432 E AndroidRuntime: Process: com.google.omakoto.testapp:second, PID: 9432
11-17 16:59:34.456 10241  9432  9432 E AndroidRuntime: android.app.RemoteServiceException$ForegroundServiceDidNotStartInTimeException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{dcaa127 u0 com.google.omakoto.testapp/.MyFgs3}
11-17 16:59:34.456 10241  9432  9432 E AndroidRuntime: 	at android.app.ActivityThread.generateForegroundServiceDidNotStartInTimeException(ActivityThread.java:1965)
11-17 16:59:34.456 10241  9432  9432 E AndroidRuntime: 	at android.app.ActivityThread.throwRemoteServiceException(ActivityThread.java:1934)
11-17 16:59:34.456 10241  9432  9432 E AndroidRuntime: 	at android.app.ActivityThread.access$2700(ActivityThread.java:255)
11-17 16:59:34.456 10241  9432  9432 E AndroidRuntime: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2190)
11-17 16:59:34.456 10241  9432  9432 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:106)
11-17 16:59:34.456 10241  9432  9432 E AndroidRuntime: 	at android.os.Looper.loopOnce(Looper.java:201)
11-17 16:59:34.456 10241  9432  9432 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:288)
11-17 16:59:34.456 10241  9432  9432 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:7839)
11-17 16:59:34.456 10241  9432  9432 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
11-17 16:59:34.456 10241  9432  9432 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
11-17 16:59:34.456 10241  9432  9432 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
```

Change-Id: I2dd8ec76213d53728eaa8fcc3760813d82a328a5
parent 4ad4975b
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment