Merge changes from topics 'offline_operation_hours_part5', 'offline_operation_hours_part4' into nyc-mr1-dev

* changes:
  Show a static title/summary if country doesn't have support
  By default select current country in support phone list.
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 017b33f..4690f88 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -7507,9 +7507,6 @@
     <!-- Title text for connecting to 24/7 available customer support [CHAR LIMIT=80]-->
     <string name="support_escalation_24_7_title">We\'re here for you 24/7</string>
 
-    <!-- Title text when customer support is closed [CHAR LIMIT=80]-->
-    <string name="support_escalation_closed_title">Support closed</string>
-
     <!-- Summary text for connecting to customer support [CHAR LIMIT=NONE]-->
     <string name="support_escalation_summary">Our support team is here to address any issues</string>
 
@@ -7519,6 +7516,9 @@
     <!-- Summary text when customer support is closed. [CHAR LIMIT=NONE]-->
     <string name="support_escalation_closed_summary">Call us during support hours (local time)&lt;br&gt;&lt;b&gt;<xliff:g id="operation_hours">%s</xliff:g>&lt;/b&gt;</string>
 
+    <!-- Summary text when customer support is unavailble in the region. [CHAR LIMIT=NONE]-->
+    <string name="support_escalation_unavailable_summary">Search help or explore tips &amp; tricks</string>
+
     <!-- Template for formatting support hours eg Mon - Fri, 8:00 AM - 19:30 PM. [CHAR LIMIT=NONE]-->
     <string name="support_hour_format" translatable="false">
         <xliff:g id="start_day">%s</xliff:g> - <xliff:g id="end_day">%s</xliff:g>, <xliff:g id="start_time">%s</xliff:g> - <xliff:g id="end_time">%s</xliff:g>&lt;br&gt;
diff --git a/src/com/android/settings/dashboard/SupportItemAdapter.java b/src/com/android/settings/dashboard/SupportItemAdapter.java
index 4f8a068..03b9fe7 100644
--- a/src/com/android/settings/dashboard/SupportItemAdapter.java
+++ b/src/com/android/settings/dashboard/SupportItemAdapter.java
@@ -88,6 +88,7 @@
             mSelectedCountry = savedInstanceState.getString(STATE_SELECTED_COUNTRY);
         }
         setAccount(mSupportFeatureProvider.getSupportEligibleAccount(mActivity));
+        mSelectedCountry = mSupportFeatureProvider.getCurrentCountryCodeIfHasConfig(PHONE);
         refreshData();
     }
 
@@ -177,32 +178,45 @@
     }
 
     private void addEscalationCards() {
-        if (mSupportFeatureProvider.isAlwaysOperating(PHONE, null /* countryCode */)
+        final boolean hasPhoneOperation =
+                mSupportFeatureProvider.isSupportTypeEnabled(mActivity, PHONE);
+        final boolean hasChatOperation =
+                mSupportFeatureProvider.isSupportTypeEnabled(mActivity, CHAT);
+        if (!hasPhoneOperation && !hasChatOperation) {
+            // No support at all.
+            mSupportData.add(new SupportData.Builder(mActivity, TYPE_TITLE)
+                    .setText1(R.string.support_escalation_title)
+                    .setText2(mActivity.getString(R.string.support_escalation_unavailable_summary))
+                    .build());
+        } else if (mSupportFeatureProvider.isAlwaysOperating(PHONE, null /* countryCode */)
                 || mSupportFeatureProvider.isAlwaysOperating(CHAT, null /* countryCode */)) {
+            // Support is available.
             mSupportData.add(new SupportData.Builder(mActivity, TYPE_TITLE)
                     .setText1(R.string.support_escalation_24_7_title)
                     .setText2(mActivity.getString(R.string.support_escalation_24_7_summary))
                     .build());
         } else if (mSupportFeatureProvider.isOperatingNow(PHONE)
                 || mSupportFeatureProvider.isOperatingNow(CHAT)) {
+            // Support is available now.
             mSupportData.add(new SupportData.Builder(mActivity, TYPE_TITLE)
                     .setText1(R.string.support_escalation_title)
                     .setText2(R.string.support_escalation_summary)
                     .build());
         } else {
+            // Support is not temporarily unavailable.
             mSupportData.add(new SupportData.Builder(mActivity, TYPE_TITLE)
-                    .setText1(R.string.support_escalation_closed_title)
+                    .setText1(R.string.support_escalation_title)
                     .setText2(mSupportFeatureProvider.getOperationHours(mActivity, PHONE, null))
                     .build());
         }
         final SupportData.Builder builder =
                 new SupportData.Builder(mActivity, TYPE_ESCALATION_OPTIONS);
-        if (mSupportFeatureProvider.isSupportTypeEnabled(mActivity, PHONE)) {
+        if (hasPhoneOperation) {
             builder.setText1(R.string.support_escalation_by_phone);
             builder.setSummary1(mSupportFeatureProvider.getEstimatedWaitTime(mActivity, PHONE));
             builder.setEnabled1(mSupportFeatureProvider.isOperatingNow(PHONE));
         }
-        if (mSupportFeatureProvider.isSupportTypeEnabled(mActivity, CHAT)) {
+        if (hasChatOperation) {
             builder.setText2(R.string.support_escalation_by_chat);
             builder.setSummary2(mSupportFeatureProvider.getEstimatedWaitTime(mActivity, CHAT));
             builder.setEnabled2(mSupportFeatureProvider.isOperatingNow(CHAT));
diff --git a/src/com/android/settings/overlay/SupportFeatureProvider.java b/src/com/android/settings/overlay/SupportFeatureProvider.java
index 75f5269..c535622 100644
--- a/src/com/android/settings/overlay/SupportFeatureProvider.java
+++ b/src/com/android/settings/overlay/SupportFeatureProvider.java
@@ -63,6 +63,11 @@
     boolean isOperatingNow(@SupportType int type);
 
     /**
+     * Returns the current country code if it has a operation config, otherwise returns null.
+     */
+    String getCurrentCountryCodeIfHasConfig(@SupportType int type);
+
+    /**
      * Returns localized string for operation hours in specified country. If country is null, use
      * current country to figure out operation hours.
      */