Handling Seat Service Binding
During bootup, the interactive may need to bind to services. However, during this time, a service might not be completely installed yet and exceptions may be thrown if the interactive tries binding to it. If exceptions are not handled correctly, the interactive can crash.
To prevent this, the interactive needs to handle the
exception and to periodically retry to bind. When the
service is completely installed, Android will broadcast an
android.intent.action.PACKAGE_ADDED
intent with the service's package name. In the meantime, the
interactive can listen for these broadcasts before trying to
bind.
Exception Examples
The following provides examples of exceptions the interactive may encounter. For additional information on Android exceptions, refer to the Android API Reference.
IO Exception
Runtime exception the Seatback Application SDK may throw. For additional information, see IOException.
Example of a crash log displaying the exception:
10-19 02:50:50.664 27156 27413 E MsgSender: connect exception: Connection refused
10-19 02:50:50.664 27156 27413 E IOException: Connection refused
10-19 02:50:50.664 27156 27413 E AndroidRuntime: FATAL EXCEPTION: socketSender
10-19 02:50:50.664 27156 27413 E AndroidRuntime: Process: aero.panasonic.next.jal.seatback, PID: 27156
10-19 02:50:50.664 27156 27413 E AndroidRuntime: java.io.IOException: Transport endpoint is not connected
10-19 02:50:50.664 27156 27413 E AndroidRuntime: at android.net.LocalSocketImpl.writeba_native(Native Method)
10-19 02:50:50.664 27156 27413 E AndroidRuntime: at android.net.LocalSocketImpl.-wrap3(Unknown Source:0)
10-19 02:50:50.664 27156 27413 E AndroidRuntime: at android.net.LocalSocketImpl$SocketOutputStream.write(LocalSocketImpl.java:144)
10-19 02:50:50.664 27156 27413 E AndroidRuntime: at java.nio.channels.Channels$WritableByteChannelImpl.write(Channels.java:453)
10-19 02:50:50.664 27156 27413 E AndroidRuntime: at aero.panasonic.inflight.services.contentdiscovery.v2.socketHandler.MsgSender.access$sendMsg(SourceFile:1074)
10-19 02:50:50.664 27156 27413 E AndroidRuntime: at aero.panasonic.inflight.services.contentdiscovery.v2.socketHandler.MsgSender$CommonConst$JsonKey.handleMessage(SourceFile:191)
10-19 02:50:50.664 27156 27413 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
10-19 02:50:50.664 27156 27413 E AndroidRuntime: at android.os.Looper.loop(Looper.java:164)
10-19 02:50:50.664 27156 27413 E AndroidRuntime: at android.os.HandlerThread.run(HandlerThread.java:65)
10-19 02:50:50.664 27156 27156 D a.p.n.j.s.p. NextMediaPlayerBase: playlist changed -> current item: MediaItem(id=31582, path=pac_tSecurity Exception
Runtime exception that the InFlight remote service may throw. For additional information on this exception, refer to bindService and SecurityException.
In this following example of a crash log, the IOException
is thrown because
aero.panasonic.inflight.remote.service has not
been installed yet:
10-30 19:57:14.137 24130 24539 W ActivityManager: Permission
Denial: Accessing service
ComponentInfo{aero.panasonic.inflight.app.seatback/aero.panasonic.inflight.services.ifeservice.IfeService} from pid=23903, uid=10080 requires aero.panasonic.inflight.permission.ACCESS_IFESERVICE
10-30 19:57:14.138 23903 23903 D AndroidRuntime: Shutting down VM
10-30 19:57:14.138 23903 23903 E AndroidRuntime: FATAL EXCEPTION: main
10-30 19:57:14.138 23903 23903 E AndroidRuntime: Process: aero.panasonic.next.jal.seatback, PID: 23903 10-30 19:57:14.138 23903 23903 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{aero.panasonic.next.jal.seatback/aero.panasonic.next.jal.seatback.MainActivity}: java.lang.SecurityException: Not allowed to bind to service Intent { act=aero.panasonic.inflight.remote.service pkg=aero.panasonic.inflight.app.seatback }
10-30 19:57:14.138 23903 23903 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.j ava:2781) 10-30 19:57:14.138 23903 23903 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.ja va:2859)
10-30 19:57:14.138 23903 23903 E AndroidRuntime: at android.app.ActivityThread.-wrap11(Unknown Source:0)