FR5955 MmTelBased Call Composer User Setting

Add constants and APIs to add a user setting
to allow the enablement/disablement of dialing
call composer calls

Change-Id: I7a156a05b8abfb03a2239774f147fc6be117e3c4
CRs-Fixed: 2643693
diff --git a/ims/ims-ext-common/src/org/codeaurora/ims/QtiCallConstants.java b/ims/ims-ext-common/src/org/codeaurora/ims/QtiCallConstants.java
index 84661e2..e1ddfaf 100644
--- a/ims/ims-ext-common/src/org/codeaurora/ims/QtiCallConstants.java
+++ b/ims/ims-ext-common/src/org/codeaurora/ims/QtiCallConstants.java
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015, 2019 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2015, 2019-2020 The Linux Foundation. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -325,6 +325,7 @@
     public static final int QTI_CONFIG_SMS_APP = 1001;
     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;
 
     /**
      * Key values for the Call Composer elements sent through the dial request
@@ -364,5 +365,14 @@
     // Type: double
     public static String EXTRA_CALL_COMPOSER_LOCATION_LONGITUDE =
             "call_composer_location_longitude";
+
+    /**
+     * User setting to control whether dialing call composer calls are allowed
+     * Type: int (0 for disable, 1 for enabled);
+     */
+    public static final String IMS_CALL_COMPOSER = "qti.settings.call_composer";
+    public static final int CALL_COMPOSER_DISABLED = 0;
+    public static final int CALL_COMPOSER_ENABLED = 1;
+
 }
 
diff --git a/ims/ims-ext-common/src/org/codeaurora/ims/QtiCarrierConfigs.java b/ims/ims-ext-common/src/org/codeaurora/ims/QtiCarrierConfigs.java
index b6b4d19..27f6566 100644
--- a/ims/ims-ext-common/src/org/codeaurora/ims/QtiCarrierConfigs.java
+++ b/ims/ims-ext-common/src/org/codeaurora/ims/QtiCarrierConfigs.java
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2016, 2020 The Linux Foundation. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -114,4 +114,10 @@
      */
     public static final String ALLOW_ONE_WAY_ACCEPT_FOR_VIDEO_CALL =
             "allow_one_way_accept_video_call";
+
+    /* Config to determine if Carrier supports call composer
+     * true - if call composer is support else false
+     */
+    public static final String KEY_CARRIER_CALL_COMPOSER_SUPPORTED =
+            "carrier_call_composer_supported_bool";
 }
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
index 16c31d2..18cde3d 100644
--- a/ims/ims-ext-common/src/org/codeaurora/ims/utils/QtiImsExtUtils.java
+++ b/ims/ims-ext-common/src/org/codeaurora/ims/utils/QtiImsExtUtils.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2015-2017, 2020 The Linux Foundation. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -641,4 +641,26 @@
         return (isCarrierConfigEnabled(phoneId, context,
                 QtiCarrierConfigs.ALLOW_ONE_WAY_ACCEPT_FOR_VIDEO_CALL));
     }
+
+    // Returns true if Carrier supports Call Composer
+    public static boolean isCallComposerSupported(int phoneId, Context context) {
+        return isCarrierConfigEnabled(phoneId, context,
+                QtiCarrierConfigs.KEY_CARRIER_CALL_COMPOSER_SUPPORTED);
+    }
+
+    // Stores user setting for Call Composer
+    public static void setCallComposerMode(ContentResolver contentResolver, int phoneId,
+            boolean turnOn) {
+        final int value = turnOn ? QtiCallConstants.CALL_COMPOSER_ENABLED :
+                QtiCallConstants.CALL_COMPOSER_DISABLED;
+        android.provider.Settings.Global.putInt(contentResolver,
+                QtiCallConstants.IMS_CALL_COMPOSER + phoneId, value);
+    }
+
+    // retrieves the stored user setting from the database per phone id
+    public static int getCallComposerMode(ContentResolver contentResolver, int phoneId) {
+        return android.provider.Settings.Global.getInt(contentResolver,
+                QtiCallConstants.IMS_CALL_COMPOSER + phoneId,
+                QtiCallConstants.AUTO_REJECT_CALL_DISABLED);
+    }
 }