Merge "Add OWNERS in packages/services/Telecomm"
diff --git a/src/com/android/server/telecom/Call.java b/src/com/android/server/telecom/Call.java
index 1cc4887..ec330ec 100644
--- a/src/com/android/server/telecom/Call.java
+++ b/src/com/android/server/telecom/Call.java
@@ -570,6 +570,13 @@
     }
 
     public void destroy() {
+        // We should not keep these bitmaps around because the Call objects may be held for logging
+        // purposes.
+        // TODO: Make a container object that only stores the information we care about for Logging.
+        if (mCallerInfo != null) {
+            mCallerInfo.cachedPhotoIcon = null;
+            mCallerInfo.cachedPhoto = null;
+        }
         Log.addEvent(this, LogUtils.Events.DESTROYED);
     }
 
diff --git a/src/com/android/server/telecom/RespondViaSmsManager.java b/src/com/android/server/telecom/RespondViaSmsManager.java
index a42513d..964f6ad 100644
--- a/src/com/android/server/telecom/RespondViaSmsManager.java
+++ b/src/com/android/server/telecom/RespondViaSmsManager.java
@@ -18,15 +18,12 @@
 
 // TODO: Needed for move to system service: import com.android.internal.R;
 import com.android.internal.os.SomeArgs;
-import com.android.internal.telephony.PhoneConstants;
 import com.android.internal.telephony.SmsApplication;
 
 import android.content.ComponentName;
 import android.content.Context;
-import android.content.Intent;
 import android.content.SharedPreferences;
 import android.content.res.Resources;
-import android.net.Uri;
 import android.os.Handler;
 import android.os.Looper;
 import android.os.Message;
@@ -34,8 +31,8 @@
 import android.telecom.Log;
 import android.telecom.Response;
 import android.telephony.PhoneNumberUtils;
+import android.telephony.SmsManager;
 import android.telephony.SubscriptionManager;
-import android.telephony.TelephonyManager;
 import android.text.Spannable;
 import android.text.SpannableString;
 import android.text.TextUtils;
@@ -178,26 +175,28 @@
      */
     private void rejectCallWithMessage(Context context, String phoneNumber, String textMessage,
             int subId, String contactName) {
-        if (!TextUtils.isEmpty(textMessage)) {
-            final ComponentName component =
-                    SmsApplication.getDefaultRespondViaMessageApplication(context,
-                            true /*updateIfNeeded*/);
-            if (component != null) {
-                // Build and send the intent
-                final Uri uri = Uri.fromParts(Constants.SCHEME_SMSTO, phoneNumber, null);
-                final Intent intent = new Intent(TelephonyManager.ACTION_RESPOND_VIA_MESSAGE, uri);
-                intent.putExtra(Intent.EXTRA_TEXT, textMessage);
-                if (SubscriptionManager.isValidSubscriptionId(subId)) {
-                    intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
-                }
+        if (TextUtils.isEmpty(textMessage)) {
+            Log.w(RespondViaSmsManager.this, "Couldn't send SMS message: empty text message. ");
+            return;
+        }
+        if (!SubscriptionManager.isValidSubscriptionId(subId)) {
+            Log.w(RespondViaSmsManager.this, "Couldn't send SMS message: Invalid SubId: " +
+                    subId);
+            return;
+        }
 
-                SomeArgs args = SomeArgs.obtain();
-                args.arg1 = !TextUtils.isEmpty(contactName) ? contactName : phoneNumber;
-                args.arg2 = context;
-                mHandler.obtainMessage(MSG_SHOW_SENT_TOAST, args).sendToTarget();
-                intent.setComponent(component);
-                context.startService(intent);
-            }
+        SmsManager smsManager = SmsManager.getSmsManagerForSubscriptionId(subId);
+        try {
+            smsManager.sendTextMessage(phoneNumber, null, textMessage, null /*sentIntent*/,
+                    null /*deliveryIntent*/);
+
+            SomeArgs args = SomeArgs.obtain();
+            args.arg1 = !TextUtils.isEmpty(contactName) ? contactName : phoneNumber;
+            args.arg2 = context;
+            mHandler.obtainMessage(MSG_SHOW_SENT_TOAST, args).sendToTarget();
+        } catch (IllegalArgumentException e) {
+            Log.w(RespondViaSmsManager.this, "Couldn't send SMS message: " +
+                    e.getMessage());
         }
     }
 }
diff --git a/src/com/android/server/telecom/TelecomServiceImpl.java b/src/com/android/server/telecom/TelecomServiceImpl.java
index b333213..72cf998 100644
--- a/src/com/android/server/telecom/TelecomServiceImpl.java
+++ b/src/com/android/server/telecom/TelecomServiceImpl.java
@@ -79,6 +79,7 @@
         }
     }
 
+    private static final String TIME_LINE_ARG = "timeline";
     private static final int DEFAULT_VIDEO_STATE = -1;
 
     private final ITelecomService.Stub mBinderImpl = new ITelecomService.Stub() {
@@ -1224,6 +1225,7 @@
                 Analytics.dumpToEncodedProto(writer, args);
                 return;
             }
+            boolean isTimeLineView = (args.length > 0 && TIME_LINE_ARG.equalsIgnoreCase(args[0]));
 
             final IndentingPrintWriter pw = new IndentingPrintWriter(writer, "  ");
             if (mCallsManager != null) {
@@ -1242,8 +1244,11 @@
                 Analytics.dump(pw);
                 pw.decreaseIndent();
             }
-
-            Log.dumpEvents(pw);
+            if (isTimeLineView) {
+                Log.dumpEventsTimeline(pw);
+            } else {
+                Log.dumpEvents(pw);
+            }
         }
 
         /**