merge in klp-release history after reset to klp-dev
diff --git a/InCallUI/src/com/android/incallui/CallButtonPresenter.java b/InCallUI/src/com/android/incallui/CallButtonPresenter.java
index 3642630..3b1411b 100644
--- a/InCallUI/src/com/android/incallui/CallButtonPresenter.java
+++ b/InCallUI/src/com/android/incallui/CallButtonPresenter.java
@@ -33,7 +33,6 @@
         implements InCallStateListener, AudioModeListener, IncomingCallListener {
 
     private Call mCall;
-    private ProximitySensor mProximitySensor;
     private boolean mAutomaticallyMuted = false;
     private boolean mPreviousMuteState = false;
 
@@ -49,7 +48,6 @@
     public void onUiReady(CallButtonUi ui) {
         super.onUiReady(ui);
 
-        mProximitySensor = InCallPresenter.getInstance().getProximitySensor();
         AudioModeProvider.getInstance().addListener(this);
 
         // register for call state changes last
@@ -64,8 +62,6 @@
         InCallPresenter.getInstance().removeListener(this);
         AudioModeProvider.getInstance().removeListener(this);
         InCallPresenter.getInstance().removeIncomingCallListener(this);
-
-        mProximitySensor = null;
     }
 
     @Override
@@ -210,8 +206,6 @@
     public void showDialpadClicked(boolean checked) {
         Log.v(this, "Show dialpad " + String.valueOf(checked));
         getUi().displayDialpad(checked);
-        mProximitySensor.onDialpadVisible(checked);
-
         updateExtraButtonRow();
     }
 
diff --git a/InCallUI/src/com/android/incallui/CallerInfo.java b/InCallUI/src/com/android/incallui/CallerInfo.java
index 4047d99..c5d3971 100644
--- a/InCallUI/src/com/android/incallui/CallerInfo.java
+++ b/InCallUI/src/com/android/incallui/CallerInfo.java
@@ -20,6 +20,7 @@
 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;
@@ -560,17 +561,27 @@
      *         is in.
      */
     private static String getCurrentCountryIso(Context context, Locale locale) {
-      String countryIso;
-      CountryDetector detector = (CountryDetector) context.getSystemService(
-          Context.COUNTRY_DETECTOR);
-      if (detector != null) {
-        countryIso = detector.detectCountry().getCountryIso();
-      } else {
-        countryIso = locale.getCountry();
-            Log.v(TAG, "No CountryDetector; falling back to countryIso based on 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;
+        }
+        return countryIso;
+    }
+
+    protected static String getCurrentCountryIso(Context context) {
+        return getCurrentCountryIso(context, Locale.getDefault());
     }
 
     /**
diff --git a/InCallUI/src/com/android/incallui/CallerInfoAsyncQuery.java b/InCallUI/src/com/android/incallui/CallerInfoAsyncQuery.java
index c9d282b..c09baf2 100644
--- a/InCallUI/src/com/android/incallui/CallerInfoAsyncQuery.java
+++ b/InCallUI/src/com/android/incallui/CallerInfoAsyncQuery.java
@@ -20,7 +20,6 @@
 import android.content.Context;
 import android.database.Cursor;
 import android.database.SQLException;
-import android.location.CountryDetector;
 import android.net.Uri;
 import android.os.Handler;
 import android.os.Looper;
@@ -269,11 +268,9 @@
 
                     // Use the number entered by the user for display.
                     if (!TextUtils.isEmpty(cw.number)) {
-                        CountryDetector detector = (CountryDetector) mQueryContext.getSystemService(
-                                Context.COUNTRY_DETECTOR);
                         mCallerInfo.phoneNumber = PhoneNumberUtils.formatNumber(cw.number,
                                 mCallerInfo.normalizedNumber,
-                                detector.detectCountry().getCountryIso());
+                                CallerInfo.getCurrentCountryIso(mQueryContext));
                     }
                 }
 
diff --git a/InCallUI/src/com/android/incallui/InCallActivity.java b/InCallUI/src/com/android/incallui/InCallActivity.java
index ac21d52..58db132 100644
--- a/InCallUI/src/com/android/incallui/InCallActivity.java
+++ b/InCallUI/src/com/android/incallui/InCallActivity.java
@@ -389,6 +389,8 @@
             mDialpadFragment.setVisible(false);
             mCallCardFragment.setVisible(true);
         }
+
+        InCallPresenter.getInstance().getProximitySensor().onDialpadVisible(showDialpad);
     }
 
     public boolean isDialpadVisible() {
diff --git a/InCallUI/src/com/android/incallui/Log.java b/InCallUI/src/com/android/incallui/Log.java
index 35cb370..c859e5c 100644
--- a/InCallUI/src/com/android/incallui/Log.java
+++ b/InCallUI/src/com/android/incallui/Log.java
@@ -24,8 +24,7 @@
     // Generic tag for all In Call logging
     private static final String TAG = "InCall";
 
-    public static final boolean DEBUG = android.util.Log.isLoggable(TAG, android.util.Log.DEBUG)
-            || (System.getProperty("ro.build.type", "").equals("userdebug"));
+    public static final boolean DEBUG = android.util.Log.isLoggable(TAG, android.util.Log.DEBUG);
     public static final boolean VERBOSE = android.util.Log.isLoggable(TAG,
             android.util.Log.VERBOSE);
     public static final String TAG_DELIMETER = " - ";