Merge "Support different SIM power states"
diff --git a/radio/1.1/Android.bp b/radio/1.1/Android.bp
index f5ba178..c352b6d 100644
--- a/radio/1.1/Android.bp
+++ b/radio/1.1/Android.bp
@@ -3,6 +3,7 @@
 filegroup {
     name: "android.hardware.radio@1.1_hal",
     srcs: [
+        "types.hal",
         "IRadio.hal",
         "IRadioIndication.hal",
         "IRadioResponse.hal",
@@ -17,6 +18,7 @@
         ":android.hardware.radio@1.1_hal",
     ],
     out: [
+        "android/hardware/radio/1.1/types.cpp",
         "android/hardware/radio/1.1/RadioAll.cpp",
         "android/hardware/radio/1.1/RadioIndicationAll.cpp",
         "android/hardware/radio/1.1/RadioResponseAll.cpp",
@@ -31,6 +33,8 @@
         ":android.hardware.radio@1.1_hal",
     ],
     out: [
+        "android/hardware/radio/1.1/types.h",
+        "android/hardware/radio/1.1/hwtypes.h",
         "android/hardware/radio/1.1/IRadio.h",
         "android/hardware/radio/1.1/IHwRadio.h",
         "android/hardware/radio/1.1/BnHwRadio.h",
diff --git a/radio/1.1/IRadio.hal b/radio/1.1/IRadio.hal
index c2bfa53..44b08fe 100644
--- a/radio/1.1/IRadio.hal
+++ b/radio/1.1/IRadio.hal
@@ -51,4 +51,34 @@
      */
      oneway setCarrierInfoForImsiEncryption(int32_t serial, vec<uint8_t> carrierKey,
              string keyIdentifier);
+
+    /**
+     * Set SIM card power state.
+     * Request is equivalent to inserting or removing the card.
+     *
+     * The radio modem must generate IRadioIndication.simStatusChanged() as if the SIM had been
+     * inserted or removed.
+     *
+     * @param serial Serial number of request
+     * @param powerUp POWER_DOWN if powering down the SIM card,
+     *                POWER_UP if powering up the SIM card,
+     *                POWER_UP_PASS_THROUGH if powering up the SIM card in pass through mode.
+     * When SIM card is in POWER_UP_PASS_THROUGH, the modem does not send any command to it
+     * (for example SELECT of MF, or TERMINAL CAPABILITY), and the SIM card is controlled
+     * completely by Telephony sending APDUs directly. The SIM card state must be
+     * RIL_CARDSTATE_PRESENT and the number of card apps will be 0.
+     * No new error code is generated. Emergency calls are supported in the same way as if the
+     * SIM card is absent.
+     * POWER_UP_PASS_THROUGH mode is valid only for the specific card session where it is activated,
+     * and normal behavior occurs at the next SIM initialization, unless POWER_UP_PASS_THROUGH mode
+     * is requested again.
+     * The device is required to power down the SIM card before it can switch the mode between
+     * POWER_UP and POWER_UP_PASS_THROUGH.
+     * At device power up, the SIM interface is powered up automatically. Each subsequent request
+     * to this method is processed only after the completion of the previous one.
+     *
+     * Response callback is IRadioResponse.setSimCardPowerResponse_1_1()
+     */
+    oneway setSimCardPower_1_1(int32_t serial, CardPowerState powerUp);
+
 };
diff --git a/radio/1.1/IRadioResponse.hal b/radio/1.1/IRadioResponse.hal
index b0aece9..7727ef1 100644
--- a/radio/1.1/IRadioResponse.hal
+++ b/radio/1.1/IRadioResponse.hal
@@ -34,4 +34,16 @@
      *   RadioError:MODEM_INTERNAL_FAILURE
      */
     oneway setCarrierInfoForImsiEncryptionResponse(RadioResponseInfo info);
+
+    /**
+     * @param info Response info struct containing response type, serial no. and error
+     *
+     * Valid errors returned:
+     *   RadioError:NONE
+     *   RadioError:RADIO_NOT_AVAILABLE
+     *   RadioError:REQUEST_NOT_SUPPORTED
+     *   RadioError:INVALID_ARGUMENTS
+     */
+    oneway setSimCardPowerResponse_1_1(RadioResponseInfo info);
+
 };
diff --git a/radio/1.1/types.hal b/radio/1.1/types.hal
new file mode 100644
index 0000000..266f64f
--- /dev/null
+++ b/radio/1.1/types.hal
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.radio@1.1;
+
+enum CardPowerState : int32_t {
+    POWER_DOWN,
+    POWER_UP,
+    POWER_UP_PASS_THROUGH,
+};