diff options
Diffstat (limited to 'InCallUI')
7 files changed, 85 insertions, 2 deletions
diff --git a/InCallUI/src/com/android/incallui/Call.java b/InCallUI/src/com/android/incallui/Call.java index 7418218e7..e1ca45d50 100644 --- a/InCallUI/src/com/android/incallui/Call.java +++ b/InCallUI/src/com/android/incallui/Call.java @@ -175,6 +175,60 @@ public class Call { } } + /** + * Tracks any state variables that is useful for logging. There is some amount of overlap with + * existing call member variables, but this duplication helps to ensure that none of these + * logging variables will interface with/and affect call logic. + */ + public static class LogState { + public static final int LOOKUP_NOT_FOUND = 1; + public static final int LOOKUP_LOCAL_CONTACT = 2; + public static final int LOOKUP_LOCAL_CACHE = 3; + public static final int LOOKUP_REMOTE_CONTACT = 4; + public static final int LOOKUP_EMERGENCY = 5; + public static final int LOOKUP_VOICEMAIL = 6; + + public DisconnectCause disconnectCause; + public boolean isIncoming = false; + public int contactLookupResult = LOOKUP_NOT_FOUND; + // TODO: Populate this field by passing in extras from Dialer + public int callInitiationMethod; + public long duration = 0; + + @Override + public String toString() { + return String.format(Locale.US, "[" + + "%s, " // DisconnectCause toString already describes the object type + + "isIncoming: %s, " + + "contactLookup: %s, " + + "callInitiation: %s, " + + "duration: %s" + + "]", + disconnectCause, + isIncoming, + lookupToString(contactLookupResult), + callInitiationMethod, + duration); + } + + private static String lookupToString(int lookupType) { + switch (lookupType) { + case LOOKUP_LOCAL_CONTACT: + return "Local"; + case LOOKUP_LOCAL_CACHE: + return "Cache"; + case LOOKUP_REMOTE_CONTACT: + return "Remote"; + case LOOKUP_EMERGENCY: + return "Emergency"; + case LOOKUP_VOICEMAIL: + return "Voicemail"; + default: + return "Not found"; + } + } + } + private static final String ID_PREFIX = Call.class.getSimpleName() + "_"; private static int sIdCounter = 0; @@ -266,6 +320,8 @@ public class Call { private String mLastForwardedNumber; private String mCallSubject; + private LogState mLogState = new LogState(); + /** * Used only to create mock calls for testing */ @@ -444,6 +500,12 @@ public class Call { public void setState(int state) { mState = state; + if (mState == State.INCOMING) { + mLogState.isIncoming = true; + } else if (mState == State.DISCONNECTED) { + mLogState.duration = getConnectTimeMillis() == 0 ? + 0: System.currentTimeMillis() - getConnectTimeMillis(); + } } public int getNumberPresentation() { @@ -500,6 +562,7 @@ public class Call { public void setDisconnectCause(DisconnectCause disconnectCause) { mDisconnectCause = disconnectCause; + mLogState.disconnectCause = mDisconnectCause; } /** Returns the possible text message responses. */ @@ -659,6 +722,10 @@ public class Call { return mSessionModificationState; } + public LogState getLogState() { + return mLogState; + } + @Override public String toString() { if (mTelecomCall == null) { diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java index c608d3ae5..0460829af 100644 --- a/InCallUI/src/com/android/incallui/CallCardPresenter.java +++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java @@ -37,6 +37,7 @@ import android.telephony.PhoneNumberUtils; import android.text.TextUtils; import android.view.accessibility.AccessibilityManager; +import com.android.incallui.Call.LogState; import com.android.incallui.ContactInfoCache.ContactCacheEntry; import com.android.incallui.ContactInfoCache.ContactInfoCacheCallback; import com.android.incallui.InCallPresenter.InCallDetailsListener; @@ -517,6 +518,10 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> if (entry.name != null) { Log.d(TAG, "Contact found: " + entry); } + final Call call = CallList.getInstance().getCallById(callId); + if (call != null) { + call.getLogState().contactLookupResult = entry.contactLookupResult; + } if (entry.contactUri != null) { CallerInfoUtils.sendViewNotification(mContext, entry.contactUri); } diff --git a/InCallUI/src/com/android/incallui/CallList.java b/InCallUI/src/com/android/incallui/CallList.java index 8a58e5568..3b2f94dd2 100644 --- a/InCallUI/src/com/android/incallui/CallList.java +++ b/InCallUI/src/com/android/incallui/CallList.java @@ -24,6 +24,8 @@ import android.telecom.PhoneAccount; import com.android.contacts.common.testing.NeededForTesting; import com.android.dialer.database.FilteredNumberAsyncQueryHandler; +import com.android.dialer.logging.Logger; + import com.google.common.base.Preconditions; import com.google.common.collect.Maps; @@ -134,6 +136,7 @@ public class CallList { public void onCallRemoved(android.telecom.Call telecomCall) { if (mCallByTelecomCall.containsKey(telecomCall)) { Call call = mCallByTelecomCall.get(telecomCall); + Logger.logCall(call); if (updateCallInMap(call)) { Log.w(this, "Removing call not previously disconnected " + call.getId()); } diff --git a/InCallUI/src/com/android/incallui/CallerInfo.java b/InCallUI/src/com/android/incallui/CallerInfo.java index 88d1be1ab..c7f032345 100644 --- a/InCallUI/src/com/android/incallui/CallerInfo.java +++ b/InCallUI/src/com/android/incallui/CallerInfo.java @@ -40,8 +40,6 @@ import java.util.Locale; /** * Looks up caller information for the given phone number. - * - * {@hide} */ public class CallerInfo { private static final String TAG = "CallerInfo"; diff --git a/InCallUI/src/com/android/incallui/ContactInfoCache.java b/InCallUI/src/com/android/incallui/ContactInfoCache.java index 698442f61..7de16486e 100644 --- a/InCallUI/src/com/android/incallui/ContactInfoCache.java +++ b/InCallUI/src/com/android/incallui/ContactInfoCache.java @@ -35,6 +35,7 @@ import com.android.dialer.calllog.ContactInfo; import com.android.dialer.service.CachedNumberLookupService; import com.android.dialer.service.CachedNumberLookupService.CachedContactInfo; import com.android.dialer.util.MoreStrings; +import com.android.incallui.Call.LogState; import com.android.incallui.service.PhoneNumberService; import com.android.incalluibind.ObjectFactory; @@ -269,6 +270,7 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete ContactCacheEntry entry = new ContactCacheEntry(); entry.name = info.getDisplayName(); entry.number = info.getNumber(); + entry.contactLookupResult = info.getLookupSource(); final int type = info.getPhoneType(); final String label = info.getPhoneLabel(); if (type == Phone.TYPE_CUSTOM) { @@ -502,6 +504,10 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete cce.location = displayLocation; cce.label = label; cce.isSipCall = isSipCall; + + if (info.contactExists) { + cce.contactLookupResult = LogState.LOOKUP_LOCAL_CONTACT; + } } /** @@ -579,6 +585,7 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete public Uri displayPhotoUri; public Uri lookupUri; // Sent to NotificationMananger public String lookupKey; + public int contactLookupResult = LogState.LOOKUP_NOT_FOUND; @Override public String toString() { @@ -591,6 +598,7 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete .add("isSipCall", isSipCall) .add("contactUri", contactUri) .add("displayPhotoUri", displayPhotoUri) + .add("contactLookupResult", contactLookupResult) .toString(); } } diff --git a/InCallUI/src/com/android/incallui/StatusBarNotifier.java b/InCallUI/src/com/android/incallui/StatusBarNotifier.java index e583434da..35a22c9d8 100644 --- a/InCallUI/src/com/android/incallui/StatusBarNotifier.java +++ b/InCallUI/src/com/android/incallui/StatusBarNotifier.java @@ -176,6 +176,7 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener, public void onContactInfoComplete(String callId, ContactCacheEntry entry) { Call call = CallList.getInstance().getCallById(callId); if (call != null) { + call.getLogState().contactLookupResult = entry.contactLookupResult; buildAndSendNotification(call, entry); } } diff --git a/InCallUI/src/com/android/incallui/service/PhoneNumberService.java b/InCallUI/src/com/android/incallui/service/PhoneNumberService.java index 3ce84b9a2..cddc478cf 100644 --- a/InCallUI/src/com/android/incallui/service/PhoneNumberService.java +++ b/InCallUI/src/com/android/incallui/service/PhoneNumberService.java @@ -61,5 +61,6 @@ public interface PhoneNumberService { public String getNormalizedNumber(); public String getImageUrl(); public boolean isBusiness(); + public int getLookupSource(); } } |