Add p2 option in OpenLogicalChannel

- Adding support for P2 parameter
- Needed to support OMAPI 3.0 defined
  by SIM Alliance

Test: Basic telephony sanity
Bug: 27360148
Merged-In: I6a274195065ab1ef8406849228f60859ee826e53
Change-Id: I88134eded001e14c12e1f2a18efd0a2b51bc22fe
diff --git a/radio/1.0/IRadio.hal b/radio/1.0/IRadio.hal
index 2976290..236dbf5 100644
--- a/radio/1.0/IRadio.hal
+++ b/radio/1.0/IRadio.hal
@@ -1285,10 +1285,11 @@
      *
      * @param serial Serial number of request.
      * @param aid AID value, See ETSI 102.221 and 101.220.
+     * @param p2 P2 value, described in ISO 7816-4. Ignore if equal to P2Constant:NO_P2
      *
      * Response callback is IRadioResponse.iccOpenLogicalChannelResponse()
      */
-    oneway iccOpenLogicalChannel(int32_t serial, string aid);
+    oneway iccOpenLogicalChannel(int32_t serial, string aid, int32_t p2);
 
     /**
      * Close a previously opened logical channel. This command reflects TS 27.007
diff --git a/radio/1.0/types.hal b/radio/1.0/types.hal
index 2224c8b..c5d7f8a 100644
--- a/radio/1.0/types.hal
+++ b/radio/1.0/types.hal
@@ -1161,6 +1161,10 @@
                                           // this doesn't mean no data is expected.
 };
 
+enum P2Constant : int32_t {
+    NO_P2 = -1,                           // No P2 value is provided
+};
+
 struct RadioResponseInfo {
     RadioResponseType type;               // Response type
     int32_t serial;                       // Serial number of the request
diff --git a/radio/1.0/vts/functional/radio_hidl_hal_icc.cpp b/radio/1.0/vts/functional/radio_hidl_hal_icc.cpp
index 19738d5..b759c48 100644
--- a/radio/1.0/vts/functional/radio_hidl_hal_icc.cpp
+++ b/radio/1.0/vts/functional/radio_hidl_hal_icc.cpp
@@ -246,12 +246,15 @@
  */
 TEST_F(RadioHidlTest, iccOpenLogicalChannel) {
   int serial = 1;
-
+  int p2 = 0x04;
+  // Specified in ISO 7816-4 clause 7.1.1 0x04 means that FCP template is
+  // requested.
   for (int i = 0; i < (int)cardStatus.applications.size(); i++) {
-    radio->iccOpenLogicalChannel(++serial, cardStatus.applications[i].aidPtr);
-    EXPECT_EQ(std::cv_status::no_timeout, wait());
-    EXPECT_EQ(serial, radioRsp->rspInfo.serial);
-    EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
+      radio->iccOpenLogicalChannel(++serial, cardStatus.applications[i].aidPtr,
+                                   p2);
+      EXPECT_EQ(std::cv_status::no_timeout, wait());
+      EXPECT_EQ(serial, radioRsp->rspInfo.serial);
+      EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
   }
 }
 
@@ -317,4 +320,4 @@
   if (cardStatus.cardState == CardState::ABSENT) {
     ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::PASSWORD_INCORRECT);
   }
-}
\ No newline at end of file
+}