Adding toString methods to IMS classes to aid logging.
Tyler Gunn [Tue, 18 Nov 2014 16:40:49 +0000 (08:40 -0800)]
Bug: 18200934

Change-Id: Iad06de4e5ba1e343749c5b53efac84cf7c20327a

src/java/com/android/ims/ImsCall.java
src/java/com/android/ims/internal/ImsCallSession.java

index 520f298..342f527 100644 (file)
@@ -2636,4 +2636,54 @@ public class ImsCall implements ICall {
             }
         }
     }
+
+    /**
+     * Provides a human-readable string representation of an update request.
+     *
+     * @param updateRequest The update request.
+     * @return The string representation.
+     */
+    private String updateRequestToString(int updateRequest) {
+        switch (updateRequest) {
+            case UPDATE_NONE:
+                return "NONE";
+            case UPDATE_HOLD:
+                return "HOLD";
+            case UPDATE_HOLD_MERGE:
+                return "HOLD_MERGE";
+            case UPDATE_RESUME:
+                return "RESUME";
+            case UPDATE_MERGE:
+                return "MERGE";
+            case UPDATE_EXTEND_TO_CONFERENCE:
+                return "EXTEND_TO_CONFERENCE";
+            case UPDATE_UNSPECIFIED:
+                return "UNSPECIFIED";
+            default:
+                return "UNKNOWN";
+        }
+    }
+
+    /**
+     * Provides a string representation of the {@link ImsCall}.  Primarily intended for use in log
+     * statements.
+     *
+     * @return String representation of call.
+     */
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append("[ImsCall objId:");
+        sb.append(System.identityHashCode(this));
+        sb.append(" multiParty:");
+        sb.append(isMultiparty()?"Y":"N");
+        sb.append(" session:");
+        sb.append(mSession);
+        sb.append(" updateRequest:");
+        sb.append(updateRequestToString(mUpdateRequest));
+        sb.append(" transientSession:");
+        sb.append(mTransientConferenceSession);
+        sb.append("]");
+        return sb.toString();
+    }
 }
index aa2c0c6..eeca7a8 100644 (file)
@@ -1130,4 +1130,23 @@ public class ImsCallSession {
             }
         }
     }
+
+    /**
+     * Provides a string representation of the {@link ImsCallSession}.  Primarily intended for
+     * use in log statements.
+     *
+     * @return String representation of session.
+     */
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append("[ImsCallSession objId:");
+        sb.append(System.identityHashCode(this));
+        sb.append(" state:");
+        sb.append(State.toString(getState()));
+        sb.append(" callId:");
+        sb.append(getCallId());
+        sb.append("]");
+        return sb.toString();
+    }
 }