diff --git a/dom/system/gonk/ril_consts.js b/dom/system/gonk/ril_consts.js index dddce0382a78..401c4e7bec86 100644 --- a/dom/system/gonk/ril_consts.js +++ b/dom/system/gonk/ril_consts.js @@ -2332,26 +2332,46 @@ this.GECKO_RADIOSTATE_UNAVAILABLE = null; this.GECKO_RADIOSTATE_OFF = "off"; this.GECKO_RADIOSTATE_READY = "ready"; -this.GECKO_CARDSTATE_NOT_READY = null; -this.GECKO_CARDSTATE_UNKNOWN = "unknown"; -this.GECKO_CARDSTATE_ABSENT = "absent"; -this.GECKO_CARDSTATE_PIN_REQUIRED = "pinRequired"; -this.GECKO_CARDSTATE_PUK_REQUIRED = "pukRequired"; -this.GECKO_CARDSTATE_NETWORK_LOCKED = "networkLocked"; -this.GECKO_CARDSTATE_CORPORATE_LOCKED = "corporateLocked"; -this.GECKO_CARDSTATE_SERVICE_PROVIDER_LOCKED = "serviceProviderLocked"; -this.GECKO_CARDSTATE_READY = "ready"; +this.GECKO_CARDSTATE_NOT_READY = null; +this.GECKO_CARDSTATE_UNKNOWN = "unknown"; +this.GECKO_CARDSTATE_ABSENT = "absent"; +this.GECKO_CARDSTATE_PIN_REQUIRED = "pinRequired"; +this.GECKO_CARDSTATE_PUK_REQUIRED = "pukRequired"; +this.GECKO_CARDSTATE_PERSONALIZATION_IN_PROGRESS = "personalizationInProgress"; +this.GECKO_CARDSTATE_NETWORK_LOCKED = "networkLocked"; +this.GECKO_CARDSTATE_NETWORK_SUBSET_LOCKED = "networkSubsetLocked"; +this.GECKO_CARDSTATE_CORPORATE_LOCKED = "corporateLocked"; +this.GECKO_CARDSTATE_SERVICE_PROVIDER_LOCKED = "serviceProviderLocked"; +this.GECKO_CARDSTATE_SIM_LOCKED = "simPersonalizationLock"; +this.GECKO_CARDSTATE_NETWORK_PUK_REQUIRED = "networkPukRequired"; +this.GECKO_CARDSTATE_NETWORK_SUBSET_PUK_REQUIRED = "networkSubsetPukRequired"; +this.GECKO_CARDSTATE_CORPORATE_PUK_REQUIRED = "corporatePukRequired"; +this.GECKO_CARDSTATE_SERVICE_PROVIDER_PUK_REQUIRED = "serviceProviderPukRequired"; +this.GECKO_CARDSTATE_SIM_PUK_REQUIRED = "simPersonalizationPukRequired"; +this.GECKO_CARDSTATE_READY = "ready"; // See ril.h RIL_PersoSubstate this.PERSONSUBSTATE = {}; PERSONSUBSTATE[CARD_PERSOSUBSTATE_UNKNOWN] = GECKO_CARDSTATE_UNKNOWN; -PERSONSUBSTATE[CARD_PERSOSUBSTATE_IN_PROGRESS] = "inProgress"; -PERSONSUBSTATE[CARD_PERSOSUBSTATE_READY] = GECKO_CARDSTATE_READY; +PERSONSUBSTATE[CARD_PERSOSUBSTATE_IN_PROGRESS] = GECKO_CARDSTATE_PERSONALIZATION_IN_PROGRESS; PERSONSUBSTATE[CARD_PERSOSUBSTATE_SIM_NETWORK] = GECKO_CARDSTATE_NETWORK_LOCKED; -PERSONSUBSTATE[CARD_PERSOSUBSTATE_SIM_NETWORK_SUBSET] = "networkSubsetLocked"; +PERSONSUBSTATE[CARD_PERSOSUBSTATE_SIM_NETWORK_SUBSET] = GECKO_CARDSTATE_NETWORK_SUBSET_LOCKED; PERSONSUBSTATE[CARD_PERSOSUBSTATE_SIM_CORPORATE] = GECKO_CARDSTATE_CORPORATE_LOCKED; PERSONSUBSTATE[CARD_PERSOSUBSTATE_SIM_SERVICE_PROVIDER] = GECKO_CARDSTATE_SERVICE_PROVIDER_LOCKED; -PERSONSUBSTATE[CARD_PERSOSUBSTATE_SIM_SIM] = "simPersonalizationLock"; +PERSONSUBSTATE[CARD_PERSOSUBSTATE_SIM_SIM] = GECKO_CARDSTATE_SIM_LOCKED; +PERSONSUBSTATE[CARD_PERSOSUBSTATE_SIM_NETWORK_PUK] = GECKO_CARDSTATE_NETWORK_PUK_REQUIRED; +PERSONSUBSTATE[CARD_PERSOSUBSTATE_SIM_NETWORK_SUBSET_PUK] = GECKO_CARDSTATE_NETWORK_SUBSET_PUK_REQUIRED; +PERSONSUBSTATE[CARD_PERSOSUBSTATE_SIM_CORPORATE_PUK] = GECKO_CARDSTATE_CORPORATE_PUK_REQUIRED; +PERSONSUBSTATE[CARD_PERSOSUBSTATE_SIM_SERVICE_PROVIDER_PUK] = GECKO_CARDSTATE_SERVICE_PROVIDER_PUK_REQUIRED; +PERSONSUBSTATE[CARD_PERSOSUBSTATE_READY] = GECKO_CARDSTATE_READY; + +this.GECKO_PERSO_LOCK_TO_CARD_PERSO_LOCK = {}; +GECKO_PERSO_LOCK_TO_CARD_PERSO_LOCK["nck"] = CARD_PERSOSUBSTATE_SIM_NETWORK; +GECKO_PERSO_LOCK_TO_CARD_PERSO_LOCK["cck"] = CARD_PERSOSUBSTATE_SIM_CORPORATE; +GECKO_PERSO_LOCK_TO_CARD_PERSO_LOCK["spck"] = CARD_PERSOSUBSTATE_SIM_SERVICE_PROVIDER; +GECKO_PERSO_LOCK_TO_CARD_PERSO_LOCK["nckPuk"] = CARD_PERSOSUBSTATE_SIM_NETWORK_PUK; +GECKO_PERSO_LOCK_TO_CARD_PERSO_LOCK["cckPuk"] = CARD_PERSOSUBSTATE_SIM_CORPORATE_PUK; +GECKO_PERSO_LOCK_TO_CARD_PERSO_LOCK["spckPuk"] = CARD_PERSOSUBSTATE_SIM_SERVICE_PROVIDER_PUK; this.GECKO_NETWORK_SELECTION_UNKNOWN = null; this.GECKO_NETWORK_SELECTION_AUTOMATIC = "automatic"; diff --git a/dom/system/gonk/ril_worker.js b/dom/system/gonk/ril_worker.js index efa8dddbbbe7..fd88f44d59d4 100644 --- a/dom/system/gonk/ril_worker.js +++ b/dom/system/gonk/ril_worker.js @@ -980,17 +980,19 @@ let RIL = { this.enterICCPUK2(options); break; case "nck": - options.type = CARD_PERSOSUBSTATE_SIM_NETWORK; - this.enterDepersonalization(options); + case "cck": // Fall through. + case "spck": { + let type = GECKO_PERSO_LOCK_TO_CARD_PERSO_LOCK[options.lockType]; + this.enterDepersonalization(type, options.pin, options); break; - case "cck": - options.type = CARD_PERSOSUBSTATE_SIM_CORPORATE; - this.enterDepersonalization(options); - break; - case "spck": - options.type = CARD_PERSOSUBSTATE_SIM_SERVICE_PROVIDER; - this.enterDepersonalization(options); + } + case "nckPuk": + case "cckPuk": // Fall through. + case "spckPuk": { + let type = GECKO_PERSO_LOCK_TO_CARD_PERSO_LOCK[options.lockType]; + this.enterDepersonalization(type, options.puk, options); break; + } default: options.errorMsg = "Unsupported Card Lock."; options.success = false; @@ -1039,13 +1041,13 @@ let RIL = { * * @param type * Integer indicating the network personalization be deactivated. - * @param pin - * String containing the pin. + * @param password + * String containing the password. */ - enterDepersonalization: function enterDepersonalization(options) { + enterDepersonalization: function enterDepersonalization(type, password, options) { Buf.newParcel(REQUEST_ENTER_NETWORK_DEPERSONALIZATION_CODE, options); - Buf.writeUint32(options.type); - Buf.writeString(options.pin); + Buf.writeUint32(type); + Buf.writeString(password); Buf.sendParcel(); }, diff --git a/dom/system/gonk/tests/test_ril_worker_icc.js b/dom/system/gonk/tests/test_ril_worker_icc.js index 032dcf2c0614..a361c45e60b4 100644 --- a/dom/system/gonk/tests/test_ril_worker_icc.js +++ b/dom/system/gonk/tests/test_ril_worker_icc.js @@ -2676,58 +2676,51 @@ add_test(function test_find_free_icc_contact() { contactHelper.findFreeICCContact(CARD_APPTYPE_USIM, "adn", successCb, errorCb); }); -/** - * Verify cardState 'corporateLocked'. - */ -add_test(function test_card_state_corporateLocked() { +add_test(function test_personalization_state() { let worker = newUint8Worker(); let ril = worker.RIL; - let iccStatus = { - gsmUmtsSubscriptionAppIndex: 0, - apps: [ - { - app_state: CARD_APPSTATE_SUBSCRIPTION_PERSO, - perso_substate: CARD_PERSOSUBSTATE_SIM_CORPORATE - }], - }; - ril._processICCStatus(iccStatus); - do_check_eq(ril.cardState, GECKO_CARDSTATE_CORPORATE_LOCKED); + function testPersonalization(cardPersoState, geckoCardState) { + let iccStatus = { + gsmUmtsSubscriptionAppIndex: 0, + apps: [ + { + app_state: CARD_APPSTATE_SUBSCRIPTION_PERSO, + perso_substate: cardPersoState + }], + }; + + ril._processICCStatus(iccStatus); + do_check_eq(ril.cardState, geckoCardState); + } + + testPersonalization(CARD_PERSOSUBSTATE_SIM_NETWORK, + GECKO_CARDSTATE_NETWORK_LOCKED); + testPersonalization(CARD_PERSOSUBSTATE_SIM_CORPORATE, + GECKO_CARDSTATE_CORPORATE_LOCKED); + testPersonalization(CARD_PERSOSUBSTATE_SIM_SERVICE_PROVIDER, + GECKO_CARDSTATE_SERVICE_PROVIDER_LOCKED); + testPersonalization(CARD_PERSOSUBSTATE_SIM_NETWORK_PUK, + GECKO_CARDSTATE_NETWORK_PUK_REQUIRED); + testPersonalization(CARD_PERSOSUBSTATE_SIM_CORPORATE_PUK, + GECKO_CARDSTATE_CORPORATE_PUK_REQUIRED); + testPersonalization(CARD_PERSOSUBSTATE_SIM_SERVICE_PROVIDER_PUK, + GECKO_CARDSTATE_SERVICE_PROVIDER_PUK_REQUIRED); run_next_test(); }); /** - * Verify cardState 'serviceProviderLocked'. - */ -add_test(function test_card_state_serviceProviderLocked() { - let worker = newUint8Worker(); - let ril = worker.RIL; - let iccStatus = { - gsmUmtsSubscriptionAppIndex: 0, - apps: [ - { - app_state: CARD_APPSTATE_SUBSCRIPTION_PERSO, - perso_substate: CARD_PERSOSUBSTATE_SIM_SERVICE_PROVIDER - }], - }; - - ril._processICCStatus(iccStatus); - do_check_eq(ril.cardState, GECKO_CARDSTATE_SERVICE_PROVIDER_LOCKED); - - run_next_test(); -}); - -/** - * Verify iccUnlockCardLock with lockType is "cck" and "spck". + * Verify iccUnlockCardLock. */ add_test(function test_unlock_card_lock_corporateLocked() { let worker = newUint8Worker(); let ril = worker.RIL; let buf = worker.Buf; const pin = "12345678"; + const puk = "12345678"; - function do_test(aLock, aPin) { + function do_test(aLock, aPassword) { buf.sendParcel = function fakeSendParcel () { // Request Type. do_check_eq(this.readUint32(), REQUEST_ENTER_NETWORK_DEPERSONALIZATION_CODE); @@ -2735,23 +2728,29 @@ add_test(function test_unlock_card_lock_corporateLocked() { // Token : we don't care this.readUint32(); - let lockType = aLock === "cck" ? - CARD_PERSOSUBSTATE_SIM_CORPORATE : - CARD_PERSOSUBSTATE_SIM_SERVICE_PROVIDER; - + let lockType = GECKO_PERSO_LOCK_TO_CARD_PERSO_LOCK[aLock]; // Lock Type do_check_eq(this.readUint32(), lockType); - // Pin. - do_check_eq(this.readString(), aPin); + // Pin/Puk. + do_check_eq(this.readString(), aPassword); }; - ril.iccUnlockCardLock({lockType: aLock, - pin: aPin}); + if (aLock.endsWith("Puk")) { + ril.iccUnlockCardLock({lockType: aLock, + puk: aPassword}); + } else { + ril.iccUnlockCardLock({lockType: aLock, + pin: aPassword}); + } } + do_test("nck", pin); do_test("cck", pin); do_test("spck", pin); + do_test("nckPuk", puk); + do_test("cckPuk", puk); + do_test("spckPuk", puk); run_next_test(); });