From a97a1875751ba5030c47589d3db62b78e260c1b8 Mon Sep 17 00:00:00 2001
From: Bryan Stine <bryan@southcape.org>
Date: Fri, 26 Mar 2010 02:32:11 -0400
Subject: [PATCH] Fix PIN unlock, possibly enable PIN change

We were looking for a CPIN reponse when entering SIM PIN. It appears
that we actually get a CREG reply, searching for network, immediately:

D/RILJ    ( 1250): [0022]> ENTER_SIM_PIN
D/RIL     ( 1169): onRequest: ENTER_SIM_PIN
D/AT      ( 1169): AT> AT+CPIN="xxxx"
D/AT      ( 1169): AT< +CREG: 2
D/RILJ    ( 1250): [UNSL]< UNSOL_RESPONSE_NETWORK_STATE_CHANGED
D/RILJ    ( 1250): [0023]> OPERATOR
D/AT      ( 1169): AT< +CGREG: 2
D/AT      ( 1169): AT< OK

Update PIN handling to reflect that. Tried enabling PIN change as well,
but have not tested. Please review.
---
 htcgeneric-ril.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/htcgeneric-ril.c b/htcgeneric-ril.c
index fd1e4bc..2c8edf1 100644
--- a/htcgeneric-ril.c
+++ b/htcgeneric-ril.c
@@ -2162,7 +2162,7 @@ static void  requestEnterSimPin(void*  data, size_t  datalen, RIL_Token  t)
 		} else
 			goto error;
 
-		err = at_send_command_singleline(cmd, "+CPIN:", &p_response);
+		err = at_send_command_singleline(cmd, "+CREG:", &p_response);
 		free(cmd);
 
 		if (err < 0 || p_response->success == 0) {
@@ -3593,12 +3593,12 @@ onRequest (int request, void *data, size_t datalen, RIL_Token t)
 			break;
 		}
 		case RIL_REQUEST_ENTER_SIM_PIN:
+		case RIL_REQUEST_CHANGE_SIM_PIN:
 			requestEnterSimPin(data, datalen, t);
 			break;
 		case RIL_REQUEST_ENTER_SIM_PUK:
 		case RIL_REQUEST_ENTER_SIM_PIN2:
 		case RIL_REQUEST_ENTER_SIM_PUK2:
-		case RIL_REQUEST_CHANGE_SIM_PIN:
 		case RIL_REQUEST_CHANGE_SIM_PIN2:
 		case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION:
 			requestNotSupported(t);
-- 
1.7.0.2


