This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12738 from crdlc/bug-918432-v1.2
Bug 918432 - Operator apps are installed at a fixed position even when the SIM wasn't present at first boot
- Loading branch information
Showing
19 changed files
with
608 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
'use strict'; | ||
|
||
var OperatorVariant = (function() { | ||
function setIsSIMPresentOnFirstBoot(value) { | ||
var result = navigator.mozSettings.createLock().set( | ||
{ 'ftu.simPresentOnFirstBoot' : value }); | ||
|
||
result.onerror = function ov_error() { | ||
console.error('An error occurre setting ftu.simPresentOnFirstBoot: ' + | ||
value); | ||
}; | ||
}; | ||
|
||
/** | ||
* If ftu.simPresentOnFirstBoot setting has value do nothing otherwise | ||
* set ftu.simPresentOnFirstBoot = true if | ||
* IccHelper.cardState value is: | ||
* 'pinRequired', | ||
* 'pukRequired', | ||
* 'networkLocked', | ||
* 'corporateLocked', | ||
* 'serviceProviderLocked', | ||
* 'ready'. | ||
* otherwise set to false. | ||
*/ | ||
function setSIMOnFirstBootState() { | ||
var cardState; | ||
|
||
try { | ||
if (!IccHelper || !IccHelper.enabled || !IccHelper.cardState) { | ||
cardState = undefined; | ||
} else { | ||
cardState = IccHelper.cardState; | ||
} | ||
|
||
var settings = navigator.mozSettings; | ||
if (!settings) { | ||
console.log('Settings is not available'); | ||
return; | ||
} | ||
|
||
var req = settings.createLock().get('ftu.simPresentOnFirstBoot'); | ||
|
||
req.onsuccess = function ov_onsuccess() { | ||
var currentStatus = req.result['ftu.simPresentOnFirstBoot']; | ||
if (currentStatus === undefined || currentStatus === null) { | ||
switch (cardState) { | ||
case 'pinRequired': | ||
case 'pukRequired': | ||
case 'networkLocked': | ||
case 'corporateLocked': | ||
case 'serviceProviderLocked': | ||
case 'ready': | ||
setIsSIMPresentOnFirstBoot(true); | ||
break; | ||
default: | ||
setIsSIMPresentOnFirstBoot(false); | ||
break; | ||
} | ||
} | ||
cardState = null; | ||
}; | ||
|
||
req.onerror = function ov_error() { | ||
console.error('Error retrieving ftu.simPresentOnFirstBoot'); | ||
}; | ||
|
||
} catch (e) { | ||
console.error('Error setSIMOnFirstBootState. ' + e); | ||
} | ||
}; | ||
|
||
return { | ||
setSIMOnFirstBootState: setSIMOnFirstBootState | ||
}; | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
for (var key in obj) { | ||
settings[key] = obj[key]; | ||
} | ||
return {}; | ||
} | ||
|
||
function mns_mLockGet(key) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
var MockOperatorVariant = { | ||
setSIMOnFirstBootState: function() {} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
'use strict'; | ||
|
||
requireApp('communications/ftu/test/unit/mock_icc_helper.js'); | ||
requireApp('communications/ftu/test/unit/mock_navigator_moz_settings.js'); | ||
|
||
requireApp('communications/ftu/js/operatorVariant.js'); | ||
|
||
var mocksHelper = new MocksHelper([ | ||
'IccHelper' | ||
]).init(); | ||
|
||
|
||
suite('operatorVariant set First run state >', function() { | ||
const KEY_SIM_ON_1ST_RUN = 'ftu.simPresentOnFirstBoot'; | ||
var SAVE_STATE_WAIT_TIMEOUT = 200; | ||
var realSettings; | ||
|
||
suiteSetup(function() { | ||
mocksHelper.suiteSetup(); | ||
realSettings = navigator.mozSettings; | ||
navigator.mozSettings = MockNavigatorSettings; | ||
}); | ||
|
||
suiteTeardown(function() { | ||
mocksHelper.suiteTeardown(); | ||
navigator.mozSettings = realSettings; | ||
realSettings = null; | ||
}); | ||
|
||
// helper to change single key-value of mozSettings | ||
function changeSettings(key, value) { | ||
var cset = {}; | ||
cset[key] = value; | ||
MockNavigatorSettings.createLock().set(cset); | ||
} | ||
|
||
|
||
setup(function() { | ||
mocksHelper.setup(); | ||
}); | ||
|
||
var testCases = [ | ||
{ | ||
'preValSet': undefined, | ||
'expecValSet': false, | ||
'cardState': 'unknown', | ||
'title': 'Operator Variant set first run type - unkown sim' | ||
}, | ||
{ | ||
'preValSet': undefined, | ||
'expecValSet': true, | ||
'cardState': 'ready', | ||
'title': 'Operator Variant set first run type - sim ready' | ||
}, | ||
{ | ||
'preValSet': undefined, | ||
'expecValSet': true, | ||
'cardState': 'pinRequired', | ||
'title': 'Operator Variant set first run type - sim pinRequired' | ||
}, | ||
{ | ||
'preValSet': true, | ||
'expecValSet': true, | ||
'cardState': 'ready', | ||
'title': 'Operator Variant first run type previously set true' | ||
}, | ||
{ | ||
'preValSet': false, | ||
'expecValSet': false, | ||
'cardState': 'ready', | ||
'title': 'Operator Variant set first run type previously set false' | ||
} | ||
]; | ||
|
||
testCases.forEach((function(testCase) { | ||
test(testCase.title, function(done) { | ||
MockIccHelper.mProps['cardState'] = testCase.cardState; | ||
changeSettings(KEY_SIM_ON_1ST_RUN, testCase.preValSet); | ||
OperatorVariant.setSIMOnFirstBootState(); | ||
setTimeout(function() { | ||
var mSettings = MockNavigatorSettings.mSettings; | ||
assert.equal(mSettings[KEY_SIM_ON_1ST_RUN], testCase.expecValSet); | ||
done(); | ||
}, SAVE_STATE_WAIT_TIMEOUT); | ||
}); | ||
})); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.