Fake sim status changed appropriately
Wink Saville [Sat, 6 Oct 2012 21:14:48 +0000 (14:14 -0700)]
On a VZW GN if we always do ENTER_SIM_PIN the GET_SIM_STATUS comes so
quickly that it causes the SIMRecords to return an operator.numeric of
666666 instead of 311480. To fix this we only fake sim status changed
when an error occurs on the CHANGE/ENTER SIM_PIN/PIN2. Also, faking on
RIL_REQUEST_SET_FACILITY_LOCK on errors so on a VZW GN we automatically
go to the main lock screen when the PUK is needed,

Finally, on VZN GN RIL_REQUEST_ENTER_SIM_PUK we need to always fake
RIL_RESPONSE_UNSOL_SIM_STATUS_CHANGED, otherwise we won't automatically
leave the main lock screen when we enter the correct PUK. I also do this
for RIL_REQUEST_ENTER_SIM_PUK2 for consistency.

Bug: 7255789
Change-Id: I712cc5020970317922f0c3d686c621a6abcd552c

src/java/com/android/internal/telephony/RIL.java

index e27c9c6..faae72a 100644 (file)
@@ -2347,26 +2347,39 @@ public final class RIL extends BaseCommands implements CommandsInterface {
             }
         }
 
-        // Some devices do not send RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED so fake it.
-        // See b/7255789
+        // Here and below fake RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED, see b/7255789.
+        // This is needed otherwise we don't automatically transition to the main lock
+        // screen when the pin or puk is entered incorrectly.
         switch (rr.mRequest) {
-            case RIL_REQUEST_ENTER_SIM_PIN:
             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:
-                if (RILJ_LOGD) {
-                    riljLog("fakeSimStatusChanged: reg count="
-                            + mIccStatusChangedRegistrants.size());
-                }
                 if (mIccStatusChangedRegistrants != null) {
+                    if (RILJ_LOGD) {
+                        riljLog("ON enter sim puk fakeSimStatusChanged: reg count="
+                                + mIccStatusChangedRegistrants.size());
+                    }
                     mIccStatusChangedRegistrants.notifyRegistrants();
                 }
                 break;
         }
 
         if (error != 0) {
+            switch (rr.mRequest) {
+                case RIL_REQUEST_ENTER_SIM_PIN:
+                case RIL_REQUEST_ENTER_SIM_PIN2:
+                case RIL_REQUEST_CHANGE_SIM_PIN:
+                case RIL_REQUEST_CHANGE_SIM_PIN2:
+                case RIL_REQUEST_SET_FACILITY_LOCK:
+                    if (mIccStatusChangedRegistrants != null) {
+                        if (RILJ_LOGD) {
+                            riljLog("ON some errors fakeSimStatusChanged: reg count="
+                                    + mIccStatusChangedRegistrants.size());
+                        }
+                        mIccStatusChangedRegistrants.notifyRegistrants();
+                    }
+                    break;
+            }
+
             rr.onError(error, ret);
             rr.release();
             return;