blob: 912af73eff0df6a04bafdd9f64786ad70fef7e7a [file] [log] [blame]
Santos Cordon7d4ddf62013-07-10 11:58:08 -07001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.phone;
18
19import android.animation.LayoutTransition;
20import android.content.ContentUris;
21import android.content.Context;
22import android.content.res.Resources;
23import android.graphics.Bitmap;
24import android.graphics.drawable.BitmapDrawable;
25import android.graphics.drawable.Drawable;
26import android.net.Uri;
27import android.os.Handler;
28import android.os.Message;
29import android.provider.ContactsContract.Contacts;
30import android.telephony.PhoneNumberUtils;
31import android.text.TextUtils;
32import android.text.format.DateUtils;
33import android.util.AttributeSet;
34import android.util.Log;
35import android.view.Gravity;
36import android.view.View;
37import android.view.ViewGroup;
38import android.view.ViewStub;
39import android.view.accessibility.AccessibilityEvent;
40import android.widget.ImageView;
41import android.widget.LinearLayout;
42import android.widget.TextView;
43
44import com.android.internal.telephony.Call;
45import com.android.internal.telephony.CallManager;
46import com.android.internal.telephony.CallerInfo;
47import com.android.internal.telephony.CallerInfoAsyncQuery;
48import com.android.internal.telephony.Connection;
49import com.android.internal.telephony.Phone;
50import com.android.internal.telephony.PhoneConstants;
51
52import java.util.List;
53
54
55/**
56 * "Call card" UI element: the in-call screen contains a tiled layout of call
57 * cards, each representing the state of a current "call" (ie. an active call,
58 * a call on hold, or an incoming call.)
59 */
60public class CallCard extends LinearLayout
61 implements CallTime.OnTickListener, CallerInfoAsyncQuery.OnQueryCompleteListener,
62 ContactsAsyncHelper.OnImageLoadCompleteListener {
63 private static final String LOG_TAG = "CallCard";
64 private static final boolean DBG = (PhoneGlobals.DBG_LEVEL >= 2);
65
66 private static final int TOKEN_UPDATE_PHOTO_FOR_CALL_STATE = 0;
67 private static final int TOKEN_DO_NOTHING = 1;
68
69 /**
70 * Used with {@link ContactsAsyncHelper#startObtainPhotoAsync(int, Context, Uri,
71 * ContactsAsyncHelper.OnImageLoadCompleteListener, Object)}
72 */
73 private static class AsyncLoadCookie {
74 public final ImageView imageView;
75 public final CallerInfo callerInfo;
76 public final Call call;
77 public AsyncLoadCookie(ImageView imageView, CallerInfo callerInfo, Call call) {
78 this.imageView = imageView;
79 this.callerInfo = callerInfo;
80 this.call = call;
81 }
82 }
83
84 /**
85 * Reference to the InCallScreen activity that owns us. This may be
86 * null if we haven't been initialized yet *or* after the InCallScreen
87 * activity has been destroyed.
88 */
89 private InCallScreen mInCallScreen;
90
91 // Phone app instance
92 private PhoneGlobals mApplication;
93
94 // Top-level subviews of the CallCard
95 /** Container for info about the current call(s) */
96 private ViewGroup mCallInfoContainer;
97 /** Primary "call info" block (the foreground or ringing call) */
98 private ViewGroup mPrimaryCallInfo;
99 /** "Call banner" for the primary call */
100 private ViewGroup mPrimaryCallBanner;
101 /** Secondary "call info" block (the background "on hold" call) */
102 private ViewStub mSecondaryCallInfo;
103
104 /**
105 * Container for both provider info and call state. This will take care of showing/hiding
106 * animation for those views.
107 */
108 private ViewGroup mSecondaryInfoContainer;
109 private ViewGroup mProviderInfo;
110 private TextView mProviderLabel;
111 private TextView mProviderAddress;
112
113 // "Call state" widgets
114 private TextView mCallStateLabel;
115 private TextView mElapsedTime;
116
117 // Text colors, used for various labels / titles
118 private int mTextColorCallTypeSip;
119
120 // The main block of info about the "primary" or "active" call,
121 // including photo / name / phone number / etc.
122 private ImageView mPhoto;
123 private View mPhotoDimEffect;
124
125 private TextView mName;
126 private TextView mPhoneNumber;
127 private TextView mLabel;
128 private TextView mCallTypeLabel;
129 // private TextView mSocialStatus;
130
131 /**
132 * Uri being used to load contact photo for mPhoto. Will be null when nothing is being loaded,
133 * or a photo is already loaded.
134 */
135 private Uri mLoadingPersonUri;
136
137 // Info about the "secondary" call, which is the "call on hold" when
138 // two lines are in use.
139 private TextView mSecondaryCallName;
140 private ImageView mSecondaryCallPhoto;
141 private View mSecondaryCallPhotoDimEffect;
142
143 // Onscreen hint for the incoming call RotarySelector widget.
144 private int mIncomingCallWidgetHintTextResId;
145 private int mIncomingCallWidgetHintColorResId;
146
147 private CallTime mCallTime;
148
149 // Track the state for the photo.
150 private ContactsAsyncHelper.ImageTracker mPhotoTracker;
151
152 // Cached DisplayMetrics density.
153 private float mDensity;
154
155 /**
156 * Sent when it takes too long (MESSAGE_DELAY msec) to load a contact photo for the given
157 * person, at which we just start showing the default avatar picture instead of the person's
158 * one. Note that we will *not* cancel the ongoing query and eventually replace the avatar
159 * with the person's photo, when it is available anyway.
160 */
161 private static final int MESSAGE_SHOW_UNKNOWN_PHOTO = 101;
162 private static final int MESSAGE_DELAY = 500; // msec
163 private final Handler mHandler = new Handler() {
164 @Override
165 public void handleMessage(Message msg) {
166 switch (msg.what) {
167 case MESSAGE_SHOW_UNKNOWN_PHOTO:
168 showImage(mPhoto, R.drawable.picture_unknown);
169 break;
170 default:
171 Log.wtf(LOG_TAG, "mHandler: unexpected message: " + msg);
172 break;
173 }
174 }
175 };
176
177 public CallCard(Context context, AttributeSet attrs) {
178 super(context, attrs);
179
180 if (DBG) log("CallCard constructor...");
181 if (DBG) log("- this = " + this);
182 if (DBG) log("- context " + context + ", attrs " + attrs);
183
184 mApplication = PhoneGlobals.getInstance();
185
186 mCallTime = new CallTime(this);
187
188 // create a new object to track the state for the photo.
189 mPhotoTracker = new ContactsAsyncHelper.ImageTracker();
190
191 mDensity = getResources().getDisplayMetrics().density;
192 if (DBG) log("- Density: " + mDensity);
193 }
194
195 /* package */ void setInCallScreenInstance(InCallScreen inCallScreen) {
196 mInCallScreen = inCallScreen;
197 }
198
199 @Override
200 public void onTickForCallTimeElapsed(long timeElapsed) {
201 // While a call is in progress, update the elapsed time shown
202 // onscreen.
203 updateElapsedTimeWidget(timeElapsed);
204 }
205
206 /* package */ void stopTimer() {
207 mCallTime.cancelTimer();
208 }
209
210 @Override
211 protected void onFinishInflate() {
212 super.onFinishInflate();
213
214 if (DBG) log("CallCard onFinishInflate(this = " + this + ")...");
215
216 mCallInfoContainer = (ViewGroup) findViewById(R.id.call_info_container);
217 mPrimaryCallInfo = (ViewGroup) findViewById(R.id.primary_call_info);
218 mPrimaryCallBanner = (ViewGroup) findViewById(R.id.primary_call_banner);
219
220 mSecondaryInfoContainer = (ViewGroup) findViewById(R.id.secondary_info_container);
221 mProviderInfo = (ViewGroup) findViewById(R.id.providerInfo);
222 mProviderLabel = (TextView) findViewById(R.id.providerLabel);
223 mProviderAddress = (TextView) findViewById(R.id.providerAddress);
224 mCallStateLabel = (TextView) findViewById(R.id.callStateLabel);
225 mElapsedTime = (TextView) findViewById(R.id.elapsedTime);
226
227 // Text colors
228 mTextColorCallTypeSip = getResources().getColor(R.color.incall_callTypeSip);
229
230 // "Caller info" area, including photo / name / phone numbers / etc
231 mPhoto = (ImageView) findViewById(R.id.photo);
232 mPhotoDimEffect = findViewById(R.id.dim_effect_for_primary_photo);
233
234 mName = (TextView) findViewById(R.id.name);
235 mPhoneNumber = (TextView) findViewById(R.id.phoneNumber);
236 mLabel = (TextView) findViewById(R.id.label);
237 mCallTypeLabel = (TextView) findViewById(R.id.callTypeLabel);
238 // mSocialStatus = (TextView) findViewById(R.id.socialStatus);
239
240 // Secondary info area, for the background ("on hold") call
241 mSecondaryCallInfo = (ViewStub) findViewById(R.id.secondary_call_info);
242 }
243
244 /**
245 * Updates the state of all UI elements on the CallCard, based on the
246 * current state of the phone.
247 */
248 /* package */ void updateState(CallManager cm) {
249 if (DBG) log("updateState(" + cm + ")...");
250
251 // Update the onscreen UI based on the current state of the phone.
252
253 PhoneConstants.State state = cm.getState(); // IDLE, RINGING, or OFFHOOK
254 Call ringingCall = cm.getFirstActiveRingingCall();
255 Call fgCall = cm.getActiveFgCall();
256 Call bgCall = cm.getFirstActiveBgCall();
257
258 // Update the overall layout of the onscreen elements, if in PORTRAIT.
259 // Portrait uses a programatically altered layout, whereas landscape uses layout xml's.
260 // Landscape view has the views side by side, so no shifting of the picture is needed
261 if (!PhoneUtils.isLandscape(this.getContext())) {
262 updateCallInfoLayout(state);
263 }
264
265 // If the FG call is dialing/alerting, we should display for that call
266 // and ignore the ringing call. This case happens when the telephony
267 // layer rejects the ringing call while the FG call is dialing/alerting,
268 // but the incoming call *does* briefly exist in the DISCONNECTING or
269 // DISCONNECTED state.
270 if ((ringingCall.getState() != Call.State.IDLE)
271 && !fgCall.getState().isDialing()) {
272 // A phone call is ringing, call waiting *or* being rejected
273 // (ie. another call may also be active as well.)
274 updateRingingCall(cm);
275 } else if ((fgCall.getState() != Call.State.IDLE)
276 || (bgCall.getState() != Call.State.IDLE)) {
277 // We are here because either:
278 // (1) the phone is off hook. At least one call exists that is
279 // dialing, active, or holding, and no calls are ringing or waiting,
280 // or:
281 // (2) the phone is IDLE but a call just ended and it's still in
282 // the DISCONNECTING or DISCONNECTED state. In this case, we want
283 // the main CallCard to display "Hanging up" or "Call ended".
284 // The normal "foreground call" code path handles both cases.
285 updateForegroundCall(cm);
286 } else {
287 // We don't have any DISCONNECTED calls, which means that the phone
288 // is *truly* idle.
289 if (mApplication.inCallUiState.showAlreadyDisconnectedState) {
290 // showAlreadyDisconnectedState implies the phone call is disconnected
291 // and we want to show the disconnected phone call for a moment.
292 //
293 // This happens when a phone call ends while the screen is off,
294 // which means the user had no chance to see the last status of
295 // the call. We'll turn off showAlreadyDisconnectedState flag
296 // and bail out of the in-call screen soon.
297 updateAlreadyDisconnected(cm);
298 } else {
299 // It's very rare to be on the InCallScreen at all in this
300 // state, but it can happen in some cases:
301 // - A stray onPhoneStateChanged() event came in to the
302 // InCallScreen *after* it was dismissed.
303 // - We're allowed to be on the InCallScreen because
304 // an MMI or USSD is running, but there's no actual "call"
305 // to display.
306 // - We're displaying an error dialog to the user
307 // (explaining why the call failed), so we need to stay on
308 // the InCallScreen so that the dialog will be visible.
309 //
310 // In these cases, put the callcard into a sane but "blank" state:
311 updateNoCall(cm);
312 }
313 }
314 }
315
316 /**
317 * Updates the overall size and positioning of mCallInfoContainer and
318 * the "Call info" blocks, based on the phone state.
319 */
320 private void updateCallInfoLayout(PhoneConstants.State state) {
321 boolean ringing = (state == PhoneConstants.State.RINGING);
322 if (DBG) log("updateCallInfoLayout()... ringing = " + ringing);
323
324 // Based on the current state, update the overall
325 // CallCard layout:
326
327 // - Update the bottom margin of mCallInfoContainer to make sure
328 // the call info area won't overlap with the touchable
329 // controls on the bottom part of the screen.
330
331 int reservedVerticalSpace = mInCallScreen.getInCallTouchUi().getTouchUiHeight();
332 ViewGroup.MarginLayoutParams callInfoLp =
333 (ViewGroup.MarginLayoutParams) mCallInfoContainer.getLayoutParams();
334 callInfoLp.bottomMargin = reservedVerticalSpace; // Equivalent to setting
335 // android:layout_marginBottom in XML
336 if (DBG) log(" ==> callInfoLp.bottomMargin: " + reservedVerticalSpace);
337 mCallInfoContainer.setLayoutParams(callInfoLp);
338 }
339
340 /**
341 * Updates the UI for the state where the phone is in use, but not ringing.
342 */
343 private void updateForegroundCall(CallManager cm) {
344 if (DBG) log("updateForegroundCall()...");
345 // if (DBG) PhoneUtils.dumpCallManager();
346
347 Call fgCall = cm.getActiveFgCall();
348 Call bgCall = cm.getFirstActiveBgCall();
349
350 if (fgCall.getState() == Call.State.IDLE) {
351 if (DBG) log("updateForegroundCall: no active call, show holding call");
352 // TODO: make sure this case agrees with the latest UI spec.
353
354 // Display the background call in the main info area of the
355 // CallCard, since there is no foreground call. Note that
356 // displayMainCallStatus() will notice if the call we passed in is on
357 // hold, and display the "on hold" indication.
358 fgCall = bgCall;
359
360 // And be sure to not display anything in the "on hold" box.
361 bgCall = null;
362 }
363
364 displayMainCallStatus(cm, fgCall);
365
366 Phone phone = fgCall.getPhone();
367
368 int phoneType = phone.getPhoneType();
369 if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) {
370 if ((mApplication.cdmaPhoneCallState.getCurrentCallState()
371 == CdmaPhoneCallState.PhoneCallState.THRWAY_ACTIVE)
372 && mApplication.cdmaPhoneCallState.IsThreeWayCallOrigStateDialing()) {
373 displaySecondaryCallStatus(cm, fgCall);
374 } else {
375 //This is required so that even if a background call is not present
376 // we need to clean up the background call area.
377 displaySecondaryCallStatus(cm, bgCall);
378 }
379 } else if ((phoneType == PhoneConstants.PHONE_TYPE_GSM)
380 || (phoneType == PhoneConstants.PHONE_TYPE_SIP)) {
381 displaySecondaryCallStatus(cm, bgCall);
382 }
383 }
384
385 /**
386 * Updates the UI for the state where an incoming call is ringing (or
387 * call waiting), regardless of whether the phone's already offhook.
388 */
389 private void updateRingingCall(CallManager cm) {
390 if (DBG) log("updateRingingCall()...");
391
392 Call ringingCall = cm.getFirstActiveRingingCall();
393
394 // Display caller-id info and photo from the incoming call:
395 displayMainCallStatus(cm, ringingCall);
396
397 // And even in the Call Waiting case, *don't* show any info about
398 // the current ongoing call and/or the current call on hold.
399 // (Since the caller-id info for the incoming call totally trumps
400 // any info about the current call(s) in progress.)
401 displaySecondaryCallStatus(cm, null);
402 }
403
404 /**
405 * Updates the UI for the state where an incoming call is just disconnected while we want to
406 * show the screen for a moment.
407 *
408 * This case happens when the whole in-call screen is in background when phone calls are hanged
409 * up, which means there's no way to determine which call was the last call finished. Right now
410 * this method simply shows the previous primary call status with a photo, closing the
411 * secondary call status. In most cases (including conference call or misc call happening in
412 * CDMA) this behaves right.
413 *
414 * If there were two phone calls both of which were hung up but the primary call was the
415 * first, this would behave a bit odd (since the first one still appears as the
416 * "last disconnected").
417 */
418 private void updateAlreadyDisconnected(CallManager cm) {
419 // For the foreground call, we manually set up every component based on previous state.
420 mPrimaryCallInfo.setVisibility(View.VISIBLE);
421 mSecondaryInfoContainer.setLayoutTransition(null);
422 mProviderInfo.setVisibility(View.GONE);
423 mCallStateLabel.setVisibility(View.VISIBLE);
424 mCallStateLabel.setText(mContext.getString(R.string.card_title_call_ended));
425 mElapsedTime.setVisibility(View.VISIBLE);
426 mCallTime.cancelTimer();
427
428 // Just hide it.
429 displaySecondaryCallStatus(cm, null);
430 }
431
432 /**
433 * Updates the UI for the state where the phone is not in use.
434 * This is analogous to updateForegroundCall() and updateRingingCall(),
435 * but for the (uncommon) case where the phone is
436 * totally idle. (See comments in updateState() above.)
437 *
438 * This puts the callcard into a sane but "blank" state.
439 */
440 private void updateNoCall(CallManager cm) {
441 if (DBG) log("updateNoCall()...");
442
443 displayMainCallStatus(cm, null);
444 displaySecondaryCallStatus(cm, null);
445 }
446
447 /**
448 * Updates the main block of caller info on the CallCard
449 * (ie. the stuff in the primaryCallInfo block) based on the specified Call.
450 */
451 private void displayMainCallStatus(CallManager cm, Call call) {
452 if (DBG) log("displayMainCallStatus(call " + call + ")...");
453
454 if (call == null) {
455 // There's no call to display, presumably because the phone is idle.
456 mPrimaryCallInfo.setVisibility(View.GONE);
457 return;
458 }
459 mPrimaryCallInfo.setVisibility(View.VISIBLE);
460
461 Call.State state = call.getState();
462 if (DBG) log(" - call.state: " + call.getState());
463
464 switch (state) {
465 case ACTIVE:
466 case DISCONNECTING:
467 // update timer field
468 if (DBG) log("displayMainCallStatus: start periodicUpdateTimer");
469 mCallTime.setActiveCallMode(call);
470 mCallTime.reset();
471 mCallTime.periodicUpdateTimer();
472
473 break;
474
475 case HOLDING:
476 // update timer field
477 mCallTime.cancelTimer();
478
479 break;
480
481 case DISCONNECTED:
482 // Stop getting timer ticks from this call
483 mCallTime.cancelTimer();
484
485 break;
486
487 case DIALING:
488 case ALERTING:
489 // Stop getting timer ticks from a previous call
490 mCallTime.cancelTimer();
491
492 break;
493
494 case INCOMING:
495 case WAITING:
496 // Stop getting timer ticks from a previous call
497 mCallTime.cancelTimer();
498
499 break;
500
501 case IDLE:
502 // The "main CallCard" should never be trying to display
503 // an idle call! In updateState(), if the phone is idle,
504 // we call updateNoCall(), which means that we shouldn't
505 // have passed a call into this method at all.
506 Log.w(LOG_TAG, "displayMainCallStatus: IDLE call in the main call card!");
507
508 // (It is possible, though, that we had a valid call which
509 // became idle *after* the check in updateState() but
510 // before we get here... So continue the best we can,
511 // with whatever (stale) info we can get from the
512 // passed-in Call object.)
513
514 break;
515
516 default:
517 Log.w(LOG_TAG, "displayMainCallStatus: unexpected call state: " + state);
518 break;
519 }
520
521 updateCallStateWidgets(call);
522
523 if (PhoneUtils.isConferenceCall(call)) {
524 // Update onscreen info for a conference call.
525 updateDisplayForConference(call);
526 } else {
527 // Update onscreen info for a regular call (which presumably
528 // has only one connection.)
529 Connection conn = null;
530 int phoneType = call.getPhone().getPhoneType();
531 if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) {
532 conn = call.getLatestConnection();
533 } else if ((phoneType == PhoneConstants.PHONE_TYPE_GSM)
534 || (phoneType == PhoneConstants.PHONE_TYPE_SIP)) {
535 conn = call.getEarliestConnection();
536 } else {
537 throw new IllegalStateException("Unexpected phone type: " + phoneType);
538 }
539
540 if (conn == null) {
541 if (DBG) log("displayMainCallStatus: connection is null, using default values.");
542 // if the connection is null, we run through the behaviour
543 // we had in the past, which breaks down into trivial steps
544 // with the current implementation of getCallerInfo and
545 // updateDisplayForPerson.
546 CallerInfo info = PhoneUtils.getCallerInfo(getContext(), null /* conn */);
547 updateDisplayForPerson(info, PhoneConstants.PRESENTATION_ALLOWED, false, call,
548 conn);
549 } else {
550 if (DBG) log(" - CONN: " + conn + ", state = " + conn.getState());
551 int presentation = conn.getNumberPresentation();
552
553 // make sure that we only make a new query when the current
554 // callerinfo differs from what we've been requested to display.
555 boolean runQuery = true;
556 Object o = conn.getUserData();
557 if (o instanceof PhoneUtils.CallerInfoToken) {
558 runQuery = mPhotoTracker.isDifferentImageRequest(
559 ((PhoneUtils.CallerInfoToken) o).currentInfo);
560 } else {
561 runQuery = mPhotoTracker.isDifferentImageRequest(conn);
562 }
563
564 // Adding a check to see if the update was caused due to a Phone number update
565 // or CNAP update. If so then we need to start a new query
566 if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) {
567 Object obj = conn.getUserData();
568 String updatedNumber = conn.getAddress();
569 String updatedCnapName = conn.getCnapName();
570 CallerInfo info = null;
571 if (obj instanceof PhoneUtils.CallerInfoToken) {
572 info = ((PhoneUtils.CallerInfoToken) o).currentInfo;
573 } else if (o instanceof CallerInfo) {
574 info = (CallerInfo) o;
575 }
576
577 if (info != null) {
578 if (updatedNumber != null && !updatedNumber.equals(info.phoneNumber)) {
579 if (DBG) log("- displayMainCallStatus: updatedNumber = "
580 + updatedNumber);
581 runQuery = true;
582 }
583 if (updatedCnapName != null && !updatedCnapName.equals(info.cnapName)) {
584 if (DBG) log("- displayMainCallStatus: updatedCnapName = "
585 + updatedCnapName);
586 runQuery = true;
587 }
588 }
589 }
590
591 if (runQuery) {
592 if (DBG) log("- displayMainCallStatus: starting CallerInfo query...");
593 PhoneUtils.CallerInfoToken info =
594 PhoneUtils.startGetCallerInfo(getContext(), conn, this, call);
595 updateDisplayForPerson(info.currentInfo, presentation, !info.isFinal,
596 call, conn);
597 } else {
598 // No need to fire off a new query. We do still need
599 // to update the display, though (since we might have
600 // previously been in the "conference call" state.)
601 if (DBG) log("- displayMainCallStatus: using data we already have...");
602 if (o instanceof CallerInfo) {
603 CallerInfo ci = (CallerInfo) o;
604 // Update CNAP information if Phone state change occurred
605 ci.cnapName = conn.getCnapName();
606 ci.numberPresentation = conn.getNumberPresentation();
607 ci.namePresentation = conn.getCnapNamePresentation();
608 if (DBG) log("- displayMainCallStatus: CNAP data from Connection: "
609 + "CNAP name=" + ci.cnapName
610 + ", Number/Name Presentation=" + ci.numberPresentation);
611 if (DBG) log(" ==> Got CallerInfo; updating display: ci = " + ci);
612 updateDisplayForPerson(ci, presentation, false, call, conn);
613 } else if (o instanceof PhoneUtils.CallerInfoToken){
614 CallerInfo ci = ((PhoneUtils.CallerInfoToken) o).currentInfo;
615 if (DBG) log("- displayMainCallStatus: CNAP data from Connection: "
616 + "CNAP name=" + ci.cnapName
617 + ", Number/Name Presentation=" + ci.numberPresentation);
618 if (DBG) log(" ==> Got CallerInfoToken; updating display: ci = " + ci);
619 updateDisplayForPerson(ci, presentation, true, call, conn);
620 } else {
621 Log.w(LOG_TAG, "displayMainCallStatus: runQuery was false, "
622 + "but we didn't have a cached CallerInfo object! o = " + o);
623 // TODO: any easy way to recover here (given that
624 // the CallCard is probably displaying stale info
625 // right now?) Maybe force the CallCard into the
626 // "Unknown" state?
627 }
628 }
629 }
630 }
631
632 // In some states we override the "photo" ImageView to be an
633 // indication of the current state, rather than displaying the
634 // regular photo as set above.
635 updatePhotoForCallState(call);
636
637 // One special feature of the "number" text field: For incoming
638 // calls, while the user is dragging the RotarySelector widget, we
639 // use mPhoneNumber to display a hint like "Rotate to answer".
640 if (mIncomingCallWidgetHintTextResId != 0) {
641 // Display the hint!
642 mPhoneNumber.setText(mIncomingCallWidgetHintTextResId);
643 mPhoneNumber.setTextColor(getResources().getColor(mIncomingCallWidgetHintColorResId));
644 mPhoneNumber.setVisibility(View.VISIBLE);
645 mLabel.setVisibility(View.GONE);
646 }
647 // If we don't have a hint to display, just don't touch
648 // mPhoneNumber and mLabel. (Their text / color / visibility have
649 // already been set correctly, by either updateDisplayForPerson()
650 // or updateDisplayForConference().)
651 }
652
653 /**
654 * Implemented for CallerInfoAsyncQuery.OnQueryCompleteListener interface.
655 * refreshes the CallCard data when it called.
656 */
657 @Override
658 public void onQueryComplete(int token, Object cookie, CallerInfo ci) {
659 if (DBG) log("onQueryComplete: token " + token + ", cookie " + cookie + ", ci " + ci);
660
661 if (cookie instanceof Call) {
662 // grab the call object and update the display for an individual call,
663 // as well as the successive call to update image via call state.
664 // If the object is a textview instead, we update it as we need to.
665 if (DBG) log("callerinfo query complete, updating ui from displayMainCallStatus()");
666 Call call = (Call) cookie;
667 Connection conn = null;
668 int phoneType = call.getPhone().getPhoneType();
669 if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) {
670 conn = call.getLatestConnection();
671 } else if ((phoneType == PhoneConstants.PHONE_TYPE_GSM)
672 || (phoneType == PhoneConstants.PHONE_TYPE_SIP)) {
673 conn = call.getEarliestConnection();
674 } else {
675 throw new IllegalStateException("Unexpected phone type: " + phoneType);
676 }
677 PhoneUtils.CallerInfoToken cit =
678 PhoneUtils.startGetCallerInfo(getContext(), conn, this, null);
679
680 int presentation = PhoneConstants.PRESENTATION_ALLOWED;
681 if (conn != null) presentation = conn.getNumberPresentation();
682 if (DBG) log("- onQueryComplete: presentation=" + presentation
683 + ", contactExists=" + ci.contactExists);
684
685 // Depending on whether there was a contact match or not, we want to pass in different
686 // CallerInfo (for CNAP). Therefore if ci.contactExists then use the ci passed in.
687 // Otherwise, regenerate the CIT from the Connection and use the CallerInfo from there.
688 if (ci.contactExists) {
689 updateDisplayForPerson(ci, PhoneConstants.PRESENTATION_ALLOWED, false, call, conn);
690 } else {
691 updateDisplayForPerson(cit.currentInfo, presentation, false, call, conn);
692 }
693 updatePhotoForCallState(call);
694
695 } else if (cookie instanceof TextView){
696 if (DBG) log("callerinfo query complete, updating ui from ongoing or onhold");
697 ((TextView) cookie).setText(PhoneUtils.getCompactNameFromCallerInfo(ci, mContext));
698 }
699 }
700
701 /**
702 * Implemented for ContactsAsyncHelper.OnImageLoadCompleteListener interface.
703 * make sure that the call state is reflected after the image is loaded.
704 */
705 @Override
706 public void onImageLoadComplete(int token, Drawable photo, Bitmap photoIcon, Object cookie) {
707 mHandler.removeMessages(MESSAGE_SHOW_UNKNOWN_PHOTO);
708 if (mLoadingPersonUri != null) {
709 // Start sending view notification after the current request being done.
710 // New image may possibly be available from the next phone calls.
711 //
712 // TODO: may be nice to update the image view again once the newer one
713 // is available on contacts database.
714 PhoneUtils.sendViewNotificationAsync(mApplication, mLoadingPersonUri);
715 } else {
716 // This should not happen while we need some verbose info if it happens..
717 Log.w(LOG_TAG, "Person Uri isn't available while Image is successfully loaded.");
718 }
719 mLoadingPersonUri = null;
720
721 AsyncLoadCookie asyncLoadCookie = (AsyncLoadCookie) cookie;
722 CallerInfo callerInfo = asyncLoadCookie.callerInfo;
723 ImageView imageView = asyncLoadCookie.imageView;
724 Call call = asyncLoadCookie.call;
725
726 callerInfo.cachedPhoto = photo;
727 callerInfo.cachedPhotoIcon = photoIcon;
728 callerInfo.isCachedPhotoCurrent = true;
729
730 // Note: previously ContactsAsyncHelper has done this job.
731 // TODO: We will need fade-in animation. See issue 5236130.
732 if (photo != null) {
733 showImage(imageView, photo);
734 } else if (photoIcon != null) {
735 showImage(imageView, photoIcon);
736 } else {
737 showImage(imageView, R.drawable.picture_unknown);
738 }
739
740 if (token == TOKEN_UPDATE_PHOTO_FOR_CALL_STATE) {
741 updatePhotoForCallState(call);
742 }
743 }
744
745 /**
746 * Updates the "call state label" and the elapsed time widget based on the
747 * current state of the call.
748 */
749 private void updateCallStateWidgets(Call call) {
750 if (DBG) log("updateCallStateWidgets(call " + call + ")...");
751 final Call.State state = call.getState();
752 final Context context = getContext();
753 final Phone phone = call.getPhone();
754 final int phoneType = phone.getPhoneType();
755
756 String callStateLabel = null; // Label to display as part of the call banner
757 int bluetoothIconId = 0; // Icon to display alongside the call state label
758
759 switch (state) {
760 case IDLE:
761 // "Call state" is meaningless in this state.
762 break;
763
764 case ACTIVE:
765 // We normally don't show a "call state label" at all in
766 // this state (but see below for some special cases).
767 break;
768
769 case HOLDING:
770 callStateLabel = context.getString(R.string.card_title_on_hold);
771 break;
772
773 case DIALING:
774 case ALERTING:
775 callStateLabel = context.getString(R.string.card_title_dialing);
776 break;
777
778 case INCOMING:
779 case WAITING:
780 callStateLabel = context.getString(R.string.card_title_incoming_call);
781
782 // Also, display a special icon (alongside the "Incoming call"
783 // label) if there's an incoming call and audio will be routed
784 // to bluetooth when you answer it.
Santos Cordon27a3c1f2013-08-06 07:49:27 -0700785 // TODO(klp): Add bluetooth label to new UI screen for incoming calls.
786 //if (mApplication.showBluetoothIndication()) {
787 // bluetoothIconId = R.drawable.ic_incoming_call_bluetooth;
788 //}
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700789 break;
790
791 case DISCONNECTING:
792 // While in the DISCONNECTING state we display a "Hanging up"
793 // message in order to make the UI feel more responsive. (In
794 // GSM it's normal to see a delay of a couple of seconds while
795 // negotiating the disconnect with the network, so the "Hanging
796 // up" state at least lets the user know that we're doing
797 // something. This state is currently not used with CDMA.)
798 callStateLabel = context.getString(R.string.card_title_hanging_up);
799 break;
800
801 case DISCONNECTED:
802 callStateLabel = getCallFailedString(call);
803 break;
804
805 default:
806 Log.wtf(LOG_TAG, "updateCallStateWidgets: unexpected call state: " + state);
807 break;
808 }
809
810 // Check a couple of other special cases (these are all CDMA-specific).
811
812 if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) {
813 if ((state == Call.State.ACTIVE)
814 && mApplication.cdmaPhoneCallState.IsThreeWayCallOrigStateDialing()) {
815 // Display "Dialing" while dialing a 3Way call, even
816 // though the foreground call state is actually ACTIVE.
817 callStateLabel = context.getString(R.string.card_title_dialing);
818 } else if (PhoneGlobals.getInstance().notifier.getIsCdmaRedialCall()) {
819 callStateLabel = context.getString(R.string.card_title_redialing);
820 }
821 }
822 if (PhoneUtils.isPhoneInEcm(phone)) {
823 // In emergency callback mode (ECM), use a special label
824 // that shows your own phone number.
825 callStateLabel = getECMCardTitle(context, phone);
826 }
827
828 final InCallUiState inCallUiState = mApplication.inCallUiState;
829 if (DBG) {
830 log("==> callStateLabel: '" + callStateLabel
831 + "', bluetoothIconId = " + bluetoothIconId
832 + ", providerInfoVisible = " + inCallUiState.providerInfoVisible);
833 }
834
835 // Animation will be done by mCallerDetail's LayoutTransition, but in some cases, we don't
836 // want that.
837 // - DIALING: This is at the beginning of the phone call.
838 // - DISCONNECTING, DISCONNECTED: Screen will disappear soon; we have no time for animation.
839 final boolean skipAnimation = (state == Call.State.DIALING
840 || state == Call.State.DISCONNECTING
841 || state == Call.State.DISCONNECTED);
842 LayoutTransition layoutTransition = null;
843 if (skipAnimation) {
844 // Evict LayoutTransition object to skip animation.
845 layoutTransition = mSecondaryInfoContainer.getLayoutTransition();
846 mSecondaryInfoContainer.setLayoutTransition(null);
847 }
848
849 if (inCallUiState.providerInfoVisible) {
850 mProviderInfo.setVisibility(View.VISIBLE);
851 mProviderLabel.setText(context.getString(R.string.calling_via_template,
852 inCallUiState.providerLabel));
853 mProviderAddress.setText(inCallUiState.providerAddress);
854
855 mInCallScreen.requestRemoveProviderInfoWithDelay();
856 } else {
857 mProviderInfo.setVisibility(View.GONE);
858 }
859
860 if (!TextUtils.isEmpty(callStateLabel)) {
861 mCallStateLabel.setVisibility(View.VISIBLE);
862 mCallStateLabel.setText(callStateLabel);
863
864 // ...and display the icon too if necessary.
865 if (bluetoothIconId != 0) {
866 mCallStateLabel.setCompoundDrawablesWithIntrinsicBounds(bluetoothIconId, 0, 0, 0);
867 mCallStateLabel.setCompoundDrawablePadding((int) (mDensity * 5));
868 } else {
869 // Clear out any icons
870 mCallStateLabel.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
871 }
872 } else {
873 mCallStateLabel.setVisibility(View.GONE);
874 // Gravity is aligned left when receiving an incoming call in landscape.
875 // In that rare case, the gravity needs to be reset to the right.
876 // Also, setText("") is used since there is a delay in making the view GONE,
877 // so the user will otherwise see the text jump to the right side before disappearing.
878 if(mCallStateLabel.getGravity() != Gravity.END) {
879 mCallStateLabel.setText("");
880 mCallStateLabel.setGravity(Gravity.END);
881 }
882 }
883 if (skipAnimation) {
884 // Restore LayoutTransition object to recover animation.
885 mSecondaryInfoContainer.setLayoutTransition(layoutTransition);
886 }
887
888 // ...and update the elapsed time widget too.
889 switch (state) {
890 case ACTIVE:
891 case DISCONNECTING:
892 // Show the time with fade-in animation.
893 AnimationUtils.Fade.show(mElapsedTime);
894 updateElapsedTimeWidget(call);
895 break;
896
897 case DISCONNECTED:
898 // In the "Call ended" state, leave the mElapsedTime widget
899 // visible, but don't touch it (so we continue to see the
900 // elapsed time of the call that just ended.)
901 // Check visibility to keep possible fade-in animation.
902 if (mElapsedTime.getVisibility() != View.VISIBLE) {
903 mElapsedTime.setVisibility(View.VISIBLE);
904 }
905 break;
906
907 default:
908 // Call state here is IDLE, ACTIVE, HOLDING, DIALING, ALERTING,
909 // INCOMING, or WAITING.
910 // In all of these states, the "elapsed time" is meaningless, so
911 // don't show it.
912 AnimationUtils.Fade.hide(mElapsedTime, View.INVISIBLE);
913
914 // Additionally, in call states that can only occur at the start
915 // of a call, reset the elapsed time to be sure we won't display
916 // stale info later (like if we somehow go straight from DIALING
917 // or ALERTING to DISCONNECTED, which can actually happen in
918 // some failure cases like "line busy").
919 if ((state == Call.State.DIALING) || (state == Call.State.ALERTING)) {
920 updateElapsedTimeWidget(0);
921 }
922
923 break;
924 }
925 }
926
927 /**
928 * Updates mElapsedTime based on the given {@link Call} object's information.
929 *
930 * @see CallTime#getCallDuration(Call)
931 * @see Connection#getDurationMillis()
932 */
933 /* package */ void updateElapsedTimeWidget(Call call) {
934 long duration = CallTime.getCallDuration(call); // msec
935 updateElapsedTimeWidget(duration / 1000);
936 // Also see onTickForCallTimeElapsed(), which updates this
937 // widget once per second while the call is active.
938 }
939
940 /**
941 * Updates mElapsedTime based on the specified number of seconds.
942 */
943 private void updateElapsedTimeWidget(long timeElapsed) {
944 // if (DBG) log("updateElapsedTimeWidget: " + timeElapsed);
945 mElapsedTime.setText(DateUtils.formatElapsedTime(timeElapsed));
946 }
947
948 /**
949 * Updates the "on hold" box in the "other call" info area
950 * (ie. the stuff in the secondaryCallInfo block)
951 * based on the specified Call.
952 * Or, clear out the "on hold" box if the specified call
953 * is null or idle.
954 */
955 private void displaySecondaryCallStatus(CallManager cm, Call call) {
956 if (DBG) log("displayOnHoldCallStatus(call =" + call + ")...");
957
958 if ((call == null) || (PhoneGlobals.getInstance().isOtaCallInActiveState())) {
959 mSecondaryCallInfo.setVisibility(View.GONE);
960 return;
961 }
962
963 Call.State state = call.getState();
964 switch (state) {
965 case HOLDING:
966 // Ok, there actually is a background call on hold.
967 // Display the "on hold" box.
968
969 // Note this case occurs only on GSM devices. (On CDMA,
970 // the "call on hold" is actually the 2nd connection of
971 // that ACTIVE call; see the ACTIVE case below.)
972 showSecondaryCallInfo();
973
974 if (PhoneUtils.isConferenceCall(call)) {
975 if (DBG) log("==> conference call.");
976 mSecondaryCallName.setText(getContext().getString(R.string.confCall));
977 showImage(mSecondaryCallPhoto, R.drawable.picture_conference);
978 } else {
979 // perform query and update the name temporarily
980 // make sure we hand the textview we want updated to the
981 // callback function.
982 if (DBG) log("==> NOT a conf call; call startGetCallerInfo...");
983 PhoneUtils.CallerInfoToken infoToken = PhoneUtils.startGetCallerInfo(
984 getContext(), call, this, mSecondaryCallName);
985 mSecondaryCallName.setText(
986 PhoneUtils.getCompactNameFromCallerInfo(infoToken.currentInfo,
987 getContext()));
988
989 // Also pull the photo out of the current CallerInfo.
990 // (Note we assume we already have a valid photo at
991 // this point, since *presumably* the caller-id query
992 // was already run at some point *before* this call
993 // got put on hold. If there's no cached photo, just
994 // fall back to the default "unknown" image.)
995 if (infoToken.isFinal) {
996 showCachedImage(mSecondaryCallPhoto, infoToken.currentInfo);
997 } else {
998 showImage(mSecondaryCallPhoto, R.drawable.picture_unknown);
999 }
1000 }
1001
1002 AnimationUtils.Fade.show(mSecondaryCallPhotoDimEffect);
1003 break;
1004
1005 case ACTIVE:
1006 // CDMA: This is because in CDMA when the user originates the second call,
1007 // although the Foreground call state is still ACTIVE in reality the network
1008 // put the first call on hold.
1009 if (mApplication.phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) {
1010 showSecondaryCallInfo();
1011
1012 List<Connection> connections = call.getConnections();
1013 if (connections.size() > 2) {
1014 // This means that current Mobile Originated call is the not the first 3-Way
1015 // call the user is making, which in turn tells the PhoneGlobals that we no
1016 // longer know which previous caller/party had dropped out before the user
1017 // made this call.
1018 mSecondaryCallName.setText(
1019 getContext().getString(R.string.card_title_in_call));
1020 showImage(mSecondaryCallPhoto, R.drawable.picture_unknown);
1021 } else {
1022 // This means that the current Mobile Originated call IS the first 3-Way
1023 // and hence we display the first callers/party's info here.
1024 Connection conn = call.getEarliestConnection();
1025 PhoneUtils.CallerInfoToken infoToken = PhoneUtils.startGetCallerInfo(
1026 getContext(), conn, this, mSecondaryCallName);
1027
1028 // Get the compactName to be displayed, but then check that against
1029 // the number presentation value for the call. If it's not an allowed
1030 // presentation, then display the appropriate presentation string instead.
1031 CallerInfo info = infoToken.currentInfo;
1032
1033 String name = PhoneUtils.getCompactNameFromCallerInfo(info, getContext());
1034 boolean forceGenericPhoto = false;
1035 if (info != null && info.numberPresentation !=
1036 PhoneConstants.PRESENTATION_ALLOWED) {
1037 name = PhoneUtils.getPresentationString(
1038 getContext(), info.numberPresentation);
1039 forceGenericPhoto = true;
1040 }
1041 mSecondaryCallName.setText(name);
1042
1043 // Also pull the photo out of the current CallerInfo.
1044 // (Note we assume we already have a valid photo at
1045 // this point, since *presumably* the caller-id query
1046 // was already run at some point *before* this call
1047 // got put on hold. If there's no cached photo, just
1048 // fall back to the default "unknown" image.)
1049 if (!forceGenericPhoto && infoToken.isFinal) {
1050 showCachedImage(mSecondaryCallPhoto, info);
1051 } else {
1052 showImage(mSecondaryCallPhoto, R.drawable.picture_unknown);
1053 }
1054 }
1055 } else {
1056 // We shouldn't ever get here at all for non-CDMA devices.
1057 Log.w(LOG_TAG, "displayOnHoldCallStatus: ACTIVE state on non-CDMA device");
1058 mSecondaryCallInfo.setVisibility(View.GONE);
1059 }
1060
1061 AnimationUtils.Fade.hide(mSecondaryCallPhotoDimEffect, View.GONE);
1062 break;
1063
1064 default:
1065 // There's actually no call on hold. (Presumably this call's
1066 // state is IDLE, since any other state is meaningless for the
1067 // background call.)
1068 mSecondaryCallInfo.setVisibility(View.GONE);
1069 break;
1070 }
1071 }
1072
1073 private void showSecondaryCallInfo() {
1074 // This will call ViewStub#inflate() when needed.
1075 mSecondaryCallInfo.setVisibility(View.VISIBLE);
1076 if (mSecondaryCallName == null) {
1077 mSecondaryCallName = (TextView) findViewById(R.id.secondaryCallName);
1078 }
1079 if (mSecondaryCallPhoto == null) {
1080 mSecondaryCallPhoto = (ImageView) findViewById(R.id.secondaryCallPhoto);
1081 }
1082 if (mSecondaryCallPhotoDimEffect == null) {
1083 mSecondaryCallPhotoDimEffect = findViewById(R.id.dim_effect_for_secondary_photo);
1084 mSecondaryCallPhotoDimEffect.setOnClickListener(mInCallScreen);
1085 // Add a custom OnTouchListener to manually shrink the "hit target".
1086 mSecondaryCallPhotoDimEffect.setOnTouchListener(new SmallerHitTargetTouchListener());
1087 }
1088 mInCallScreen.updateButtonStateOutsideInCallTouchUi();
1089 }
1090
1091 /**
1092 * Method which is expected to be called from
1093 * {@link InCallScreen#updateButtonStateOutsideInCallTouchUi()}.
1094 */
1095 /* package */ void setSecondaryCallClickable(boolean clickable) {
1096 if (mSecondaryCallPhotoDimEffect != null) {
1097 mSecondaryCallPhotoDimEffect.setEnabled(clickable);
1098 }
1099 }
1100
1101 private String getCallFailedString(Call call) {
1102 Connection c = call.getEarliestConnection();
1103 int resID;
1104
1105 if (c == null) {
1106 if (DBG) log("getCallFailedString: connection is null, using default values.");
1107 // if this connection is null, just assume that the
1108 // default case occurs.
1109 resID = R.string.card_title_call_ended;
1110 } else {
1111
1112 Connection.DisconnectCause cause = c.getDisconnectCause();
1113
1114 // TODO: The card *title* should probably be "Call ended" in all
1115 // cases, but if the DisconnectCause was an error condition we should
1116 // probably also display the specific failure reason somewhere...
1117
1118 switch (cause) {
1119 case BUSY:
1120 resID = R.string.callFailed_userBusy;
1121 break;
1122
1123 case CONGESTION:
1124 resID = R.string.callFailed_congestion;
1125 break;
1126
1127 case TIMED_OUT:
1128 resID = R.string.callFailed_timedOut;
1129 break;
1130
1131 case SERVER_UNREACHABLE:
1132 resID = R.string.callFailed_server_unreachable;
1133 break;
1134
1135 case NUMBER_UNREACHABLE:
1136 resID = R.string.callFailed_number_unreachable;
1137 break;
1138
1139 case INVALID_CREDENTIALS:
1140 resID = R.string.callFailed_invalid_credentials;
1141 break;
1142
1143 case SERVER_ERROR:
1144 resID = R.string.callFailed_server_error;
1145 break;
1146
1147 case OUT_OF_NETWORK:
1148 resID = R.string.callFailed_out_of_network;
1149 break;
1150
1151 case LOST_SIGNAL:
1152 case CDMA_DROP:
1153 resID = R.string.callFailed_noSignal;
1154 break;
1155
1156 case LIMIT_EXCEEDED:
1157 resID = R.string.callFailed_limitExceeded;
1158 break;
1159
1160 case POWER_OFF:
1161 resID = R.string.callFailed_powerOff;
1162 break;
1163
1164 case ICC_ERROR:
1165 resID = R.string.callFailed_simError;
1166 break;
1167
1168 case OUT_OF_SERVICE:
1169 resID = R.string.callFailed_outOfService;
1170 break;
1171
1172 case INVALID_NUMBER:
1173 case UNOBTAINABLE_NUMBER:
1174 resID = R.string.callFailed_unobtainable_number;
1175 break;
1176
1177 default:
1178 resID = R.string.card_title_call_ended;
1179 break;
1180 }
1181 }
1182 return getContext().getString(resID);
1183 }
1184
1185 /**
1186 * Updates the name / photo / number / label fields on the CallCard
1187 * based on the specified CallerInfo.
1188 *
1189 * If the current call is a conference call, use
1190 * updateDisplayForConference() instead.
1191 */
1192 private void updateDisplayForPerson(CallerInfo info,
1193 int presentation,
1194 boolean isTemporary,
1195 Call call,
1196 Connection conn) {
1197 if (DBG) log("updateDisplayForPerson(" + info + ")\npresentation:" +
1198 presentation + " isTemporary:" + isTemporary);
1199
1200 // inform the state machine that we are displaying a photo.
1201 mPhotoTracker.setPhotoRequest(info);
1202 mPhotoTracker.setPhotoState(ContactsAsyncHelper.ImageTracker.DISPLAY_IMAGE);
1203
1204 // The actual strings we're going to display onscreen:
1205 String displayName;
1206 String displayNumber = null;
1207 String label = null;
1208 Uri personUri = null;
1209 // String socialStatusText = null;
1210 // Drawable socialStatusBadge = null;
1211
1212 // Gather missing info unless the call is generic, in which case we wouldn't use
1213 // the gathered information anyway.
1214 if (info != null && !call.isGeneric()) {
1215
1216 // It appears that there is a small change in behaviour with the
1217 // PhoneUtils' startGetCallerInfo whereby if we query with an
1218 // empty number, we will get a valid CallerInfo object, but with
1219 // fields that are all null, and the isTemporary boolean input
1220 // parameter as true.
1221
1222 // In the past, we would see a NULL callerinfo object, but this
1223 // ends up causing null pointer exceptions elsewhere down the
1224 // line in other cases, so we need to make this fix instead. It
1225 // appears that this was the ONLY call to PhoneUtils
1226 // .getCallerInfo() that relied on a NULL CallerInfo to indicate
1227 // an unknown contact.
1228
1229 // Currently, infi.phoneNumber may actually be a SIP address, and
1230 // if so, it might sometimes include the "sip:" prefix. That
1231 // prefix isn't really useful to the user, though, so strip it off
1232 // if present. (For any other URI scheme, though, leave the
1233 // prefix alone.)
1234 // TODO: It would be cleaner for CallerInfo to explicitly support
1235 // SIP addresses instead of overloading the "phoneNumber" field.
1236 // Then we could remove this hack, and instead ask the CallerInfo
1237 // for a "user visible" form of the SIP address.
1238 String number = info.phoneNumber;
1239 if ((number != null) && number.startsWith("sip:")) {
1240 number = number.substring(4);
1241 }
1242
1243 if (TextUtils.isEmpty(info.name)) {
1244 // No valid "name" in the CallerInfo, so fall back to
1245 // something else.
1246 // (Typically, we promote the phone number up to the "name" slot
1247 // onscreen, and possibly display a descriptive string in the
1248 // "number" slot.)
1249 if (TextUtils.isEmpty(number)) {
1250 // No name *or* number! Display a generic "unknown" string
1251 // (or potentially some other default based on the presentation.)
1252 displayName = PhoneUtils.getPresentationString(getContext(), presentation);
1253 if (DBG) log(" ==> no name *or* number! displayName = " + displayName);
1254 } else if (presentation != PhoneConstants.PRESENTATION_ALLOWED) {
1255 // This case should never happen since the network should never send a phone #
1256 // AND a restricted presentation. However we leave it here in case of weird
1257 // network behavior
1258 displayName = PhoneUtils.getPresentationString(getContext(), presentation);
1259 if (DBG) log(" ==> presentation not allowed! displayName = " + displayName);
1260 } else if (!TextUtils.isEmpty(info.cnapName)) {
1261 // No name, but we do have a valid CNAP name, so use that.
1262 displayName = info.cnapName;
1263 info.name = info.cnapName;
1264 displayNumber = number;
1265 if (DBG) log(" ==> cnapName available: displayName '"
1266 + displayName + "', displayNumber '" + displayNumber + "'");
1267 } else {
1268 // No name; all we have is a number. This is the typical
1269 // case when an incoming call doesn't match any contact,
1270 // or if you manually dial an outgoing number using the
1271 // dialpad.
1272
1273 // Promote the phone number up to the "name" slot:
1274 displayName = number;
1275
1276 // ...and use the "number" slot for a geographical description
1277 // string if available (but only for incoming calls.)
1278 if ((conn != null) && (conn.isIncoming())) {
1279 // TODO (CallerInfoAsyncQuery cleanup): Fix the CallerInfo
1280 // query to only do the geoDescription lookup in the first
1281 // place for incoming calls.
1282 displayNumber = info.geoDescription; // may be null
1283 }
1284
1285 if (DBG) log(" ==> no name; falling back to number: displayName '"
1286 + displayName + "', displayNumber '" + displayNumber + "'");
1287 }
1288 } else {
1289 // We do have a valid "name" in the CallerInfo. Display that
1290 // in the "name" slot, and the phone number in the "number" slot.
1291 if (presentation != PhoneConstants.PRESENTATION_ALLOWED) {
1292 // This case should never happen since the network should never send a name
1293 // AND a restricted presentation. However we leave it here in case of weird
1294 // network behavior
1295 displayName = PhoneUtils.getPresentationString(getContext(), presentation);
1296 if (DBG) log(" ==> valid name, but presentation not allowed!"
1297 + " displayName = " + displayName);
1298 } else {
1299 displayName = info.name;
1300 displayNumber = number;
1301 label = info.phoneLabel;
1302 if (DBG) log(" ==> name is present in CallerInfo: displayName '"
1303 + displayName + "', displayNumber '" + displayNumber + "'");
1304 }
1305 }
1306 personUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, info.person_id);
1307 if (DBG) log("- got personUri: '" + personUri
1308 + "', based on info.person_id: " + info.person_id);
1309 } else {
1310 displayName = PhoneUtils.getPresentationString(getContext(), presentation);
1311 }
1312
1313 if (call.isGeneric()) {
1314 updateGenericInfoUi();
1315 } else {
1316 updateInfoUi(displayName, displayNumber, label);
1317 }
1318
1319 // Update mPhoto
1320 // if the temporary flag is set, we know we'll be getting another call after
1321 // the CallerInfo has been correctly updated. So, we can skip the image
1322 // loading until then.
1323
1324 // If the photoResource is filled in for the CallerInfo, (like with the
1325 // Emergency Number case), then we can just set the photo image without
1326 // requesting for an image load. Please refer to CallerInfoAsyncQuery.java
1327 // for cases where CallerInfo.photoResource may be set. We can also avoid
1328 // the image load step if the image data is cached.
1329 if (isTemporary && (info == null || !info.isCachedPhotoCurrent)) {
1330 mPhoto.setTag(null);
1331 mPhoto.setVisibility(View.INVISIBLE);
1332 } else if (info != null && info.photoResource != 0){
1333 showImage(mPhoto, info.photoResource);
1334 } else if (!showCachedImage(mPhoto, info)) {
1335 if (personUri == null) {
1336 Log.w(LOG_TAG, "personPri is null. Just use Unknown picture.");
1337 showImage(mPhoto, R.drawable.picture_unknown);
1338 } else if (personUri.equals(mLoadingPersonUri)) {
1339 if (DBG) {
1340 log("The requested Uri (" + personUri + ") is being loaded already."
1341 + " Ignoret the duplicate load request.");
1342 }
1343 } else {
1344 // Remember which person's photo is being loaded right now so that we won't issue
1345 // unnecessary load request multiple times, which will mess up animation around
1346 // the contact photo.
1347 mLoadingPersonUri = personUri;
1348
1349 // Forget the drawable previously used.
1350 mPhoto.setTag(null);
1351 // Show empty screen for a moment.
1352 mPhoto.setVisibility(View.INVISIBLE);
1353 // Load the image with a callback to update the image state.
1354 // When the load is finished, onImageLoadComplete() will be called.
1355 ContactsAsyncHelper.startObtainPhotoAsync(TOKEN_UPDATE_PHOTO_FOR_CALL_STATE,
1356 getContext(), personUri, this, new AsyncLoadCookie(mPhoto, info, call));
1357
1358 // If the image load is too slow, we show a default avatar icon afterward.
1359 // If it is fast enough, this message will be canceled on onImageLoadComplete().
1360 mHandler.removeMessages(MESSAGE_SHOW_UNKNOWN_PHOTO);
1361 mHandler.sendEmptyMessageDelayed(MESSAGE_SHOW_UNKNOWN_PHOTO, MESSAGE_DELAY);
1362 }
1363 }
1364
1365 // If the phone call is on hold, show it with darker status.
1366 // Right now we achieve it by overlaying opaque View.
1367 // Note: See also layout file about why so and what is the other possibilities.
1368 if (call.getState() == Call.State.HOLDING) {
1369 AnimationUtils.Fade.show(mPhotoDimEffect);
1370 } else {
1371 AnimationUtils.Fade.hide(mPhotoDimEffect, View.GONE);
1372 }
1373
1374 // Other text fields:
1375 updateCallTypeLabel(call);
1376 // updateSocialStatus(socialStatusText, socialStatusBadge, call); // Currently unused
1377 }
1378
1379 /**
1380 * Updates the info portion of the UI to be generic. Used for CDMA 3-way calls.
1381 */
1382 private void updateGenericInfoUi() {
1383 mName.setText(R.string.card_title_in_call);
1384 mPhoneNumber.setVisibility(View.GONE);
1385 mLabel.setVisibility(View.GONE);
1386 }
1387
1388 /**
1389 * Updates the info portion of the call card with passed in values.
1390 */
1391 private void updateInfoUi(String displayName, String displayNumber, String label) {
1392 mName.setText(displayName);
1393 mName.setVisibility(View.VISIBLE);
1394
1395 if (TextUtils.isEmpty(displayNumber)) {
1396 mPhoneNumber.setVisibility(View.GONE);
1397 // We have a real phone number as "mName" so make it always LTR
1398 mName.setTextDirection(View.TEXT_DIRECTION_LTR);
1399 } else {
1400 mPhoneNumber.setText(displayNumber);
1401 mPhoneNumber.setVisibility(View.VISIBLE);
1402 // We have a real phone number as "mPhoneNumber" so make it always LTR
1403 mPhoneNumber.setTextDirection(View.TEXT_DIRECTION_LTR);
1404 }
1405
1406 if (TextUtils.isEmpty(label)) {
1407 mLabel.setVisibility(View.GONE);
1408 } else {
1409 mLabel.setText(label);
1410 mLabel.setVisibility(View.VISIBLE);
1411 }
1412 }
1413
1414 /**
1415 * Updates the name / photo / number / label fields
1416 * for the special "conference call" state.
1417 *
1418 * If the current call has only a single connection, use
1419 * updateDisplayForPerson() instead.
1420 */
1421 private void updateDisplayForConference(Call call) {
1422 if (DBG) log("updateDisplayForConference()...");
1423
1424 int phoneType = call.getPhone().getPhoneType();
1425 if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) {
1426 // This state corresponds to both 3-Way merged call and
1427 // Call Waiting accepted call.
1428 // In this case we display the UI in a "generic" state, with
1429 // the generic "dialing" icon and no caller information,
1430 // because in this state in CDMA the user does not really know
1431 // which caller party he is talking to.
1432 showImage(mPhoto, R.drawable.picture_dialing);
1433 mName.setText(R.string.card_title_in_call);
1434 } else if ((phoneType == PhoneConstants.PHONE_TYPE_GSM)
1435 || (phoneType == PhoneConstants.PHONE_TYPE_SIP)) {
1436 // Normal GSM (or possibly SIP?) conference call.
1437 // Display the "conference call" image as the contact photo.
1438 // TODO: Better visual treatment for contact photos in a
1439 // conference call (see bug 1313252).
1440 showImage(mPhoto, R.drawable.picture_conference);
1441 mName.setText(R.string.card_title_conf_call);
1442 } else {
1443 throw new IllegalStateException("Unexpected phone type: " + phoneType);
1444 }
1445
1446 mName.setVisibility(View.VISIBLE);
1447
1448 // TODO: For a conference call, the "phone number" slot is specced
1449 // to contain a summary of who's on the call, like "Bill Foldes
1450 // and Hazel Nutt" or "Bill Foldes and 2 others".
1451 // But for now, just hide it:
1452 mPhoneNumber.setVisibility(View.GONE);
1453 mLabel.setVisibility(View.GONE);
1454
1455 // Other text fields:
1456 updateCallTypeLabel(call);
1457 // updateSocialStatus(null, null, null); // socialStatus is never visible in this state
1458
1459 // TODO: for a GSM conference call, since we do actually know who
1460 // you're talking to, consider also showing names / numbers /
1461 // photos of some of the people on the conference here, so you can
1462 // see that info without having to click "Manage conference". We
1463 // probably have enough space to show info for 2 people, at least.
1464 //
1465 // To do this, our caller would pass us the activeConnections
1466 // list, and we'd call PhoneUtils.getCallerInfo() separately for
1467 // each connection.
1468 }
1469
1470 /**
1471 * Updates the CallCard "photo" IFF the specified Call is in a state
1472 * that needs a special photo (like "busy" or "dialing".)
1473 *
1474 * If the current call does not require a special image in the "photo"
1475 * slot onscreen, don't do anything, since presumably the photo image
1476 * has already been set (to the photo of the person we're talking, or
1477 * the generic "picture_unknown" image, or the "conference call"
1478 * image.)
1479 */
1480 private void updatePhotoForCallState(Call call) {
1481 if (DBG) log("updatePhotoForCallState(" + call + ")...");
1482 int photoImageResource = 0;
1483
1484 // Check for the (relatively few) telephony states that need a
1485 // special image in the "photo" slot.
1486 Call.State state = call.getState();
1487 switch (state) {
1488 case DISCONNECTED:
1489 // Display the special "busy" photo for BUSY or CONGESTION.
1490 // Otherwise (presumably the normal "call ended" state)
1491 // leave the photo alone.
1492 Connection c = call.getEarliestConnection();
1493 // if the connection is null, we assume the default case,
1494 // otherwise update the image resource normally.
1495 if (c != null) {
1496 Connection.DisconnectCause cause = c.getDisconnectCause();
1497 if ((cause == Connection.DisconnectCause.BUSY)
1498 || (cause == Connection.DisconnectCause.CONGESTION)) {
1499 photoImageResource = R.drawable.picture_busy;
1500 }
1501 } else if (DBG) {
1502 log("updatePhotoForCallState: connection is null, ignoring.");
1503 }
1504
1505 // TODO: add special images for any other DisconnectCauses?
1506 break;
1507
1508 case ALERTING:
1509 case DIALING:
1510 default:
1511 // Leave the photo alone in all other states.
1512 // If this call is an individual call, and the image is currently
1513 // displaying a state, (rather than a photo), we'll need to update
1514 // the image.
1515 // This is for the case where we've been displaying the state and
1516 // now we need to restore the photo. This can happen because we
1517 // only query the CallerInfo once, and limit the number of times
1518 // the image is loaded. (So a state image may overwrite the photo
1519 // and we would otherwise have no way of displaying the photo when
1520 // the state goes away.)
1521
1522 // if the photoResource field is filled-in in the Connection's
1523 // caller info, then we can just use that instead of requesting
1524 // for a photo load.
1525
1526 // look for the photoResource if it is available.
1527 CallerInfo ci = null;
1528 {
1529 Connection conn = null;
1530 int phoneType = call.getPhone().getPhoneType();
1531 if (phoneType == PhoneConstants.PHONE_TYPE_CDMA) {
1532 conn = call.getLatestConnection();
1533 } else if ((phoneType == PhoneConstants.PHONE_TYPE_GSM)
1534 || (phoneType == PhoneConstants.PHONE_TYPE_SIP)) {
1535 conn = call.getEarliestConnection();
1536 } else {
1537 throw new IllegalStateException("Unexpected phone type: " + phoneType);
1538 }
1539
1540 if (conn != null) {
1541 Object o = conn.getUserData();
1542 if (o instanceof CallerInfo) {
1543 ci = (CallerInfo) o;
1544 } else if (o instanceof PhoneUtils.CallerInfoToken) {
1545 ci = ((PhoneUtils.CallerInfoToken) o).currentInfo;
1546 }
1547 }
1548 }
1549
1550 if (ci != null) {
1551 photoImageResource = ci.photoResource;
1552 }
1553
1554 // If no photoResource found, check to see if this is a conference call. If
1555 // it is not a conference call:
1556 // 1. Try to show the cached image
1557 // 2. If the image is not cached, check to see if a load request has been
1558 // made already.
1559 // 3. If the load request has not been made [DISPLAY_DEFAULT], start the
1560 // request and note that it has started by updating photo state with
1561 // [DISPLAY_IMAGE].
1562 if (photoImageResource == 0) {
1563 if (!PhoneUtils.isConferenceCall(call)) {
1564 if (!showCachedImage(mPhoto, ci) && (mPhotoTracker.getPhotoState() ==
1565 ContactsAsyncHelper.ImageTracker.DISPLAY_DEFAULT)) {
1566 Uri photoUri = mPhotoTracker.getPhotoUri();
1567 if (photoUri == null) {
1568 Log.w(LOG_TAG, "photoUri became null. Show default avatar icon");
1569 showImage(mPhoto, R.drawable.picture_unknown);
1570 } else {
1571 if (DBG) {
1572 log("start asynchronous load inside updatePhotoForCallState()");
1573 }
1574 mPhoto.setTag(null);
1575 // Make it invisible for a moment
1576 mPhoto.setVisibility(View.INVISIBLE);
1577 ContactsAsyncHelper.startObtainPhotoAsync(TOKEN_DO_NOTHING,
1578 getContext(), photoUri, this,
1579 new AsyncLoadCookie(mPhoto, ci, null));
1580 }
1581 mPhotoTracker.setPhotoState(
1582 ContactsAsyncHelper.ImageTracker.DISPLAY_IMAGE);
1583 }
1584 }
1585 } else {
1586 showImage(mPhoto, photoImageResource);
1587 mPhotoTracker.setPhotoState(ContactsAsyncHelper.ImageTracker.DISPLAY_IMAGE);
1588 return;
1589 }
1590 break;
1591 }
1592
1593 if (photoImageResource != 0) {
1594 if (DBG) log("- overrriding photo image: " + photoImageResource);
1595 showImage(mPhoto, photoImageResource);
1596 // Track the image state.
1597 mPhotoTracker.setPhotoState(ContactsAsyncHelper.ImageTracker.DISPLAY_DEFAULT);
1598 }
1599 }
1600
1601 /**
1602 * Try to display the cached image from the callerinfo object.
1603 *
1604 * @return true if we were able to find the image in the cache, false otherwise.
1605 */
1606 private static final boolean showCachedImage(ImageView view, CallerInfo ci) {
1607 if ((ci != null) && ci.isCachedPhotoCurrent) {
1608 if (ci.cachedPhoto != null) {
1609 showImage(view, ci.cachedPhoto);
1610 } else {
1611 showImage(view, R.drawable.picture_unknown);
1612 }
1613 return true;
1614 }
1615 return false;
1616 }
1617
1618 /** Helper function to display the resource in the imageview AND ensure its visibility.*/
1619 private static final void showImage(ImageView view, int resource) {
1620 showImage(view, view.getContext().getResources().getDrawable(resource));
1621 }
1622
1623 private static final void showImage(ImageView view, Bitmap bitmap) {
1624 showImage(view, new BitmapDrawable(view.getContext().getResources(), bitmap));
1625 }
1626
1627 /** Helper function to display the drawable in the imageview AND ensure its visibility.*/
1628 private static final void showImage(ImageView view, Drawable drawable) {
1629 Resources res = view.getContext().getResources();
1630 Drawable current = (Drawable) view.getTag();
1631
1632 if (current == null) {
1633 if (DBG) log("Start fade-in animation for " + view);
1634 view.setImageDrawable(drawable);
1635 AnimationUtils.Fade.show(view);
1636 view.setTag(drawable);
1637 } else {
1638 AnimationUtils.startCrossFade(view, current, drawable);
1639 view.setVisibility(View.VISIBLE);
1640 }
1641 }
1642
1643 /**
1644 * Returns the special card title used in emergency callback mode (ECM),
1645 * which shows your own phone number.
1646 */
1647 private String getECMCardTitle(Context context, Phone phone) {
1648 String rawNumber = phone.getLine1Number(); // may be null or empty
1649 String formattedNumber;
1650 if (!TextUtils.isEmpty(rawNumber)) {
1651 formattedNumber = PhoneNumberUtils.formatNumber(rawNumber);
1652 } else {
1653 formattedNumber = context.getString(R.string.unknown);
1654 }
1655 String titleFormat = context.getString(R.string.card_title_my_phone_number);
1656 return String.format(titleFormat, formattedNumber);
1657 }
1658
1659 /**
1660 * Updates the "Call type" label, based on the current foreground call.
1661 * This is a special label and/or branding we display for certain
1662 * kinds of calls.
1663 *
1664 * (So far, this is used only for SIP calls, which get an
1665 * "Internet call" label. TODO: But eventually, the telephony
1666 * layer might allow each pluggable "provider" to specify a string
1667 * and/or icon to be displayed here.)
1668 */
1669 private void updateCallTypeLabel(Call call) {
1670 int phoneType = (call != null) ? call.getPhone().getPhoneType() :
1671 PhoneConstants.PHONE_TYPE_NONE;
1672 if (phoneType == PhoneConstants.PHONE_TYPE_SIP) {
1673 mCallTypeLabel.setVisibility(View.VISIBLE);
1674 mCallTypeLabel.setText(R.string.incall_call_type_label_sip);
1675 mCallTypeLabel.setTextColor(mTextColorCallTypeSip);
1676 // If desired, we could also display a "badge" next to the label, as follows:
1677 // mCallTypeLabel.setCompoundDrawablesWithIntrinsicBounds(
1678 // callTypeSpecificBadge, null, null, null);
1679 // mCallTypeLabel.setCompoundDrawablePadding((int) (mDensity * 6));
1680 } else {
1681 mCallTypeLabel.setVisibility(View.GONE);
1682 }
1683 }
1684
1685 /**
1686 * Updates the "social status" label with the specified text and
1687 * (optional) badge.
1688 */
1689 /*private void updateSocialStatus(String socialStatusText,
1690 Drawable socialStatusBadge,
1691 Call call) {
1692 // The socialStatus field is *only* visible while an incoming call
1693 // is ringing, never in any other call state.
1694 if ((socialStatusText != null)
1695 && (call != null)
1696 && call.isRinging()
1697 && !call.isGeneric()) {
1698 mSocialStatus.setVisibility(View.VISIBLE);
1699 mSocialStatus.setText(socialStatusText);
1700 mSocialStatus.setCompoundDrawablesWithIntrinsicBounds(
1701 socialStatusBadge, null, null, null);
1702 mSocialStatus.setCompoundDrawablePadding((int) (mDensity * 6));
1703 } else {
1704 mSocialStatus.setVisibility(View.GONE);
1705 }
1706 }*/
1707
1708 /**
1709 * Hides the top-level UI elements of the call card: The "main
1710 * call card" element representing the current active or ringing call,
1711 * and also the info areas for "ongoing" or "on hold" calls in some
1712 * states.
1713 *
1714 * This is intended to be used in special states where the normal
1715 * in-call UI is totally replaced by some other UI, like OTA mode on a
1716 * CDMA device.
1717 *
1718 * To bring back the regular CallCard UI, just re-run the normal
1719 * updateState() call sequence.
1720 */
1721 public void hideCallCardElements() {
1722 mPrimaryCallInfo.setVisibility(View.GONE);
1723 mSecondaryCallInfo.setVisibility(View.GONE);
1724 }
1725
1726 /*
1727 * Updates the hint (like "Rotate to answer") that we display while
1728 * the user is dragging the incoming call RotarySelector widget.
1729 */
1730 /* package */ void setIncomingCallWidgetHint(int hintTextResId, int hintColorResId) {
1731 mIncomingCallWidgetHintTextResId = hintTextResId;
1732 mIncomingCallWidgetHintColorResId = hintColorResId;
1733 }
1734
1735 // Accessibility event support.
1736 // Since none of the CallCard elements are focusable, we need to manually
1737 // fill in the AccessibilityEvent here (so that the name / number / etc will
1738 // get pronounced by a screen reader, for example.)
1739 @Override
1740 public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
1741 if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
1742 dispatchPopulateAccessibilityEvent(event, mName);
1743 dispatchPopulateAccessibilityEvent(event, mPhoneNumber);
1744 return true;
1745 }
1746
1747 dispatchPopulateAccessibilityEvent(event, mCallStateLabel);
1748 dispatchPopulateAccessibilityEvent(event, mPhoto);
1749 dispatchPopulateAccessibilityEvent(event, mName);
1750 dispatchPopulateAccessibilityEvent(event, mPhoneNumber);
1751 dispatchPopulateAccessibilityEvent(event, mLabel);
1752 // dispatchPopulateAccessibilityEvent(event, mSocialStatus);
1753 if (mSecondaryCallName != null) {
1754 dispatchPopulateAccessibilityEvent(event, mSecondaryCallName);
1755 }
1756 if (mSecondaryCallPhoto != null) {
1757 dispatchPopulateAccessibilityEvent(event, mSecondaryCallPhoto);
1758 }
1759 return true;
1760 }
1761
1762 private void dispatchPopulateAccessibilityEvent(AccessibilityEvent event, View view) {
1763 List<CharSequence> eventText = event.getText();
1764 int size = eventText.size();
1765 view.dispatchPopulateAccessibilityEvent(event);
1766 // if no text added write null to keep relative position
1767 if (size == eventText.size()) {
1768 eventText.add(null);
1769 }
1770 }
1771
1772 public void clear() {
1773 // The existing phone design is to keep an instance of call card forever. Until that
1774 // design changes, this method is needed to clear (reset) the call card for the next call
1775 // so old data is not shown.
1776
1777 // Other elements can also be cleared here. Starting with elapsed time to fix a bug.
1778 mElapsedTime.setVisibility(View.GONE);
1779 mElapsedTime.setText(null);
1780 }
1781
1782
1783 // Debugging / testing code
1784
1785 private static void log(String msg) {
1786 Log.d(LOG_TAG, msg);
1787 }
1788}