Add Properties to Call.Details.

Moved some capabilities to properties which seemed appropriate.

Bug: 20160395
Change-Id: Iacef4365822e5c3e50f0c41a501bf295c22055f1
diff --git a/telecomm/java/android/telecom/Call.java b/telecomm/java/android/telecom/Call.java
index 9273939..fee6495 100644
--- a/telecomm/java/android/telecom/Call.java
+++ b/telecomm/java/android/telecom/Call.java
@@ -132,7 +132,7 @@
         /**
          * @hide
          */
-        public static final int CAPABILITY_UNUSED = 0x00000010;
+        public static final int CAPABILITY_UNUSED_1 = 0x00000010;
 
         /** Call supports responding via text option. */
         public static final int CAPABILITY_RESPOND_VIA_TEXT = 0x00000020;
@@ -189,27 +189,6 @@
         public static final int CAPABILITY_DISCONNECT_FROM_CONFERENCE = 0x00002000;
 
         /**
-         * Whether the call is a generic conference, where we do not know the precise state of
-         * participants in the conference (eg. on CDMA).
-         */
-        public static final int CAPABILITY_GENERIC_CONFERENCE = 0x00004000;
-
-        /**
-         * Call is using high definition audio.
-         */
-        public static final int CAPABILITY_HIGH_DEF_AUDIO = 0x00008000;
-
-        /**
-         * Call is using WIFI.
-         */
-        public static final int CAPABILITY_WIFI = 0x00010000;
-
-        /**
-         * Indicates that the current device callback number should be shown.
-         */
-        public static final int CAPABILITY_SHOW_CALLBACK_NUMBER = 0x00020000;
-
-        /**
          * Speed up audio setup for MT call.
          * @hide
          */
@@ -228,7 +207,37 @@
         public static final int CAPABILITY_CAN_PAUSE_VIDEO = 0x00100000;
 
         //******************************************************************************************
-        // Next CAPABILITY value: 0x00200000
+        // Next CAPABILITY value: 0x00004000
+        //******************************************************************************************
+
+        /**
+         * Whether the call is currently a conference.
+         */
+        public static final int PROPERTY_CONFERENCE = 0x00000001;
+
+        /**
+         * Whether the call is a generic conference, where we do not know the precise state of
+         * participants in the conference (eg. on CDMA).
+         */
+        public static final int PROPERTY_GENERIC_CONFERENCE = 0x00000002;
+
+        /**
+         * Whether the call is made while the device is in emergency callback mode.
+         */
+        public static final int PROPERTY_EMERGENCY_CALLBACK_MODE = 0x00000004;
+
+        /**
+         * Connection is using WIFI.
+         */
+        public static final int PROPERTY_WIFI = 0x00000008;
+
+        /**
+         * Call is using high definition audio.
+         */
+        public static final int PROPERTY_HIGH_DEF_AUDIO = 0x00000010;
+
+        //******************************************************************************************
+        // Next PROPERTY value: 0x00000020
         //******************************************************************************************
 
         private final Uri mHandle;
@@ -314,18 +323,6 @@
             if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL)) {
                 builder.append(" CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL");
             }
-            if (can(capabilities, CAPABILITY_HIGH_DEF_AUDIO)) {
-                builder.append(" CAPABILITY_HIGH_DEF_AUDIO");
-            }
-            if (can(capabilities, CAPABILITY_WIFI)) {
-                builder.append(" CAPABILITY_WIFI");
-            }
-            if (can(capabilities, CAPABILITY_GENERIC_CONFERENCE)) {
-                builder.append(" CAPABILITY_GENERIC_CONFERENCE");
-            }
-            if (can(capabilities, CAPABILITY_SHOW_CALLBACK_NUMBER)) {
-                builder.append(" CAPABILITY_SHOW_CALLBACK_NUMBER");
-            }
             if (can(capabilities, CAPABILITY_SPEED_UP_MT_AUDIO)) {
                 builder.append(" CAPABILITY_SPEED_UP_MT_AUDIO");
             }
@@ -340,6 +337,55 @@
         }
 
         /**
+         * Whether the supplied properties includes the specified property.
+         *
+         * @param properties A bit field of properties.
+         * @param property The property to check properties for.
+         * @return Whether the specified property is supported.
+         */
+        public static boolean hasProperty(int properties, int property) {
+            return (properties & property) != 0;
+        }
+
+        /**
+         * Whether the properties of this {@code Details} includes the specified property.
+         *
+         * @param property The property to check properties for.
+         * @return Whether the specified property is supported.
+         */
+        public boolean hasProperty(int property) {
+            return hasProperty(mCallProperties, property);
+        }
+
+        /**
+         * Render a set of property bits ({@code PROPERTY_*}) as a human readable string.
+         *
+         * @param properties A property bit field.
+         * @return A human readable string representation.
+         */
+        public static String propertiesToString(int properties) {
+            StringBuilder builder = new StringBuilder();
+            builder.append("[Properties:");
+            if (hasProperty(properties, PROPERTY_CONFERENCE)) {
+                builder.append(" PROPERTY_CONFERENCE");
+            }
+            if (hasProperty(properties, PROPERTY_GENERIC_CONFERENCE)) {
+                builder.append(" PROPERTY_GENERIC_CONFERENCE");
+            }
+            if (hasProperty(properties, PROPERTY_WIFI)) {
+                builder.append(" PROPERTY_WIFI");
+            }
+            if (hasProperty(properties, PROPERTY_HIGH_DEF_AUDIO)) {
+                builder.append(" PROPERTY_HIGH_DEF_AUDIO");
+            }
+            if (hasProperty(properties, PROPERTY_EMERGENCY_CALLBACK_MODE)) {
+                builder.append(" EMERGENCY_CALLBACK_MODE");
+            }
+            builder.append("]");
+            return builder.toString();
+        }
+
+        /**
          * @return The handle (e.g., phone number) to which the {@code Call} is currently
          * connected.
          */
@@ -387,8 +433,8 @@
         }
 
         /**
-         * @return A bitmask of the properties of the {@code Call}, as defined in
-         *         {@link CallProperties}.
+         * @return A bitmask of the properties of the {@code Call}, as defined by the various
+         *         {@code PROPERTY_*} constants in this class.
          */
         public int getCallProperties() {
             return mCallProperties;