Merge "Make string for work profile consistent with provisioning and framework strings." into lmp-dev
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 6e1b2b8..03b2e90 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -646,6 +646,7 @@
         <item>get usage stats</item>
         <item>mute/unmute microphone</item>
         <item>project media</item>
+        <item>activate VPN</item>
     </string-array>
 
     <!-- User display names for app ops codes -->
@@ -696,6 +697,7 @@
         <item>Get usage stats</item>
         <item>Mute/unmute microphone</item>
         <item>Project media</item>
+        <item>Activate VPN</item>
     </string-array>
 
     <!-- Titles for the list of long press timeout options. -->
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 8e2551e..317e6ca 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3339,8 +3339,6 @@
     <string name="input_methods_settings_title">Text input</string>
     <!-- Setting name for Input Method chooser -->
     <string name="input_method">Input method</string>
-    <!-- Title for the option to press to enable or disable keyboards, also known as input methods [CHAR LIMIT=35] -->
-    <string name="choose_input_methods">Choose Keyboards</string>
     <!-- Title for the option to press to choose the current keyboard, also known as input method [CHAR LIMIT=35] -->
     <string name="current_input_method">Current Keyboard</string>
     <!-- Title for setting the visibility of input method selector [CHAR LIMIT=35] -->
@@ -3431,6 +3429,8 @@
     <string name="allow_mock_location">Allow mock locations</string>
     <!-- setting Checkbox summary whether to allow mock locations  -->
     <string name="allow_mock_location_summary">Allow mock locations</string>
+    <!-- Setting Checkbox title whether to enable view attribute inspection -->
+    <string name="debug_view_attributes">Enable view attribute inspection</string>
     <!-- Title of warning dialog about the implications of enabling USB debugging -->
     <string name="adb_warning_title">Allow USB debugging?</string>
     <!-- Warning text to user about the implications of enabling USB debugging -->
@@ -4432,9 +4432,9 @@
         following operations:</string>
 
     <!-- Title for screen to set a profile owner [CHAR LIMIT=40] -->
-    <string name="profile_owner_add_title">Profile owner</string>
+    <string name="profile_owner_add_title">Activate Profile Manager?</string>
     <!-- Warning when trying to add a profile owner admin after setup has completed. [CHAR LIMIT=none] -->
-    <string name="adding_profile_owner_warning" translatable="false">This application wants to assume COMPLETE control of this user, including restricting critical operations. Only allow this if you trust this application.</string>
+    <string name="adding_profile_owner_warning">By proceeding, your User will be managed by your Administrator which may also be able to store associated data, in addition to your personal data.\n\nYour Administrator has the ability to monitor and manage settings, access, apps, and data associated with this User, including network activity and your device\’s location information.</string>
 
     <!-- Name to assign to a Network Access Point that was saved without a name -->
     <string name="untitled_apn">Untitled</string>
diff --git a/res/xml/development_prefs.xml b/res/xml/development_prefs.xml
index 2a1a5bb..807ae8b 100644
--- a/res/xml/development_prefs.xml
+++ b/res/xml/development_prefs.xml
@@ -86,6 +86,10 @@
             android:title="@string/allow_mock_location"
             android:summary="@string/allow_mock_location_summary"/>
 
+        <CheckBoxPreference
+                android:key="debug_view_attributes"
+                android:title="@string/debug_view_attributes" />
+
         <PreferenceScreen android:key="debug_app"
                 android:title="@string/debug_app" />
 
diff --git a/res/xml/language_settings.xml b/res/xml/language_settings.xml
index b60dc5e..46072bf 100644
--- a/res/xml/language_settings.xml
+++ b/res/xml/language_settings.xml
@@ -46,12 +46,6 @@
             android:title="@string/keyboard_settings_category"
             settings:keywords="@string/keywords_keyboard_and_ime">
 
-        <!-- An intent for this preference will be populated programmatically. -->
-        <PreferenceScreen
-                android:key="choose_input_methods"
-                android:title="@string/choose_input_methods"
-                />
-
         <PreferenceScreen
                 android:key="current_input_method"
                 android:title="@string/current_input_method"
diff --git a/res/xml/sim_settings.xml b/res/xml/sim_settings.xml
index 105be2e..a36d524 100644
--- a/res/xml/sim_settings.xml
+++ b/res/xml/sim_settings.xml
@@ -27,8 +27,7 @@
 
         <com.android.settings.notification.DropDownPreference
             android:key="sim_cellular_data"
-            android:title="@string/cellular_data_title"
-            android:dialogTitle="@string/cellular_data_title" />
+            android:title="@string/cellular_data_title" />
 
         <com.android.settings.notification.DropDownPreference
             android:key="sim_calls"
@@ -36,8 +35,7 @@
 
         <com.android.settings.notification.DropDownPreference
             android:key="sim_sms"
-            android:title="@string/sms_messages_title"
-            android:dialogTitle="@string/sms_messages_title" />
+            android:title="@string/sms_messages_title" />
 
     </PreferenceCategory>
 
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java
index 11dc3c6..2cffe28 100644
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -110,6 +110,7 @@
     private static final String DEBUG_APP_KEY = "debug_app";
     private static final String WAIT_FOR_DEBUGGER_KEY = "wait_for_debugger";
     private static final String VERIFY_APPS_OVER_USB_KEY = "verify_apps_over_usb";
+    private static final String DEBUG_VIEW_ATTRIBUTES =  "debug_view_attributes";
     private static final String STRICT_MODE_KEY = "strict_mode";
     private static final String POINTER_LOCATION_KEY = "pointer_location";
     private static final String SHOW_TOUCHES_KEY = "show_touches";
@@ -187,6 +188,7 @@
     private CheckBoxPreference mBtHciSnoopLog;
     private CheckBoxPreference mEnableOemUnlock;
     private CheckBoxPreference mAllowMockLocation;
+    private CheckBoxPreference mDebugViewAttributes;
 
     private PreferenceScreen mPassword;
     private String mDebugApp;
@@ -295,6 +297,7 @@
             mEnableOemUnlock = null;
         }
         mAllowMockLocation = findAndInitCheckboxPref(ALLOW_MOCK_LOCATION);
+        mDebugViewAttributes = findAndInitCheckboxPref(DEBUG_VIEW_ATTRIBUTES);
         mPassword = (PreferenceScreen) findPreference(LOCAL_BACKUP_PASSWORD);
         mAllPrefs.add(mPassword);
 
@@ -513,6 +516,8 @@
         }
         updateCheckBox(mAllowMockLocation, Settings.Secure.getInt(cr,
                 Settings.Secure.ALLOW_MOCK_LOCATION, 0) != 0);
+        updateCheckBox(mDebugViewAttributes, Settings.Global.getInt(cr,
+                Settings.Global.DEBUG_VIEW_ATTRIBUTES, 0) != 0);
         updateHdcpValues();
         updatePasswordSummary();
         updateDebuggerOptions();
@@ -1019,7 +1024,7 @@
     private void writeUSBAudioOptions() {
         Settings.Secure.putInt(getContentResolver(),
                 Settings.Secure.USB_AUDIO_AUTOMATIC_ROUTING_DISABLED,
-                    mUSBAudio.isChecked() ? 1 : 0);
+                mUSBAudio.isChecked() ? 1 : 0);
     }
 
     private void updateForceRtlOptions() {
@@ -1380,6 +1385,10 @@
             Settings.Secure.putInt(getActivity().getContentResolver(),
                     Settings.Secure.ALLOW_MOCK_LOCATION,
                     mAllowMockLocation.isChecked() ? 1 : 0);
+        } else if (preference == mDebugViewAttributes) {
+            Settings.Global.putInt(getActivity().getContentResolver(),
+                    Settings.Global.DEBUG_VIEW_ATTRIBUTES,
+                    mDebugViewAttributes.isChecked() ? 1 : 0);
         } else if (preference == mDebugAppPref) {
             startActivityForResult(new Intent(getActivity(), AppPicker.class), RESULT_DEBUG_APP);
         } else if (preference == mWaitForDebugger) {
diff --git a/src/com/android/settings/applications/AppOpsState.java b/src/com/android/settings/applications/AppOpsState.java
index 75a8372..580c44e 100644
--- a/src/com/android/settings/applications/AppOpsState.java
+++ b/src/com/android/settings/applications/AppOpsState.java
@@ -190,13 +190,15 @@
                     AppOpsManager.OP_WRITE_SETTINGS,
                     AppOpsManager.OP_SYSTEM_ALERT_WINDOW,
                     AppOpsManager.OP_WAKE_LOCK,
-                    AppOpsManager.OP_PROJECT_MEDIA },
+                    AppOpsManager.OP_PROJECT_MEDIA,
+                    AppOpsManager.OP_ACTIVATE_VPN, },
             new boolean[] { false,
                     true,
                     true,
                     true,
                     true,
                     true,
+                    false,
                     false, }
             );
 
diff --git a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
index e8bad0c..eca0cca 100644
--- a/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
+++ b/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
@@ -318,6 +318,6 @@
                 return R.drawable.ic_bt_headset_hfp;
             }
         }
-        return 0;
+        return R.drawable.ic_settings_bluetooth2;
     }
 }
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java
index 3c62ba9..8ea680f 100755
--- a/src/com/android/settings/bluetooth/BluetoothSettings.java
+++ b/src/com/android/settings/bluetooth/BluetoothSettings.java
@@ -230,10 +230,19 @@
     }
 
     private void startScanning() {
-        if (isUiRestricted()) return;
+        if (isUiRestricted()) {
+            return;
+        }
+
         if (!mAvailableDevicesCategoryIsPresent) {
             getPreferenceScreen().addPreference(mAvailableDevicesCategory);
         }
+
+        if (mAvailableDevicesCategory != null) {
+            setDeviceListGroup(mAvailableDevicesCategory);
+            removeAllDevices();
+        }
+
         mLocalManager.getCachedDeviceManager().clearCachedDevices();
         mAvailableDevicesCategory.removeAll();
         mLocalAdapter.startScanning(true);
diff --git a/src/com/android/settings/bluetooth/DeviceProfilesSettings.java b/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
index ea43bad..8b0c357 100755
--- a/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
+++ b/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
@@ -135,8 +135,10 @@
         mCachedDevice = cachedDevice;
 
         mCachedDevice.registerCallback(this);
-        addPreferencesForProfiles();
-        refresh();
+        if (isResumed()) {
+            addPreferencesForProfiles();
+            refresh();
+        }
     }
 
     private void addPreferencesForProfiles() {
diff --git a/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java b/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java
index 3528c56..f18694c 100644
--- a/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java
+++ b/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java
@@ -80,7 +80,6 @@
         InputMethodPreference.OnSavePreferenceListener {
     private static final String KEY_SPELL_CHECKERS = "spellcheckers_settings";
     private static final String KEY_PHONE_LANGUAGE = "phone_language";
-    private static final String KEY_CHOOSE_INPUT_METHODS = "choose_input_methods";
     private static final String KEY_CURRENT_INPUT_METHOD = "current_input_method";
     private static final String KEY_INPUT_METHOD_SELECTOR = "input_method_selector";
     private static final String KEY_USER_DICTIONARY_SETTINGS = "key_user_dictionary_settings";
@@ -154,14 +153,6 @@
             }
             mKeyboardSettingsCategory.removeAll();
             getPreferenceScreen().addPreference(mKeyboardSettingsCategory);
-        } else {
-            final Preference pref = findPreference(KEY_CHOOSE_INPUT_METHODS);
-            final Intent intent = new Intent(Settings.ACTION_INPUT_METHOD_SETTINGS);
-            intent.setClass(activity, SubSettings.class);
-            intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT, getClass().getName());
-            intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE_RESID,
-                    R.string.choose_input_methods);
-            pref.setIntent(intent);
         }
 
         // Build hard keyboard and game controller preference categories.
diff --git a/src/com/android/settings/vpn2/VpnSettings.java b/src/com/android/settings/vpn2/VpnSettings.java
index d409764..ab84654 100644
--- a/src/com/android/settings/vpn2/VpnSettings.java
+++ b/src/com/android/settings/vpn2/VpnSettings.java
@@ -45,8 +45,10 @@
 import android.view.MenuItem;
 import android.view.View;
 import android.widget.AdapterView.AdapterContextMenuInfo;
+import android.widget.AdapterView.OnItemSelectedListener;
 import android.widget.ArrayAdapter;
 import android.widget.ListView;
+import android.widget.Spinner;
 import android.widget.TextView;
 import android.widget.Toast;
 
@@ -56,7 +58,6 @@
 import com.android.internal.util.ArrayUtils;
 import com.android.settings.R;
 import com.android.settings.SettingsPreferenceFragment;
-
 import com.google.android.collect.Lists;
 
 import java.util.ArrayList;
@@ -349,15 +350,6 @@
 
         if (preference instanceof VpnPreference) {
             VpnProfile profile = ((VpnPreference) preference).getProfile();
-            if (mInfo != null && profile.key.equals(mInfo.key) &&
-                    mInfo.state == LegacyVpnInfo.STATE_CONNECTED) {
-                try {
-                    mInfo.intent.send();
-                    return true;
-                } catch (Exception e) {
-                    // ignore
-                }
-            }
             mDialog = new VpnDialog(getActivity(), this, profile, false);
         } else {
             // Generate a new key. Here we just use the current time.
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 5366d66..1503f22 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -41,10 +41,10 @@
 import android.net.wifi.WifiInfo;
 import android.net.wifi.WifiManager;
 import android.net.wifi.WpsInfo;
+import android.os.Build;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Message;
-import android.os.Parcelable;
 import android.preference.Preference;
 import android.preference.PreferenceScreen;
 import android.util.Log;
@@ -101,12 +101,7 @@
     private static final int MENU_ID_MODIFY = Menu.FIRST + 8;
     private static final int MENU_ID_WRITE_NFC = Menu.FIRST + 9;
 
-    private static final String KEY_ASSISTANT_DISMISS_TIME = "wifi_assistant_dismiss_time";
-    private static final String KEY_ASSISTANT_START_TIME = "wifi_assistant_start_time";
-
-    private static final long MILI_SECONDS_30_DAYS = 30L * 24L * 60L * 60L * 1000L;
-    private static final long MILI_SECONDS_90_DAYS = MILI_SECONDS_30_DAYS * 3L;
-    private static final long MILI_SECONDS_180_DAYS = MILI_SECONDS_90_DAYS * 2L;
+    private static final String KEY_ASSISTANT_DISMISS_PLATFORM = "wifi_assistant_dismiss_platform";
 
     public static final int WIFI_DIALOG_ID = 1;
     /* package */ static final int WPS_PBC_DIALOG_ID = 2;
@@ -336,7 +331,7 @@
     public void onActivityResult(int requestCode, int resultCode, Intent resultData) {
         if (requestCode == REQUEST_ENABLE_WIFI_ASSISTANT) {
             if (resultCode == Activity.RESULT_OK) {
-                setWifiAssistantTimeout();
+                disableWifiAssistantCardUntilPlatformUpgrade();
                 getListView().removeHeaderView(mWifiAssistantCard);
                 mWifiAssistantApp = null;
             }
@@ -720,10 +715,11 @@
         }
 
         SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
-        long lastTimeoutEndTime = sharedPreferences.getLong(KEY_ASSISTANT_START_TIME, 0);
-        long dismissTime = sharedPreferences.getLong(KEY_ASSISTANT_DISMISS_TIME, 0);
+        int lastDismissPlatform = sharedPreferences.getInt(KEY_ASSISTANT_DISMISS_PLATFORM, 0);
 
-        if ((System.currentTimeMillis() - lastTimeoutEndTime) <= dismissTime) {
+        if (Build.VERSION.SDK_INT <= lastDismissPlatform) {
+            // User has dismissed the Wi-Fi assistant card on this SDK release. Suppress the card
+            // until the next major platform upgrade.
             return;
         }
 
@@ -761,7 +757,7 @@
                 noThanks.setOnClickListener(new OnClickListener() {
                     @Override
                     public void onClick(View v) {
-                        setWifiAssistantTimeout();
+                        disableWifiAssistantCardUntilPlatformUpgrade();
                         getListView().removeHeaderView(mWifiAssistantCard);
                         mWifiAssistantApp = null;
                     }
@@ -770,23 +766,10 @@
         }
     }
 
-    private void setWifiAssistantTimeout() {
+    private void disableWifiAssistantCardUntilPlatformUpgrade() {
         SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
         SharedPreferences.Editor editor = sharedPreferences.edit();
-        long dismissTime = sharedPreferences.getLong(KEY_ASSISTANT_DISMISS_TIME, 0);
-
-        if (dismissTime == 0) {
-            dismissTime = MILI_SECONDS_30_DAYS;
-        } else if (dismissTime == MILI_SECONDS_30_DAYS) {
-            dismissTime = MILI_SECONDS_90_DAYS;
-        } else if (dismissTime == MILI_SECONDS_90_DAYS) {
-            dismissTime = MILI_SECONDS_180_DAYS;
-        } else if (dismissTime == MILI_SECONDS_180_DAYS) {
-            dismissTime = java.lang.Long.MAX_VALUE;
-        }
-
-        editor.putLong(KEY_ASSISTANT_DISMISS_TIME, dismissTime);
-        editor.putLong(KEY_ASSISTANT_START_TIME, System.currentTimeMillis());
+        editor.putLong(KEY_ASSISTANT_DISMISS_PLATFORM, Build.VERSION.SDK_INT);
         editor.apply();
     }