Restore SE activated mode in case of failure.

There is a tight race condition where opening
of the SE can fail, due to a tag/p2p device
having just come in. In that case, restore
the original state of the SE activated mode.

This will prevent future calls into this
method and Connect() from immediately bailing out.

Bug: 8599167
Change-Id: I1890e4efb73a9f5bdd6abe0644f88051b32e8c02
diff --git a/src/phLibNfc_SE.c b/src/phLibNfc_SE.c
index 2cdb24e..0ccfce6 100644
--- a/src/phLibNfc_SE.c
+++ b/src/phLibNfc_SE.c
@@ -470,6 +470,7 @@
     }
     else 
     {
+        phLibNfc_eSE_ActivationMode originalMode = pLibContext->sSeContext.eActivatedMode;
         switch(eActivation_mode)
         {
             case phLibNfc_SE_ActModeVirtual: 
@@ -655,6 +656,8 @@
         }
         else
         {
+            // Restore original mode
+            pLibContext->sSeContext.eActivatedMode = originalMode;
             Status = NFCSTATUS_FAILED;
         }
     }