Merge "Separate auto click preference controller from accessibility"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 07dd1dd..cf1ae94 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -2271,6 +2271,7 @@
                   android:excludeFromRecents="true"
                   android:label=""
                   android:screenOrientation="nosensor"
+                  android:taskAffinity="com.android.settings.FallbackHome"
                   android:theme="@style/FallbackHome">
             <intent-filter android:priority="-1000">
                 <action android:name="android.intent.action.MAIN" />
diff --git a/res/drawable/ic_arrow_down_24dp.xml b/res/drawable/ic_arrow_down_24dp.xml
index 8503511..f2efb4c 100644
--- a/res/drawable/ic_arrow_down_24dp.xml
+++ b/res/drawable/ic_arrow_down_24dp.xml
@@ -16,9 +16,10 @@
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
         android:width="24dp"
         android:height="24dp"
+        android:tint="?android:attr/colorControlNormal"
         android:viewportWidth="24.0"
         android:viewportHeight="24.0">
     <path
-        android:fillColor="?android:attr/colorControlNormal"
+        android:fillColor="@android:color/white"
         android:pathData="M12,16.41l-6.71,-6.7l1.42,-1.42l5.29,5.3l5.29,-5.3l1.42,1.42z"/>
 </vector>
diff --git a/res/drawable/ic_content_copy_grey600_24dp.xml b/res/drawable/ic_content_copy_grey600_24dp.xml
index 827c66e..ba17ab6 100644
--- a/res/drawable/ic_content_copy_grey600_24dp.xml
+++ b/res/drawable/ic_content_copy_grey600_24dp.xml
@@ -1,9 +1,10 @@
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
     android:width="24dp"
     android:height="24dp"
+    android:tint="@*android:color/material_grey_600"
     android:viewportWidth="24"
     android:viewportHeight="24">
   <path
       android:pathData="M16,1L4,1c-1.1,0 -2,0.9 -2,2v14h2L4,3h12L16,1zM19,5L8,5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h11c1.1,0 2,-0.9 2,-2L21,7c0,-1.1 -0.9,-2 -2,-2zM19,21L8,21L8,7h11v14z"
-      android:fillColor="#757575"/>
+      android:fillColor="@android:color/white"/>
 </vector>
diff --git a/res/drawable/ic_devices_other_32dp.xml b/res/drawable/ic_devices_other_32dp.xml
index 0890dea..7f9df8c 100644
--- a/res/drawable/ic_devices_other_32dp.xml
+++ b/res/drawable/ic_devices_other_32dp.xml
@@ -16,10 +16,10 @@
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
     android:width="32dp"
     android:height="32dp"
+    android:tint="?android:attr/colorAccent"
     android:viewportWidth="24"
-    android:viewportHeight="24"
-    android:tint="?android:attr/colorAccent">
+    android:viewportHeight="24">
   <path
-      android:fillColor="#FF000000"
+      android:fillColor="@android:color/white"
       android:pathData="M3,6h18L21,4L3,4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h4v-2L3,18L3,6zM13,12L9,12v1.78c-0.61,0.55 -1,1.33 -1,2.22 0,0.89 0.39,1.67 1,2.22L9,20h4v-1.78c0.61,-0.55 1,-1.34 1,-2.22s-0.39,-1.67 -1,-2.22L13,12zM11,17.5c-0.83,0 -1.5,-0.67 -1.5,-1.5s0.67,-1.5 1.5,-1.5 1.5,0.67 1.5,1.5 -0.67,1.5 -1.5,1.5zM22,8h-6c-0.5,0 -1,0.5 -1,1v10c0,0.5 0.5,1 1,1h6c0.5,0 1,-0.5 1,-1L23,9c0,-0.5 -0.5,-1 -1,-1zM21,18h-4v-8h4v8z"/>
 </vector>
diff --git a/res/drawable/ic_friction_lock_closed.xml b/res/drawable/ic_friction_lock_closed.xml
index 2f035e7..2c34060 100644
--- a/res/drawable/ic_friction_lock_closed.xml
+++ b/res/drawable/ic_friction_lock_closed.xml
@@ -17,9 +17,10 @@
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
         android:width="24dp"
         android:height="24dp"
+        android:tint="?android:attr/colorControlNormal"
         android:viewportWidth="24"
         android:viewportHeight="24">
     <path
-        android:fillColor="?android:attr/colorControlNormal"
+        android:fillColor="@android:color/white"
         android:pathData="M18,8h-1V6c0,-2.76 -2.24,-5 -5,-5S7,3.24 7,6v2H6c-1.1,0 -2,0.9 -2,2v10c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2V10C20,8.9 19.1,8 18,8zM9,6c0,-1.66 1.34,-3 3,-3s3,1.34 3,3v2H9V6zM18,20H6V10h12V20zM12,17c1.1,0 2,-0.9 2,-2c0,-1.1 -0.9,-2 -2,-2c-1.1,0 -2,0.9 -2,2C10,16.1 10.9,17 12,17z"/>
 </vector>
diff --git a/res/layout/contextual_slice_deferred_setup.xml b/res/layout/contextual_slice_deferred_setup.xml
index e695d1d..7d5b688 100644
--- a/res/layout/contextual_slice_deferred_setup.xml
+++ b/res/layout/contextual_slice_deferred_setup.xml
@@ -25,7 +25,7 @@
         android:id="@+id/content"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:gravity="left"
+        android:gravity="start"
         android:orientation="vertical"
         android:paddingEnd="@dimen/contextual_card_padding_end"
         android:paddingTop="@dimen/contextual_deferred_setup_card_padding_top"
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index 3ad5d6e..eddce0f 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -75,7 +75,8 @@
 
         <SwitchPreference
             android:key="toggle_large_pointer_icon"
-            android:title="@string/accessibility_toggle_large_pointer_icon_title"/>
+            android:title="@string/accessibility_toggle_large_pointer_icon_title"
+            settings:controller="com.android.settings.accessibility.LargePointerIconPreferenceController"/>
 
         <SwitchPreference
             android:key="toggle_disable_animations"
@@ -97,7 +98,9 @@
         <SwitchPreference
             android:key="toggle_power_button_ends_call_preference"
             android:title="@string/accessibility_power_button_ends_call_prerefence_title"
-            android:persistent="false"/>
+            android:persistent="false"
+            settings:controller="com.android.settings.accessibility.PowerButtonEndsCallPreferenceController"/>
+
 
         <SwitchPreference
             android:key="toggle_lock_screen_rotation_preference"
@@ -163,7 +166,8 @@
 
         <SwitchPreference
             android:key="toggle_high_text_contrast_preference"
-            android:title="@string/accessibility_toggle_high_text_contrast_preference_title"/>
+            android:title="@string/accessibility_toggle_high_text_contrast_preference_title"
+            settings:controller="com.android.settings.accessibility.HighTextContrastPreferenceController"/>
 
         <Preference
             android:fragment="com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment"
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index fd05714..a302411 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -39,8 +39,6 @@
 import android.provider.Settings;
 import android.text.TextUtils;
 import android.util.ArrayMap;
-import android.view.KeyCharacterMap;
-import android.view.KeyEvent;
 import android.view.accessibility.AccessibilityManager;
 
 import androidx.annotation.VisibleForTesting;
@@ -97,12 +95,8 @@
     };
 
     // Preferences
-    private static final String TOGGLE_HIGH_TEXT_CONTRAST_PREFERENCE =
-            "toggle_high_text_contrast_preference";
     private static final String TOGGLE_INVERSION_PREFERENCE =
             "toggle_inversion_preference";
-    private static final String TOGGLE_POWER_BUTTON_ENDS_CALL_PREFERENCE =
-            "toggle_power_button_ends_call_preference";
     private static final String TOGGLE_LARGE_POINTER_ICON =
             "toggle_large_pointer_icon";
     private static final String TOGGLE_DISABLE_ANIMATIONS = "toggle_disable_animations";
@@ -198,8 +192,6 @@
     private final Map<ComponentName, PreferenceCategory> mPreBundledServiceComponentToCategoryMap =
             new ArrayMap<>();
 
-    private SwitchPreference mToggleHighTextContrastPreference;
-    private SwitchPreference mTogglePowerButtonEndsCallPreference;
     private SwitchPreference mToggleLargePointerIconPreference;
     private SwitchPreference mToggleDisableAnimationsPreference;
     private SwitchPreference mToggleMasterMonoPreference;
@@ -312,16 +304,7 @@
 
     @Override
     public boolean onPreferenceTreeClick(Preference preference) {
-        if (mToggleHighTextContrastPreference == preference) {
-            handleToggleTextContrastPreferenceClick();
-            return true;
-        } else if (mTogglePowerButtonEndsCallPreference == preference) {
-            handleTogglePowerButtonEndsCallPreferenceClick();
-            return true;
-        } else if (mToggleLargePointerIconPreference == preference) {
-            handleToggleLargePointerIconPreferenceClick();
-            return true;
-        } else if (mToggleMasterMonoPreference == preference) {
+        if (mToggleMasterMonoPreference == preference) {
             handleToggleMasterMonoPreferenceClick();
             return true;
         } else if (mHearingAidPreferenceController.handlePreferenceTreeClick(preference)) {
@@ -364,26 +347,6 @@
                         DeviceConfig.NAMESPACE_TELEPHONY, RAMPING_RINGER_ENABLED, false);
     }
 
-    private void handleToggleTextContrastPreferenceClick() {
-        Settings.Secure.putInt(getContentResolver(),
-                Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED,
-                (mToggleHighTextContrastPreference.isChecked() ? 1 : 0));
-    }
-
-    private void handleTogglePowerButtonEndsCallPreferenceClick() {
-        Settings.Secure.putInt(getContentResolver(),
-                Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR,
-                (mTogglePowerButtonEndsCallPreference.isChecked()
-                        ? Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_HANGUP
-                        : Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_SCREEN_OFF));
-    }
-
-    private void handleToggleLargePointerIconPreferenceClick() {
-        Settings.Secure.putInt(getContentResolver(),
-                Settings.Secure.ACCESSIBILITY_LARGE_POINTER_ICON,
-                mToggleLargePointerIconPreference.isChecked() ? 1 : 0);
-    }
-
     private void handleToggleMasterMonoPreferenceClick() {
         Settings.System.putIntForUser(getContentResolver(), Settings.System.MASTER_MONO,
                 mToggleMasterMonoPreference.isChecked() ? 1 : 0, UserHandle.USER_CURRENT);
@@ -395,25 +358,11 @@
             mCategoryToPrefCategoryMap.put(CATEGORIES[i], prefCategory);
         }
 
-        // Text contrast.
-        mToggleHighTextContrastPreference =
-                (SwitchPreference) findPreference(TOGGLE_HIGH_TEXT_CONTRAST_PREFERENCE);
-
         // Display inversion.
         mToggleInversionPreference = findPreference(TOGGLE_INVERSION_PREFERENCE);
 
-        // Power button ends calls.
-        mTogglePowerButtonEndsCallPreference =
-                (SwitchPreference) findPreference(TOGGLE_POWER_BUTTON_ENDS_CALL_PREFERENCE);
-        if (!KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_POWER)
-                || !Utils.isVoiceCapable(getActivity())) {
-            mCategoryToPrefCategoryMap.get(CATEGORY_INTERACTION_CONTROL)
-                    .removePreference(mTogglePowerButtonEndsCallPreference);
-        }
-
         // Large pointer icon.
-        mToggleLargePointerIconPreference =
-                (SwitchPreference) findPreference(TOGGLE_LARGE_POINTER_ICON);
+        mToggleLargePointerIconPreference = findPreference(TOGGLE_LARGE_POINTER_ICON);
 
         mToggleDisableAnimationsPreference =
                 (SwitchPreference) findPreference(TOGGLE_DISABLE_ANIMATIONS);
@@ -674,29 +623,9 @@
             displayCategory.addPreference(mDisplayDaltonizerPreferenceScreen);
         }
 
-        // Text contrast.
-        mToggleHighTextContrastPreference.setChecked(
-                Settings.Secure.getInt(getContentResolver(),
-                        Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED, 0) == 1);
-
         // Dark Mode
         mDarkUIPreferenceController.updateState(mDarkUIModePreference);
 
-        // Power button ends calls.
-        if (KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_POWER)
-                && Utils.isVoiceCapable(getActivity())) {
-            final int incallPowerBehavior = Settings.Secure.getInt(getContentResolver(),
-                    Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR,
-                    Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT);
-            final boolean powerButtonEndsCall =
-                    (incallPowerBehavior == Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_HANGUP);
-            mTogglePowerButtonEndsCallPreference.setChecked(powerButtonEndsCall);
-        }
-
-        // Large pointer icon.
-        mToggleLargePointerIconPreference.setChecked(Settings.Secure.getInt(getContentResolver(),
-                Settings.Secure.ACCESSIBILITY_LARGE_POINTER_ICON, 0) != 0);
-
         // Master mono
         updateMasterMono();
 
diff --git a/src/com/android/settings/accessibility/HighTextContrastPreferenceController.java b/src/com/android/settings/accessibility/HighTextContrastPreferenceController.java
new file mode 100644
index 0000000..f4474d6
--- /dev/null
+++ b/src/com/android/settings/accessibility/HighTextContrastPreferenceController.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2019 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.accessibility;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import com.android.settings.core.TogglePreferenceController;
+
+public class HighTextContrastPreferenceController extends TogglePreferenceController {
+
+    public HighTextContrastPreferenceController(Context context, String preferenceKey) {
+        super(context, preferenceKey);
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE;
+    }
+
+    @Override
+    public boolean isChecked() {
+        return Settings.Secure.getInt(mContext.getContentResolver(),
+                Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED, 0) == 1;
+    }
+
+    @Override
+    public boolean setChecked(boolean isChecked) {
+        return Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED, (isChecked ? 1 : 0));
+    }
+}
diff --git a/src/com/android/settings/accessibility/LargePointerIconPreferenceController.java b/src/com/android/settings/accessibility/LargePointerIconPreferenceController.java
new file mode 100644
index 0000000..a7ee3d5
--- /dev/null
+++ b/src/com/android/settings/accessibility/LargePointerIconPreferenceController.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2019 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.accessibility;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import androidx.annotation.VisibleForTesting;
+
+import com.android.settings.core.TogglePreferenceController;
+
+public class LargePointerIconPreferenceController extends TogglePreferenceController {
+
+    @VisibleForTesting
+    static final int ON = 1;
+    @VisibleForTesting
+    static final int OFF = 0;
+
+    public LargePointerIconPreferenceController(Context context, String preferenceKey) {
+        super(context, preferenceKey);
+    }
+
+    @Override
+    public boolean isChecked() {
+        return Settings.Secure.getInt(mContext.getContentResolver(),
+                Settings.Secure.ACCESSIBILITY_LARGE_POINTER_ICON, OFF) != OFF;
+    }
+
+    @Override
+    public boolean setChecked(boolean isChecked) {
+        return Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.ACCESSIBILITY_LARGE_POINTER_ICON, isChecked ? ON : OFF);
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE;
+    }
+}
diff --git a/src/com/android/settings/accessibility/PowerButtonEndsCallPreferenceController.java b/src/com/android/settings/accessibility/PowerButtonEndsCallPreferenceController.java
new file mode 100644
index 0000000..9ea9644
--- /dev/null
+++ b/src/com/android/settings/accessibility/PowerButtonEndsCallPreferenceController.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2019 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.accessibility;
+
+import android.content.Context;
+import android.provider.Settings;
+import android.view.KeyCharacterMap;
+import android.view.KeyEvent;
+
+import com.android.settings.Utils;
+import com.android.settings.core.TogglePreferenceController;
+
+public class PowerButtonEndsCallPreferenceController extends TogglePreferenceController {
+
+    public PowerButtonEndsCallPreferenceController(Context context, String preferenceKey) {
+        super(context, preferenceKey);
+    }
+
+    @Override
+    public boolean isChecked() {
+        final int incallPowerBehavior = Settings.Secure.getInt(mContext.getContentResolver(),
+                Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR,
+                Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT);
+        return incallPowerBehavior == Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_HANGUP;
+    }
+
+    @Override
+    public boolean setChecked(boolean isChecked) {
+        return Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR,
+                (isChecked ? Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_HANGUP
+                        : Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_SCREEN_OFF));
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return !KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_POWER)
+                || !Utils.isVoiceCapable(mContext) ? UNSUPPORTED_ON_DEVICE : AVAILABLE;
+    }
+}
diff --git a/src/com/android/settings/tts/TextToSpeechSettings.java b/src/com/android/settings/tts/TextToSpeechSettings.java
index d4c7318..325370f 100644
--- a/src/com/android/settings/tts/TextToSpeechSettings.java
+++ b/src/com/android/settings/tts/TextToSpeechSettings.java
@@ -26,7 +26,10 @@
 import android.content.Context;
 import android.content.Intent;
 import android.os.Bundle;
+import android.os.UserHandle;
+import android.os.UserManager;
 import android.provider.SearchIndexableResource;
+import android.provider.Settings.Secure;
 import android.speech.tts.TextToSpeech;
 import android.speech.tts.TextToSpeech.EngineInfo;
 import android.speech.tts.TtsEngines;
@@ -44,6 +47,7 @@
 import com.android.settings.SettingsPreferenceFragment;
 import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settings.search.Indexable;
+import com.android.settings.Utils;
 import com.android.settings.widget.GearPreference;
 import com.android.settings.widget.SeekBarPreference;
 import com.android.settingslib.search.SearchIndexable;
@@ -148,6 +152,11 @@
      */
     private final TextToSpeech.OnInitListener mInitListener = this::onInitEngine;
 
+    /**
+     * A UserManager used to set settings for both person and work profiles for a user
+     */
+    private UserManager mUserManager;
+
     @Override
     public int getMetricsCategory() {
         return SettingsEnums.TTS_TEXT_TO_SPEECH;
@@ -176,6 +185,9 @@
                 .setButton2OnClickListener(v -> resetTts())
                 .setButton1Enabled(true);
 
+        mUserManager = (UserManager) getActivity()
+                .getApplicationContext().getSystemService(Context.USER_SERVICE);
+
         if (savedInstanceState == null) {
             mLocalePreference.setEnabled(false);
             mLocalePreference.setEntries(new CharSequence[0]);
@@ -670,8 +682,7 @@
     private void updateSpeechRate(int speechRateSeekBarProgress) {
         mDefaultRate = getValueFromSeekBarProgress(KEY_DEFAULT_RATE, speechRateSeekBarProgress);
         try {
-            android.provider.Settings.Secure.putInt(
-                    getContentResolver(), TTS_DEFAULT_RATE, mDefaultRate);
+            updateTTSSetting(TTS_DEFAULT_RATE, mDefaultRate);
             if (mTts != null) {
                 mTts.setSpeechRate(mDefaultRate / 100.0f);
             }
@@ -685,8 +696,7 @@
     private void updateSpeechPitchValue(int speechPitchSeekBarProgress) {
         mDefaultPitch = getValueFromSeekBarProgress(KEY_DEFAULT_PITCH, speechPitchSeekBarProgress);
         try {
-            android.provider.Settings.Secure.putInt(
-                    getContentResolver(), TTS_DEFAULT_PITCH, mDefaultPitch);
+            updateTTSSetting(TTS_DEFAULT_PITCH, mDefaultPitch);
             if (mTts != null) {
                 mTts.setPitch(mDefaultPitch / 100.0f);
             }
@@ -697,6 +707,16 @@
         return;
     }
 
+    private void updateTTSSetting(String key, int value) {
+        Secure.putInt(
+                    getContentResolver(), key, value);
+        final int managedProfileUserId =
+                Utils.getManagedProfileId(mUserManager, UserHandle.myUserId());
+        if (managedProfileUserId != UserHandle.USER_NULL) {
+            Secure.putIntForUser(getContentResolver(), key, value, managedProfileUserId);
+        }
+    }
+
     private void updateWidgetState(boolean enable) {
         getActivity().runOnUiThread(() -> {
             mActionButtons.setButton1Enabled(enable);
diff --git a/tests/robotests/res/values/overlayable_icons_test.xml b/tests/robotests/res/values/overlayable_icons_test.xml
index 4f4b668..532670d 100644
--- a/tests/robotests/res/values/overlayable_icons_test.xml
+++ b/tests/robotests/res/values/overlayable_icons_test.xml
@@ -26,8 +26,6 @@
     <item>@drawable/ic_arrow_back</item>
     <item>@drawable/ic_arrow_down_24dp</item>
     <item>@drawable/ic_battery_charging_full</item>
-    <item>@drawable/ic_battery_saver_accent_24dp</item>
-    <item>@drawable/ic_battery_status_bad_24dp</item>
     <item>@drawable/ic_battery_status_good_24dp</item>
     <item>@drawable/ic_battery_status_maybe_24dp</item>
     <item>@drawable/ic_call_24dp</item>
@@ -38,13 +36,13 @@
     <item>@drawable/ic_content_copy_grey600_24dp</item>
     <item>@drawable/ic_data_saver</item>
     <item>@drawable/ic_delete</item>
-    <item>@drawable/ic_delete_accent</item>
     <item>@drawable/ic_devices_other</item>
     <item>@drawable/ic_devices_other_32dp</item>
     <item>@drawable/ic_do_not_disturb_on_24dp</item>
     <item>@drawable/ic_eject_24dp</item>
     <item>@drawable/ic_expand_less</item>
     <item>@drawable/ic_expand_more_inverse</item>
+    <item>@drawable/ic_find_in_page_24px</item>
     <item>@drawable/ic_folder_vd_theme_24</item>
     <item>@drawable/ic_friction_lock_closed</item>
     <item>@drawable/ic_gray_scale_24dp</item>
@@ -73,7 +71,9 @@
     <item>@drawable/ic_settings_delete</item>
     <item>@drawable/ic_settings_display_white</item>
     <item>@drawable/ic_settings_home</item>
+    <item>@drawable/ic_settings_language</item>
     <item>@drawable/ic_settings_location</item>
+    <item>@drawable/ic_settings_multiuser</item>
     <item>@drawable/ic_settings_night_display</item>
     <item>@drawable/ic_settings_open</item>
     <item>@drawable/ic_settings_print</item>
@@ -82,7 +82,6 @@
     <item>@drawable/ic_settings_sim</item>
     <item>@drawable/ic_settings_system_dashboard_white</item>
     <item>@drawable/ic_settings_wireless</item>
-    <item>@drawable/ic_settings_wireless_white</item>
     <item>@drawable/ic_storage</item>
     <item>@drawable/ic_storage_white</item>
     <item>@drawable/ic_suggestion_night_display</item>
@@ -92,5 +91,6 @@
     <item>@drawable/ic_volume_ringer_vibrate</item>
     <item>@drawable/ic_volume_up_24dp</item>
     <item>@drawable/ic_vpn_key</item>
+    <item>@drawable/ic_wifi_tethering</item>
   </array>
 </resources>
diff --git a/tests/robotests/src/com/android/settings/accessibility/HighTextContrastPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/HighTextContrastPreferenceControllerTest.java
new file mode 100644
index 0000000..6eaf7a7
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/HighTextContrastPreferenceControllerTest.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2019 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.accessibility;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import androidx.preference.SwitchPreference;
+
+import com.android.settings.core.BasePreferenceController;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class HighTextContrastPreferenceControllerTest {
+
+    private static final int ON = 1;
+    private static final int OFF = 0;
+    private static final int UNKNOWN = -1;
+
+    private Context mContext;
+    private SwitchPreference mPreference;
+    private HighTextContrastPreferenceController mController;
+
+    @Before
+    public void setUp() {
+        mContext = RuntimeEnvironment.application;
+        mPreference = new SwitchPreference(mContext);
+        mController = new HighTextContrastPreferenceController(mContext, "text_contrast");
+    }
+
+    @Test
+    public void getAvailabilityStatus_byDefault_shouldReturnAvailable() {
+        assertThat(mController.getAvailabilityStatus()).isEqualTo(
+                BasePreferenceController.AVAILABLE);
+    }
+
+    @Test
+    public void isChecked_enabledTextContrast_shouldReturnTrue() {
+        Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED, ON);
+
+        mController.updateState(mPreference);
+
+        assertThat(mController.isChecked()).isTrue();
+        assertThat(mPreference.isChecked()).isTrue();
+    }
+
+    @Test
+    public void isChecked_disabledTextContrast_shouldReturnFalse() {
+        Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED, OFF);
+
+        mController.updateState(mPreference);
+
+        assertThat(mController.isChecked()).isFalse();
+        assertThat(mPreference.isChecked()).isFalse();
+    }
+
+    @Test
+    public void setChecked_setTrue_shouldEnableTextContrast() {
+        mController.setChecked(true);
+
+        assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
+                Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED, UNKNOWN)).isEqualTo(ON);
+
+    }
+
+    @Test
+    public void setChecked_setFalse_shouldDisableTextContrast() {
+        mController.setChecked(false);
+
+        assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
+                Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED, UNKNOWN)).isEqualTo(OFF);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/accessibility/LargePointerIconPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/LargePointerIconPreferenceControllerTest.java
new file mode 100644
index 0000000..1f7f5ad
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/LargePointerIconPreferenceControllerTest.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2019 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.accessibility;
+
+import static com.android.settings.accessibility.LargePointerIconPreferenceController.OFF;
+import static com.android.settings.accessibility.LargePointerIconPreferenceController.ON;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import androidx.preference.SwitchPreference;
+
+import com.android.settings.core.BasePreferenceController;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class LargePointerIconPreferenceControllerTest {
+
+    private static final int UNKNOWN = -1;
+
+    private Context mContext;
+    private SwitchPreference mPreference;
+    private LargePointerIconPreferenceController mController;
+
+    @Before
+    public void setUp() {
+        mContext = RuntimeEnvironment.application;
+        mPreference = new SwitchPreference(mContext);
+        mController = new LargePointerIconPreferenceController(mContext, "large_pointer");
+    }
+
+    @Test
+    public void getAvailabilityStatus_shouldReturnAvailable() {
+        assertThat(mController.getAvailabilityStatus()).isEqualTo(
+                BasePreferenceController.AVAILABLE);
+    }
+
+    @Test
+    public void isChecked_enabledLargePointer_shouldReturnTrue() {
+        Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.ACCESSIBILITY_LARGE_POINTER_ICON, ON);
+
+        mController.updateState(mPreference);
+
+        assertThat(mController.isChecked()).isTrue();
+        assertThat(mPreference.isChecked()).isTrue();
+    }
+
+    @Test
+    public void isChecked_disabledLargePointer_shouldReturnFalse() {
+        Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.ACCESSIBILITY_LARGE_POINTER_ICON, OFF);
+
+        mController.updateState(mPreference);
+
+        assertThat(mController.isChecked()).isFalse();
+        assertThat(mPreference.isChecked()).isFalse();
+    }
+
+    @Test
+    public void setChecked_enabled_shouldEnableLargePointer() {
+        mController.setChecked(true);
+
+        assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
+                Settings.Secure.ACCESSIBILITY_LARGE_POINTER_ICON, UNKNOWN)).isEqualTo(ON);
+    }
+
+    @Test
+    public void setChecked_disabled_shouldDisableLargePointer() {
+        mController.setChecked(false);
+
+        assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
+                Settings.Secure.ACCESSIBILITY_LARGE_POINTER_ICON, UNKNOWN)).isEqualTo(OFF);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/accessibility/PowerButtonEndsCallPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/PowerButtonEndsCallPreferenceControllerTest.java
new file mode 100644
index 0000000..3258cbd
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/PowerButtonEndsCallPreferenceControllerTest.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2019 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.accessibility;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import androidx.preference.SwitchPreference;
+
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.testutils.shadow.ShadowKeyCharacterMap;
+import com.android.settings.testutils.shadow.ShadowUtils;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+@RunWith(RobolectricTestRunner.class)
+@Config(shadows = {ShadowUtils.class, ShadowKeyCharacterMap.class})
+public class PowerButtonEndsCallPreferenceControllerTest {
+
+    private static final int UNKNOWN = -1;
+
+    private Context mContext;
+    private SwitchPreference mPreference;
+    private PowerButtonEndsCallPreferenceController mController;
+
+    @Before
+    public void setUp() {
+        mContext = RuntimeEnvironment.application;
+        mPreference = new SwitchPreference(mContext);
+        mController = new PowerButtonEndsCallPreferenceController(mContext, "power_button");
+    }
+
+    @After
+    public void tearDown() {
+        ShadowUtils.reset();
+        ShadowKeyCharacterMap.reset();
+    }
+
+    @Test
+    public void getAvailabilityStatus_hasPowerKeyAndVoiceCapable_shouldReturnAvailable() {
+        ShadowKeyCharacterMap.setDevicehasKey(true);
+        ShadowUtils.setIsVoiceCapable(true);
+
+        assertThat(mController.getAvailabilityStatus())
+                .isEqualTo(BasePreferenceController.AVAILABLE);
+    }
+
+    @Test
+    public void getAvailabilityStatus_noVoiceCapable_shouldReturnUnsupportedOnDevice() {
+        ShadowKeyCharacterMap.setDevicehasKey(true);
+        ShadowUtils.setIsVoiceCapable(false);
+
+        assertThat(mController.getAvailabilityStatus())
+                .isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE);
+    }
+
+    @Test
+    public void getAvailabilityStatus_noPowerKey_shouldReturnUnsupportedOnDevice() {
+        ShadowKeyCharacterMap.setDevicehasKey(false);
+        ShadowUtils.setIsVoiceCapable(true);
+
+        assertThat(mController.getAvailabilityStatus())
+                .isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE);
+    }
+
+    @Test
+    public void isChecked_enabledHangUp_shouldReturnTrue() {
+        Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR,
+                Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_HANGUP);
+
+        mController.updateState(mPreference);
+
+        assertThat(mController.isChecked()).isTrue();
+        assertThat(mPreference.isChecked()).isTrue();
+    }
+
+    @Test
+    public void isChecked_disabledHangUp_shouldReturnFalse() {
+        Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR,
+                Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_SCREEN_OFF);
+
+        mController.updateState(mPreference);
+
+        assertThat(mController.isChecked()).isFalse();
+        assertThat(mPreference.isChecked()).isFalse();
+    }
+
+    @Test
+    public void setChecked_enabled_shouldEnableHangUp() {
+        mController.setChecked(true);
+
+        assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
+                Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR, UNKNOWN))
+                .isEqualTo(Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_HANGUP);
+    }
+
+    @Test
+    public void setChecked_disabled_shouldDisableHangUp() {
+        mController.setChecked(false);
+
+        assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
+                Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR, UNKNOWN))
+                .isEqualTo(Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_SCREEN_OFF);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowKeyCharacterMap.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowKeyCharacterMap.java
new file mode 100644
index 0000000..59c05ff
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowKeyCharacterMap.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2019 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.testutils.shadow;
+
+import android.view.KeyCharacterMap;
+
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+
+@Implements(KeyCharacterMap.class)
+public class ShadowKeyCharacterMap extends org.robolectric.shadows.ShadowKeyCharacterMap{
+
+    private static boolean sIsDeviceHasKey;
+
+    public static void reset() {
+        sIsDeviceHasKey = false;
+    }
+
+    public static void setDevicehasKey(boolean isDeviceHasKey) {
+        sIsDeviceHasKey = isDeviceHasKey;
+    }
+
+    @Implementation
+    protected static boolean deviceHasKey(int keyCode) {
+        return sIsDeviceHasKey;
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUtils.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUtils.java
index f8644d9..cf96aba 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUtils.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUtils.java
@@ -39,6 +39,7 @@
     private static ComponentName sDeviceOwnerComponentName;
     private static Map<String, String> sAppNameMap;
     private static boolean sIsSystemAlertWindowEnabled;
+    private static boolean sIsVoiceCapable;
 
     @Implementation
     protected static int enforceSameOwner(Context context, int userId) {
@@ -58,6 +59,7 @@
         sFingerprintManager = null;
         sIsUserAMonkey = false;
         sIsDemoUser = false;
+        sIsVoiceCapable = false;
     }
 
     public static void setIsDemoUser(boolean isDemoUser) {
@@ -123,4 +125,13 @@
     public static void setIsSystemAlertWindowEnabled(boolean enabled) {
         sIsSystemAlertWindowEnabled = enabled;
     }
+
+    @Implementation
+    protected static boolean isVoiceCapable(Context context) {
+        return sIsVoiceCapable;
+    }
+
+    public static void setIsVoiceCapable(boolean isVoiceCapable) {
+        sIsVoiceCapable = isVoiceCapable;
+    }
 }