Merge "Removed telephony apex" into tm-dev
diff --git a/src/com/android/phone/CallBarringEditPreference.java b/src/com/android/phone/CallBarringEditPreference.java
index 757600e..34c017c 100644
--- a/src/com/android/phone/CallBarringEditPreference.java
+++ b/src/com/android/phone/CallBarringEditPreference.java
@@ -101,9 +101,8 @@
     }
 
     void init(TimeConsumingPreferenceListener listener, boolean skipReading, Phone phone) {
-        if (DBG) {
-            Log.d(LOG_TAG, "init: phone id = " + phone.getPhoneId());
-        }
+        Log.d(LOG_TAG, "init: phone id = " + phone.getPhoneId());
+
         mPhone = phone;
 
         mTcpListener = listener;
@@ -184,10 +183,9 @@
     @Override
     protected void onDialogClosed(boolean positiveResult) {
         super.onDialogClosed(positiveResult);
-        if (DBG) {
-            Log.d(LOG_TAG, "onDialogClosed: mButtonClicked=" + mButtonClicked + ", positiveResult="
-                    + positiveResult);
-        }
+        Log.d(LOG_TAG, "onDialogClosed: mButtonClicked=" + mButtonClicked + ", positiveResult="
+                + positiveResult);
+
         if (mButtonClicked != DialogInterface.BUTTON_NEGATIVE) {
             String password = getEditText().getText().toString();
 
@@ -199,9 +197,8 @@
                 return;
             }
 
-            if (DBG) {
-                Log.d(LOG_TAG, "onDialogClosed: password=" + password);
-            }
+            Log.d(LOG_TAG, "onDialogClosed");
+
             // Send set call barring message to RIL layer.
             mPhone.setCallBarring(mFacility, !mIsActivated, password,
                     mHandler.obtainMessage(MyHandler.MESSAGE_SET_CALL_BARRING),
@@ -214,9 +211,7 @@
 
     void handleCallBarringResult(boolean status) {
         mIsActivated = status;
-        if (DBG) {
-            Log.d(LOG_TAG, "handleCallBarringResult: mIsActivated=" + mIsActivated);
-        }
+        Log.i(LOG_TAG, "handleCallBarringResult: mIsActivated=" + mIsActivated);
     }
 
     private static int getServiceClassForCallBarring(Phone phone) {
@@ -277,9 +272,7 @@
                 return;
             }
 
-            if (DBG) {
-                Log.d(LOG_TAG, "handleGetCallBarringResponse: done");
-            }
+            Log.i(LOG_TAG, "handleGetCallBarringResponse: done");
 
             AsyncResult ar = (AsyncResult) msg.obj;
 
@@ -291,9 +284,7 @@
 
             // Unsuccessful query for call barring.
             if (ar.exception != null) {
-                if (DBG) {
-                    Log.d(LOG_TAG, "handleGetCallBarringResponse: ar.exception=" + ar.exception);
-                }
+                Log.i(LOG_TAG, "handleGetCallBarringResponse: ar.exception=" + ar.exception);
                 pref.mTcpListener.onException(pref, (CommandException) ar.exception);
             } else {
                 if (ar.userObj instanceof Throwable) {
@@ -301,18 +292,14 @@
                 }
                 int[] ints = (int[]) ar.result;
                 if (ints.length == 0) {
-                    if (DBG) {
-                        Log.d(LOG_TAG, "handleGetCallBarringResponse: ar.result.length==0");
-                    }
+                    Log.i(LOG_TAG, "handleGetCallBarringResponse: ar.result.length==0");
                     pref.setEnabled(false);
                     pref.mTcpListener.onError(pref, RESPONSE_ERROR);
                 } else {
                     pref.handleCallBarringResult(ints[0] != 0);
-                    if (DBG) {
-                        Log.d(LOG_TAG,
-                                "handleGetCallBarringResponse: CB state successfully queried: "
-                                        + ints[0]);
-                    }
+                    Log.i(LOG_TAG,
+                            "handleGetCallBarringResponse: CB state successfully queried: "
+                                    + ints[0]);
                 }
             }
             // Update call barring status.
@@ -329,13 +316,9 @@
             AsyncResult ar = (AsyncResult) msg.obj;
 
             if (ar.exception != null || ar.userObj instanceof Throwable) {
-                if (DBG) {
-                    Log.d(LOG_TAG, "handleSetCallBarringResponse: ar.exception=" + ar.exception);
-                }
+                Log.i(LOG_TAG, "handleSetCallBarringResponse: ar.exception=" + ar.exception);
             }
-            if (DBG) {
-                Log.d(LOG_TAG, "handleSetCallBarringResponse: re-get call barring option");
-            }
+            Log.i(LOG_TAG, "handleSetCallBarringResponse: re-get call barring option");
             pref.mPhone.getCallBarring(
                     pref.mFacility,
                     "",
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index bb38ef0..a5168ef 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -751,10 +751,14 @@
                                 IccOpenLogicalChannelResponse.STATUS_NO_ERROR, selectResponse);
 
                         uiccPort = getUiccPortFromRequest(request);
-                        IccLogicalChannelRequest channelRequest =
-                                (IccLogicalChannelRequest) request.argument;
-                        channelRequest.channel = channelId;
-                        uiccPort.onLogicalChannelOpened(channelRequest);
+                        if (uiccPort == null) {
+                            loge("EVENT_OPEN_CHANNEL_DONE: UiccPort is null");
+                        } else {
+                            IccLogicalChannelRequest channelRequest =
+                                    (IccLogicalChannelRequest) request.argument;
+                            channelRequest.channel = channelId;
+                            uiccPort.onLogicalChannelOpened(channelRequest);
+                        }
                     } else {
                         if (ar.result == null) {
                             loge("iccOpenLogicalChannel: Empty response");
@@ -800,8 +804,12 @@
                     if (ar.exception == null) {
                         request.result = true;
                         uiccPort = getUiccPortFromRequest(request);
-                        final int channelId = (Integer) request.argument;
-                        uiccPort.onLogicalChannelClosed(channelId);
+                        if (uiccPort == null) {
+                            loge("EVENT_CLOSE_CHANNEL_DONE: UiccPort is null");
+                        } else {
+                            final int channelId = (Integer) request.argument;
+                            uiccPort.onLogicalChannelClosed(channelId);
+                        }
                     } else {
                         request.result = false;
                         Exception exception = null;
@@ -2369,7 +2377,8 @@
                 ? getDefaultPhone() : getPhone(subId);
     }
 
-    private UiccPort getUiccPortFromRequest(MainThreadRequest request) {
+    @Nullable
+    private UiccPort getUiccPortFromRequest(@NonNull MainThreadRequest request) {
         Phone phone = getPhoneFromRequest(request);
         return phone == null ? null :
                 UiccController.getInstance().getUiccPort(phone.getPhoneId());
diff --git a/src/com/android/phone/TimeConsumingPreferenceActivity.java b/src/com/android/phone/TimeConsumingPreferenceActivity.java
index caef176..d21f6a8 100644
--- a/src/com/android/phone/TimeConsumingPreferenceActivity.java
+++ b/src/com/android/phone/TimeConsumingPreferenceActivity.java
@@ -197,6 +197,7 @@
 
     @Override
     public void onException(Preference preference, CommandException exception) {
+        Log.i(LOG_TAG, "onError, preference=" + preference.getKey() + ", exception=" + exception);
         if (exception.getCommandError() == CommandException.Error.FDN_CHECK_FAILURE) {
             onError(preference, FDN_CHECK_FAILURE);
         } else if (exception.getCommandError() == CommandException.Error.RADIO_NOT_AVAILABLE) {
@@ -210,6 +211,10 @@
             onError(preference, STK_CC_SS_TO_USSD_ERROR);
         } else if (exception.getCommandError() == CommandException.Error.SS_MODIFIED_TO_SS) {
             onError(preference, STK_CC_SS_TO_SS_ERROR);
+        } else if (exception.getCommandError() == CommandException.Error.REQUEST_NOT_SUPPORTED) {
+            preference.setEnabled(false);
+            // Don't show an error dialog; just disable it if the request is not supported.
+            Log.i(LOG_TAG, "onError, suppress error dialog as not supported");
         } else {
             preference.setEnabled(false);
             onError(preference, EXCEPTION_ERROR);