Merge "Update strings for removing work profile" into lmp-dev
diff --git a/res/drawable/setup_wizard_card_bg.xml b/res/drawable/setup_wizard_card_bg.xml
new file mode 100644
index 0000000..8621437
--- /dev/null
+++ b/res/drawable/setup_wizard_card_bg.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="rectangle">
+
+    <corners
+        android:topLeftRadius="@dimen/setup_wizard_card_corner_radius"
+        android:topRightRadius="@dimen/setup_wizard_card_corner_radius" />
+
+    <solid android:color="?android:attr/colorBackground" />
+
+</shape>
+
diff --git a/res/layout-sw600dp-land/setup_preference.xml b/res/layout-sw600dp-land/setup_preference.xml
index 0943817..3d4db3d 100644
--- a/res/layout-sw600dp-land/setup_preference.xml
+++ b/res/layout-sw600dp-land/setup_preference.xml
@@ -37,14 +37,17 @@
             <TextView
                 android:id="@+id/title"
                 style="@style/SetupCardTitle"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:layout_weight="6"
                 android:text="@string/wifi_setup_wizard_title"/>
 
             <LinearLayout
                 android:layout_width="0dp"
                 android:layout_height="match_parent"
-                android:layout_marginTop="@dimen/setup_wizard_card_margin_top"
+                android:layout_marginTop="@dimen/setup_wizard_card_land_margin_top"
                 android:layout_weight="8"
-                android:background="?android:attr/colorBackground"
+                android:background="@drawable/setup_wizard_card_bg"
                 android:elevation="@dimen/setup_wizard_card_elevation"
                 android:orientation="vertical">
 
diff --git a/res/layout-sw720dp-port/setup_preference.xml b/res/layout-sw720dp-port/setup_preference.xml
new file mode 100644
index 0000000..8d1f53b
--- /dev/null
+++ b/res/layout-sw720dp-port/setup_preference.xml
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+    Copyright (C) 2014 Google Inc.
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical">
+
+    <com.android.settings.widget.SetupWizardIllustration
+        android:id="@+id/title_area"
+        android:layout_width="match_parent"
+        android:layout_height="0dp"
+        android:layout_weight="1"
+        android:background="@drawable/setup_illustration_bg"
+        android:foreground="@drawable/setup_illustration_wifi_wide"
+        settings:aspectRatio="4.0">
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:orientation="vertical"
+            android:paddingLeft="@dimen/setup_wizard_card_port_margin_sides"
+            android:paddingRight="@dimen/setup_wizard_card_port_margin_sides">
+
+            <TextView
+                android:id="@+id/title"
+                style="@style/SetupCardTitle"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="@string/wifi_setup_wizard_title" />
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="0dp"
+                android:layout_weight="1"
+                android:background="@drawable/setup_wizard_card_bg"
+                android:elevation="@dimen/setup_wizard_card_elevation"
+                android:orientation="vertical">
+
+                <TextView
+                    android:id="@+id/wifi_required_info"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_marginBottom="6dp"
+                    android:text="@string/wifi_required_info_text"
+                    android:textAppearance="?android:attr/textAppearanceMedium"
+                    android:visibility="gone" />
+
+                <ListView
+                    android:id="@android:id/list"
+                    android:layout_width="match_parent"
+                    android:layout_height="0dp"
+                    android:layout_weight="1"
+                    android:cacheColorHint="@android:color/transparent"
+                    android:clipToPadding="false"
+                    android:drawSelectorOnTop="false"
+                    android:headerDividersEnabled="false"
+                    android:scrollbarAlwaysDrawVerticalTrack="true" />
+
+            </LinearLayout>
+
+        </LinearLayout>
+
+    </com.android.settings.widget.SetupWizardIllustration>
+
+    <fragment
+        android:id="@+id/navigation_bar"
+        android:name="com.android.setupwizard.navigationbar.SetupWizardNavBar"
+        style="@style/setup_wizard_navbar_style" />
+
+</LinearLayout>
+
diff --git a/res/layout/apn_preference_layout.xml b/res/layout/apn_preference_layout.xml
index f3ee453..05ffe51 100644
--- a/res/layout/apn_preference_layout.xml
+++ b/res/layout/apn_preference_layout.xml
@@ -27,8 +27,6 @@
         android:id="@+id/text_layout"
         android:layout_width="0dip"
         android:layout_height="match_parent"
-        android:paddingStart="8dip"
-        android:paddingEnd="8dip"
         android:gravity="center_vertical"
         android:layout_weight="1"
         android:focusable="true"
@@ -40,7 +38,7 @@
             android:layout_height="wrap_content"
             android:focusable="true"
             android:singleLine="true"
-            android:textAppearance="?android:attr/textAppearanceMedium" />
+            android:textAppearance="?android:attr/textAppearanceListItem" />
 
         <TextView
             android:id="@+android:id/summary"
@@ -48,13 +46,13 @@
             android:layout_height="wrap_content"
             android:layout_below="@android:id/title"
             android:layout_alignStart="@android:id/title"
-            android:textAppearance="?android:attr/textAppearanceSmall"
+            android:textAppearance="?android:attr/textAppearanceListItemSecondary"
+            android:textColor="?android:attr/textColorSecondary"
             android:maxLines="2" />
 
     </RelativeLayout>
 
     <RadioButton
-        xmlns:android="http://schemas.android.com/apk/res/android"
         android:id="@+id/apn_radiobutton"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
diff --git a/res/layout/manage_applications_apps.xml b/res/layout/manage_applications_apps.xml
index 68fcb1b..4033d43 100644
--- a/res/layout/manage_applications_apps.xml
+++ b/res/layout/manage_applications_apps.xml
@@ -20,7 +20,7 @@
         android:orientation="vertical">
 
     <FrameLayout android:id="@+id/pinned_header"
-            android:layout_width="match_parent"
+            android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:visibility="gone" />
 
diff --git a/res/layout/manage_applications_running.xml b/res/layout/manage_applications_running.xml
index cc8c1867..6cacf2a 100644
--- a/res/layout/manage_applications_running.xml
+++ b/res/layout/manage_applications_running.xml
@@ -20,7 +20,7 @@
             android:orientation="vertical">
 
     <FrameLayout android:id="@+id/pinned_header"
-                 android:layout_width="match_parent"
+                 android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:visibility="gone" />
 
diff --git a/res/layout/preference_list_fragment.xml b/res/layout/preference_list_fragment.xml
index a44535f..b47e175 100644
--- a/res/layout/preference_list_fragment.xml
+++ b/res/layout/preference_list_fragment.xml
@@ -25,7 +25,7 @@
       android:background="@android:color/transparent">
 
     <FrameLayout android:id="@+id/pinned_header"
-                 android:layout_width="match_parent"
+                 android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:visibility="gone" />
 
diff --git a/res/layout/user_preference.xml b/res/layout/user_preference.xml
index 79ffc38..625a065 100644
--- a/res/layout/user_preference.xml
+++ b/res/layout/user_preference.xml
@@ -16,7 +16,7 @@
 
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:id="@android:id/widget_frame"
-        android:layout_width="match_parent"
+        android:layout_width="wrap_content"
         android:layout_height="@dimen/user_spinner_item_height"
         android:orientation="horizontal" >
 
@@ -39,6 +39,7 @@
             android:ellipsize="marquee"
             android:fadingEdge="horizontal"
             android:paddingStart="@dimen/user_spinner_padding"
+            android:paddingEnd="@dimen/user_spinner_padding"
             style="@style/TextAppearance.Medium" />
 
 </LinearLayout>
\ No newline at end of file
diff --git a/res/values-land/dimens.xml b/res/values-land/dimens.xml
index 79529e2..1aa4b55 100755
--- a/res/values-land/dimens.xml
+++ b/res/values-land/dimens.xml
@@ -45,4 +45,10 @@
     <!-- Dashboard tile image margin start / end -->
     <dimen name="dashboard_tile_image_margin_start">12dp</dimen>
 
+    <dimen name="setup_wizard_card_title_margin_top">256dp</dimen>
+    <dimen name="setup_wizard_card_title_padding_end">32dp</dimen>
+    <dimen name="setup_wizard_card_title_padding_start">56dp</dimen>
+    <dimen name="setup_wizard_card_title_padding_top">24dp</dimen>
+    <dimen name="setup_wizard_card_title_padding_bottom">0dp</dimen>
+
 </resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 865b029..bbe62a5 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -48,12 +48,15 @@
     <!-- Size of padding to give in the wifi list when there is no icon -->
     <dimen name="setup_list_no_icon_padding">56dp</dimen>
     <dimen name="setup_add_network_item_height">56dp</dimen>
+    <dimen name="setup_wizard_card_corner_radius">2dp</dimen>
     <dimen name="setup_wizard_card_elevation">5dp</dimen>
-    <dimen name="setup_wizard_card_margin_top">128dp</dimen>
-    <dimen name="setup_wizard_card_title_margin_top">256dp</dimen>
-    <dimen name="setup_wizard_card_title_padding_end">32dp</dimen>
-    <dimen name="setup_wizard_card_title_padding_start">56dp</dimen>
-    <dimen name="setup_wizard_card_title_padding_top">24dp</dimen>
+    <dimen name="setup_wizard_card_title_margin_top">0dp</dimen>
+    <dimen name="setup_wizard_card_title_padding_end">0dp</dimen>
+    <dimen name="setup_wizard_card_title_padding_start">0dp</dimen>
+    <dimen name="setup_wizard_card_title_padding_top">16dp</dimen>
+    <dimen name="setup_wizard_card_title_padding_bottom">28dp</dimen>
+    <dimen name="setup_wizard_card_port_margin_sides">56dp</dimen>
+    <dimen name="setup_wizard_card_land_margin_top">128dp</dimen>
     <dimen name="setup_wizard_margin_sides">40dp</dimen>
 
     <dimen name="divider_height">3dip</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ed8142b..93b4320 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3602,6 +3602,8 @@
     <string name="accessibility_feature_state_on">On</string>
     <!-- Summary for the disabled state of an accessibility feature. [CHAR LIMIT=10] -->
     <string name="accessibility_feature_state_off">Off</string>
+    <!-- Summary when an accessibility feature or ime is not permitted. [CHAR LIMIT=40] -->
+    <string name="accessibility_feature_or_input_method_not_allowed">Not allowed by your organization</string>
 
     <!-- Title for the preference category containing the video caption preview. [CHAR LIMIT=35] -->
     <string name="captioning_preview_title">Preview</string>
@@ -5180,7 +5182,7 @@
     <!-- User settings summary for a restricted profile [CHAR LIMIT=50] -->
     <string name="user_summary_restricted_profile">Restricted profile</string>
     <!-- User settings summary for a managed profile [CHAR LIMIT=50] -->
-    <string name="user_summary_managed_profile">Managed profile</string>
+    <string name="user_summary_managed_profile">Work profile</string>
     <!-- User settings warning that restricted profile needs a screen lock [CHAR LIMIT=NONE] -->
     <string name="user_need_lock_message">Before you can create a restricted profile, you\'ll need to set up a screen lock to protect your apps and personal data.</string>
     <!-- User settings dialog button to set screen lock [CHAR LIMIT=25] -->
@@ -5190,7 +5192,7 @@
     <!-- User summary to indicate that restricted profile is currently not set up [CHAR LIMIT=100] -->
     <string name="user_summary_restricted_not_set_up">Not set up - Restricted profile</string>
     <!-- User summary to indicate that a managed profile is currently not set up [CHAR LIMIT=100] -->
-    <string name="user_summary_managed_profile_not_set_up">Not set up - Managed profile</string>
+    <string name="user_summary_managed_profile_not_set_up">Not set up - Work profile</string>
     <!-- User information string to represent the owner of the device [CHAR LIMIT=25] -->
     <string name="user_owner">Owner</string>
     <!-- User settings title for current user entry "You" user. [CHAR LIMIT=30] -->
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 1b08e0f..3f5f39d 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -174,15 +174,17 @@
         <item name="android:paddingTop">@dimen/setup_title_padding_top</item>
     </style>
 
-    <!-- Alternate title style used for some tablet-landscape layouts -->
-    <style name="SetupCardTitle" parent="@android:style/TextAppearance.Material.Display1">
-        <item name="android:layout_width">0dp</item>
-        <item name="android:layout_height">wrap_content</item>
+    <!-- Alternate title style used for some tablet layouts -->
+    <style name="SetupCardTitle">
         <item name="android:layout_marginTop">@dimen/setup_wizard_card_title_margin_top</item>
-        <item name="android:layout_weight">6</item>
-        <item name="android:paddingStart">@dimen/setup_wizard_card_title_padding_start</item>
+        <item name="android:paddingBottom">@dimen/setup_wizard_card_title_padding_bottom</item>
         <item name="android:paddingEnd">@dimen/setup_wizard_card_title_padding_end</item>
+        <item name="android:paddingStart">@dimen/setup_wizard_card_title_padding_start</item>
         <item name="android:paddingTop">@dimen/setup_wizard_card_title_padding_top</item>
+        <item name="android:textAppearance">@style/TextAppearance.SetupWizardCardTitle</item>
+    </style>
+
+    <style name="TextAppearance.SetupWizardCardTitle" parent="@android:style/TextAppearance.Material.Display1">
         <item name="android:textColor">@android:color/white</item>
     </style>
 
diff --git a/src/com/android/settings/WirelessSettings.java b/src/com/android/settings/WirelessSettings.java
index b256f94..ce3164d 100644
--- a/src/com/android/settings/WirelessSettings.java
+++ b/src/com/android/settings/WirelessSettings.java
@@ -129,9 +129,13 @@
         if (mTm.hasIccCard() && (ni != null)) {
             // Check for carrier apps that can handle provisioning first
             Intent provisioningIntent = new Intent(TelephonyIntents.ACTION_CARRIER_SETUP);
-            provisioningIntent.addCategory(TelephonyIntents.CATEGORY_MCCMNC_PREFIX
-                    + mTm.getSimOperator());
-            if (mPm.resolveActivity(provisioningIntent, 0 /* flags */) != null) {
+            List<String> carrierPackages =
+                    mTm.getCarrierPackageNamesForBroadcastIntent(provisioningIntent);
+            if (carrierPackages != null && !carrierPackages.isEmpty()) {
+                if (carrierPackages.size() != 1) {
+                    Log.w(TAG, "Multiple matching carrier apps found, launching the first.");
+                }
+                provisioningIntent.setPackage(carrierPackages.get(0));
                 startActivity(provisioningIntent);
                 return;
             }
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 36025a6..eff5fb6 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -18,6 +18,7 @@
 
 import android.accessibilityservice.AccessibilityServiceInfo;
 import android.app.ActivityManagerNative;
+import android.app.admin.DevicePolicyManager;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.pm.PackageManager;
@@ -28,6 +29,7 @@
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.RemoteException;
+import android.os.UserHandle;
 import android.preference.CheckBoxPreference;
 import android.preference.ListPreference;
 import android.preference.Preference;
@@ -197,11 +199,15 @@
 
     private int mLongPressTimeoutDefault;
 
+    private DevicePolicyManager mDpm;
+
     @Override
     public void onCreate(Bundle icicle) {
         super.onCreate(icicle);
         addPreferencesFromResource(R.xml.accessibility_settings);
         initializeAllPreferences();
+        mDpm = (DevicePolicyManager) (getActivity()
+                .getSystemService(Context.DEVICE_POLICY_SERVICE));
     }
 
     @Override
@@ -434,7 +440,8 @@
                 accessibilityManager.getInstalledAccessibilityServiceList();
         Set<ComponentName> enabledServices = AccessibilityUtils.getEnabledServicesFromSettings(
                 getActivity());
-
+        List<String> permittedServices = mDpm.getPermittedAccessibilityServices(
+                UserHandle.myUserId());
         final boolean accessibilityEnabled = Settings.Secure.getInt(getContentResolver(),
                 Settings.Secure.ACCESSIBILITY_ENABLED, 0) == 1;
 
@@ -454,12 +461,27 @@
             preference.setTitle(title);
             final boolean serviceEnabled = accessibilityEnabled
                     && enabledServices.contains(componentName);
+            String serviceEnabledString;
             if (serviceEnabled) {
-                preference.setSummary(getString(R.string.accessibility_feature_state_on));
+                serviceEnabledString = getString(R.string.accessibility_feature_state_on);
             } else {
-                preference.setSummary(getString(R.string.accessibility_feature_state_off));
+                serviceEnabledString = getString(R.string.accessibility_feature_state_off);
             }
 
+            // Disable all accessibility services that are not permitted.
+            String packageName = serviceInfo.packageName;
+            boolean serviceAllowed =
+                    permittedServices == null || permittedServices.contains(packageName);
+            preference.setEnabled(serviceAllowed || serviceEnabled);
+
+            String summaryString;
+            if (serviceAllowed) {
+                summaryString = serviceEnabledString;
+            } else  {
+                summaryString = getString(R.string.accessibility_feature_or_input_method_not_allowed);
+            }
+            preference.setSummary(summaryString);
+
             preference.setOrder(i);
             preference.setFragment(ToggleAccessibilityServicePreferenceFragment.class.getName());
             preference.setPersistent(true);
diff --git a/src/com/android/settings/bluetooth/DeviceProfilesSettings.java b/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
index 8b0c357..64c807f 100755
--- a/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
+++ b/src/com/android/settings/bluetooth/DeviceProfilesSettings.java
@@ -58,8 +58,6 @@
     private static final String KEY_UNPAIR = "unpair";
     private static final String KEY_PBAP_SERVER = "PBAP Server";
 
-    public static final String EXTRA_DEVICE = "device";
-
     private CachedBluetoothDevice mCachedDevice;
     private LocalBluetoothManager mManager;
     private LocalBluetoothProfileManager mProfileManager;
@@ -102,7 +100,6 @@
     @Override
     public void onSaveInstanceState(Bundle outState) {
         super.onSaveInstanceState(outState);
-        outState.putParcelable(EXTRA_DEVICE, mCachedDevice.getDevice());
     }
 
     @Override
diff --git a/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java b/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java
index f18694c..d0bc0cc 100644
--- a/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java
+++ b/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java
@@ -18,6 +18,7 @@
 
 import android.app.Activity;
 import android.app.Fragment;
+import android.app.admin.DevicePolicyManager;
 import android.content.ComponentName;
 import android.content.ContentResolver;
 import android.content.Context;
@@ -34,6 +35,7 @@
 import android.hardware.input.KeyboardLayout;
 import android.os.Bundle;
 import android.os.Handler;
+import android.os.UserHandle;
 import android.preference.CheckBoxPreference;
 import android.preference.ListPreference;
 import android.preference.Preference;
@@ -102,6 +104,7 @@
     private SettingsObserver mSettingsObserver;
     private Intent mIntentWaitingForResult;
     private InputMethodSettingValuesWrapper mInputMethodSettingValues;
+    private DevicePolicyManager mDpm;
 
     @Override
     public void onCreate(Bundle icicle) {
@@ -175,6 +178,8 @@
 
         mHandler = new Handler();
         mSettingsObserver = new SettingsObserver(mHandler, activity);
+        mDpm = (DevicePolicyManager) (getActivity().
+                getSystemService(Context.DEVICE_POLICY_SERVICE));
     }
 
     private void updateInputMethodSelectorSummary(int value) {
@@ -403,6 +408,7 @@
                 mKeyboardSettingsCategory.removePreference(pref);
             }
             mInputMethodPreferenceList.clear();
+            List<String> permittedList = mDpm.getPermittedInputMethodsForCurrentUser();
             final Context context = getActivity();
             final List<InputMethodInfo> imis = mShowsOnlyFullImeAndKeyboardList
                     ? mInputMethodSettingValues.getInputMethodList()
@@ -410,8 +416,11 @@
             final int N = (imis == null ? 0 : imis.size());
             for (int i = 0; i < N; ++i) {
                 final InputMethodInfo imi = imis.get(i);
+                final boolean isAllowedByOrganization = permittedList == null
+                        || permittedList.contains(imi.getPackageName());
                 final InputMethodPreference pref = new InputMethodPreference(
-                        context, imi, mShowsOnlyFullImeAndKeyboardList /* hasSwitch */, this);
+                        context, imi, mShowsOnlyFullImeAndKeyboardList /* hasSwitch */,
+                        isAllowedByOrganization, this);
                 mInputMethodPreferenceList.add(pref);
             }
             final Collator collator = Collator.getInstance();
diff --git a/src/com/android/settings/inputmethod/InputMethodPreference.java b/src/com/android/settings/inputmethod/InputMethodPreference.java
index 111f79b..5cf5d6a 100755
--- a/src/com/android/settings/inputmethod/InputMethodPreference.java
+++ b/src/com/android/settings/inputmethod/InputMethodPreference.java
@@ -68,6 +68,7 @@
     private final boolean mHasPriorityInSorting;
     private final OnSavePreferenceListener mOnSaveListener;
     private final InputMethodSettingValuesWrapper mInputMethodSettingValues;
+    private final boolean mIsAllowedByOrganization;
 
     private AlertDialog mDialog = null;
 
@@ -78,14 +79,18 @@
      * @param imi The {@link InputMethodInfo} of this preference.
      * @param isImeEnabler true if this preference is the IME enabler that has enable/disable
      *     switches for all available IMEs, not the list of enabled IMEs.
+     * @param isAllowedByOrganization false if the IME has been disabled by a device or profile
+           owner.
      * @param onSaveListener The listener called when this preference has been changed and needs
      *     to save the state to shared preference.
      */
     InputMethodPreference(final Context context, final InputMethodInfo imi,
-            final boolean isImeEnabler, final OnSavePreferenceListener onSaveListener) {
+            final boolean isImeEnabler, final boolean isAllowedByOrganization,
+            final OnSavePreferenceListener onSaveListener) {
         super(context);
         setPersistent(false);
         mImi = imi;
+        mIsAllowedByOrganization = isAllowedByOrganization;
         mOnSaveListener = onSaveListener;
         if (!isImeEnabler) {
             // Hide switch widget.
@@ -178,7 +183,7 @@
                 mImi, getContext());
         // Only when this preference has a switch and an input method should be always enabled,
         // this preference should be disabled to prevent accidentally disabling an input method.
-        setEnabled(!(isAlwaysChecked && isImeEnabler()));
+        setEnabled(!((isAlwaysChecked && isImeEnabler()) || (!mIsAllowedByOrganization)));
         setChecked(mInputMethodSettingValues.isEnabledImi(mImi));
         setSummary(getSummaryString());
     }
@@ -189,6 +194,9 @@
 
     private String getSummaryString() {
         final Context context = getContext();
+        if (!mIsAllowedByOrganization) {
+            return context.getString(R.string.accessibility_feature_or_input_method_not_allowed);
+        }
         final InputMethodManager imm = getInputMethodManager();
         final List<InputMethodSubtype> subtypes = imm.getEnabledInputMethodSubtypeList(mImi, true);
         final ArrayList<CharSequence> subtypeLabels = new ArrayList<>();
diff --git a/src/com/android/settings/wifi/AccessPoint.java b/src/com/android/settings/wifi/AccessPoint.java
index 3df4ece..0321e7f 100644
--- a/src/com/android/settings/wifi/AccessPoint.java
+++ b/src/com/android/settings/wifi/AccessPoint.java
@@ -456,7 +456,7 @@
                 if (result.seen == 0)
                     continue;
 
-                if (result.status != ScanResult.ENABLED)
+                if (result.autoJoinStatus != ScanResult.ENABLED)
                     numBlackListed++;
 
                 if (result.frequency > LOWER_FREQ_5GHZ