API support for reporting of changes to call features.
(eg VoLTE, VoWIFI, etc)

Bug: 15987281
Change-Id: I5a18046ca0e2ff78ee96af610b5a3b88d93a52ad
diff --git a/src/com/android/telecomm/Call.java b/src/com/android/telecomm/Call.java
index 4265c65..ddd4b1d 100644
--- a/src/com/android/telecomm/Call.java
+++ b/src/com/android/telecomm/Call.java
@@ -74,6 +74,7 @@
         void onChildrenChanged(Call call);
         void onCannedSmsResponsesLoaded(Call call);
         void onCallVideoProviderChanged(Call call);
+        void onFeaturesChanged(Call call);
     }
 
     private static final OnQueryCompleteListener sCallerInfoQueryListener =
@@ -208,6 +209,9 @@
 
     private ICallVideoProvider mCallVideoProvider;
 
+    /** Features associated with the call which the InCall UI may wish to show icons for. */
+    private int mFeatures;
+
     /**
      * Creates an empty call object.
      *
@@ -1068,4 +1072,26 @@
     public ICallVideoProvider getCallVideoProvider() {
         return mCallVideoProvider;
     }
+
+    /**
+     * Returns the features of this call.
+     *
+     * @return The features of this call.
+     */
+    public int getFeatures() {
+        return mFeatures;
+    }
+
+    /**
+     * Set the features associated with the call and notify any listeners of the change.
+     *
+     * @param features The features.
+     */
+    public void setFeatures(int features) {
+        Log.d(this, "setFeatures: %d", features);
+        mFeatures = features;
+        for (Listener l : mListeners) {
+            l.onFeaturesChanged(Call.this);
+        }
+    }
 }
diff --git a/src/com/android/telecomm/CallServiceWrapper.java b/src/com/android/telecomm/CallServiceWrapper.java
index 5970846..5e0d9a8 100644
--- a/src/com/android/telecomm/CallServiceWrapper.java
+++ b/src/com/android/telecomm/CallServiceWrapper.java
@@ -77,6 +77,7 @@
         private static final int MSG_HANDOFF_CALL = 15;
         private static final int MSG_QUERY_REMOTE_CALL_SERVICES = 16;
         private static final int MSG_SET_CALL_VIDEO_PROVIDER = 17;
+        private static final int MSG_SET_FEATURES = 18;
 
         private final Handler mHandler = new Handler() {
             @Override
@@ -296,6 +297,19 @@
                         }
                         break;
                     }
+                    case MSG_SET_FEATURES: {
+                        SomeArgs args = (SomeArgs) msg.obj;
+                        try {
+                            call = mCallIdMapper.getCall(args.arg1);
+                            int features = (int) args.arg2;
+                            if (call != null) {
+                                call.setFeatures(features);
+                            }
+                        } finally {
+                            args.recycle();
+                        }
+                        break;
+                    }
                 }
             }
         };
@@ -465,6 +479,16 @@
             logIncoming("queryRemoteCSs");
             mHandler.obtainMessage(MSG_QUERY_REMOTE_CALL_SERVICES, callback).sendToTarget();
         }
+
+        @Override
+        public void setFeatures(String callId, int features) {
+            logIncoming("setFeatures %s %d", callId, features);
+            mCallIdMapper.checkValidCallId(callId);
+            SomeArgs args = SomeArgs.obtain();
+            args.arg1 = callId;
+            args.arg2 = features;
+            mHandler.obtainMessage(MSG_SET_FEATURES, args).sendToTarget();
+        }
     }
 
     private final Adapter mAdapter = new Adapter();
diff --git a/src/com/android/telecomm/CallsManager.java b/src/com/android/telecomm/CallsManager.java
index 26f627f..85593ef 100644
--- a/src/com/android/telecomm/CallsManager.java
+++ b/src/com/android/telecomm/CallsManager.java
@@ -66,6 +66,7 @@
         void onIsConferencedChanged(Call call);
         void onCannedSmsResponsesLoaded(Call call);
         void onCallVideoProviderChanged(Call call);
+        void onFeaturesChanged(Call call);
     }
 
     private static final CallsManager INSTANCE = new CallsManager();
@@ -233,6 +234,14 @@
         }
     }
 
+    @Override
+    public void onFeaturesChanged(Call call) {
+        Log.v(this, "onFeaturesChanged: %d", call.getFeatures());
+        for (CallsManagerListener listener : mListeners) {
+            listener.onFeaturesChanged(call);
+        }
+    }
+
     ImmutableCollection<Call> getCalls() {
         return ImmutableList.copyOf(mCalls);
     }
diff --git a/src/com/android/telecomm/CallsManagerListenerBase.java b/src/com/android/telecomm/CallsManagerListenerBase.java
index 26d122b..8b03eee 100644
--- a/src/com/android/telecomm/CallsManagerListenerBase.java
+++ b/src/com/android/telecomm/CallsManagerListenerBase.java
@@ -89,6 +89,9 @@
 
     @Override
     public void onCallVideoProviderChanged(Call call) {
+    }
 
+    @Override
+    public void onFeaturesChanged(Call call) {
     }
 }
diff --git a/src/com/android/telecomm/InCallController.java b/src/com/android/telecomm/InCallController.java
index 871bf75..90d24fd 100644
--- a/src/com/android/telecomm/InCallController.java
+++ b/src/com/android/telecomm/InCallController.java
@@ -36,7 +36,6 @@
 import com.google.common.collect.ImmutableCollection;
 
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 
 /**
@@ -167,6 +166,12 @@
         updateCall(call);
     }
 
+    @Override
+    public void onFeaturesChanged(Call call) {
+        Log.v(this,"onFeaturesChanged: %d", call.getFeatures());
+        updateCall(call);
+    }
+
     void bringToForeground(boolean showDialpad) {
         if (mInCallService != null) {
             try {
@@ -317,7 +322,7 @@
                 call.getCannedSmsResponses(), capabilities, connectTimeMillis, call.getHandle(),
                 call.getGatewayInfo(), call.getSubscription(), descriptor,
                 call.getHandoffCallServiceDescriptor(), call.getCallVideoProvider(),
-                parentCallId, childCallIds);
+                parentCallId, childCallIds, call.getFeatures());
     }
 
 }