зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1114935 - Part 6.8: Migration in MobileIdentityManager.jsm. r=ferjmoreno
--HG-- extra : rebase_source : 2534742021c367def5a9ef7128ed2a77cc40ef8a extra : histedit_source : c40a1db0266bf57be66c9940b3152e0f5b5d3479
This commit is contained in:
Родитель
9428c56c69
Коммит
a50ecd65f3
|
@ -56,9 +56,9 @@ XPCOMUtils.defineLazyServiceGetter(this, "Ril",
|
|||
"@mozilla.org/ril;1",
|
||||
"nsIRadioInterfaceLayer");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "IccProvider",
|
||||
"@mozilla.org/ril/content-helper;1",
|
||||
"nsIIccProvider");
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "IccService",
|
||||
"@mozilla.org/icc/iccservice;1",
|
||||
"nsIIccService");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "MobileConnectionService",
|
||||
"@mozilla.org/mobileconnection/mobileconnectionservice;1",
|
||||
|
@ -116,11 +116,11 @@ this.MobileIdentityManager = {
|
|||
return Ril;
|
||||
},
|
||||
|
||||
get iccProvider() {
|
||||
if (this._iccProvider) {
|
||||
return this._iccProvider;
|
||||
get iccService() {
|
||||
if (this._iccService) {
|
||||
return this._iccService;
|
||||
}
|
||||
return IccProvider;
|
||||
return IccService;
|
||||
},
|
||||
|
||||
get mobileConnectionService() {
|
||||
|
@ -153,8 +153,10 @@ this.MobileIdentityManager = {
|
|||
// We don't need to keep listening for changes until we rebuild the
|
||||
// cache again.
|
||||
for (let i = 0; i < self._iccInfo.length; i++) {
|
||||
self.iccProvider.unregisterIccMsg(self._iccInfo[i].clientId,
|
||||
iccListener);
|
||||
let icc = self.iccService.getIccByServiceId(i);
|
||||
if (icc) {
|
||||
icc.unregisterListener(iccListener);
|
||||
}
|
||||
}
|
||||
|
||||
self._iccInfo = null;
|
||||
|
@ -214,7 +216,10 @@ this.MobileIdentityManager = {
|
|||
|
||||
// We need to subscribe to ICC change notifications so we can refresh
|
||||
// the cache if any change is observed.
|
||||
this.iccProvider.registerIccMsg(i, iccListener);
|
||||
let icc = this.iccService.getIccByServiceId(i);
|
||||
if (icc) {
|
||||
icc.registerListener(iccListener);
|
||||
}
|
||||
}
|
||||
|
||||
return this._iccInfo;
|
||||
|
|
|
@ -1002,13 +1002,19 @@ add_test(function() {
|
|||
}
|
||||
};
|
||||
|
||||
MobileIdentityManager._iccProvider = {
|
||||
MobileIdentityManager._iccService = {
|
||||
_iccs: [],
|
||||
_listeners: [],
|
||||
registerIccMsg: function(aClientId, aIccListener) {
|
||||
this._listeners.push(aIccListener);
|
||||
},
|
||||
unregisterIccMsg: function() {
|
||||
this._listeners.pop();
|
||||
getIccByServiceId: function(aClientId) {
|
||||
let self = this;
|
||||
this_iccs.push({
|
||||
registerListener: function(aIccListener) {
|
||||
self._listeners.push(aIccListener);
|
||||
},
|
||||
unregisterListener: function() {
|
||||
self._listeners.pop();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1027,17 +1033,17 @@ add_test(function() {
|
|||
}
|
||||
|
||||
// We should have listeners for each valid icc.
|
||||
do_check_eq(MobileIdentityManager._iccProvider._listeners.length, 2);
|
||||
do_check_eq(MobileIdentityManager._iccService._listeners.length, 2);
|
||||
|
||||
// We can mock an ICC change event at this point.
|
||||
MobileIdentityManager._iccProvider._listeners[0].notifyIccInfoChanged();
|
||||
MobileIdentityManager._iccService._listeners[0].notifyIccInfoChanged();
|
||||
|
||||
// After the ICC change event the caches should be null.
|
||||
do_check_null(MobileIdentityManager._iccInfo);
|
||||
do_check_null(MobileIdentityManager._iccIds);
|
||||
|
||||
// And we should have unregistered all listeners for ICC change events.
|
||||
do_check_eq(MobileIdentityManager._iccProvider._listeners.length, 0);
|
||||
do_check_eq(MobileIdentityManager._iccService._listeners.length, 0);
|
||||
|
||||
do_test_finished();
|
||||
run_next_test();
|
||||
|
@ -1104,13 +1110,19 @@ add_test(function() {
|
|||
}
|
||||
};
|
||||
|
||||
MobileIdentityManager._iccProvider = {
|
||||
MobileIdentityManager._iccService = {
|
||||
_iccs: [],
|
||||
_listeners: [],
|
||||
registerIccMsg: function(aClientId, aIccListener) {
|
||||
this._listeners.push(aIccListener);
|
||||
},
|
||||
unregisterIccMsg: function() {
|
||||
this._listeners.pop();
|
||||
getIccByServiceId: function(aClientId) {
|
||||
let self = this;
|
||||
this_iccs.push({
|
||||
registerListener: function(aIccListener) {
|
||||
self._listeners.push(aIccListener);
|
||||
},
|
||||
unregisterListener: function() {
|
||||
self._listeners.pop();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1121,7 +1133,7 @@ add_test(function() {
|
|||
do_check_eq(MobileIdentityManager._iccIds.length, 0);
|
||||
|
||||
// We should have listeners for each valid icc.
|
||||
do_check_eq(MobileIdentityManager._iccProvider._listeners.length, 0);
|
||||
do_check_eq(MobileIdentityManager._iccService._listeners.length, 0);
|
||||
|
||||
do_test_finished();
|
||||
run_next_test();
|
||||
|
|
Загрузка…
Ссылка в новой задаче