summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/incallui/AudioModeProvider.java3
-rw-r--r--src/com/android/incallui/CallButtonPresenter.java19
-rw-r--r--src/com/android/incallui/CallHandlerService.java5
-rw-r--r--src/com/android/incallui/CallList.java8
-rw-r--r--src/com/android/incallui/CallerInfo.java67
-rw-r--r--src/com/android/incallui/CallerInfoAsyncQuery.java19
-rw-r--r--src/com/android/incallui/ContactInfoCache.java10
-rw-r--r--src/com/android/incallui/InCallActivity.java2
-rw-r--r--src/com/android/incallui/InCallPresenter.java2
9 files changed, 61 insertions, 74 deletions
diff --git a/src/com/android/incallui/AudioModeProvider.java b/src/com/android/incallui/AudioModeProvider.java
index 87008756..407aa3a0 100644
--- a/src/com/android/incallui/AudioModeProvider.java
+++ b/src/com/android/incallui/AudioModeProvider.java
@@ -16,13 +16,12 @@
package com.android.incallui;
-import com.google.android.collect.Lists;
+import com.google.common.collect.Lists;
import com.android.services.telephony.common.AudioMode;
import java.util.List;
-
/**
* Proxy class for getting and setting the audio mode.
*/
diff --git a/src/com/android/incallui/CallButtonPresenter.java b/src/com/android/incallui/CallButtonPresenter.java
index be257378..67a642b0 100644
--- a/src/com/android/incallui/CallButtonPresenter.java
+++ b/src/com/android/incallui/CallButtonPresenter.java
@@ -16,6 +16,8 @@
package com.android.incallui;
+import com.android.contacts.common.util.PhoneNumberHelper;
+import com.android.contacts.common.util.TelephonyManagerUtils;
import com.android.incallui.AudioModeProvider.AudioModeListener;
import com.android.incallui.InCallPresenter.InCallState;
import com.android.incallui.InCallPresenter.InCallStateListener;
@@ -24,7 +26,7 @@ import com.android.services.telephony.common.AudioMode;
import com.android.services.telephony.common.Call;
import com.android.services.telephony.common.Call.Capabilities;
-import android.telephony.PhoneNumberUtils;
+import android.app.Fragment;
/**
* Logic for call buttons.
@@ -66,6 +68,7 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto
@Override
public void onStateChange(InCallState state, CallList callList) {
+ CallButtonUi ui = getUi();
if (state == InCallState.OUTGOING) {
mCall = callList.getOutgoingCall();
@@ -76,12 +79,18 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto
// (On previous releases we showed it when in-call shows up, before waiting for
// OUTGOING. We may want to do that once we start showing "Voice mail" label on
// the dialpad too.)
- if (mPreviousState == InCallState.OUTGOING
- && mCall != null && PhoneNumberUtils.isVoiceMailNumber(mCall.getNumber())) {
- getUi().displayDialpad(true);
+ if (ui != null) {
+ final Fragment callButtonFragment = (Fragment) ui;
+ if (mPreviousState == InCallState.OUTGOING && mCall != null
+ && TelephonyManagerUtils.isVoiceMailNumber(mCall.getNumber(),
+ callButtonFragment.getActivity())) {
+ ui.displayDialpad(true);
+ }
}
} else if (state == InCallState.INCOMING) {
- getUi().displayDialpad(false);
+ if (ui != null) {
+ ui.displayDialpad(false);
+ }
mCall = null;
} else {
mCall = null;
diff --git a/src/com/android/incallui/CallHandlerService.java b/src/com/android/incallui/CallHandlerService.java
index 06b10ab2..ebd20c30 100644
--- a/src/com/android/incallui/CallHandlerService.java
+++ b/src/com/android/incallui/CallHandlerService.java
@@ -233,7 +233,10 @@ public class CallHandlerService extends Service {
*/
private class MainHandler extends Handler {
MainHandler() {
- super(getApplicationContext().getMainLooper(), null, true);
+ // TODO: Evaluate whether we need to send messages asynchronously. The Handler
+ // implementation in the public API handles message sending synchronously, which may
+ // cause deadlocks.
+ super(getApplicationContext().getMainLooper());
}
@Override
diff --git a/src/com/android/incallui/CallList.java b/src/com/android/incallui/CallList.java
index dee27557..e8edc4d3 100644
--- a/src/com/android/incallui/CallList.java
+++ b/src/com/android/incallui/CallList.java
@@ -16,9 +16,9 @@
package com.android.incallui;
-import com.google.android.collect.Lists;
-import com.google.android.collect.Maps;
-import com.google.android.collect.Sets;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
import com.google.common.base.Preconditions;
import android.os.Handler;
@@ -50,7 +50,7 @@ public class CallList {
private final HashMap<Integer, Call> mCallMap = Maps.newHashMap();
private final HashMap<Integer, ArrayList<String>> mCallTextReponsesMap =
Maps.newHashMap();
- private final Set<Listener> mListeners = Sets.newArraySet();
+ private final Set<Listener> mListeners = Sets.newHashSet();
private final HashMap<Integer, List<CallUpdateListener>> mCallUpdateListenerMap = Maps
.newHashMap();
diff --git a/src/com/android/incallui/CallerInfo.java b/src/com/android/incallui/CallerInfo.java
index ea6ebd9f..2e89e48d 100644
--- a/src/com/android/incallui/CallerInfo.java
+++ b/src/com/android/incallui/CallerInfo.java
@@ -16,29 +16,27 @@
package com.android.incallui;
+import com.android.contacts.common.util.PhoneNumberHelper;
+import com.android.contacts.common.util.TelephonyManagerUtils;
import android.content.Context;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
-import android.location.Country;
-import android.location.CountryDetector;
import android.net.Uri;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.Data;
import android.provider.ContactsContract.PhoneLookup;
import android.provider.ContactsContract.RawContacts;
import android.telephony.PhoneNumberUtils;
-import android.telephony.TelephonyManager;
import android.text.TextUtils;
-import com.android.i18n.phonenumbers.geocoding.PhoneNumberOfflineGeocoder;
-import com.android.i18n.phonenumbers.NumberParseException;
-import com.android.i18n.phonenumbers.PhoneNumberUtil;
-import com.android.i18n.phonenumbers.Phonenumber.PhoneNumber;
+import com.google.i18n.phonenumbers.geocoding.PhoneNumberOfflineGeocoder;
+import com.google.i18n.phonenumbers.NumberParseException;
+import com.google.i18n.phonenumbers.PhoneNumberUtil;
+import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber;
import java.util.Locale;
-
/**
* Looks up caller information for the given phone number.
*
@@ -195,7 +193,7 @@ public class CallerInfo {
if (typeColumnIndex != -1) {
info.numberType = cursor.getInt(typeColumnIndex);
info.numberLabel = cursor.getString(columnIndex);
- info.phoneLabel = Phone.getDisplayLabel(context,
+ info.phoneLabel = Phone.getTypeLabel(context.getResources(),
info.numberType, info.numberLabel)
.toString();
}
@@ -274,10 +272,10 @@ public class CallerInfo {
// Change the callerInfo number ONLY if it is an emergency number
// or if it is the voicemail number. If it is either, take a
// shortcut and skip the query.
- if (PhoneNumberUtils.isLocalEmergencyNumber(number, context)) {
+ if (PhoneNumberHelper.isLocalEmergencyNumber(number, context)) {
return new CallerInfo().markAsEmergency(context);
- } else if (PhoneNumberUtils.isVoiceMailNumber(number)) {
- return new CallerInfo().markAsVoiceMail();
+ } else if (TelephonyManagerUtils.isVoiceMailNumber(number, context)) {
+ return new CallerInfo().markAsVoiceMail(context);
}
Uri contactUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
@@ -307,8 +305,8 @@ public class CallerInfo {
static CallerInfo doSecondaryLookupIfNecessary(Context context,
String number, CallerInfo previousResult) {
if (!previousResult.contactExists
- && PhoneNumberUtils.isUriNumber(number)) {
- String username = PhoneNumberUtils.getUsernameFromUriNumber(number);
+ && PhoneNumberHelper.isUriNumber(number)) {
+ String username = PhoneNumberHelper.getUsernameFromUriNumber(number);
if (PhoneNumberUtils.isGlobalPhoneNumber(username)) {
previousResult = getCallerInfo(context,
Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
@@ -396,13 +394,14 @@ public class CallerInfo {
*/
// TODO: As in the emergency number handling, we end up writing a
// string in the phone number field.
- /* package */ CallerInfo markAsVoiceMail() {
+ /* package */ CallerInfo markAsVoiceMail(Context context) {
mIsVoiceMail = true;
try {
- String voiceMailLabel = TelephonyManager.getDefault().getVoiceMailAlphaTag();
-
- phoneNumber = voiceMailLabel;
+ // For voicemail calls, we display the voice mail tag
+ // instead of the real phone number in the "number"
+ // field.
+ phoneNumber = TelephonyManagerUtils.getVoiceMailAlphaTag(context);
} catch (SecurityException se) {
// Should never happen: if this process does not have
// permission to retrieve VM tag, it should not have
@@ -534,7 +533,7 @@ public class CallerInfo {
PhoneNumberOfflineGeocoder geocoder = PhoneNumberOfflineGeocoder.getInstance();
Locale locale = context.getResources().getConfiguration().locale;
- String countryIso = getCurrentCountryIso(context, locale);
+ String countryIso = TelephonyManagerUtils.getCurrentCountryIso(context, locale);
PhoneNumber pn = null;
try {
Log.v(TAG, "parsing '" + number
@@ -550,37 +549,9 @@ public class CallerInfo {
String description = geocoder.getDescriptionForNumber(pn, locale);
Log.v(TAG, "- got description: '" + description + "'");
return description;
- } else {
- return null;
}
- }
-
- /**
- * @return The ISO 3166-1 two letters country code of the country the user
- * is in.
- */
- private static String getCurrentCountryIso(Context context, Locale locale) {
- String countryIso = null;
- CountryDetector detector = (CountryDetector) context.getSystemService(
- Context.COUNTRY_DETECTOR);
- if (detector != null) {
- Country country = detector.detectCountry();
- if (country != null) {
- countryIso = country.getCountryIso();
- } else {
- Log.e(TAG, "CountryDetector.detectCountry() returned null.");
- }
- }
- if (countryIso == null) {
- countryIso = locale.getCountry();
- Log.w(TAG, "No CountryDetector; falling back to countryIso based on locale: "
- + countryIso);
- }
- return countryIso;
- }
- protected static String getCurrentCountryIso(Context context) {
- return getCurrentCountryIso(context, Locale.getDefault());
+ return null;
}
/**
diff --git a/src/com/android/incallui/CallerInfoAsyncQuery.java b/src/com/android/incallui/CallerInfoAsyncQuery.java
index c09baf21..a186d37f 100644
--- a/src/com/android/incallui/CallerInfoAsyncQuery.java
+++ b/src/com/android/incallui/CallerInfoAsyncQuery.java
@@ -27,9 +27,13 @@ import android.os.Message;
import android.provider.ContactsContract.CommonDataKinds.SipAddress;
import android.provider.ContactsContract.Data;
import android.provider.ContactsContract.PhoneLookup;
-import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
+import com.android.contacts.common.util.PhoneNumberHelper;
+import com.android.contacts.common.util.TelephonyManagerUtils;
+
+import java.util.Locale;
+
/**
* Helper class to make it easier to run asynchronous caller-id lookup queries.
* @see CallerInfo
@@ -231,7 +235,7 @@ public class CallerInfoAsyncQuery {
// comments at the top of CallerInfo class).
mCallerInfo = new CallerInfo().markAsEmergency(mQueryContext);
} else if (cw.event == EVENT_VOICEMAIL_NUMBER) {
- mCallerInfo = new CallerInfo().markAsVoiceMail();
+ mCallerInfo = new CallerInfo().markAsVoiceMail(mQueryContext);
} else {
mCallerInfo = CallerInfo.getCallerInfo(mQueryContext, mQueryUri, cursor);
Log.d(this, "==> Got mCallerInfo: " + mCallerInfo);
@@ -268,9 +272,10 @@ public class CallerInfoAsyncQuery {
// Use the number entered by the user for display.
if (!TextUtils.isEmpty(cw.number)) {
- mCallerInfo.phoneNumber = PhoneNumberUtils.formatNumber(cw.number,
+ mCallerInfo.phoneNumber = PhoneNumberHelper.formatNumber(cw.number,
mCallerInfo.normalizedNumber,
- CallerInfo.getCurrentCountryIso(mQueryContext));
+ TelephonyManagerUtils.getCurrentCountryIso(mQueryContext,
+ Locale.getDefault()));
}
}
@@ -343,7 +348,7 @@ public class CallerInfoAsyncQuery {
String selection;
String[] selectionArgs;
- if (PhoneNumberUtils.isUriNumber(number)) {
+ if (PhoneNumberHelper.isUriNumber(number)) {
// "number" is really a SIP address.
Log.d(LOG_TAG, " - Treating number as a SIP address: " + /* number */"xxxxxxx");
@@ -396,9 +401,9 @@ public class CallerInfoAsyncQuery {
cw.number = number;
// check to see if these are recognized numbers, and use shortcuts if we can.
- if (PhoneNumberUtils.isLocalEmergencyNumber(number, context)) {
+ if (PhoneNumberHelper.isLocalEmergencyNumber(number, context)) {
cw.event = EVENT_EMERGENCY_NUMBER;
- } else if (PhoneNumberUtils.isVoiceMailNumber(number)) {
+ } else if (TelephonyManagerUtils.isVoiceMailNumber(number, context)) {
cw.event = EVENT_VOICEMAIL_NUMBER;
} else {
cw.event = EVENT_NEW_QUERY;
diff --git a/src/com/android/incallui/ContactInfoCache.java b/src/com/android/incallui/ContactInfoCache.java
index 448de7fe..54de7057 100644
--- a/src/com/android/incallui/ContactInfoCache.java
+++ b/src/com/android/incallui/ContactInfoCache.java
@@ -25,17 +25,17 @@ import android.net.Uri;
import android.os.Looper;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.CommonDataKinds.Phone;
-import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
+import com.android.contacts.common.util.PhoneNumberHelper;
import com.android.incallui.service.PhoneNumberService;
import com.android.incalluibind.ServiceFactory;
import com.android.services.telephony.common.Call;
import com.android.services.telephony.common.CallIdentification;
import com.android.services.telephony.common.MoreStrings;
-import com.google.android.collect.Lists;
-import com.google.android.collect.Maps;
-import com.google.android.collect.Sets;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
@@ -376,7 +376,7 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete
String number = info.phoneNumber;
if (!TextUtils.isEmpty(number)) {
- isSipCall = PhoneNumberUtils.isUriNumber(number);
+ isSipCall = PhoneNumberHelper.isUriNumber(number);
if (number.startsWith("sip:")) {
number = number.substring(4);
}
diff --git a/src/com/android/incallui/InCallActivity.java b/src/com/android/incallui/InCallActivity.java
index 08a8f12d..9c408a6f 100644
--- a/src/com/android/incallui/InCallActivity.java
+++ b/src/com/android/incallui/InCallActivity.java
@@ -267,7 +267,7 @@ public class InCallActivity extends Activity {
// Dump starting from the top-level view of the entire activity:
Window w = this.getWindow();
View decorView = w.getDecorView();
- decorView.debug();
+ Log.d(this, "View dump:" + decorView);
return true;
}
break;
diff --git a/src/com/android/incallui/InCallPresenter.java b/src/com/android/incallui/InCallPresenter.java
index 8bec492d..69eba98d 100644
--- a/src/com/android/incallui/InCallPresenter.java
+++ b/src/com/android/incallui/InCallPresenter.java
@@ -17,7 +17,7 @@
package com.android.incallui;
import com.android.incallui.service.PhoneNumberService;
-import com.google.android.collect.Sets;
+import com.google.common.collect.Sets;
import com.google.common.base.Preconditions;
import android.content.Context;