VulpesOS/assets/webapps/system.gaiamobile.org/js/telephony_monitor.js
OverSu b38dea0597 Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
2026-09-30 23:13:03 +02:00

42 lines
1.1 KiB
JavaScript

/* global BaseModule */
'use strict';
(function() {
var TelephonyMonitor = function(telephony) {
this.telephony = telephony;
};
TelephonyMonitor.STATES = [
'inCall',
'hasActiveCall'
];
BaseModule.create(TelephonyMonitor, {
name: 'TelephonyMonitor',
inCall: false,
/**
* Check if there is active call
* @param {Number} index If not specified, it means any active call;
* if specified, it means the active call at this SIM slot.
* @return {Boolean} There is active call or not.
*/
hasActiveCall: function(index) {
if (index) {
return this.telephony.active &&
this.telephony.active.serviceId === index;
} else {
return !!this.telephony.active;
}
},
handleEvent: function(evt) {
this.inCall = this.telephony.calls.length > 0;
this.publish('callschanged', {
detail: evt.detail
});
},
_start: function() {
this.telephony.addEventListener('callschanged', this);
},
_stop: function() {
this.telephony.removeEventListener('callschanged', this);
}
});
}());