diff options
author | Yorke Lee <yorkelee@google.com> | 2014-06-27 16:20:46 -0700 |
---|---|---|
committer | Yorke Lee <yorkelee@google.com> | 2014-06-30 09:37:08 -0700 |
commit | 45b79134b1b857b33addc4bcd2a7fd41e4295098 (patch) | |
tree | f3a31e363cdc1dcbac3d39efb60534d8bfa3e979 /src | |
parent | 6fb54653fe0458acc6768a24a2f1280fbeddd430 (diff) | |
download | android_packages_apps_PhoneCommon-45b79134b1b857b33addc4bcd2a7fd41e4295098.tar.gz android_packages_apps_PhoneCommon-45b79134b1b857b33addc4bcd2a7fd41e4295098.tar.bz2 android_packages_apps_PhoneCommon-45b79134b1b857b33addc4bcd2a7fd41e4295098.zip |
Remove use of CallerInfo in CallLogAsync(1/2)
Remove unneeded AddCall related methods in CallLogAsync
Bug: 6948882
Change-Id: Ia3f7688c99bb02cf2eca2f828eff26ca84ff8e79
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/phone/common/CallLogAsync.java | 125 |
1 files changed, 2 insertions, 123 deletions
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 @@ import com.android.internal.telephony.CallerInfo; * * 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 @@ public class CallLogAsync { 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 class CallLogAsync { 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 @@ public class CallLogAsync { } /** - * 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> { |