Add support for post-dial digits to logs.

Bug: 24955678
Change-Id: I9bc7ecc574dd50b2f389a147245aab7a65ae1e2c
diff --git a/src/com/android/server/telecom/Call.java b/src/com/android/server/telecom/Call.java
index 28dd676..eed9228 100644
--- a/src/com/android/server/telecom/Call.java
+++ b/src/com/android/server/telecom/Call.java
@@ -29,7 +29,6 @@
 import android.telecom.DisconnectCause;
 import android.telecom.Connection;
 import android.telecom.GatewayInfo;
-import android.telecom.InCallService.VideoCall;
 import android.telecom.ParcelableConnection;
 import android.telecom.PhoneAccount;
 import android.telecom.PhoneAccountHandle;
@@ -201,6 +200,11 @@
     private boolean mIsUnknown;
 
     /**
+     * The post-dial digits that were dialed after the network portion of the number
+     */
+    private final String mPostDialDigits;
+
+    /**
      * The time this call was created. Beyond logging and such, may also be used for bookkeeping
      * and specifically for marking certain call attempts as failed attempts.
      */
@@ -371,6 +375,7 @@
         mContactsAsyncHelper = contactsAsyncHelper;
         mCallerInfoAsyncQueryFactory = callerInfoAsyncQueryFactory;
         setHandle(handle);
+        mPostDialDigits = PhoneNumberUtils.extractPostDialPortion(handle.getSchemeSpecificPart());
         mGatewayInfo = gatewayInfo;
         setConnectionManagerPhoneAccount(connectionManagerPhoneAccountHandle);
         setTargetPhoneAccount(targetPhoneAccountHandle);
@@ -623,6 +628,10 @@
         return mHandle;
     }
 
+    public String getPostDialDigits() {
+        return mPostDialDigits;
+    }
+
     int getHandlePresentation() {
         return mHandlePresentation;
     }
diff --git a/src/com/android/server/telecom/CallLogManager.java b/src/com/android/server/telecom/CallLogManager.java
index 1fe491e..77c82b7 100755
--- a/src/com/android/server/telecom/CallLogManager.java
+++ b/src/com/android/server/telecom/CallLogManager.java
@@ -51,12 +51,13 @@
          * @param durationInMillis Duration of the call (milliseconds).
          * @param dataUsage Data usage in bytes, or null if not applicable.
          */
-        public AddCallArgs(Context context, CallerInfo callerInfo, String number,
+        public AddCallArgs(Context context, CallerInfo callerInfo, String number, String postDialDigits,
                 int presentation, int callType, int features, PhoneAccountHandle accountHandle,
                 long creationDate, long durationInMillis, Long dataUsage) {
             this.context = context;
             this.callerInfo = callerInfo;
             this.number = number;
+            this.postDialDigits = postDialDigits;
             this.presentation = presentation;
             this.callType = callType;
             this.features = features;
@@ -70,6 +71,7 @@
         public final Context context;
         public final CallerInfo callerInfo;
         public final String number;
+        public final String postDialDigits;
         public final int presentation;
         public final int callType;
         public final int features;
@@ -147,9 +149,9 @@
 
         // TODO(vt): Once data usage is available, wire it up here.
         int callFeatures = getCallFeatures(call.getVideoStateHistory());
-        logCall(call.getCallerInfo(), logNumber, call.getHandlePresentation(),
-                callLogType, callFeatures, accountHandle, creationTime, age, null,
-                call.isEmergencyCall());
+        logCall(call.getCallerInfo(), logNumber, call.getPostDialDigits(),
+                call.getHandlePresentation(), callLogType, callFeatures, accountHandle,
+                creationTime, age, null, call.isEmergencyCall());
     }
 
     /**
@@ -157,6 +159,8 @@
      *
      * @param callerInfo Caller details.
      * @param number The number the call was made to or from.
+     * @param postDialDigits The post-dial digits that were dialed after the number,
+     *                       if it was an outgoing call. Otherwise ''.
      * @param presentation
      * @param callType The type of call.
      * @param features The features of the call.
@@ -168,6 +172,7 @@
     private void logCall(
             CallerInfo callerInfo,
             String number,
+            String postDialDigits,
             int presentation,
             int callType,
             int features,
@@ -192,8 +197,8 @@
             Log.d(TAG, "Logging Calllog entry: " + callerInfo + ", "
                     + Log.pii(number) + "," + presentation + ", " + callType
                     + ", " + start + ", " + duration);
-            AddCallArgs args = new AddCallArgs(mContext, callerInfo, number, presentation,
-                    callType, features, accountHandle, start, duration, dataUsage);
+            AddCallArgs args = new AddCallArgs(mContext, callerInfo, number, postDialDigits,
+                    presentation, callType, features, accountHandle, start, duration, dataUsage);
             logCallAsync(args);
         } else {
           Log.d(TAG, "Not adding emergency call to call log.");
@@ -260,9 +265,9 @@
 
                 try {
                     // May block.
-                    result[i] = Calls.addCall(c.callerInfo, c.context, c.number, c.presentation,
-                            c.callType, c.features, c.accountHandle, c.timestamp, c.durationInSec,
-                            c.dataUsage, true /* addForAllUsers */);
+                    result[i] = Calls.addCall(c.callerInfo, c.context, c.number, c.postDialDigits,
+                            c.presentation, c.callType, c.features, c.accountHandle, c.timestamp,
+                            c.durationInSec, c.dataUsage, true /* addForAllUsers */);
                 } catch (Exception e) {
                     // This is very rare but may happen in legitimate cases.
                     // E.g. If the phone is encrypted and thus write request fails, it may cause