summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Annie Meng <anniemeng@google.com> 2018-05-03 16:24:03 +0100
committer Annie Meng <anniemeng@google.com> 2018-05-09 12:44:08 +0000
commit9feb24a16feb149ef3d2f33e56d783dfba0b866c (patch)
treeb2101a466751d1c71f87fbbba4e250514cacec74
parent9ea13ca0b67e77c5efda1c94c141dc49987c0745 (diff)
Add navbar magnification to critical accessibility check
If a user enables navbar magnification on their new device and the setting was disabled on their old device, we don't want to overwrite this setting and disable it on their new device during d2d restore. Bug: 79189332 Test: 1) atest SettingsHelperRestoreTest 2) manual: - Source device setting off -> target device turns setting on in SUW -> d2d restore does not overwrite - Source device setting on -> target device does not turn setting on in SUW -> d2d restores setting properly Merged-In: I58648010a9d4d3380c1c01cdaaab03828e3ea2c4 Change-Id: I58648010a9d4d3380c1c01cdaaab03828e3ea2c4
-rw-r--r--packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java1
-rw-r--r--packages/SettingsProvider/test/Android.mk4
-rw-r--r--packages/SettingsProvider/test/src/com/android/providers/settings/SettingsHelperRestoreTest.java105
3 files changed, 109 insertions, 1 deletions
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java
index 4c98bb8cc2e8..1c635c41172a 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java
@@ -254,6 +254,7 @@ public class SettingsHelper {
case Settings.Secure.TOUCH_EXPLORATION_ENABLED:
case Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED:
case Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED:
+ case Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED:
case Settings.Secure.UI_NIGHT_MODE:
return Settings.Secure.getInt(mContext.getContentResolver(), name, 0) != 0;
case Settings.Secure.TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES:
diff --git a/packages/SettingsProvider/test/Android.mk b/packages/SettingsProvider/test/Android.mk
index bd5b1f2c64ef..1ca6afee6daf 100644
--- a/packages/SettingsProvider/test/Android.mk
+++ b/packages/SettingsProvider/test/Android.mk
@@ -10,7 +10,9 @@ LOCAL_SRC_FILES := $(call all-subdir-java-files) \
../src/com/android/providers/settings/SettingsState.java \
../src/com/android/providers/settings/SettingsHelper.java
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ android-support-test \
+ truth-prebuilt
LOCAL_JAVA_LIBRARIES := android.test.base
diff --git a/packages/SettingsProvider/test/src/com/android/providers/settings/SettingsHelperRestoreTest.java b/packages/SettingsProvider/test/src/com/android/providers/settings/SettingsHelperRestoreTest.java
new file mode 100644
index 000000000000..b438e9130a88
--- /dev/null
+++ b/packages/SettingsProvider/test/src/com/android/providers/settings/SettingsHelperRestoreTest.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2018 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.providers.settings;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.ContentResolver;
+import android.content.ContentValues;
+import android.content.Context;
+import android.net.Uri;
+import android.os.Build;
+import android.provider.Settings;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Tests for {@link SettingsHelper#restoreValue(Context, ContentResolver, ContentValues, Uri,
+ * String, String, int)}. Specifically verifies that we restore critical accessibility settings only
+ * if the user has not already configured these in SUW.
+ */
+@RunWith(AndroidJUnit4.class)
+public class SettingsHelperRestoreTest {
+ private Context mContext;
+ private ContentResolver mContentResolver;
+ private SettingsHelper mSettingsHelper;
+
+ @Before
+ public void setUp() {
+ mContext = InstrumentationRegistry.getContext();
+ mContentResolver = mContext.getContentResolver();
+ mSettingsHelper = new SettingsHelper(mContext);
+ }
+
+ /** Tests for {@link Settings.Secure#ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED}. */
+ @Test
+ public void
+ restoreAccessibilityDisplayMagnificationNavbarEnabled_alreadyConfigured_doesNotRestore()
+ throws Exception {
+ // Simulate already configuring setting via SUW.
+ Settings.Secure.putInt(
+ mContentResolver,
+ Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED,
+ 1);
+
+ mSettingsHelper.restoreValue(
+ mContext,
+ mContentResolver,
+ new ContentValues(2),
+ Settings.Secure.getUriFor(
+ Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED),
+ Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED,
+ String.valueOf(0),
+ Build.VERSION.SDK_INT);
+
+ assertThat(
+ Settings.Secure.getInt(
+ mContentResolver,
+ Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED))
+ .isEqualTo(1);
+ }
+
+ @Test
+ public void
+ restoreAccessibilityDisplayMagnificationNavbarEnabled_notAlreadyConfigured_restores()
+ throws Exception {
+ // Simulate system default at boot.
+ Settings.Secure.putInt(
+ mContentResolver,
+ Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED,
+ 0);
+
+ mSettingsHelper.restoreValue(
+ mContext,
+ mContentResolver,
+ new ContentValues(2),
+ Settings.Secure.getUriFor(
+ Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED),
+ Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED,
+ String.valueOf(1),
+ Build.VERSION.SDK_INT);
+
+ assertThat(
+ Settings.Secure.getInt(
+ mContentResolver,
+ Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED))
+ .isEqualTo(1);
+ }
+}