Merge "IMS-VT: Disable TTY mode settings when in a video call" into mm-wireless-dev
diff --git a/src/com/android/phone/PhoneGlobals.java b/src/com/android/phone/PhoneGlobals.java
index 1b4e648..bf20b48 100644
--- a/src/com/android/phone/PhoneGlobals.java
+++ b/src/com/android/phone/PhoneGlobals.java
@@ -48,7 +48,7 @@
 import android.os.UpdateLock;
 import android.os.UserHandle;
 import android.preference.PreferenceManager;
-import android.provider.Settings.System;
+import android.provider.Settings;
 import android.telephony.CarrierConfigManager;
 import android.telephony.ServiceState;
 import android.telephony.SubscriptionInfo;
@@ -789,8 +789,8 @@
         public void onReceive(Context context, Intent intent) {
             String action = intent.getAction();
             if (action.equals(Intent.ACTION_AIRPLANE_MODE_CHANGED)) {
-                boolean enabled = System.getInt(getContentResolver(),
-                        System.AIRPLANE_MODE_ON, 0) == 0;
+                boolean enabled = Settings.Global.getInt(getContentResolver(),
+                        Settings.Global.AIRPLANE_MODE_ON, 0) == 0;
                 PhoneUtils.setRadioPower(enabled);
             } else if (action.equals(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED)) {
                 int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY,
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 32dbfde..68b6823 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -194,8 +194,9 @@
         public Object argument;
         /** The result of the request that is run on the main thread */
         public Object result;
-        /** The subscriber id that this request applies to. Null if default. */
-        public Integer subId;
+        // The subscriber id that this request applies to. Defaults to
+        // SubscriptionManager.INVALID_SUBSCRIPTION_ID
+        public Integer subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
 
         public MainThreadRequest(Object argument) {
             this.argument = argument;
@@ -203,7 +204,9 @@
 
         public MainThreadRequest(Object argument, Integer subId) {
             this.argument = argument;
-            this.subId = subId;
+            if (subId != null) {
+                this.subId = subId;
+            }
         }
     }
 
@@ -779,7 +782,7 @@
      * @see #sendRequestAsync
      */
     private Object sendRequest(int command, Object argument) {
-        return sendRequest(command, argument, null);
+        return sendRequest(command, argument, SubscriptionManager.INVALID_SUBSCRIPTION_ID);
     }
 
     /**
@@ -866,7 +869,8 @@
     }
 
     private Phone getPhoneFromRequest(MainThreadRequest request) {
-        return (request.subId == null) ? mPhone : getPhone(request.subId);
+        return (request.subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID)
+                ? mPhone : getPhone(request.subId);
     }
 
     // returns phone associated with the subId.
@@ -1507,7 +1511,8 @@
 
             try {
                 cells = (ArrayList<NeighboringCellInfo>) sendRequest(
-                        CMD_HANDLE_NEIGHBORING_CELL, null, null);
+                        CMD_HANDLE_NEIGHBORING_CELL, null,
+                        SubscriptionManager.INVALID_SUBSCRIPTION_ID);
             } catch (RuntimeException e) {
                 Log.e(LOG_TAG, "getNeighboringCellInfo " + e);
             }
diff --git a/src/com/android/services/telephony/ImsConference.java b/src/com/android/services/telephony/ImsConference.java
index 7556798..97cafec 100644
--- a/src/com/android/services/telephony/ImsConference.java
+++ b/src/com/android/services/telephony/ImsConference.java
@@ -19,6 +19,7 @@
 import android.content.Context;
 import android.graphics.drawable.Icon;
 import android.net.Uri;
+import android.os.Bundle;
 import android.telecom.Conference;
 import android.telecom.ConferenceParticipant;
 import android.telecom.Connection.VideoProvider;
@@ -182,6 +183,12 @@
             Log.v(this, "onStatusHintsChanged");
             updateStatusHints();
         }
+
+        @Override
+        public void onExtrasChanged(Connection c, Bundle extras) {
+            Log.v(this, "onExtrasChanged: c=" + c + " Extras=" + extras);
+            setExtras(extras);
+        }
     };
 
     /**
diff --git a/src/com/android/services/telephony/TtyManager.java b/src/com/android/services/telephony/TtyManager.java
index a3aeeb2..3389ce8 100644
--- a/src/com/android/services/telephony/TtyManager.java
+++ b/src/com/android/services/telephony/TtyManager.java
@@ -23,6 +23,7 @@
 import android.os.AsyncResult;
 import android.os.Handler;
 import android.os.Message;
+import android.provider.Settings;
 import android.telecom.TelecomManager;
 
 import com.android.internal.telephony.Phone;
@@ -83,6 +84,9 @@
             ttyMode = telecomManager.getCurrentTtyMode();
         }
         updateTtyMode(ttyMode);
+        //Get preferred TTY mode from data base as UI Tty mode is always user preferred Tty mode.
+        ttyMode = Settings.Secure.getInt(context.getContentResolver(),
+                Settings.Secure.PREFERRED_TTY_MODE, TelecomManager.TTY_MODE_OFF);
         updateUiTtyMode(ttyMode);
     }