Merge "Avoid checking the restricted items in the list." into nyc-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index b3d1d61..ceea92e 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1968,6 +1968,17 @@
                   android:theme="@android:style/Theme.Material.Light.Dialog.NoActionBar">
         </activity>
 
+        <activity android:name=".RemoteBugreportActivity"
+                  android:excludeFromRecents="true"
+                  android:exported="true"
+                  android:permission="android.permission.DUMP"
+                  android:theme="@android:style/Theme.Material.Light.Dialog.NoActionBar">
+            <intent-filter>
+                <action android:name="android.settings.SHOW_REMOTE_BUGREPORT_DIALOG" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
+        </activity>
+
         <activity android:name=".bluetooth.RequestPermissionHelperActivity"
                   android:label="@string/bluetooth_pairing_request"
                   android:excludeFromRecents="true"
diff --git a/res/layout/preview_seek_bar_view_pager.xml b/res/layout/preview_seek_bar_view_pager.xml
index d16a356..72aee10 100644
--- a/res/layout/preview_seek_bar_view_pager.xml
+++ b/res/layout/preview_seek_bar_view_pager.xml
@@ -24,8 +24,7 @@
         android:id="@+id/preview_pager"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:background="?android:attr/colorBackgroundFloating"
-        android:importantForAccessibility="noHideDescendants"/>
+        android:background="?android:attr/colorBackgroundFloating" />
 
     <View
         android:layout_width="match_parent"
diff --git a/res/layout/redaction_interstitial.xml b/res/layout/redaction_interstitial.xml
index 06dc6aa..aafeb1b 100644
--- a/res/layout/redaction_interstitial.xml
+++ b/res/layout/redaction_interstitial.xml
@@ -65,4 +65,14 @@
 
     </RadioGroup>
 
+    <CheckBox
+            android:id="@+id/lockscreen_remote_input"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="@dimen/redaction_vertical_margins"
+            android:layout_marginStart="?android:attr/listPreferredItemPaddingStart"
+            android:layout_marginEnd="?android:attr/listPreferredItemPaddingEnd"
+            android:text="@string/lockscreen_remote_input"
+            android:textAppearance="?android:attr/textAppearanceMedium" />
+
 </LinearLayout>
\ No newline at end of file
diff --git a/res/layout/screen_zoom_preview_1.xml b/res/layout/screen_zoom_preview_1.xml
index 62cd093..a8408aa 100644
--- a/res/layout/screen_zoom_preview_1.xml
+++ b/res/layout/screen_zoom_preview_1.xml
@@ -20,7 +20,8 @@
     android:layout_height="match_parent"
     android:background="@color/conversation_background"
     android:padding="@dimen/conversation_message_list_padding"
-    android:orientation="vertical" >
+    android:orientation="vertical"
+    android:importantForAccessibility="noHideDescendants">
 
     <com.android.settings.display.ConversationMessageView
         android:layout_width="match_parent"
diff --git a/res/layout/screen_zoom_preview_2.xml b/res/layout/screen_zoom_preview_2.xml
index d9b748d..b61f92a 100644
--- a/res/layout/screen_zoom_preview_2.xml
+++ b/res/layout/screen_zoom_preview_2.xml
@@ -16,4 +16,5 @@
 <com.android.settings.display.AppGridView
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
-    android:layout_height="match_parent" />
+    android:layout_height="match_parent"
+    android:importantForAccessibility="noHideDescendants" />
diff --git a/res/layout/screen_zoom_preview_app_icon.xml b/res/layout/screen_zoom_preview_app_icon.xml
index b5ab4ac..7d7d983 100644
--- a/res/layout/screen_zoom_preview_app_icon.xml
+++ b/res/layout/screen_zoom_preview_app_icon.xml
@@ -16,7 +16,8 @@
 
 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="match_parent"
-             android:layout_height="wrap_content">
+             android:layout_height="wrap_content"
+             android:importantForAccessibility="noHideDescendants">
 
     <LinearLayout
         android:layout_width="@dimen/screen_zoom_preview_app_icon_width"
diff --git a/res/layout/screen_zoom_preview_settings.xml b/res/layout/screen_zoom_preview_settings.xml
index cf9a8bd..2e68009 100644
--- a/res/layout/screen_zoom_preview_settings.xml
+++ b/res/layout/screen_zoom_preview_settings.xml
@@ -18,7 +18,8 @@
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:scrollbars="none"
-    android:background="?android:attr/colorBackgroundFloating">
+    android:background="?android:attr/colorBackgroundFloating"
+    android:importantForAccessibility="noHideDescendants">
 
     <LinearLayout
         android:layout_width="match_parent"
diff --git a/res/menu/zen_settings_menu.xml b/res/menu/zen_settings_menu.xml
deleted file mode 100644
index ff28403..0000000
--- a/res/menu/zen_settings_menu.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 The Android Open Source Project
-
-     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.
--->
-
-<menu xmlns:android="http://schemas.android.com/apk/res/android">
-    <item
-        android:id="@+id/zen_access"
-        android:title="@string/manage_zen_access_title"
-        android:showAsAction="never" />
-</menu>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 1c78f56..62476f7 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -147,6 +147,9 @@
     <!-- Used for diagnostic info screens, precise translation isn't needed. Formats the SD card in the phone, meaning it will be erased and reformatted -->
     <string name="sdcard_format" product="default">Erase SD card</string>
 
+    <!-- Content description for dot pager indicator for preview pager. [CHAR LIMIT=NONE] -->
+    <string name="preview_page_indicator_content_description">Preview screen <xliff:g id="current_page" example="3">%1$d</xliff:g> of <xliff:g id="num_pages" example="9">%2$d</xliff:g></string>
+
     <!-- Summary of font size setting screen. [CHAR LIMIT=NONE] -->
     <string name="font_size_summary">Make the text on screen smaller or larger.</string>
 
@@ -6689,6 +6692,19 @@
     <!-- Description of how many more permissions to view on next page [CHAR LIMIT=30] -->
     <string name="additional_permissions_more"><xliff:g id="count" example="2">%1$d</xliff:g> more</string>
 
+    <!-- Title of dialog shown to ask for user consent for sharing a bugreport that was requested remotely by the IT administrator. -->
+    <string name="share_remote_bugreport_dialog_title">Share bug report?</string>
+    <!-- Message of a dialog shown to ask for user consent for sharing a bugreport that was requested remotely by the IT administrator. -->
+    <string name="share_remote_bugreport_dialog_message_finished">Your IT admin requested a bug report to help troubleshoot this device. Apps and data may be shared.</string>
+    <!-- Message of a dialog shown to ask for user consent for sharing a bugreport that was requested remotely by the IT administrator and it's still being taken. -->
+    <string name="share_remote_bugreport_dialog_message">Your IT admin requested a bug report to help troubleshoot this device. Apps and data may be shared, and your device may temporarily slow down.</string>
+    <!-- Message of a dialog shown to inform that the remote bugreport that was requested remotely by the IT administrator is still being taken and will be shared when finished. -->
+    <string name="sharing_remote_bugreport_dialog_message">This bug report is being shared with your IT admin. Contact them for more details.</string>
+    <!-- Acceptance label of dialog shown to ask for user consent for sharing the remote bugreport. -->
+    <string name="share_remote_bugreport_action">Share</string>
+    <!-- Decline label of dialog shown to ask for user consent for sharing the remote bugreport. -->
+    <string name="decline_remote_bugreport_action">Decline</string>
+
     <!-- Title of one of the choices in a dialog (with title defined in usb_use) that lets the user
          select what the USB connection for this device should be used for. This choice
          is for charging only. -->
diff --git a/res/xml/configure_notification_settings.xml b/res/xml/configure_notification_settings.xml
index cb93792..3574aed 100644
--- a/res/xml/configure_notification_settings.xml
+++ b/res/xml/configure_notification_settings.xml
@@ -30,17 +30,4 @@
             android:title="@string/lock_screen_notifications_title"
             android:summary="%s" />
 
-    <PreferenceCategory
-        android:key="advanced"
-        android:title="@string/advanced_section_header" >
-
-        <!-- Notification access -->
-        <Preference
-                android:key="manage_notification_access"
-                android:title="@string/manage_notification_access_title"
-                android:persistent="false"
-                android:fragment="com.android.settings.notification.NotificationAccessSettings" />
-
-    </PreferenceCategory>
-
 </PreferenceScreen>
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java
index 068d534..d604473 100644
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -54,6 +54,7 @@
 import android.os.StrictMode;
 import android.os.SystemProperties;
 import android.os.UserHandle;
+import android.service.persistentdata.PersistentDataBlockManager;
 import android.os.UserManager;
 import android.os.storage.IMountService;
 import android.provider.SearchIndexableResource;
@@ -221,6 +222,7 @@
     private DevicePolicyManager mDpm;
     private UserManager mUm;
     private WifiManager mWifiManager;
+    private PersistentDataBlockManager mOemUnlockManager;
 
     private SwitchBar mSwitchBar;
     private boolean mLastEnabledState;
@@ -328,6 +330,8 @@
                 ServiceManager.getService(Context.BACKUP_SERVICE));
         mWebViewUpdateService  =
             IWebViewUpdateService.Stub.asInterface(ServiceManager.getService("webviewupdate"));
+        mOemUnlockManager = (PersistentDataBlockManager)getActivity()
+                .getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE);
 
         mDpm = (DevicePolicyManager)getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE);
         mUm = (UserManager) getSystemService(Context.USER_SERVICE);
@@ -999,9 +1003,13 @@
         return !SystemProperties.get(PERSISTENT_DATA_BLOCK_PROP).equals("");
     }
 
-    private static boolean enableOemUnlockPreference() {
-        String flashLocked = SystemProperties.get(FLASH_LOCKED_PROP);
-        return !"0".equals(flashLocked);
+    private boolean enableOemUnlockPreference() {
+        int flashLockState = PersistentDataBlockManager.FLASH_LOCK_UNKNOWN;
+        if (mOemUnlockManager != null) {
+            flashLockState = mOemUnlockManager.getFlashLockState();
+        }
+
+        return flashLockState == PersistentDataBlockManager.FLASH_LOCK_LOCKED;
     }
 
     private void updateOemUnlockOptions() {
diff --git a/src/com/android/settings/PreviewPagerAdapter.java b/src/com/android/settings/PreviewPagerAdapter.java
index 72b0b2f..8032f92 100644
--- a/src/com/android/settings/PreviewPagerAdapter.java
+++ b/src/com/android/settings/PreviewPagerAdapter.java
@@ -50,6 +50,9 @@
         for (int i = 0; i < previewSampleResIds.length; ++i) {
             mPreviewFrames[i] = (TouchBlockingFrameLayout) LayoutInflater.from(context)
                     .inflate(R.layout.preview_frame_container, null);
+            mPreviewFrames[i].setContentDescription(
+                    context.getString(R.string.preview_page_indicator_content_description, i + 1,
+                            previewSampleResIds.length));
 
             for (Configuration configuration : configurations) {
                 // Create a new configuration for the specified value. It won't
diff --git a/src/com/android/settings/PreviewSeekBarPreferenceFragment.java b/src/com/android/settings/PreviewSeekBarPreferenceFragment.java
index ad32c2d..15baa38 100644
--- a/src/com/android/settings/PreviewSeekBarPreferenceFragment.java
+++ b/src/com/android/settings/PreviewSeekBarPreferenceFragment.java
@@ -20,10 +20,12 @@
 import android.content.res.Configuration;
 import android.os.Bundle;
 import android.support.v4.view.ViewPager;
+import android.support.v4.view.ViewPager.OnPageChangeListener;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.view.ViewGroup;
+import android.view.accessibility.AccessibilityEvent;
 import android.widget.SeekBar;
 import android.widget.SeekBar.OnSeekBarChangeListener;
 import android.widget.TextView;
@@ -48,11 +50,12 @@
     /** Resource id of the layout for this preference fragment. */
     protected int mActivityLayoutResId;
 
-    /** Resource id of the layout that defines the contents instide preview screen. */
+    /** Resource id of the layout that defines the contents inside preview screen. */
     protected int[] mPreviewSampleResIds;
 
     private ViewPager mPreviewPager;
     private PreviewPagerAdapter mPreviewPagerAdapter;
+    private DotsPageIndicator mPageIndicator;
 
     private TextView mLabel;
     private View mLarger;
@@ -132,7 +135,7 @@
             seekBar.setEnabled(false);
         }
 
-        final Context context = getContext();
+        final Context context = getPrefContext();
         final Configuration origConfig = context.getResources().getConfiguration();
         Configuration[] configurations = new Configuration[mEntries.length];
         for (int i = 0; i < mEntries.length; ++i) {
@@ -143,14 +146,47 @@
                 configurations);
         mPreviewPager = (ViewPager) content.findViewById(R.id.preview_pager);
         mPreviewPager.setAdapter(mPreviewPagerAdapter);
+        mPreviewPager.addOnPageChangeListener(new OnPageChangeListener() {
+            @Override
+            public void onPageScrollStateChanged(int state) {
+                // Do nothing.
+            }
 
-        final DotsPageIndicator pageIndicator =
-                (DotsPageIndicator) content.findViewById(R.id.page_indicator);
+            @Override
+            public void onPageScrolled(int position, float positionOffset,
+                    int positionOffsetPixels) {
+                // Do nothing.
+            }
+
+            @Override
+            public void onPageSelected(int position) {
+                mPreviewPager.sendAccessibilityEvent(AccessibilityEvent.TYPE_ANNOUNCEMENT);
+            }
+        });
+
+        mPageIndicator = (DotsPageIndicator) content.findViewById(R.id.page_indicator);
         if (mPreviewSampleResIds.length > 1) {
-            pageIndicator.setViewPager(mPreviewPager);
-            pageIndicator.setVisibility(View.VISIBLE);
+            mPageIndicator.setViewPager(mPreviewPager);
+            mPageIndicator.setVisibility(View.VISIBLE);
+            mPageIndicator.setOnPageChangeListener(new OnPageChangeListener() {
+                @Override
+                public void onPageScrollStateChanged(int state) {
+                    // Do nothing.
+                }
+
+                @Override
+                public void onPageScrolled(int position, float positionOffset,
+                        int positionOffsetPixels) {
+                    // Do nothing.
+                }
+
+                @Override
+                public void onPageSelected(int position) {
+                    setPagerIndicatorContentDescription(position);
+                }
+            });
         } else {
-            pageIndicator.setVisibility(View.GONE);
+            mPageIndicator.setVisibility(View.GONE);
         }
 
         setPreviewLayer(mInitialIndex, false);
@@ -176,11 +212,19 @@
         mSmaller.setEnabled(index > 0);
         mLarger.setEnabled(index < mEntries.length - 1);
 
+        setPagerIndicatorContentDescription(mPreviewPager.getCurrentItem());
+
         mPreviewPagerAdapter.setPreviewLayer(index, mCurrentIndex, mPreviewPager.getCurrentItem(),
                 animate);
         mCurrentIndex = index;
     }
 
+    private void setPagerIndicatorContentDescription(int position) {
+        mPageIndicator.setContentDescription(
+                getPrefContext().getString(R.string.preview_page_indicator_content_description,
+                        position + 1, mPreviewSampleResIds.length));
+    }
+
     /**
      * Persists the selected value and sends a configuration change.
      */
diff --git a/src/com/android/settings/RemoteBugreportActivity.java b/src/com/android/settings/RemoteBugreportActivity.java
new file mode 100644
index 0000000..0589a24
--- /dev/null
+++ b/src/com/android/settings/RemoteBugreportActivity.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * 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.
+ */
+package com.android.settings;
+
+import android.annotation.Nullable;
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.admin.DevicePolicyManager;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.UserHandle;
+import android.util.Log;
+import android.widget.LinearLayout;
+
+import com.android.settings.R;
+
+/**
+ * UI for the remote bugreport dialog. Shows one of 3 possible dialogs:
+ * <ul>
+ * <li>bugreport is still being taken and can be shared or declined</li>
+ * <li>bugreport has been taken and can be shared or declined</li>
+ * <li>bugreport has already been accepted to be shared, but is still being taken</li>
+ * </ul>
+ */
+public class RemoteBugreportActivity extends Activity {
+
+    private static final String TAG = "RemoteBugreportActivity";
+
+    @Override
+    protected void onCreate(@Nullable Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        final int notificationType = getIntent().getIntExtra(
+                DevicePolicyManager.EXTRA_BUGREPORT_NOTIFICATION_TYPE, -1);
+
+        if (notificationType == DevicePolicyManager.NOTIFICATION_BUGREPORT_ACCEPTED_NOT_FINISHED) {
+            AlertDialog dialog = new AlertDialog.Builder(this)
+                    .setMessage(R.string.sharing_remote_bugreport_dialog_message)
+                    .setOnDismissListener(new DialogInterface.OnDismissListener() {
+                        @Override
+                        public void onDismiss(DialogInterface dialog) {
+                            finish();
+                        }
+                    })
+                    .setNegativeButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+                        @Override
+                        public void onClick(DialogInterface dialog, int which) {
+                            finish();
+                        }
+                    })
+                    .create();
+            dialog.show();
+        } else if (notificationType == DevicePolicyManager.NOTIFICATION_BUGREPORT_STARTED
+                || notificationType
+                        == DevicePolicyManager.NOTIFICATION_BUGREPORT_FINISHED_NOT_ACCEPTED) {
+            AlertDialog dialog = new AlertDialog.Builder(this)
+                    .setTitle(R.string.share_remote_bugreport_dialog_title)
+                    .setMessage(notificationType
+                                    == DevicePolicyManager.NOTIFICATION_BUGREPORT_STARTED
+                            ? R.string.share_remote_bugreport_dialog_message
+                            : R.string.share_remote_bugreport_dialog_message_finished)
+                    .setOnDismissListener(new DialogInterface.OnDismissListener() {
+                        @Override
+                        public void onDismiss(DialogInterface dialog) {
+                            finish();
+                        }
+                    })
+                    .setNegativeButton(R.string.decline_remote_bugreport_action,
+                            new DialogInterface.OnClickListener() {
+                        @Override
+                        public void onClick(DialogInterface dialog, int which) {
+                            Intent intent = new Intent(
+                                    DevicePolicyManager.ACTION_BUGREPORT_SHARING_DECLINED);
+                            RemoteBugreportActivity.this.sendBroadcastAsUser(intent,
+                                    UserHandle.SYSTEM, android.Manifest.permission.DUMP);
+                            finish();
+                        }
+                    })
+                    .setPositiveButton(R.string.share_remote_bugreport_action,
+                            new DialogInterface.OnClickListener() {
+                        @Override
+                        public void onClick(DialogInterface dialog, int which) {
+                            Intent intent = new Intent(
+                                    DevicePolicyManager.ACTION_BUGREPORT_SHARING_ACCEPTED);
+                            RemoteBugreportActivity.this.sendBroadcastAsUser(intent,
+                                    UserHandle.SYSTEM, android.Manifest.permission.DUMP);
+                            finish();
+                        }
+                    })
+                    .create();
+            dialog.show();
+        } else {
+            Log.e(TAG, "Incorrect dialog type, no dialog shown. Received: " + notificationType);
+        }
+    }
+}
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java
index ccc158f..728c302 100644
--- a/src/com/android/settings/SecuritySettings.java
+++ b/src/com/android/settings/SecuritySettings.java
@@ -117,7 +117,9 @@
 
     // These switch preferences need special handling since they're not all stored in Settings.
     private static final String SWITCH_PREFERENCE_KEYS[] = {
-            KEY_SHOW_PASSWORD, KEY_TOGGLE_INSTALL_APPLICATIONS, KEY_UNIFICATION };
+            KEY_SHOW_PASSWORD, KEY_TOGGLE_INSTALL_APPLICATIONS, KEY_UNIFICATION,
+            KEY_VISIBLE_PATTERN_PROFILE
+    };
 
     // Only allow one trust agent on the platform.
     private static final boolean ONLY_ONE_TRUST_AGENT = true;
diff --git a/src/com/android/settings/SetupChooseLockPassword.java b/src/com/android/settings/SetupChooseLockPassword.java
index d9b034b..e1e0d51 100644
--- a/src/com/android/settings/SetupChooseLockPassword.java
+++ b/src/com/android/settings/SetupChooseLockPassword.java
@@ -102,7 +102,7 @@
         @Override
         public void onViewCreated(View view, Bundle savedInstanceState) {
             super.onViewCreated(view, savedInstanceState);
-            SystemBarHelper.setImeInsetView(mLayout.findViewById(R.id.suw_bottom_scroll_view));
+            SystemBarHelper.setImeInsetView(mLayout);
             SetupWizardUtils.setImmersiveMode(getActivity());
             mLayout.setHeaderText(getActivity().getTitle());
         }
diff --git a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java
index 7e7f4d6..5109edd 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettingsForSetupWizardActivity.java
@@ -20,6 +20,7 @@
 import android.app.FragmentTransaction;
 import android.os.Bundle;
 import android.text.TextUtils;
+import android.view.accessibility.AccessibilityEvent;
 import android.view.Menu;
 import android.view.View;
 
@@ -31,6 +32,8 @@
 
 public class AccessibilitySettingsForSetupWizardActivity extends SettingsActivity {
 
+    private boolean mSendExtraWindowStateChanged;
+
     @Override
     protected void onCreate(Bundle savedState) {
         super.onCreate(savedState);
@@ -59,6 +62,12 @@
     }
 
     @Override
+    public void onResume() {
+        super.onResume();
+        mSendExtraWindowStateChanged = false;
+    }
+
+    @Override
     public boolean onCreateOptionsMenu(Menu menu) {
         // Return true, so we get notified when items in the menu are clicked.
         return true;
@@ -67,6 +76,11 @@
     @Override
     public boolean onNavigateUp() {
         onBackPressed();
+
+        // Clear accessibility focus and let the screen reader announce the new title.
+        getWindow().getDecorView()
+                .sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
+
         return true;
     }
 
@@ -83,6 +97,16 @@
         // Start the new Fragment.
         args.putInt(SettingsPreferenceFragment.HELP_URI_RESOURCE_KEY, 0);
         startPreferenceFragment(Fragment.instantiate(this, fragmentClass, args), true);
+        mSendExtraWindowStateChanged = true;
+    }
+
+    @Override
+    public void onAttachFragment(Fragment fragment) {
+        if (mSendExtraWindowStateChanged) {
+            // Clear accessibility focus and let the screen reader announce the new title.
+            getWindow().getDecorView()
+                    .sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
+        }
     }
 
     /**
diff --git a/src/com/android/settings/notification/NotificationLockscreenPreference.java b/src/com/android/settings/notification/NotificationLockscreenPreference.java
index cbf31ad..34770da 100644
--- a/src/com/android/settings/notification/NotificationLockscreenPreference.java
+++ b/src/com/android/settings/notification/NotificationLockscreenPreference.java
@@ -86,7 +86,7 @@
     }
 
     private static int checkboxVisibilityForSelectedIndex(int selected, boolean showRemoteAtAll) {
-        return selected == 0 && showRemoteAtAll ? View.VISIBLE : View.GONE;
+        return selected == 1 && showRemoteAtAll ? View.VISIBLE : View.GONE;
     }
 
     private class Listener implements DialogInterface.OnClickListener,
diff --git a/src/com/android/settings/notification/RedactionInterstitial.java b/src/com/android/settings/notification/RedactionInterstitial.java
index bd1dfe8..abadb8b 100644
--- a/src/com/android/settings/notification/RedactionInterstitial.java
+++ b/src/com/android/settings/notification/RedactionInterstitial.java
@@ -24,6 +24,8 @@
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.CheckBox;
+import android.widget.CompoundButton;
 import android.widget.RadioButton;
 import android.widget.RadioGroup;
 import android.widget.TextView;
@@ -74,11 +76,12 @@
     }
 
     public static class RedactionInterstitialFragment extends SettingsPreferenceFragment
-            implements RadioGroup.OnCheckedChangeListener {
+            implements RadioGroup.OnCheckedChangeListener, CompoundButton.OnCheckedChangeListener {
 
         private RadioGroup mRadioGroup;
         private RestrictedRadioButton mShowAllButton;
         private RestrictedRadioButton mRedactSensitiveButton;
+        private CheckBox mRemoteInputCheckbox;
         private int mUserId;
 
         @Override
@@ -99,6 +102,8 @@
             mShowAllButton = (RestrictedRadioButton) view.findViewById(R.id.show_all);
             mRedactSensitiveButton =
                     (RestrictedRadioButton) view.findViewById(R.id.redact_sensitive);
+            mRemoteInputCheckbox = (CheckBox) view.findViewById(R.id.lockscreen_remote_input);
+            mRemoteInputCheckbox.setOnCheckedChangeListener(this);
 
             mRadioGroup.setOnCheckedChangeListener(this);
             mUserId = Utils.getUserIdFromBundle(
@@ -150,6 +155,12 @@
             }
 
             mRadioGroup.check(checkedButtonId);
+
+            boolean allowRemoteInput = Settings.Secure.getIntForUser(getContentResolver(),
+                    Settings.Secure.LOCK_SCREEN_ALLOW_REMOTE_INPUT, 0, mUserId) != 0;
+            mRemoteInputCheckbox.setChecked(!allowRemoteInput);
+
+            updateRemoteInputCheckboxVisibility();
         }
 
         @Override
@@ -161,6 +172,21 @@
                     Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, show ? 1 : 0, mUserId);
             Settings.Secure.putIntForUser(getContentResolver(),
                     Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, enabled ? 1 : 0, mUserId);
+
+            updateRemoteInputCheckboxVisibility();
+        }
+
+        @Override
+        public void onCheckedChanged(CompoundButton buttonView, boolean checked) {
+            if (buttonView == mRemoteInputCheckbox) {
+                Settings.Secure.putIntForUser(getContentResolver(),
+                        Settings.Secure.LOCK_SCREEN_ALLOW_REMOTE_INPUT, checked ? 0 : 1, mUserId);
+            }
+        }
+
+        private void updateRemoteInputCheckboxVisibility() {
+            boolean visible = mRadioGroup.getCheckedRadioButtonId() == R.id.show_all;
+            mRemoteInputCheckbox.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
         }
     }
 }
diff --git a/src/com/android/settings/notification/ZenModeSettings.java b/src/com/android/settings/notification/ZenModeSettings.java
index 297029e..8cca84f 100644
--- a/src/com/android/settings/notification/ZenModeSettings.java
+++ b/src/com/android/settings/notification/ZenModeSettings.java
@@ -78,23 +78,6 @@
         updateVisualSettingsSummary();
     }
 
-    @Override
-    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
-        inflater.inflate(R.menu.zen_settings_menu, menu);
-    }
-
-    @Override
-    public boolean onOptionsItemSelected(MenuItem item) {
-        switch (item.getItemId()) {
-            case R.id.zen_access:
-                ((SettingsActivity) getActivity()).startPreferencePanel(
-                            ZenAccessSettings.class.getCanonicalName(), null,
-                            R.string.manage_zen_access_title, null, this, 0);
-                return true;
-        }
-        return super.onOptionsItemSelected(item);
-    }
-
     private void updatePrioritySettingsSummary() {
         String s = getResources().getString(R.string.zen_mode_alarms);
         s = appendLowercase(s, isCategoryEnabled(mPolicy, Policy.PRIORITY_CATEGORY_REMINDERS),
diff --git a/src/com/android/settings/users/RestrictionUtils.java b/src/com/android/settings/users/RestrictionUtils.java
index 33b6a95..a5cecde 100644
--- a/src/com/android/settings/users/RestrictionUtils.java
+++ b/src/com/android/settings/users/RestrictionUtils.java
@@ -78,9 +78,8 @@
     public static void setRestrictions(Context context, ArrayList<RestrictionEntry> entries,
             UserHandle user) {
         UserManager um = UserManager.get(context);
-
         for (RestrictionEntry entry : entries) {
-            um.setUserRestriction(entry.getKey(), !entry.getSelectedState());
+            um.setUserRestriction(entry.getKey(), !entry.getSelectedState(), user);
         }
     }
 }