diff options
author | Christine Chen <christinech@google.com> | 2013-10-18 16:50:13 -0700 |
---|---|---|
committer | Christine Chen <christinech@google.com> | 2013-10-25 13:49:29 -0700 |
commit | 27ef1e6c1ae0a0b6b15c7ff83cbb7396d7bd976e (patch) | |
tree | ae7e3be29f6576261abcc2c2fbb8c2ce0d3cb4b1 /InCallUI | |
parent | c41b2a6789b92b564c9c1c8cdbb926079e4215fa (diff) |
Removing private dependencies in InCallUi
- This CL addresses most of the private API calls in InCallUi.
- This CL removed Android.mk as we are not building InCallUi.apk
separately anymore. Changes to make an unbundled app will go into
Dialer, GoogleDialer, and Contacts apps' makefiles.
- Separated CLs will add libphonenumber, libgeocoding, and util classes
for TelephonyManager and PhoneNumberUtils.
- The only thing left for InCallUi is to unbundle ProximitySensor.
Currently PowerManager's functions to deal with the proximity sensor
are all private. It will take a rather substaintial amount of work to
implement the proximity sensor functions ourselves (read proximity
sensor event values, ask the screen to turn on, etc.). So we should
rather push to get those functions into the public API.
Change-Id: I18b3c52adb41c6131c1eb3c07ce32ebd56d0cc59
Diffstat (limited to 'InCallUI')
10 files changed, 61 insertions, 92 deletions
diff --git a/InCallUI/Android.mk b/InCallUI/Android.mk deleted file mode 100644 index 74c91ebfd..000000000 --- a/InCallUI/Android.mk +++ /dev/null @@ -1,18 +0,0 @@ -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_STATIC_JAVA_LIBRARIES := com.android.services.telephony.common \ - guava \ - -LOCAL_SRC_FILES := $(call all-java-files-under, src) - -LOCAL_PACKAGE_NAME := InCallUI -LOCAL_CERTIFICATE := platform -LOCAL_PRIVELEGED_MODULE := false - -LOCAL_PROGUARD_FLAG_FILES := proguard.flags - -include $(BUILD_PACKAGE) - -# Build the test package -include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/InCallUI/src/com/android/incallui/AudioModeProvider.java b/InCallUI/src/com/android/incallui/AudioModeProvider.java index 870087565..407aa3a0f 100644 --- a/InCallUI/src/com/android/incallui/AudioModeProvider.java +++ b/InCallUI/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/InCallUI/src/com/android/incallui/CallButtonPresenter.java b/InCallUI/src/com/android/incallui/CallButtonPresenter.java index be257378f..67a642b06 100644 --- a/InCallUI/src/com/android/incallui/CallButtonPresenter.java +++ b/InCallUI/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/InCallUI/src/com/android/incallui/CallHandlerService.java b/InCallUI/src/com/android/incallui/CallHandlerService.java index 06b10ab23..ebd20c307 100644 --- a/InCallUI/src/com/android/incallui/CallHandlerService.java +++ b/InCallUI/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/InCallUI/src/com/android/incallui/CallList.java b/InCallUI/src/com/android/incallui/CallList.java index ba123b0c1..125ec164d 100644 --- a/InCallUI/src/com/android/incallui/CallList.java +++ b/InCallUI/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; @@ -49,7 +49,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/InCallUI/src/com/android/incallui/CallerInfo.java b/InCallUI/src/com/android/incallui/CallerInfo.java index ea6ebd9f3..2e89e48d9 100644 --- a/InCallUI/src/com/android/incallui/CallerInfo.java +++ b/InCallUI/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/InCallUI/src/com/android/incallui/CallerInfoAsyncQuery.java b/InCallUI/src/com/android/incallui/CallerInfoAsyncQuery.java index c09baf210..a186d37fe 100644 --- a/InCallUI/src/com/android/incallui/CallerInfoAsyncQuery.java +++ b/InCallUI/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/InCallUI/src/com/android/incallui/ContactInfoCache.java b/InCallUI/src/com/android/incallui/ContactInfoCache.java index 45a38c7cf..c950ed417 100644 --- a/InCallUI/src/com/android/incallui/ContactInfoCache.java +++ b/InCallUI/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; @@ -375,7 +375,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/InCallUI/src/com/android/incallui/InCallActivity.java b/InCallUI/src/com/android/incallui/InCallActivity.java index 58db132a6..d018b9d8a 100644 --- a/InCallUI/src/com/android/incallui/InCallActivity.java +++ b/InCallUI/src/com/android/incallui/InCallActivity.java @@ -259,7 +259,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/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java index 5830e726c..27dd569fc 100644 --- a/InCallUI/src/com/android/incallui/InCallPresenter.java +++ b/InCallUI/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; |