Merge "Add SET_TIME permission to telephony service."
diff --git a/res/values-sw/strings.xml b/res/values-sw/strings.xml
index c452cd3..8771747 100644
--- a/res/values-sw/strings.xml
+++ b/res/values-sw/strings.xml
@@ -521,7 +521,7 @@
     <string name="pstn_phone" msgid="8782554491484326429">"Kupiga simu ya mkononi"</string>
     <string name="internet_phone" msgid="1147922660195095810">"Simu ya wavuti"</string>
     <string name="no_sip_account_found_title" msgid="6266249392379373628">"Hakuna akaunti ya upigaji simu wa Mtandao"</string>
-    <string name="no_sip_account_found" msgid="724325811961769997">"Hakuna akaunti za kupiga simu za mtandao kwenye simu hii. Je, unataka kuongeza moja sasa?"</string>
+    <string name="no_sip_account_found" msgid="724325811961769997">"Hakuna akaunti za kupiga simu za mtandao kwenye simu hii. Je, ungependa kuongeza akaunti sasa?"</string>
     <string name="sip_menu_add" msgid="8757508498518881500">"Ongeza"</string>
     <string name="add_sip_account" msgid="5904858426290097611">"Ongeza akaunti"</string>
     <string name="remove_sip_account" msgid="7645900420385682570">"Ondoa akaunti"</string>
diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml
index 25e7290..9178574 100644
--- a/res/values-zh-rTW/strings.xml
+++ b/res/values-zh-rTW/strings.xml
@@ -75,7 +75,7 @@
     <string name="sum_cw_disabled" msgid="3648693907300104575">"通話時如有來電請通知我"</string>
     <string name="call_forwarding_settings" msgid="3378927671091537173">"來電轉接設定"</string>
     <string name="labelCF" msgid="2574386948026924737">"來電轉接"</string>
-    <string name="labelCFU" msgid="8147177368148660600">"永遠轉接"</string>
+    <string name="labelCFU" msgid="8147177368148660600">"一律轉接"</string>
     <string name="messageCFU" msgid="3560082430662923687">"永遠使用此號碼"</string>
     <string name="sum_cfu_enabled_indicator" msgid="4014187342724130197">"轉接所有來電"</string>
     <string name="sum_cfu_enabled" msgid="2450052502198827927">"將所有來電轉接至 <xliff:g id="PHONENUMBER">{0}</xliff:g>"</string>
diff --git a/src/com/android/phone/CallHandlerServiceProxy.java b/src/com/android/phone/CallHandlerServiceProxy.java
index 7c8ace7..f5b6116 100644
--- a/src/com/android/phone/CallHandlerServiceProxy.java
+++ b/src/com/android/phone/CallHandlerServiceProxy.java
@@ -58,6 +58,7 @@
     public static final int RETRY_DELAY_MILLIS = 2000;
     public static final int RETRY_DELAY_LONG_MILLIS = 30 * 1000; // 30 seconds
     private static final int BIND_RETRY_MSG = 1;
+    private static final int BIND_TIME_OUT = 2;
     private static final int MAX_SHORT_DELAY_RETRY_COUNT = 5;
 
     private AudioRouter mAudioRouter;
@@ -79,8 +80,28 @@
 
         switch (msg.what) {
             case BIND_RETRY_MSG:
+                // Remove any pending messages since we're already performing the action.
+                // If the call to setupServiceConnection() fails, it will queue up another retry.
+                removeMessages(BIND_RETRY_MSG);
                 handleConnectRetry();
                 break;
+            case BIND_TIME_OUT:
+                // Remove any pending messages since we're already performing the action.
+                // If the call to setupServiceConnection() fails, it will queue up another retry.
+                removeMessages(BIND_TIME_OUT);
+                synchronized (mServiceAndQueueLock) {
+                    if(mCallHandlerServiceGuarded == null) {
+                        Log.w(TAG, "Binding time out. InCallUI did not respond in time.");
+                        try {
+                            mContext.unbindService(mConnection);
+                        } catch(Exception e) {
+                            Log.w(TAG, "unbindservice exception", e);
+                        }
+                        mConnection = null;
+                        handleConnectRetry();
+                    }
+                }
+                break;
         }
     }
 
@@ -290,6 +311,10 @@
                 Log.d(TAG, "Service Connected");
             }
             onCallHandlerServiceConnected(ICallHandlerService.Stub.asInterface(service));
+            removeMessages(BIND_TIME_OUT);
+            if (DBG) {
+                Log.d(TAG, "Service Connected. Cancel timer");
+            }
             resetConnectRetryCount();
         }
 
@@ -390,7 +415,9 @@
 
                 if (failedConnection) {
                     mConnection = null;
-                    enqueueConnectRetry();
+                    enqueueConnectRetry(BIND_RETRY_MSG);
+                } else {
+                    enqueueConnectRetry(BIND_TIME_OUT);
                 }
             } else {
                 Log.d(TAG, "Service connection to in call service already started.");
@@ -412,10 +439,6 @@
     }
 
     private void handleConnectRetry() {
-        // Remove any pending messages since we're already performing the action.
-        // If the call to setupServiceConnection() fails, it will queue up another retry.
-        removeMessages(BIND_RETRY_MSG);
-
         // Something else triggered the connection, cancel.
         if (mConnection != null) {
             Log.i(TAG, "Retry: already connected.");
@@ -449,14 +472,14 @@
      * Called after the connection failed and a retry is needed.
      * Queues up a retry to happen with a delay.
      */
-    private void enqueueConnectRetry() {
+    private void enqueueConnectRetry(int msg) {
         final boolean isLongDelay = (mBindRetryCount > MAX_SHORT_DELAY_RETRY_COUNT);
         final int delay = isLongDelay ? RETRY_DELAY_LONG_MILLIS : RETRY_DELAY_MILLIS;
 
         Log.w(TAG, "InCallUI Connection failed. Enqueuing delayed retry for " + delay + " ms." +
                 " retries(" + mBindRetryCount + ")");
 
-        sendEmptyMessageDelayed(BIND_RETRY_MSG, delay);
+        sendEmptyMessageDelayed(msg, delay);
     }
 
     private void unbind() {