Split Ambient Display settings. am: 1ad58d0abf
am: f89766dbab
am: 0dfe46fe58
Change-Id: I33ffaa71c09cff7a4df496c42371519367e1772c
This commit is contained in:
0
res/raw/gesture_ambient_lift.mp4
Normal file
0
res/raw/gesture_ambient_lift.mp4
Normal file
@@ -2253,7 +2253,7 @@
|
|||||||
<!-- [CHAR LIMIT=30] Display settings screen, setting option name to change whether the ambient display feature is enabled. -->
|
<!-- [CHAR LIMIT=30] Display settings screen, setting option name to change whether the ambient display feature is enabled. -->
|
||||||
<string name="doze_title">Ambient display</string>
|
<string name="doze_title">Ambient display</string>
|
||||||
<!-- [CHAR LIMIT=NONE] Display settings screen, setting description for the ambient display feature. -->
|
<!-- [CHAR LIMIT=NONE] Display settings screen, setting description for the ambient display feature. -->
|
||||||
<string name="doze_summary">Wake screen when you double-tap it or get new notifications. See how</string>
|
<string name="doze_summary">Wake screen when you receive notifications</string>
|
||||||
<!-- [CHAR LIMIT=30] Sound & display settings screen, setting option name to change font size -->
|
<!-- [CHAR LIMIT=30] Sound & display settings screen, setting option name to change font size -->
|
||||||
<string name="title_font_size">Font size</string>
|
<string name="title_font_size">Font size</string>
|
||||||
<!-- Summary for Font size. Lets the user know that this will make text larger or smaller. Appears in the accessibility portion of setup wizard. [CHAR LIMIT=NONE] -->
|
<!-- Summary for Font size. Lets the user know that this will make text larger or smaller. Appears in the accessibility portion of setup wizard. [CHAR LIMIT=NONE] -->
|
||||||
@@ -7820,11 +7820,25 @@
|
|||||||
<!-- Summary text for double twist for camera mode [CHAR LIMIT=160]-->
|
<!-- Summary text for double twist for camera mode [CHAR LIMIT=160]-->
|
||||||
<string name="double_twist_for_camera_mode_summary"></string>
|
<string name="double_twist_for_camera_mode_summary"></string>
|
||||||
|
|
||||||
<!-- Title text for ambient display [CHAR LIMIT=60]-->
|
<!-- Title text for ambient display double tap [CHAR LIMIT=60]-->
|
||||||
<string name="ambient_display_title">Quick screen check</string>
|
<string name="ambient_display_title">Quick screen check - Double Tap</string>
|
||||||
|
|
||||||
<!-- Summary text for ambient display [CHAR LIMIT=160]-->
|
<!-- Summary text for ambient display double tap (phone) [CHAR LIMIT=160]-->
|
||||||
<string name="ambient_display_summary">To check your phone without waking it up fully, double-tap it or pick it up</string>
|
<string name="ambient_display_summary" product="default">To check your phone without waking it up fully, double-tap it</string>
|
||||||
|
<!-- Summary text for ambient display double tap (tablet) [CHAR LIMIT=160]-->
|
||||||
|
<string name="ambient_display_summary" product="tablet">To check your tablet without waking it up fully, double-tap it</string>
|
||||||
|
<!-- Summary text for ambient display double tap (device) [CHAR LIMIT=160]-->
|
||||||
|
<string name="ambient_display_summary" product="device">To check your device without waking it up fully, double-tap it</string>
|
||||||
|
|
||||||
|
<!-- Title text for ambient display pick up [CHAR LIMIT=60]-->
|
||||||
|
<string name="ambient_display_pickup_title">Quick screen check - Pickup notifications</string>
|
||||||
|
|
||||||
|
<!-- Summary text for ambient display (phone) [CHAR LIMIT=160]-->
|
||||||
|
<string name="ambient_display_pickup_summary" product="default">To check your phone without waking it up fully, pick it up</string>
|
||||||
|
<!-- Summary text for ambient display (tablet) [CHAR LIMIT=160]-->
|
||||||
|
<string name="ambient_display_pickup_summary" product="tablet">To check your tablet without waking it up fully, pick it up</string>
|
||||||
|
<!-- Summary text for ambient display (device) [CHAR LIMIT=160]-->
|
||||||
|
<string name="ambient_display_pickup_summary" product="device">To check your device without waking it up fully, pick it up</string>
|
||||||
|
|
||||||
<!-- Title text for fingerprint swipe for notifications [CHAR LIMIT=60]-->
|
<!-- Title text for fingerprint swipe for notifications [CHAR LIMIT=60]-->
|
||||||
<string name="fingerprint_swipe_for_notifications_title">Swipe for notifications</string>
|
<string name="fingerprint_swipe_for_notifications_title">Swipe for notifications</string>
|
||||||
|
@@ -79,19 +79,10 @@
|
|||||||
android:key="lift_to_wake"
|
android:key="lift_to_wake"
|
||||||
android:title="@string/lift_to_wake_title" />
|
android:title="@string/lift_to_wake_title" />
|
||||||
|
|
||||||
<PreferenceScreen
|
<SwitchPreference
|
||||||
android:key="doze"
|
android:key="doze"
|
||||||
android:title="@string/ambient_display_title"
|
android:title="@string/doze_title"
|
||||||
android:summary="@string/doze_summary" >
|
android:summary="@string/doze_summary" />
|
||||||
<intent
|
|
||||||
android:targetPackage="com.android.settings"
|
|
||||||
android:targetClass="com.android.settings.Settings$GestureSettingsActivity" >
|
|
||||||
<extra android:name="show_drawer_menu"
|
|
||||||
android:value="true" />
|
|
||||||
<extra android:name="gesture_scroll_to_preference"
|
|
||||||
android:value="gesture_pick_up_and_nudge" />
|
|
||||||
</intent>
|
|
||||||
</PreferenceScreen>
|
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:key="tap_to_wake"
|
android:key="tap_to_wake"
|
||||||
|
@@ -38,9 +38,15 @@
|
|||||||
settings:animation="@raw/gesture_twist"/>
|
settings:animation="@raw/gesture_twist"/>
|
||||||
|
|
||||||
<com.android.settings.gestures.GesturePreference
|
<com.android.settings.gestures.GesturePreference
|
||||||
android:key="gesture_pick_up_and_nudge"
|
android:key="gesture_double_tap_screen"
|
||||||
android:title="@string/ambient_display_title"
|
android:title="@string/ambient_display_title"
|
||||||
android:summary="@string/ambient_display_summary"
|
android:summary="@string/ambient_display_summary"
|
||||||
settings:animation="@raw/gesture_ambient_tap"/>
|
settings:animation="@raw/gesture_ambient_tap"/>
|
||||||
|
|
||||||
|
<com.android.settings.gestures.GesturePreference
|
||||||
|
android:key="gesture_pick_up"
|
||||||
|
android:title="@string/ambient_display_pickup_title"
|
||||||
|
android:summary="@string/ambient_display_pickup_summary"
|
||||||
|
settings:animation="@raw/gesture_ambient_lift"/>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
@@ -39,7 +39,6 @@ import android.support.v7.preference.DropDownPreference;
|
|||||||
import android.support.v7.preference.ListPreference;
|
import android.support.v7.preference.ListPreference;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.support.v7.preference.Preference.OnPreferenceChangeListener;
|
import android.support.v7.preference.Preference.OnPreferenceChangeListener;
|
||||||
import android.support.v7.preference.PreferenceScreen;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
@@ -92,10 +91,10 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
|
|||||||
private ListPreference mNightModePreference;
|
private ListPreference mNightModePreference;
|
||||||
private Preference mScreenSaverPreference;
|
private Preference mScreenSaverPreference;
|
||||||
private SwitchPreference mLiftToWakePreference;
|
private SwitchPreference mLiftToWakePreference;
|
||||||
|
private SwitchPreference mDozePreference;
|
||||||
private SwitchPreference mTapToWakePreference;
|
private SwitchPreference mTapToWakePreference;
|
||||||
private SwitchPreference mAutoBrightnessPreference;
|
private SwitchPreference mAutoBrightnessPreference;
|
||||||
private SwitchPreference mCameraGesturePreference;
|
private SwitchPreference mCameraGesturePreference;
|
||||||
private PreferenceScreen mDozePreference;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
@@ -139,10 +138,11 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
|
|||||||
removePreference(KEY_LIFT_TO_WAKE);
|
removePreference(KEY_LIFT_TO_WAKE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isDozeAvailable(activity)) {
|
if (isDozeAvailable(activity)) {
|
||||||
removePreference(KEY_DOZE);
|
mDozePreference = (SwitchPreference) findPreference(KEY_DOZE);
|
||||||
|
mDozePreference.setOnPreferenceChangeListener(this);
|
||||||
} else {
|
} else {
|
||||||
mDozePreference = (PreferenceScreen) findPreference(KEY_DOZE);
|
removePreference(KEY_DOZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isTapToWakeAvailable(getResources())) {
|
if (isTapToWakeAvailable(getResources())) {
|
||||||
@@ -360,6 +360,12 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
|
|||||||
mTapToWakePreference.setChecked(value != 0);
|
mTapToWakePreference.setChecked(value != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update doze if it is available.
|
||||||
|
if (mDozePreference != null) {
|
||||||
|
int value = Settings.Secure.getInt(getContentResolver(), DOZE_ENABLED, 1);
|
||||||
|
mDozePreference.setChecked(value != 0);
|
||||||
|
}
|
||||||
|
|
||||||
// Update camera gesture #1 if it is available.
|
// Update camera gesture #1 if it is available.
|
||||||
if (mCameraGesturePreference != null) {
|
if (mCameraGesturePreference != null) {
|
||||||
int value = Settings.Secure.getInt(getContentResolver(), CAMERA_GESTURE_DISABLED, 0);
|
int value = Settings.Secure.getInt(getContentResolver(), CAMERA_GESTURE_DISABLED, 0);
|
||||||
@@ -407,6 +413,10 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
|
|||||||
boolean value = (Boolean) objValue;
|
boolean value = (Boolean) objValue;
|
||||||
Settings.Secure.putInt(getContentResolver(), WAKE_GESTURE_ENABLED, value ? 1 : 0);
|
Settings.Secure.putInt(getContentResolver(), WAKE_GESTURE_ENABLED, value ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
if (preference == mDozePreference) {
|
||||||
|
boolean value = (Boolean) objValue;
|
||||||
|
Settings.Secure.putInt(getContentResolver(), DOZE_ENABLED, value ? 1 : 0);
|
||||||
|
}
|
||||||
if (preference == mTapToWakePreference) {
|
if (preference == mTapToWakePreference) {
|
||||||
boolean value = (Boolean) objValue;
|
boolean value = (Boolean) objValue;
|
||||||
Settings.Secure.putInt(getContentResolver(), DOUBLE_TAP_TO_WAKE, value ? 1 : 0);
|
Settings.Secure.putInt(getContentResolver(), DOUBLE_TAP_TO_WAKE, value ? 1 : 0);
|
||||||
|
@@ -52,16 +52,16 @@ public class GestureSettings extends SettingsPreferenceFragment implements
|
|||||||
private static final String TAG = "GestureSettings";
|
private static final String TAG = "GestureSettings";
|
||||||
private static final String PREF_KEY_DOUBLE_TAP_POWER = "gesture_double_tap_power";
|
private static final String PREF_KEY_DOUBLE_TAP_POWER = "gesture_double_tap_power";
|
||||||
private static final String PREF_KEY_DOUBLE_TWIST = "gesture_double_twist";
|
private static final String PREF_KEY_DOUBLE_TWIST = "gesture_double_twist";
|
||||||
private static final String PREF_KEY_PICK_UP_AND_NUDGE = "gesture_pick_up_and_nudge";
|
private static final String PREF_KEY_PICK_UP = "gesture_pick_up";
|
||||||
private static final String PREF_KEY_SWIPE_DOWN_FINGERPRINT = "gesture_swipe_down_fingerprint";
|
private static final String PREF_KEY_SWIPE_DOWN_FINGERPRINT = "gesture_swipe_down_fingerprint";
|
||||||
|
private static final String PREF_KEY_DOUBLE_TAP_SCREEN = "gesture_double_tap_screen";
|
||||||
private static final String DEBUG_DOZE_COMPONENT = "debug.doze.component";
|
private static final String DEBUG_DOZE_COMPONENT = "debug.doze.component";
|
||||||
private static final String ARG_SCROLL_TO_PREFERENCE = "gesture_scroll_to_preference";
|
|
||||||
private static final int PREF_ID_DOUBLE_TAP_POWER = 0;
|
private static final int PREF_ID_DOUBLE_TAP_POWER = 0;
|
||||||
private static final int PREF_ID_DOUBLE_TWIST = 1;
|
private static final int PREF_ID_DOUBLE_TWIST = 1;
|
||||||
private static final int PREF_ID_PICK_UP_AND_NUDG = 2;
|
private static final int PREF_ID_PICK_UP = 2;
|
||||||
private static final int PREF_ID_SWIPE_DOWN_FINGERPRINT = 3;
|
private static final int PREF_ID_SWIPE_DOWN_FINGERPRINT = 3;
|
||||||
|
private static final int PREF_ID_DOUBLE_TAP_SCREEN = 4;
|
||||||
|
|
||||||
private int mScrollPosition = -1;
|
|
||||||
private List<GesturePreference> mPreferences;
|
private List<GesturePreference> mPreferences;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -82,16 +82,19 @@ public class GestureSettings extends SettingsPreferenceFragment implements
|
|||||||
|
|
||||||
// Ambient Display
|
// Ambient Display
|
||||||
if (isDozeAvailable(context)) {
|
if (isDozeAvailable(context)) {
|
||||||
int dozeEnabled = Secure.getInt(getContentResolver(), Secure.DOZE_ENABLED, 1);
|
int pickup = Secure.getInt(getContentResolver(), Secure.DOZE_PULSE_ON_PICK_UP, 1);
|
||||||
addPreference(PREF_KEY_PICK_UP_AND_NUDGE, dozeEnabled != 0, PREF_ID_DOUBLE_TWIST);
|
addPreference(PREF_KEY_PICK_UP, pickup != 0, PREF_ID_PICK_UP);
|
||||||
|
int doubleTap = Secure.getInt(getContentResolver(), Secure.DOZE_PULSE_ON_DOUBLE_TAP, 1);
|
||||||
|
addPreference(PREF_KEY_DOUBLE_TAP_SCREEN, doubleTap != 0, PREF_ID_DOUBLE_TAP_SCREEN);
|
||||||
} else {
|
} else {
|
||||||
removePreference(PREF_KEY_PICK_UP_AND_NUDGE);
|
removePreference(PREF_KEY_PICK_UP);
|
||||||
|
removePreference(PREF_KEY_DOUBLE_TAP_SCREEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fingerprint slide for notifications
|
// Fingerprint slide for notifications
|
||||||
if (isSystemUINavigationAvailable(context)) {
|
if (isSystemUINavigationAvailable(context)) {
|
||||||
addPreference(PREF_KEY_SWIPE_DOWN_FINGERPRINT, isSystemUINavigationEnabled(context),
|
addPreference(PREF_KEY_SWIPE_DOWN_FINGERPRINT, isSystemUINavigationEnabled(context),
|
||||||
PREF_ID_PICK_UP_AND_NUDG);
|
PREF_ID_SWIPE_DOWN_FINGERPRINT);
|
||||||
} else {
|
} else {
|
||||||
removePreference(PREF_KEY_SWIPE_DOWN_FINGERPRINT);
|
removePreference(PREF_KEY_SWIPE_DOWN_FINGERPRINT);
|
||||||
}
|
}
|
||||||
@@ -100,23 +103,11 @@ public class GestureSettings extends SettingsPreferenceFragment implements
|
|||||||
if (isDoubleTwistAvailable(context)) {
|
if (isDoubleTwistAvailable(context)) {
|
||||||
int doubleTwistEnabled = Secure.getInt(
|
int doubleTwistEnabled = Secure.getInt(
|
||||||
getContentResolver(), Secure.CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED, 1);
|
getContentResolver(), Secure.CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED, 1);
|
||||||
addPreference(PREF_KEY_DOUBLE_TWIST, doubleTwistEnabled != 0,
|
addPreference(PREF_KEY_DOUBLE_TWIST, doubleTwistEnabled != 0, PREF_ID_DOUBLE_TWIST);
|
||||||
PREF_ID_SWIPE_DOWN_FINGERPRINT);
|
|
||||||
} else {
|
} else {
|
||||||
removePreference(PREF_KEY_DOUBLE_TWIST);
|
removePreference(PREF_KEY_DOUBLE_TWIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
|
||||||
final Bundle args = getArguments();
|
|
||||||
if (args != null && args.containsKey(ARG_SCROLL_TO_PREFERENCE)) {
|
|
||||||
String prefKey = args.getString(ARG_SCROLL_TO_PREFERENCE);
|
|
||||||
GesturePreference pref = (GesturePreference) findPreference(prefKey);
|
|
||||||
if (pref != null) {
|
|
||||||
mScrollPosition = pref.getOrder();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -124,9 +115,6 @@ public class GestureSettings extends SettingsPreferenceFragment implements
|
|||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
RecyclerView listview = getListView();
|
RecyclerView listview = getListView();
|
||||||
if (mScrollPosition >= 0) {
|
|
||||||
listview.scrollToPosition(mScrollPosition);
|
|
||||||
}
|
|
||||||
listview.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
listview.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
|
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
|
||||||
@@ -163,8 +151,10 @@ public class GestureSettings extends SettingsPreferenceFragment implements
|
|||||||
if (PREF_KEY_DOUBLE_TAP_POWER.equals(key)) {
|
if (PREF_KEY_DOUBLE_TAP_POWER.equals(key)) {
|
||||||
Secure.putInt(getContentResolver(),
|
Secure.putInt(getContentResolver(),
|
||||||
Secure.CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, enabled ? 0 : 1);
|
Secure.CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, enabled ? 0 : 1);
|
||||||
} else if (PREF_KEY_PICK_UP_AND_NUDGE.equals(key)) {
|
} else if (PREF_KEY_PICK_UP.equals(key)) {
|
||||||
Secure.putInt(getContentResolver(), Secure.DOZE_ENABLED, enabled ? 1 : 0);
|
Secure.putInt(getContentResolver(), Secure.DOZE_PULSE_ON_PICK_UP, enabled ? 1 : 0);
|
||||||
|
} else if (PREF_KEY_DOUBLE_TAP_SCREEN.equals(key)) {
|
||||||
|
Secure.putInt(getContentResolver(), Secure.DOZE_PULSE_ON_DOUBLE_TAP, enabled ? 1 : 0);
|
||||||
} else if (PREF_KEY_SWIPE_DOWN_FINGERPRINT.equals(key)) {
|
} else if (PREF_KEY_SWIPE_DOWN_FINGERPRINT.equals(key)) {
|
||||||
Secure.putInt(getContentResolver(),
|
Secure.putInt(getContentResolver(),
|
||||||
Secure.SYSTEM_NAVIGATION_KEYS_ENABLED, enabled ? 1 : 0);
|
Secure.SYSTEM_NAVIGATION_KEYS_ENABLED, enabled ? 1 : 0);
|
||||||
@@ -255,7 +245,8 @@ public class GestureSettings extends SettingsPreferenceFragment implements
|
|||||||
result.add(PREF_KEY_DOUBLE_TAP_POWER);
|
result.add(PREF_KEY_DOUBLE_TAP_POWER);
|
||||||
}
|
}
|
||||||
if (!isDozeAvailable(context)) {
|
if (!isDozeAvailable(context)) {
|
||||||
result.add(PREF_KEY_PICK_UP_AND_NUDGE);
|
result.add(PREF_KEY_PICK_UP);
|
||||||
|
result.add(PREF_KEY_DOUBLE_TAP_SCREEN);
|
||||||
}
|
}
|
||||||
if (!isSystemUINavigationAvailable(context)) {
|
if (!isSystemUINavigationAvailable(context)) {
|
||||||
result.add(PREF_KEY_SWIPE_DOWN_FINGERPRINT);
|
result.add(PREF_KEY_SWIPE_DOWN_FINGERPRINT);
|
||||||
|
@@ -7,15 +7,13 @@ LOCAL_CERTIFICATE := platform
|
|||||||
|
|
||||||
LOCAL_JAVA_LIBRARIES := android.test.runner bouncycastle
|
LOCAL_JAVA_LIBRARIES := android.test.runner bouncycastle
|
||||||
|
|
||||||
LOCAL_STATIC_ANDROID_LIBRARIES := \
|
|
||||||
android-support-v4
|
|
||||||
|
|
||||||
LOCAL_STATIC_JAVA_LIBRARIES := \
|
LOCAL_STATIC_JAVA_LIBRARIES := \
|
||||||
android-support-test \
|
android-support-test \
|
||||||
mockito-target \
|
mockito-target \
|
||||||
espresso-core \
|
espresso-core \
|
||||||
espresso-contrib \
|
espresso-contrib-nodep \
|
||||||
espresso-intents
|
espresso-intents-nodep \
|
||||||
|
ub-uiautomator
|
||||||
|
|
||||||
# Include all test java files.
|
# Include all test java files.
|
||||||
LOCAL_SRC_FILES := $(call all-java-files-under, src)
|
LOCAL_SRC_FILES := $(call all-java-files-under, src)
|
||||||
|
@@ -0,0 +1,195 @@
|
|||||||
|
/*
|
||||||
|
* 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.gesture;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.provider.Settings.Secure;
|
||||||
|
import android.support.test.filters.MediumTest;
|
||||||
|
import android.support.test.uiautomator.UiDevice;
|
||||||
|
import android.support.test.uiautomator.UiObject;
|
||||||
|
import android.support.test.uiautomator.UiSelector;
|
||||||
|
import android.support.test.uiautomator.UiScrollable;
|
||||||
|
import android.test.InstrumentationTestCase;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
import android.widget.Switch;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test for Gesture preferences.
|
||||||
|
*/
|
||||||
|
@MediumTest
|
||||||
|
public class GestureSettingsTest extends InstrumentationTestCase {
|
||||||
|
|
||||||
|
private static final String TAG = "GestureSettingsTest";
|
||||||
|
|
||||||
|
private UiDevice mDevice;
|
||||||
|
private Context mTargetContext;
|
||||||
|
private String mTargetPackage;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setUp() throws Exception {
|
||||||
|
super.setUp();
|
||||||
|
mDevice = UiDevice.getInstance(getInstrumentation());
|
||||||
|
mTargetContext = getInstrumentation().getTargetContext();
|
||||||
|
mTargetPackage = mTargetContext.getPackageName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAmbientDisplaySwitchPreference() throws Exception {
|
||||||
|
launchSettings();
|
||||||
|
UiObject dozeSwitch = getDozeSwitch();
|
||||||
|
assertNotNull(dozeSwitch);
|
||||||
|
assertTrue(dozeSwitch.exists());
|
||||||
|
assertToggleStateMatchesSettingValue(dozeSwitch, Secure.DOZE_ENABLED, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGestureSettingsExists() throws Exception {
|
||||||
|
launchMoves();
|
||||||
|
UiObject titleObj = mDevice.findObject(new UiSelector().text(
|
||||||
|
mTargetContext.getResources().getString(R.string.gesture_preference_title)));
|
||||||
|
assertNotNull(titleObj);
|
||||||
|
assertTrue(titleObj.exists());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCameraDoubleTapToggle() throws Exception {
|
||||||
|
assertSwitchToggle(mTargetContext.getResources().getString(
|
||||||
|
R.string.double_tap_power_for_camera_title),
|
||||||
|
Secure.CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCameraDoubleTwistToggle() throws Exception {
|
||||||
|
assertSwitchToggle(mTargetContext.getResources().getString(
|
||||||
|
R.string.double_twist_for_camera_mode_title),
|
||||||
|
Secure.CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFingerprintSwipeToggle() throws Exception {
|
||||||
|
assertSwitchToggle(mTargetContext.getResources().getString(
|
||||||
|
R.string.fingerprint_swipe_for_notifications_title),
|
||||||
|
Secure.SYSTEM_NAVIGATION_KEYS_ENABLED, 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDozeDoubleTapToggle() throws Exception {
|
||||||
|
assertSwitchToggle(mTargetContext.getResources().getString(
|
||||||
|
R.string.ambient_display_title),
|
||||||
|
Secure.DOZE_PULSE_ON_DOUBLE_TAP, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDozePickupToggle() throws Exception {
|
||||||
|
assertSwitchToggle(mTargetContext.getResources().getString(
|
||||||
|
R.string.ambient_display_pickup_title),
|
||||||
|
Secure.DOZE_PULSE_ON_PICK_UP, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void launchSettings() {
|
||||||
|
Intent settingsIntent = new Intent(Intent.ACTION_MAIN)
|
||||||
|
.addCategory(Intent.CATEGORY_LAUNCHER)
|
||||||
|
.setPackage(mTargetPackage)
|
||||||
|
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
getInstrumentation().getContext().startActivity(settingsIntent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void launchMoves() throws Exception {
|
||||||
|
launchSettings();
|
||||||
|
UiScrollable settings = new UiScrollable(
|
||||||
|
new UiSelector().packageName(mTargetPackage).scrollable(true));
|
||||||
|
String titleMoves =
|
||||||
|
mTargetContext.getResources().getString(R.string.gesture_preference_title);
|
||||||
|
settings.scrollTextIntoView(titleMoves);
|
||||||
|
mDevice.findObject(new UiSelector().text(titleMoves)).click();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void navigateToMovesSetting(String title) throws Exception {
|
||||||
|
launchMoves();
|
||||||
|
UiScrollable moves = new UiScrollable(
|
||||||
|
new UiSelector().packageName(mTargetPackage).scrollable(true));
|
||||||
|
moves.scrollTextIntoView(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
private UiScrollable navigateToAmbientDisplay() throws Exception {
|
||||||
|
UiScrollable settings = new UiScrollable(
|
||||||
|
new UiSelector().packageName(mTargetPackage).scrollable(true));
|
||||||
|
String titleDisplay =
|
||||||
|
mTargetContext.getResources().getString(R.string.display_settings_title);
|
||||||
|
settings.scrollTextIntoView(titleDisplay);
|
||||||
|
mDevice.findObject(new UiSelector().text(titleDisplay)).click();
|
||||||
|
settings.scrollTextIntoView(mTargetContext.getResources().getString(R.string.doze_title));
|
||||||
|
return settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
private UiObject getGestureSwitch(String title) throws Exception {
|
||||||
|
UiObject titleView = mDevice.findObject(new UiSelector().text(title));
|
||||||
|
UiObject gestureSwitch =
|
||||||
|
titleView.getFromParent(new UiSelector().className(Switch.class.getName()));
|
||||||
|
assertNotNull(gestureSwitch);
|
||||||
|
assertTrue(gestureSwitch.exists());
|
||||||
|
return gestureSwitch;
|
||||||
|
}
|
||||||
|
|
||||||
|
private UiObject getDozeSwitch() throws Exception {
|
||||||
|
UiScrollable settings = navigateToAmbientDisplay();
|
||||||
|
UiObject dozeSwitch = null;
|
||||||
|
UiSelector relativeLayoutSelector =
|
||||||
|
new UiSelector().className(RelativeLayout.class.getName());
|
||||||
|
String titleDoze = mTargetContext.getResources().getString(R.string.doze_title);
|
||||||
|
for (int i = 0; i <= settings.getChildCount(relativeLayoutSelector); i++) {
|
||||||
|
UiObject relativeLayout = settings.getChild(relativeLayoutSelector.instance(i));
|
||||||
|
if (relativeLayout.getChildCount() != 2) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
UiObject obj1 = relativeLayout.getChild(new UiSelector().index(0));
|
||||||
|
if (obj1.getText() == titleDoze) {
|
||||||
|
return relativeLayout.getFromParent(
|
||||||
|
new UiSelector().className(Switch.class.getName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertSwitchToggle(String title, String key, int defaultVal, int enabledVal)
|
||||||
|
throws Exception {
|
||||||
|
navigateToMovesSetting(title);
|
||||||
|
assertToggleStateMatchesSettingValue(getGestureSwitch(title), key, defaultVal, enabledVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertToggleStateMatchesSettingValue (
|
||||||
|
UiObject testSwitch, String key, int defaultVal, int enabledVal) throws Exception {
|
||||||
|
// check initial state
|
||||||
|
int currentValue = Secure.getInt(mTargetContext.getContentResolver(), key, defaultVal);
|
||||||
|
boolean enabled = currentValue == enabledVal;
|
||||||
|
assertEquals(enabled, testSwitch.isChecked());
|
||||||
|
// toggle the preference
|
||||||
|
testSwitch.click();
|
||||||
|
assertEquals(!enabled, testSwitch.isChecked());
|
||||||
|
int newValue = currentValue == 1 ? 0 : 1;
|
||||||
|
assertEquals(newValue, Secure.getInt(mTargetContext.getContentResolver(), key, defaultVal));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user