Merge "Settings not showing print jobs for a managed profile." into lmp-mr1-dev
diff --git a/res/values-da/strings.xml b/res/values-da/strings.xml
index 07f93b6..6b0179d 100644
--- a/res/values-da/strings.xml
+++ b/res/values-da/strings.xml
@@ -1731,24 +1731,24 @@
     <string name="menu_proc_stats_type_background" msgid="2236161340134898852">"Baggrund"</string>
     <string name="menu_proc_stats_type_foreground" msgid="2286182659954958586">"Forgrund"</string>
     <string name="menu_proc_stats_type_cached" msgid="5084272779786820693">"Cachelagret"</string>
-    <string name="voice_input_output_settings" msgid="1336135218350444783">"Taleinput og -output"</string>
+    <string name="voice_input_output_settings" msgid="1336135218350444783">"Indtaling og oplæsning"</string>
     <string name="voice_input_output_settings_title" msgid="2442850635048676991">"Indstillinger for taleinput og -output"</string>
     <string name="voice_search_settings_title" msgid="2775469246913196536">"Talesøgning"</string>
     <string name="keyboard_settings_title" msgid="5080115226780201234">"Android-tastatur"</string>
     <string name="voice_category" msgid="1430370497125803904">"Tale"</string>
-    <string name="voice_input_settings" msgid="1099937800539324567">"Indstillinger for taleinput"</string>
-    <string name="voice_input_settings_title" msgid="2676028028084981891">"Taleinput"</string>
-    <string name="voice_service_preference_section_title" msgid="3778706644257601021">"Stemmeinputtjenester"</string>
+    <string name="voice_input_settings" msgid="1099937800539324567">"Indstillinger for indtaling"</string>
+    <string name="voice_input_settings_title" msgid="2676028028084981891">"Indtaling"</string>
+    <string name="voice_service_preference_section_title" msgid="3778706644257601021">"Indtalingstjenester"</string>
     <string name="voice_interactor_preference_summary" msgid="1801414022026937190">"Komplet kommandoord og handling"</string>
-    <string name="voice_recognizer_preference_summary" msgid="669880813593690527">"Enkel tale-til-tekst"</string>
-    <string name="voice_interaction_security_warning" msgid="6378608263983737325">"Denne tjeneste til taleinput vil kunne udføre stemmeovervågning, der altid er slået til, og styre stemmeaktiverede programmer på dine vegne. Den kommer fra applikationen <xliff:g id="VOICE_INPUT_SERVICE_APP_NAME">%s</xliff:g>. Vil du aktivere brugen af denne tjeneste?"</string>
-    <string name="tts_settings" msgid="8186971894801348327">"Indstillinger for tekst-til-tale"</string>
-    <string name="tts_settings_title" msgid="1237820681016639683">"Tekst-til-tale"</string>
+    <string name="voice_recognizer_preference_summary" msgid="669880813593690527">"Enkel oplæsning"</string>
+    <string name="voice_interaction_security_warning" msgid="6378608263983737325">"Denne indtalingstjeneste vil kunne foretage lydovervågning, der altid er slået til, og styre taleaktiverede apps på dine vegne. Den kommer fra appen <xliff:g id="VOICE_INPUT_SERVICE_APP_NAME">%s</xliff:g>. Vil du aktivere brugen af denne tjeneste?"</string>
+    <string name="tts_settings" msgid="8186971894801348327">"Indstillinger for oplæsning"</string>
+    <string name="tts_settings_title" msgid="1237820681016639683">"Oplæsning"</string>
     <string name="use_default_tts_settings_title" msgid="1577063839539732930">"Brug altid mine indstil."</string>
     <string name="use_default_tts_settings_summary" msgid="5916421806783703823">"Standardindstillingerne nedenfor tilsidesætter indstillinger for app"</string>
     <string name="tts_default_settings_section" msgid="5787915620218907443">"Standardindstillinger"</string>
     <string name="tts_default_synth_title" msgid="4755558388333117572">"Standardmaskine"</string>
-    <string name="tts_default_synth_summary" msgid="6482936537135251690">"Indstiller den talesyntesemaskine, der skal bruges til talt tekst."</string>
+    <string name="tts_default_synth_summary" msgid="6482936537135251690">"Angiver den talesyntesemaskine, der skal bruges til oplæsning af tekst."</string>
     <string name="tts_default_rate_title" msgid="6030550998379310088">"Talehastighed"</string>
     <string name="tts_default_rate_summary" msgid="4061815292287182801">"Oplæsningshastighed for tekst"</string>
     <string name="tts_default_pitch_title" msgid="6135942113172488671">"Tonehøjde"</string>
@@ -1767,7 +1767,7 @@
     <string name="tts_engine_error_config" msgid="5820525416624637313">"Konfigurer"</string>
     <string name="tts_engine_error_reselect" msgid="2415399149293842112">"Vælg en anden maskine"</string>
     <string name="tts_engine_security_warning" msgid="8786238102020223650">"Denne funktion kan indsamle al den tekst, der læses op, inklusive personlige data såsom adgangskoder og kreditkortnumre. Den kommer fra <xliff:g id="TTS_PLUGIN_ENGINE_NAME">%s</xliff:g>-maskinen. Vil du aktivere brug af denne talesyntesemaskine?"</string>
-    <string name="tts_engine_network_required" msgid="1190837151485314743">"Der kræves en aktiv netværksforbindelse, for at tekst-til-tale kan anvendes på dette sprog."</string>
+    <string name="tts_engine_network_required" msgid="1190837151485314743">"Oplæsning på dette sprog fungerer kun, når der findes en aktiv netværksforbindelse."</string>
     <string name="tts_default_sample_string" msgid="4040835213373086322">"Dette er et eksempel på talesyntese."</string>
     <string name="tts_status_title" msgid="7268566550242584413">"Status for standardsprog"</string>
     <string name="tts_status_ok" msgid="1309762510278029765">"<xliff:g id="LOCALE">%1$s</xliff:g> er fuldt understøttet"</string>
diff --git a/res/values-zh-rHK/strings.xml b/res/values-zh-rHK/strings.xml
index 5da3da0..ffaac2c 100644
--- a/res/values-zh-rHK/strings.xml
+++ b/res/values-zh-rHK/strings.xml
@@ -1128,7 +1128,7 @@
     <string name="copyright_title" msgid="865906688917260647">"版權"</string>
     <string name="license_title" msgid="1990487604356037871">"授權"</string>
     <string name="terms_title" msgid="7697580845616764642">"條款及細則"</string>
-    <string name="webview_license_title" msgid="2813507464175738967">"系統 WebView 授權資訊"</string>
+    <string name="webview_license_title" msgid="2813507464175738967">"System WebView License"</string>
     <string name="wallpaper_attributions" msgid="3645880512943433928">"桌布"</string>
     <string name="wallpaper_attributions_values" msgid="2996183537914690469">"衛星影像供應商:\n©2014 CNES / Astrium, DigitalGlobe, Bluesky"</string>
     <string name="settings_license_activity_title" msgid="7553683406244228650">"開放原始碼授權"</string>
diff --git a/src/com/android/settings/DataUsageSummary.java b/src/com/android/settings/DataUsageSummary.java
index 2908829..6de7399 100644
--- a/src/com/android/settings/DataUsageSummary.java
+++ b/src/com/android/settings/DataUsageSummary.java
@@ -279,6 +279,11 @@
 
     private UidDetailProvider mUidDetailProvider;
 
+    /**
+     * Local cache of data enabled for subId, used to work around delays.
+     */
+    private final Map<String, Boolean> mMobileDataEnabled = new HashMap<String, Boolean>();
+
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -965,23 +970,18 @@
         updatePolicy(false);
     }
 
-    /**
-     * Local cache of value, used to work around delays.
-     */
-    private Boolean mMobileDataEnabled;
-
     private boolean isMobileDataEnabled(int subId) {
         if (LOGD) Log.d(TAG, "isMobileDataEnabled:+ subId=" + subId);
         boolean isEnable = false;
-        if (mMobileDataEnabled != null) {
-            // TODO: deprecate and remove this once enabled flag is on policy
-            // Multiple Subscriptions, the value need to be reseted
-            isEnable = mMobileDataEnabled.booleanValue();
+        if (mMobileDataEnabled.get(String.valueOf(subId)) != null) {
+            //TODO: deprecate and remove this once enabled flag is on policy
+            //Multiple Subscriptions, the value need to be reseted
+            isEnable = mMobileDataEnabled.get(String.valueOf(subId)).booleanValue();
             if (LOGD) {
                 Log.d(TAG, "isMobileDataEnabled: != null, subId=" + subId
                         + " isEnable=" + isEnable);
             }
-            mMobileDataEnabled = null;
+            mMobileDataEnabled.put(String.valueOf(subId), null);
         } else {
             // SUB SELECT
             isEnable = mTelephonyManager.getDataEnabled(subId);
@@ -996,7 +996,7 @@
     private void setMobileDataEnabled(int subId, boolean enabled) {
         if (LOGD) Log.d(TAG, "setMobileDataEnabled()");
         mTelephonyManager.setDataEnabled(subId, enabled);
-        mMobileDataEnabled = enabled;
+        mMobileDataEnabled.put(String.valueOf(subId), enabled);
         updatePolicy(false);
     }
 
@@ -1149,6 +1149,16 @@
         }
     }
 
+    private void disableDataForOtherSubscriptions(SubscriptionInfo currentSir) {
+        if (mSubInfoList != null) {
+            for (SubscriptionInfo subInfo : mSubInfoList) {
+                if (subInfo.getSubscriptionId() != currentSir.getSubscriptionId()) {
+                    setMobileDataEnabled(subInfo.getSubscriptionId(), false);
+                }
+            }
+        }
+    }
+
     private View.OnClickListener mDataEnabledListener = new View.OnClickListener() {
         @Override
         public void onClick(View v) {
@@ -1184,8 +1194,13 @@
         // If the device is single SIM or is enabling data on the active data SIM then forgo
         // the pop-up.
         if (!Utils.showSimCardTile(context) ||
-                (nextSir != null && currentSir.getSubscriptionId() == nextSir.getSubscriptionId())) {
+                (nextSir != null && currentSir != null &&
+                currentSir.getSubscriptionId() == nextSir.getSubscriptionId())) {
             setMobileDataEnabled(currentSir.getSubscriptionId(), true);
+            if (nextSir != null && currentSir != null &&
+                currentSir.getSubscriptionId() == nextSir.getSubscriptionId()) {
+                disableDataForOtherSubscriptions(currentSir);
+            }
             updateBody();
             return;
         }
@@ -1205,6 +1220,7 @@
             public void onClick(DialogInterface dialog, int id) {
                 mSubscriptionManager.setDefaultDataSubId(currentSir.getSubscriptionId());
                 setMobileDataEnabled(currentSir.getSubscriptionId(), true);
+                disableDataForOtherSubscriptions(currentSir);
                 updateBody();
             }
         });
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java
index 2a1fc82..c2990e5 100644
--- a/src/com/android/settings/SecuritySettings.java
+++ b/src/com/android/settings/SecuritySettings.java
@@ -379,7 +379,7 @@
 
         if (subInfoList != null) {
             for (SubscriptionInfo subInfo : subInfoList) {
-                if (tm.hasIccCard(subInfo.getSubscriptionId())) {
+                if (tm.hasIccCard(subInfo.getSimSlotIndex())) {
                     return true;
                 }
             }
diff --git a/src/com/android/settings/wifi/WifiSetupActivity.java b/src/com/android/settings/wifi/WifiSetupActivity.java
index 06a25d8..a60945f 100644
--- a/src/com/android/settings/wifi/WifiSetupActivity.java
+++ b/src/com/android/settings/wifi/WifiSetupActivity.java
@@ -42,11 +42,15 @@
         implements ButtonBarHandler, NavigationBarListener {
     private static final String TAG = "WifiSetupActivity";
 
-    private static final String EXTRA_ALLOW_SKIP = "allowSkip";
-
     // this boolean extra specifies whether to auto finish when connection is established
     private static final String EXTRA_AUTO_FINISH_ON_CONNECT = "wifi_auto_finish_on_connect";
 
+    // This boolean extra specifies whether network is required
+    private static final String EXTRA_IS_NETWORK_REQUIRED = "is_network_required";
+
+    // This boolean extra specifies whether wifi is required
+    private static final String EXTRA_IS_WIFI_REQUIRED = "is_wifi_required";
+
     // Whether auto finish is suspended until user connects to an access point
     private static final String EXTRA_REQUIRE_USER_NETWORK_SELECTION =
             "wifi_require_user_network_selection";
@@ -57,10 +61,12 @@
     // Activity result when pressing the Skip button
     private static final int RESULT_SKIP = Activity.RESULT_FIRST_USER;
 
-    // Whether we allow skipping without a valid network connection
-    private boolean mAllowSkip = true;
     // Whether to auto finish when the user selected a network and successfully connected
     private boolean mAutoFinishOnConnection;
+    // Whether network is required to proceed. This is decided in SUW and passed in as an extra.
+    private boolean mIsNetworkRequired;
+    // Whether wifi is required to proceed. This is decided in SUW and passed in as an extra.
+    private boolean mIsWifiRequired;
     // Whether the user connected to a network. This excludes the auto-connecting by the system.
     private boolean mUserSelectedNetwork;
     // Whether the device is connected to WiFi
@@ -75,7 +81,6 @@
             // Refresh the connection state with the latest connection info. Use the connection info
             // from ConnectivityManager instead of the one attached in the intent to make sure
             // we have the most up-to-date connection state. b/17511772
-
             refreshConnectionState();
         }
     };
@@ -89,7 +94,8 @@
         mFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
 
         mAutoFinishOnConnection = intent.getBooleanExtra(EXTRA_AUTO_FINISH_ON_CONNECT, false);
-        mAllowSkip = intent.getBooleanExtra(EXTRA_ALLOW_SKIP, true);
+        mIsNetworkRequired = intent.getBooleanExtra(EXTRA_IS_NETWORK_REQUIRED, false);
+        mIsWifiRequired = intent.getBooleanExtra(EXTRA_IS_WIFI_REQUIRED, false);
         // Behave like the user already selected a network if we do not require selection
         mUserSelectedNetwork = !intent.getBooleanExtra(EXTRA_REQUIRE_USER_NETWORK_SELECTION, false);
     }
@@ -106,18 +112,17 @@
         mUserSelectedNetwork = savedInstanceState.getBoolean(PARAM_USER_SELECTED_NETWORK, true);
     }
 
-    private void refreshConnectionState() {
+    private boolean isWifiConnected() {
         final ConnectivityManager connectivity = (ConnectivityManager)
                 getSystemService(Context.CONNECTIVITY_SERVICE);
-        boolean connected = connectivity != null &&
+        boolean wifiConnected = connectivity != null &&
                 connectivity.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnected();
-
-        refreshConnectionState(connected);
+        mWifiConnected = wifiConnected;
+        return wifiConnected;
     }
 
-    private void refreshConnectionState(boolean connected) {
-        mWifiConnected = connected;
-        if (connected) {
+    private void refreshConnectionState() {
+        if (isWifiConnected()) {
             if (mAutoFinishOnConnection && mUserSelectedNetwork) {
                 Log.d(TAG, "Auto-finishing with connection");
                 finishOrNext(Activity.RESULT_OK);
@@ -125,15 +130,33 @@
                 // can either connect to a different network or press "next" to proceed.
                 mUserSelectedNetwork = false;
             }
-            if (mNavigationBar != null) {
-                mNavigationBar.getNextButton().setText(R.string.setup_wizard_next_button_label);
-                mNavigationBar.getNextButton().setEnabled(true);
-            }
+            setNextButtonText(R.string.setup_wizard_next_button_label);
+            setNextButtonEnabled(true);
+        } else if (mIsWifiRequired || (mIsNetworkRequired && !isNetworkConnected())) {
+            // We do not want the user to skip wifi setting if
+            // - wifi is required, but wifi connection hasn't been established yet;
+            // - or network is required, but no valid connection has been established.
+            setNextButtonText(R.string.skip_label);
+            setNextButtonEnabled(false);
         } else {
-            if (mNavigationBar != null) {
-                mNavigationBar.getNextButton().setText(R.string.skip_label);
-                mNavigationBar.getNextButton().setEnabled(mAllowSkip);
-            }
+            // In other cases, user can choose to skip. Specifically these cases are
+            // - wifi is not required;
+            // - and network is not required;
+            // -     or network is required and a valid connection has been established.
+            setNextButtonText(R.string.skip_label);
+            setNextButtonEnabled(true);
+        }
+    }
+
+    private void setNextButtonEnabled(boolean enabled) {
+        if (mNavigationBar != null) {
+            mNavigationBar.getNextButton().setEnabled(enabled);
+        }
+    }
+
+    private void setNextButtonText(int resId) {
+        if (mNavigationBar != null) {
+            mNavigationBar.getNextButton().setText(resId);
         }
     }