Remove use of CallerInfo in CallLogAsync(1/2)

Remove unneeded AddCall related methods in CallLogAsync

Bug: 6948882

Change-Id: Ia3f7688c99bb02cf2eca2f828eff26ca84ff8e79
diff --git a/src/com/android/phone/common/CallLogAsync.java b/src/com/android/phone/common/CallLogAsync.java
index 2e00195..885086f 100644
--- a/src/com/android/phone/common/CallLogAsync.java
+++ b/src/com/android/phone/common/CallLogAsync.java
@@ -16,18 +16,13 @@
 
 package com.android.phone.common;
 import android.content.Context;
-import android.net.Uri;
 import android.os.AsyncTask;
 import android.os.Looper;
 import android.provider.CallLog.Calls;
-import android.telecomm.Subscription;
-import android.util.Log;
-import com.android.internal.telephony.CallerInfo;
 
 /**
- * Class to access the call logs database asynchronously since
- * database ops can take a long time depending on the system's load.
- * It uses AsyncTask which has its own thread pool.
+ * Class to access the call log asynchronously to avoid carrying out database operations on the
+ * UI thread, using an {@link AsyncTask}.
  *
  * <pre class="prettyprint">
  * Typical usage:
@@ -38,11 +33,6 @@
  *
  *  CallLogAsync log = new CallLogAsync();
  *
- *  CallLogAsync.AddCallArgs addCallArgs = new CallLogAsync.AddCallArgs(
- *      this, ci, number, presentation, type, timestamp, duration);
- *
- *  log.addCall(addCallArgs);
- *
  *  CallLogAsync.GetLastOutgoingCallArgs lastCallArgs = new CallLogAsync.GetLastOutgoingCallArgs(
  *      this, new CallLogAsync.OnLastOutgoingCallComplete() {
  *               public void lastOutgoingCall(String number) { mLastNumber = number; }
@@ -56,65 +46,6 @@
     private static final String TAG = "CallLogAsync";
 
     /**
-     * Parameter object to hold the args to add a call in the call log DB.
-     */
-    public static class AddCallArgs {
-        /**
-         * @param ci               CallerInfo.
-         * @param number           To be logged.
-         * @param presentation     Of the number.
-         * @param callType         The type of call (e.g INCOMING_TYPE). @see
-         *                         android.provider.CallLog for the list of values.
-         * @param timestamp        Of the call (millisecond since epoch).
-         * @param durationInMillis Of the call (millisecond).
-         */
-        public AddCallArgs(Context context,
-                           CallerInfo ci,
-                           String number,
-                           int presentation,
-                           int callType,
-                           Subscription subscription,
-                           long timestamp,
-                           long durationInMillis) {
-            // Note that the context is passed each time. We could
-            // have stored it in a member but we've run into a bunch
-            // of memory leaks in the past that resulted from storing
-            // references to contexts in places that were long lived
-            // when the contexts were expected to be short lived. For
-            // example, if you initialize this class with an Activity
-            // instead of an Application the Activity can't be GCed
-            // until this class can, and Activities tend to hold
-            // references to large amounts of RAM for things like the
-            // bitmaps in their views.
-            //
-            // Having hit more than a few of those bugs in the past
-            // we've grown cautious of storing references to Contexts
-            // when it's not very clear that the thing holding the
-            // references is tightly tied to the Context, for example
-            // Views the Activity is displaying.
-
-            this.context = context;
-            this.ci = ci;
-            this.number = number;
-            this.presentation = presentation;
-            this.callType = callType;
-            this.subscription = subscription;
-            this.timestamp = timestamp;
-            this.durationInSec = (int)(durationInMillis / 1000);
-        }
-        // Since the members are accessed directly, we don't use the
-        // mXxxx notation.
-        public final Context context;
-        public final CallerInfo ci;
-        public final String number;
-        public final int presentation;
-        public final int callType;
-        public final Subscription subscription;
-        public final long timestamp;
-        public final int durationInSec;
-    }
-
-    /**
      * Parameter object to hold the args to get the last outgoing call
      * from the call log DB.
      */
@@ -128,14 +59,6 @@
         public final OnLastOutgoingCallComplete callback;
     }
 
-    /**
-     * Non blocking version of CallLog.addCall(...)
-     */
-    public AsyncTask addCall(AddCallArgs args) {
-        assertUiThread();
-        return new AddCallTask().execute(args);
-    }
-
     /** Interface to retrieve the last dialed number asynchronously. */
     public interface OnLastOutgoingCallComplete {
         /** @param number The last dialed number or an empty string if
@@ -152,50 +75,6 @@
     }
 
     /**
-     * AsyncTask to save calls in the DB.
-     */
-    private class AddCallTask extends AsyncTask<AddCallArgs, Void, Uri[]> {
-        @Override
-        protected Uri[] doInBackground(AddCallArgs... callList) {
-            int count = callList.length;
-            Uri[] result = new Uri[count];
-            for (int i = 0; i < count; i++) {
-                AddCallArgs c = callList[i];
-
-                try {
-                    // May block.
-                    result[i] = Calls.addCall(
-                            c.ci, c.context, c.number, c.presentation,
-                            c.callType, c.subscription, c.timestamp, c.durationInSec);
-                } catch (Exception e) {
-                    // This must be very rare but may happen in legitimate cases.
-                    // e.g. If the phone is encrypted and thus write request fails, it may
-                    // cause some kind of Exception (right now it is IllegalArgumentException, but
-                    // might change).
-                    //
-                    // We don't want to crash the whole process just because of that.
-                    // Let's just ignore it and leave logs instead.
-                    Log.e(TAG, "Exception raised during adding CallLog entry: " + e);
-                    result[i] = null;
-                }
-            }
-            return result;
-        }
-
-        // Perform a simple sanity check to make sure the call was
-        // written in the database. Typically there is only one result
-        // per call so it is easy to identify which one failed.
-        @Override
-        protected void onPostExecute(Uri[] result) {
-            for (Uri uri : result) {
-                if (uri == null) {
-                    Log.e(TAG, "Failed to write call to the log.");
-                }
-            }
-        }
-    }
-
-    /**
      * AsyncTask to get the last outgoing call from the DB.
      */
     private class GetLastOutgoingCallTask extends AsyncTask<GetLastOutgoingCallArgs, Void, String> {