Merge "Add Secure Mode AIDL APIs"
diff --git a/ims/ims-ext-common/src/org/codeaurora/ims/CallComposerInfo.java b/ims/ims-ext-common/src/org/codeaurora/ims/CallComposerInfo.java
old mode 100644
new mode 100755
index f0d66f8..7a02a97
--- a/ims/ims-ext-common/src/org/codeaurora/ims/CallComposerInfo.java
+++ b/ims/ims-ext-common/src/org/codeaurora/ims/CallComposerInfo.java
@@ -25,6 +25,40 @@
  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Changes from Qualcomm Innovation Center are provided under the following license:
+ *
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted (subject to the limitations in the
+ * disclaimer below) provided that the following conditions are met:
+ *
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   * Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the following
+ *     disclaimer in the documentation and/or other materials provided
+ *     with the distribution.
+ *
+ *   * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
+ * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
+ * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 package org.codeaurora.ims;
@@ -120,18 +154,26 @@
     public static final int PRIORITY_NORMAL = 1;
     public static final int INVALID_CALLID = -1;
     public static final int INVALID_TOKEN = -1;
+    public static final String INVALID_ORGANIZATION = "";
 
     private int mPriority;
     private String mSubject;
     private Uri mImageUrl;
     private Location mLocation;
+    private String mOrganization;
 
     public CallComposerInfo(int priority, String subject, Uri imageUrl,
-            Location location) {
+            Location location, String organization) {
         mPriority = priority;
         mSubject = subject;
         mImageUrl = imageUrl;
         mLocation = location;
+        mOrganization = organization;
+    }
+
+    public CallComposerInfo(int priority, String subject, Uri imageUrl,
+            Location location) {
+        this(priority, subject, imageUrl, location, INVALID_ORGANIZATION);
     }
 
     public CallComposerInfo(int priority, String subject, Uri imageUrl) {
@@ -143,6 +185,7 @@
         mSubject = info.getSubject();
         mImageUrl = info.getImageUrl();
         mLocation = info.getLocation();
+        mOrganization = info.getOrganization();
     }
 
     public CallComposerInfo(Parcel in) {
@@ -178,12 +221,20 @@
         return mLocation;
     }
 
+    /*
+    * This method returns the organization of the call
+    */
+    public String getOrganization() {
+        return mOrganization;
+    }
+
     @Override
     public void writeToParcel(Parcel dest, int flag) {
         dest.writeInt(mPriority);
         dest.writeString(mSubject);
         dest.writeParcelable(mImageUrl, flag);
         dest.writeParcelable(mLocation, flag);
+        dest.writeString(mOrganization);
     }
 
     public void readFromParcel(Parcel in) {
@@ -191,6 +242,7 @@
         mSubject = in.readString();
         mImageUrl = in.readParcelable(Uri.class.getClassLoader());
         mLocation = in.readParcelable(Location.class.getClassLoader());
+        mOrganization = in.readString();
     }
 
     @Override
@@ -214,6 +266,7 @@
     public String toString() {
         return ("{CallComposerInfo: " + "priority = " +
                 mPriority + " , subject = " + mSubject +
-                " , image url = " + mImageUrl + ", location = " + mLocation +"}");
+                " , image url = " + mImageUrl + ", location = " + mLocation +
+                " , organization = " + mOrganization + "}");
     }
 }
diff --git a/ims/ims-ext-common/src/org/codeaurora/ims/QtiCallConstants.java b/ims/ims-ext-common/src/org/codeaurora/ims/QtiCallConstants.java
old mode 100644
new mode 100755
index f235e2f..c52986f
--- a/ims/ims-ext-common/src/org/codeaurora/ims/QtiCallConstants.java
+++ b/ims/ims-ext-common/src/org/codeaurora/ims/QtiCallConstants.java
@@ -24,6 +24,40 @@
  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Changes from Qualcomm Innovation Center are provided under the following license:
+ *
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted (subject to the limitations in the
+ * disclaimer below) provided that the following conditions are met:
+ *
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   * Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the following
+ *     disclaimer in the documentation and/or other materials provided
+ *     with the distribution.
+ *
+ *   * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
+ * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
+ * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 package org.codeaurora.ims;
@@ -327,6 +361,7 @@
     public static final int QTI_CONFIG_VVM_APP = 1002;
     public static final int QTI_CONFIG_VOWIFI_ROAMING_MODE_PREFERENCE = 1003;
     public static final int CALL_COMPOSER_MODE = 1004;
+    public static final int B2C_ENRICHED_CALLING_MODE = 1005;
 
     /**
      * Key values for the pre alerting call elements
@@ -379,6 +414,11 @@
     public static String EXTRA_CALL_COMPOSER_LOCATION_LONGITUDE =
             "call_composer_location_longitude";
 
+    // Get when organization header is added to call composer call
+    // Type: String
+    public static final String EXTRA_CALL_COMPOSER_ORGANIZATION_HEADER =
+            "call_composer_organization_header";
+
     // Set for eCnam info
     public static String EXTRA_CALL_ECNAM = "call_ecnam";
 
@@ -407,6 +447,14 @@
     public static final int CALL_COMPOSER_ENABLED = 1;
 
     /**
+     * User setting to control whether b2c enriched calling is allowed
+     * Type: int (0 for disable, 1 for enabled);
+     */
+    public static final String B2C_ENRICHED_CALLING = "qti.settings.b2c_enriched_calling";
+    public static final int B2C_ENRICHED_CALLING_DISABLED = 0;
+    public static final int B2C_ENRICHED_CALLING_ENABLED = 1;
+
+    /**
      * Constants used by clients as part of registration status change indication.
      * Below constants will be notified when modem is unable to get the geo location information.
      */
@@ -427,6 +475,8 @@
     public static final String EXTRA_ORIGINAL_CALL_TYPE = "originalCallType";
     /* Slience UI before CRS RTP come extra key */
     public static final String EXTRA_IS_PREPARATORY = "isPreparatory";
+    /* Ims vendor callId extra key */
+    public static final String EXTRA_IMS_CALL_ID = "callId";
     //INVALID if CrsData is invalid, play local ring.
     public static final int CRS_TYPE_INVALID = 0;
     //AUDIO if only audio will be played.
diff --git a/ims/ims-ext-common/src/org/codeaurora/ims/QtiCarrierConfigs.java b/ims/ims-ext-common/src/org/codeaurora/ims/QtiCarrierConfigs.java
old mode 100644
new mode 100755
index 139d80c..1b67398
--- a/ims/ims-ext-common/src/org/codeaurora/ims/QtiCarrierConfigs.java
+++ b/ims/ims-ext-common/src/org/codeaurora/ims/QtiCarrierConfigs.java
@@ -24,6 +24,40 @@
  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Changes from Qualcomm Innovation Center are provided under the following license:
+ *
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted (subject to the limitations in the
+ * disclaimer below) provided that the following conditions are met:
+ *
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   * Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the following
+ *     disclaimer in the documentation and/or other materials provided
+ *     with the distribution.
+ *
+ *   * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
+ * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
+ * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 package org.codeaurora.ims;
@@ -116,6 +150,12 @@
     public static final String KEY_CARRIER_CALL_COMPOSER_SUPPORTED =
             "carrier_call_composer_supported_bool";
 
+    /* Config to determine if Carrier supports b2c enriched calling
+     * true - if b2c enriched calling is support else false
+     */
+    public static final String KEY_CARRIER_B2C_ENRICHED_CALLING_SUPPORTED =
+            "carrier_b2c_enriched_calling_supported_bool";
+
     /* Config to determine if Carrier supports video CRS
      * true - if video CRS is support else false
      */
diff --git a/ims/ims-ext-common/src/org/codeaurora/ims/utils/CallComposerInfoUtils.java b/ims/ims-ext-common/src/org/codeaurora/ims/utils/CallComposerInfoUtils.java
old mode 100644
new mode 100755
index 3a3ea12..e4b2aab
--- a/ims/ims-ext-common/src/org/codeaurora/ims/utils/CallComposerInfoUtils.java
+++ b/ims/ims-ext-common/src/org/codeaurora/ims/utils/CallComposerInfoUtils.java
@@ -24,6 +24,40 @@
  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Changes from Qualcomm Innovation Center are provided under the following license:
+ *
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted (subject to the limitations in the
+ * disclaimer below) provided that the following conditions are met:
+ *
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   * Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the following
+ *     disclaimer in the documentation and/or other materials provided
+ *     with the distribution.
+ *
+ *   * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
+ * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
+ * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 package org.codeaurora.ims.utils;
@@ -74,13 +108,18 @@
         Bundle bundle = new Bundle();
         bundle.putInt(QtiCallConstants.EXTRA_CALL_COMPOSER_PRIORITY, info.getPriority());
         String subject = info.getSubject();
-        if (subject != null || !subject.isEmpty()) {
+        if (subject != null && !subject.isEmpty()) {
             bundle.putString(QtiCallConstants.EXTRA_CALL_COMPOSER_SUBJECT, subject);
         }
         Uri imageUrl = info.getImageUrl();
         if (imageUrl != null) {
             bundle.putParcelable(QtiCallConstants.EXTRA_CALL_COMPOSER_IMAGE, imageUrl);
         }
+        String organization = info.getOrganization();
+        if (organization != null && !organization.isEmpty()) {
+            bundle.putString(QtiCallConstants.EXTRA_CALL_COMPOSER_ORGANIZATION_HEADER,
+                    organization);
+        }
         CallComposerInfo.Location location = info.getLocation();
         if (location != null) {
             bundle.putBoolean(QtiCallConstants.EXTRA_CALL_COMPOSER_LOCATION, true);
diff --git a/ims/ims-ext-common/src/org/codeaurora/ims/utils/QtiImsExtUtils.java b/ims/ims-ext-common/src/org/codeaurora/ims/utils/QtiImsExtUtils.java
old mode 100644
new mode 100755
index c769ad5..0a26676
--- a/ims/ims-ext-common/src/org/codeaurora/ims/utils/QtiImsExtUtils.java
+++ b/ims/ims-ext-common/src/org/codeaurora/ims/utils/QtiImsExtUtils.java
@@ -25,6 +25,40 @@
  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Changes from Qualcomm Innovation Center are provided under the following license:
+ *
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted (subject to the limitations in the
+ * disclaimer below) provided that the following conditions are met:
+ *
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   * Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the following
+ *     disclaimer in the documentation and/or other materials provided
+ *     with the distribution.
+ *
+ *   * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
+ * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
+ * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 package org.codeaurora.ims.utils;
@@ -723,6 +757,28 @@
                 QtiCallConstants.CALL_COMPOSER_DISABLED);
     }
 
+    // Returns true if Carrier supports B2C Enriched Calling
+    public static boolean isB2cEnrichedCallingSupported(int phoneId, Context context) {
+        return isCarrierConfigEnabled(phoneId, context,
+                QtiCarrierConfigs.KEY_CARRIER_B2C_ENRICHED_CALLING_SUPPORTED);
+    }
+
+    // Stores user setting for B2C Enriched Calling
+    public static void setB2cEnrichedCallingMode(ContentResolver contentResolver, int phoneId,
+            boolean turnOn) {
+        final int value = turnOn ? QtiCallConstants.B2C_ENRICHED_CALLING_ENABLED :
+                QtiCallConstants.B2C_ENRICHED_CALLING_DISABLED;
+        android.provider.Settings.Global.putInt(contentResolver,
+                QtiCallConstants.B2C_ENRICHED_CALLING + phoneId, value);
+    }
+
+    // retrieves the stored user setting from the database per phone id
+    public static int getB2cEnrichedCallingMode(ContentResolver contentResolver, int phoneId) {
+        return android.provider.Settings.Global.getInt(contentResolver,
+                QtiCallConstants.B2C_ENRICHED_CALLING + phoneId,
+                QtiCallConstants.B2C_ENRICHED_CALLING_DISABLED);
+    }
+
     // Sets RTT Operation Mode to global settings
     // Takes a phoneId to support DSDS configuration.
     public static void setRttOperatingMode(ContentResolver contentResolver, int phoneId,