Android System Events#
The In-Flight Entertainment (IFE) system generates and transmits broadcast messages corresponding to multiple system events. To effectively respond to these broadcasts, the passenger’s electronic device must implement appropriate listeners that can detect and handle each of these events accordingly.
1. How to listen to the system events in a passenger’s electronic device?#
Step 1: Initialization of Service#
Initializing the System Event Service is the essential first step for enabling the application to listen to any system-level events. This service acts as the gateway for event detection and must be properly set up before any event handling can occur. It is provided as part of the Core module within the Inflight Android Companion App SDK.
private SystemV1 mSystemV1;
SystemV1.initService(this, "SeatPairing", new IInFlightCallback() {
@Override
public void onInitServiceComplete(Object o, String s) {
// System service initalized the successfully
mSystemV1 = (SystemV1) o;
}
@Override
public void onInitServiceFailed(String s, InFlight.Error error) {
// Error on during the intialization System service.
}
}, mInFlight);
Step 2: Subscribe to the events#
To subscribe to system events, a list of desired SystemV1Events must be supplied. The SystemV1 class includes a subscribe() method, which is responsible for registering these events so that the application can receive and respond to them appropriately.
ArrayList<SystemV1Events> SystemEvents = new ArrayList<>();
SystemEvents.add(SystemV1Events.PA);
SystemEvents.add(SystemV1Events.WEIGHT_ON_WHEELS);
mSystemV1.subscribe(SystemEvents);
The example above demonstrates how to subscribe to system events using the SystemV1 object. In this case, a list containing two specific events—PA (Passenger Announcement) and WEIGHT_ON_WHEELS—is created and passed to the subscribe() method. This effectively registers the application to listen for these two events, enabling it to respond appropriately when either event is broadcast by the system.
Step 3: Create a broadcast receiver#
After subscribing to an event using the SystemEventsV1 class, a broadcast receiver must be created. This broadcast receiver listens for the subscribed events. When an event is received, the receiver helps deliver it to the application. Based on the type of event received, the appropriate action is then carried out on the passenger’s personal electronic device
BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String eventName = intent.getStringExtra(InFlightIntentExtras.EVENT_NAME.getKeyName());
String intentID = intent.getStringExtra(InFlightIntentExtras.SERVICE_INSTANCE_ID.getKeyName());
// Checking the event name is PA
if (eventName.equals(SystemV1Events.getSystemV1EventName(SystemV1Events.PA))) {
// Appropriate action will be taken for the PA event
Bundle bundle = intent.getBundleExtra(InFlightAPIConstants.IntentExtras.BUNDLE_EXTRAS_EVENT_DATA);
if (bundle != null) {
int paState = bundle.getInt(InFlightAPIConstants.IntentExtras.EVENT_DATA_SYSTEM_STATE);
Log.d(TAG, paState + "");
}
// Checking event name is WEIGHT_ON_WHEELS
} else if (eventName.equals(SystemV1Events.getSystemV1EventName(SystemV1Events.WEIGHT_ON_WHEELS))) {
// Appropriate action will be taken according to WEIGHT_ON_WHEEL event
Bundle bundle = intent.getBundleExtra(InFlightAPIConstants.IntentExtras.BUNDLE_EXTRAS_EVENT_DATA);
if (bundle != null) {
String weightOnWheels = bundle.getString(InFlightAPIConstants.IntentExtras.EVENT_DATA_SYSTEM_STATE);
}
}
}
}
};
In the example above, a BroadcastReceiver is created to handle two specific events: PA (Passenger Announcement) and WEIGHT_ON_WHEELS. The receiver listens for these events and processes them when they are broadcast by the system. Similarly, in the Inflight Companion App, multiple system events can be listened to using broadcast receivers. When an event is received, relevant data associated with that event is delivered— for example, when a PA event is triggered, the receiver will receive the current PA status.
Step 4: Register the broadcast receiver#
After creating the broadcast receiver, it’s important to register it to start receiving events. In Android, you can register the broadcast receiver inside your Activity's onResume() method. This ensures the receiver starts listening as soon as the activity becomes visible to the user.
However, to avoid memory leaks and unnecessary processing when the activity is no longer active, you must also unregister the receiver. This should be done inside the onPause() or onStop() method, depending on your use case. Properly managing the lifecycle of the broadcast receiver is essential for maintaining good app performance and stability.
4.1 Register the broadcast receiver#
@Override
protected void onStart() {
super.onStart();
LocalBroadcastManager
.getInstance(this)
.registerReceiver(
broadcastReceiver,
new IntentFilter(InFlightIntentActions.ACTION_SYSTEM_EVENT.getIntentAction())
);
}
In this example, we are registering the broadcast receiver that was created in step 3. We're also setting up an IntentFilter to specify which event (action) the receiver should listen for — in this case, InFlightIntentActions.ACTION_SYSTEM_EVENT.
4.2 Unregister the broadcast receiver#
In the above example, the onPause() method shown above is part of the Android activity lifecycle. In this method, the unregisterReceiver(broadcastReceiver) call is used to stop the broadcast receiver from listening for events when the activity is no longer in the foreground. This is important for preventing memory leaks and ensuring that the receiver does not continue to handle broadcasts when the activity is paused or not visible to the user. Properly unregistering the receiver helps maintain app performance and resource efficiency.
These steps are necessary to enable the passenger’s electronic device to receive and respond to system events.
2. What are the different types of System events?#
As of now, the Inflight Companion SDK supports five different types of system events in SystemV1. These events cover a range of actions and notifications that can be utilized within the SDK, allowing the system to respond to specific triggers or conditions on the passenger's device.
2.1. Passenger Announcement#
As the name indicates, this event is triggered on a personal electronic device when a Passenger Announcement is being made on the In-Flight Entertainment (IFE) system. During this event, all ongoing operations on the device are temporarily halted. For example, if a movie is playing on the seatback display, it will be paused, and the user interface (UI) will be locked, preventing the passenger from interacting with the device. This ensures that passengers focus their attention on the announcement. A similar experience is expected on the passenger’s electronic device, where playback is paused, and user actions are restricted until the announcement is completed.
The passenger announcement event must be registered as SystemEvents.PA is using the SystemV1 object.
ArrayList<SystemV1Events> SystemEvents = new ArrayList<>();
SystemEvents.add(SystemV1Events.PA);
mSystemV1.subscribe(SystemEvents);
In the above example, SystemV1Events.PA subscribe, refer to step 2 for more details. The event is captured using a BroadcastReceiver. For further details on this process, please refer to Section 3. For every event that is received, it is essential to first extract the event name. This can be accomplished using the code snippet provided below.
Once the event name has been retrieved, it should be compared against the predefined event names available in the SystemV1 class. If a match is found, the next step is to extract the associated data, which is received from the IFE server. It is important to note that different types of events provide different kinds of data. The code below describes how to obtain event data.
Bundle bundle = intent.getBundleExtra(InFlightAPIConstants.IntentExtras.BUNDLE_EXTRAS_EVENT_DATA);
if (bundle != null) {
int paState = bundle.getInt(InFlightAPIConstants.IntentExtras.EVENT_DATA_SYSTEM_STATE);
}
In the above code, the Bundle object is retrieved using the key InFlightAPIConstants.IntentExtras.BUNDLE_EXTRAS_EVENT_DATA. From within this bundle, the specific event data is accessed using the key InFlightAPIConstants.IntentExtras.EVENT_DATA_SYSTEM_STATE. For a Public announcement (PA) event, the returned value can be either 0 or 1. A return value of 0 indicates that the PA system is turned off, while a return value of 1 indicates that the PA system is turned on.
2.2. Zonal Passenger Announcement#
The Zonal Passenger Announcement system event works similarly to the Passenger Announcement (PA) event, but with an added feature: it can be triggered for a specific zone within the aircraft. For example, an aircraft may be divided into zones based on the number of rows or class (such as economy or business class). If a particular announcement needs to be made only for a specific zone, the Zonal Passenger Announcement is useful. For instance, if the crew wants to announce the business class only, this event will ensure that only the business-class passengers hear it.
For the Zonal Passenger Announcement to work, the passenger’s electronic device must be paired with the seatback monitor. This pairing is a precondition for the event, and once paired, the device can identify which zone the passenger belongs to based on this connection.
The Pair Status API of the SeatPairing module in the Inflight CA SDK provides the zonal index after a passenger's device is paired with a seat. This zonal index helps determine if the system should perform any Zonal Passenger Announcement-related actions based on the passenger's location. For example, if an event is triggered for Zone 1 but the passenger is seated in Zone 4, the zonal passenger announcement will not be relevant to that passenger, and therefore, no action will be taken.
ArrayList<SystemV1Events> SystemEvents = new ArrayList<>();
SystemEvents.add(SystemV1Events.ZONAL_PA);
mSystemV1.subscribe(SystemEvents);
The above section demonstrates the procedure for subscribing to the Zonal Public Address (PA) system. For a more comprehensive explanation, please refer to Step 2. When a Zonal PA is triggered, an EVENT_DATA_SYSTEM_STATE event is generated. This event contains detailed information about the type of PA announcement occurring in each zone. It is important to note that different types of PA announcements can be triggered simultaneously across different zones, depending on the situation.
The above JSON is obtained when the zonal PA gets triggered, where 0,1,2 is a zonal index which is obtained after PED pairing with the seat, and three different kinds of PA get triggered in each zone.
Note: Zonal Passenger Announcement events are broadcast to all devices across the entire aircraft, no matter which seat the device is paired with or which zone the passenger is in. It is the responsibility of the companion app to check the device’s paired zone and decide whether or not to show the announcement to the passenger.
2.3. Decompression#
The decompression event is triggered during the decompression process. The method used to capture the decompression event is similar to the approach used for capturing the PA event. The decompression event also returns a value of either 0 or 1. A value of 0 indicates that decompression is inactive (i.e., decompression is off), while a value of 1 indicates that decompression is active (i.e., decompression is on). The code below shows how to subscribe to the decompression event.
ArrayList<SystemV1Events> SystemEvents = new ArrayList<>();
SystemEvents.add(SystemV1Events.DECOMPRESSION);
mSystemV1.subscribe(SystemEvents);
2.4. Local network availability#
The local network availability event is triggered when the local network becomes available. The code snippet provided below illustrates how to register for notifications related to this event. The data obtained from this event is a binary value: a value of 0 indicates that the local network is not available, while a value of 1 signifies that the local network is available. The overall process for receiving and handling this event notification follows the same approach as with other events.
ArrayList<SystemV1Events> SystemEvents = new ArrayList<>();
SystemEvents.add(SystemV1Events.LOCAL_NETWORK_AVAILABILITY);
mSystemV1.subscribe(SystemEvents);
2.5. Weight on wheels#
The Weight-on-Wheels event is a key indicator used to determine the flight status of an aircraft. When weight is detected on the wheels, it means that the aircraft is on the ground; conversely, when there is no weight on the wheels, it indicates that the aircraft is airborne. This status is represented by a numeric value: 0 or 1. A value of 0 signifies "weight off wheels," meaning the aircraft is in flight, while a value of 1 signifies "weight on wheels," meaning the aircraft is on the ground. This event is particularly useful for triggering various operations and system behaviors that should occur while the aircraft is in ground mode.
The code below shows how to subscribe to the Weight on Wheels event.
ArrayList<SystemV1Events> SystemEvents = new ArrayList<>();
SystemEvents.add(SystemV1Events.WEIGHT_ON_WHEELS);
mSystemV1.subscribe(SystemEvents);
Version 1.0