Merge "Rename panic gesture to emergency gesture in Settings"
This commit is contained in:
@@ -462,11 +462,11 @@
|
|||||||
<!-- Whether to show Smooth Display feature in Settings Options -->
|
<!-- Whether to show Smooth Display feature in Settings Options -->
|
||||||
<bool name="config_show_smooth_display">false</bool>
|
<bool name="config_show_smooth_display">false</bool>
|
||||||
|
|
||||||
<!-- Whether to show panic button gesture in Settings -->
|
<!-- Whether to show emergency gesture in Settings -->
|
||||||
<bool name="config_show_panic_gesture_settings">true</bool>
|
<bool name="config_show_emergency_gesture_settings">true</bool>
|
||||||
|
|
||||||
<!-- Optional package name if another 1p app wants to take over the panic settings UI -->
|
<!-- Optional package name if another 1p app wants to take over the emergency gesture settings UI -->
|
||||||
<string name="panic_gesture_settings_package"></string>
|
<string name="emergency_gesture_settings_package"></string>
|
||||||
|
|
||||||
<!-- Whether to show the Preference for Adaptive connectivity -->
|
<!-- Whether to show the Preference for Adaptive connectivity -->
|
||||||
<bool name="config_show_adaptive_connectivity">false</bool>
|
<bool name="config_show_adaptive_connectivity">false</bool>
|
||||||
|
@@ -11049,19 +11049,19 @@
|
|||||||
<string name="ambient_display_tap_screen_summary">To check time, notifications, and other info, tap your screen.</string>
|
<string name="ambient_display_tap_screen_summary">To check time, notifications, and other info, tap your screen.</string>
|
||||||
|
|
||||||
<!-- Preference title to enable feature for calling emergency services at panic/distress moments[CHAR_LIMIT=60]-->
|
<!-- Preference title to enable feature for calling emergency services at panic/distress moments[CHAR_LIMIT=60]-->
|
||||||
<string name="panic_gesture_screen_title">Panic button</string>
|
<string name="emergency_gesture_screen_title">Emergency SOS</string>
|
||||||
|
|
||||||
<!-- Preference title to enable feature for calling emergency services at panic/distress moments[CHAR_LIMIT=60]-->
|
<!-- Preference title to enable feature for calling emergency services at panic/distress moments[CHAR_LIMIT=60]-->
|
||||||
<string name="panic_gesture_entrypoint_summary">Managed by <xliff:g id="app_name" example="Emergency Info">%1$s</xliff:g></string>
|
<string name="emergency_gesture_entrypoint_summary">Managed by <xliff:g id="app_name" example="Emergency Info">%1$s</xliff:g></string>
|
||||||
|
|
||||||
<!-- Preference summary to enable feature for calling emergency services at panic/distress moments[CHAR_LIMIT=NONE]-->
|
<!-- Preference summary to enable feature for calling emergency services at panic/distress moments[CHAR_LIMIT=NONE]-->
|
||||||
<string name="panic_gesture_screen_summary">Start the emergency SOS actions by pressing the power button quickly 5 times.</string>
|
<string name="emergency_gesture_screen_summary">Start the emergency SOS actions by pressing the power button quickly 5 times.</string>
|
||||||
|
|
||||||
<!-- Preference title to enable generating noisy sound before calling emergency services at panic/distress moments[CHAR_LIMIT=60]-->
|
<!-- Preference title to enable generating noisy sound before calling emergency services at panic/distress moments[CHAR_LIMIT=60]-->
|
||||||
<string name="panic_gesture_sound_setting_title">Warning sound</string>
|
<string name="emergency_gesture_sound_setting_title">Warning sound</string>
|
||||||
|
|
||||||
<!-- Preference summary to enable generating noisy sound before calling emergency services at panic/distress moments[CHAR_LIMIT=NONE]-->
|
<!-- Preference summary to enable generating noisy sound before calling emergency services at panic/distress moments[CHAR_LIMIT=NONE]-->
|
||||||
<string name="panic_gesture_sound_setting_summary">Alert before starting the actions</string>
|
<string name="emergency_gesture_sound_setting_summary">Alert before starting the actions</string>
|
||||||
|
|
||||||
<!-- Title text for swiping downwards on fingerprint sensor for notifications [CHAR LIMIT=80]-->
|
<!-- Title text for swiping downwards on fingerprint sensor for notifications [CHAR LIMIT=80]-->
|
||||||
<string name="fingerprint_swipe_for_notifications_title">Swipe fingerprint for notifications</string>
|
<string name="fingerprint_swipe_for_notifications_title">Swipe fingerprint for notifications</string>
|
||||||
|
@@ -18,29 +18,29 @@
|
|||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:title="@string/panic_gesture_screen_title">
|
android:title="@string/emergency_gesture_screen_title">
|
||||||
|
|
||||||
<com.android.settings.widget.VideoPreference
|
<com.android.settings.widget.VideoPreference
|
||||||
android:key="panic_button_screen_video"
|
android:key="emergency_gesture_screen_video"
|
||||||
app:animation="@raw/gesture_double_tap"
|
app:animation="@raw/gesture_double_tap"
|
||||||
app:preview="@drawable/gesture_double_tap"/>
|
app:preview="@drawable/gesture_double_tap"/>
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:key="gesture_panic_button"
|
android:key="gesture_emergency_button"
|
||||||
android:title="@string/panic_gesture_screen_title"
|
android:title="@string/emergency_gesture_screen_title"
|
||||||
android:summary="@string/panic_gesture_screen_summary"
|
android:summary="@string/emergency_gesture_screen_summary"
|
||||||
android:icon="@drawable/ic_hand_gesture"
|
android:icon="@drawable/ic_hand_gesture"
|
||||||
app:keywords="@string/keywords_gesture"
|
app:keywords="@string/keywords_gesture"
|
||||||
app:controller="com.android.settings.gestures.PanicGesturePreferenceController"
|
app:controller="com.android.settings.gestures.EmergencyGesturePreferenceController"
|
||||||
app:allowDividerAbove="true"/>
|
app:allowDividerAbove="true"/>
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:key="panic_gesture_sound"
|
android:key="emergency_gesture_sound"
|
||||||
android:icon="@drawable/ic_hearing"
|
android:icon="@drawable/ic_hearing"
|
||||||
android:title="@string/panic_gesture_sound_setting_title"
|
android:title="@string/emergency_gesture_sound_setting_title"
|
||||||
android:summary="@string/panic_gesture_sound_setting_summary"
|
android:summary="@string/emergency_gesture_sound_setting_summary"
|
||||||
app:keywords="@string/keywords_gesture"
|
app:keywords="@string/keywords_gesture"
|
||||||
app:controller="com.android.settings.gestures.PanicGestureSoundPreferenceController"
|
app:controller="com.android.settings.gestures.EmergencyGestureSoundPreferenceController"
|
||||||
app:allowDividerAbove="true"/>
|
app:allowDividerAbove="true"/>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
@@ -21,10 +21,10 @@
|
|||||||
android:title="@string/gesture_preference_title">
|
android:title="@string/gesture_preference_title">
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="gesture_panic_button_summary"
|
android:key="gesture_emergency_summary"
|
||||||
android:title="@string/panic_gesture_screen_title"
|
android:title="@string/emergency_gesture_screen_title"
|
||||||
android:fragment="com.android.settings.gestures.PanicGestureSettings"
|
android:fragment="com.android.settings.gestures.EmergencyGestureSettings"
|
||||||
settings:controller="com.android.settings.gestures.PanicGesturePreferenceController" />
|
settings:controller="com.android.settings.gestures.EmergencyGesturePreferenceController" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="gesture_assist_input_summary"
|
android:key="gesture_assist_input_summary"
|
||||||
|
@@ -31,36 +31,36 @@ import androidx.preference.Preference;
|
|||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Preference controller for emergency sos gesture setting
|
* Preference controller for emergency gesture setting
|
||||||
*/
|
*/
|
||||||
public class PanicGesturePreferenceController extends GesturePreferenceController {
|
public class EmergencyGesturePreferenceController extends GesturePreferenceController {
|
||||||
private static final String TAG = "PanicGesturePreferenceC";
|
private static final String TAG = "EmergencyGesturePref";
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final int ON = 1;
|
static final int ON = 1;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final int OFF = 0;
|
static final int OFF = 0;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final String ACTION_PANIC_SETTINGS =
|
static final String ACTION_EMERGENCY_GESTURE_SETTINGS =
|
||||||
"com.android.settings.action.panic_settings";
|
"com.android.settings.action.emergency_gesture_settings";
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
Intent mIntent;
|
Intent mIntent;
|
||||||
|
|
||||||
private boolean mUseCustomIntent;
|
private boolean mUseCustomIntent;
|
||||||
|
|
||||||
private static final String PREF_KEY_VIDEO = "panic_button_screen_video";
|
private static final String PREF_KEY_VIDEO = "emergency_gesture_screen_video";
|
||||||
|
|
||||||
private static final String SECURE_KEY = Settings.Secure.EMERGENCY_GESTURE_ENABLED;
|
private static final String SECURE_KEY = Settings.Secure.EMERGENCY_GESTURE_ENABLED;
|
||||||
|
|
||||||
public PanicGesturePreferenceController(Context context, String key) {
|
public EmergencyGesturePreferenceController(Context context, String key) {
|
||||||
super(context, key);
|
super(context, key);
|
||||||
final String panicSettingsPackageName = context.getResources().getString(
|
final String emergencyGestureSettingsPackageName = context.getResources().getString(
|
||||||
R.string.panic_gesture_settings_package);
|
R.string.emergency_gesture_settings_package);
|
||||||
if (!TextUtils.isEmpty(panicSettingsPackageName)) {
|
if (!TextUtils.isEmpty(emergencyGestureSettingsPackageName)) {
|
||||||
mUseCustomIntent = true;
|
mUseCustomIntent = true;
|
||||||
// Use custom intent if it's configured and system can resolve it.
|
// Use custom intent if it's configured and system can resolve it.
|
||||||
final Intent intent = new Intent(ACTION_PANIC_SETTINGS)
|
final Intent intent = new Intent(ACTION_EMERGENCY_GESTURE_SETTINGS)
|
||||||
.setPackage(panicSettingsPackageName);
|
.setPackage(emergencyGestureSettingsPackageName);
|
||||||
if (canResolveIntent(intent)) {
|
if (canResolveIntent(intent)) {
|
||||||
mIntent = intent;
|
mIntent = intent;
|
||||||
}
|
}
|
||||||
@@ -80,7 +80,7 @@ public class PanicGesturePreferenceController extends GesturePreferenceControlle
|
|||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
final boolean isConfigEnabled = mContext.getResources()
|
final boolean isConfigEnabled = mContext.getResources()
|
||||||
.getBoolean(R.bool.config_show_panic_gesture_settings);
|
.getBoolean(R.bool.config_show_emergency_gesture_settings);
|
||||||
|
|
||||||
if (!isConfigEnabled) {
|
if (!isConfigEnabled) {
|
||||||
return UNSUPPORTED_ON_DEVICE;
|
return UNSUPPORTED_ON_DEVICE;
|
||||||
@@ -90,7 +90,7 @@ public class PanicGesturePreferenceController extends GesturePreferenceControlle
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSliceable() {
|
public boolean isSliceable() {
|
||||||
return TextUtils.equals(getPreferenceKey(), "gesture_panic_button");
|
return TextUtils.equals(getPreferenceKey(), "gesture_emergency_button");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -102,13 +102,13 @@ public class PanicGesturePreferenceController extends GesturePreferenceControlle
|
|||||||
public CharSequence getSummary() {
|
public CharSequence getSummary() {
|
||||||
if (mUseCustomIntent) {
|
if (mUseCustomIntent) {
|
||||||
final String packageName = mContext.getResources().getString(
|
final String packageName = mContext.getResources().getString(
|
||||||
R.string.panic_gesture_settings_package);
|
R.string.emergency_gesture_settings_package);
|
||||||
try {
|
try {
|
||||||
final PackageManager pm = mContext.getPackageManager();
|
final PackageManager pm = mContext.getPackageManager();
|
||||||
final ApplicationInfo appInfo = pm.getApplicationInfo(
|
final ApplicationInfo appInfo = pm.getApplicationInfo(
|
||||||
packageName, PackageManager.MATCH_DISABLED_COMPONENTS
|
packageName, PackageManager.MATCH_DISABLED_COMPONENTS
|
||||||
| PackageManager.MATCH_DISABLED_UNTIL_USED_COMPONENTS);
|
| PackageManager.MATCH_DISABLED_UNTIL_USED_COMPONENTS);
|
||||||
return mContext.getString(R.string.panic_gesture_entrypoint_summary,
|
return mContext.getString(R.string.emergency_gesture_entrypoint_summary,
|
||||||
appInfo.loadLabel(pm));
|
appInfo.loadLabel(pm));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.d(TAG, "Failed to get custom summary, falling back.");
|
Log.d(TAG, "Failed to get custom summary, falling back.");
|
@@ -25,16 +25,16 @@ import com.android.settings.search.BaseSearchIndexProvider;
|
|||||||
import com.android.settingslib.search.SearchIndexable;
|
import com.android.settingslib.search.SearchIndexable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Settings page for emergency sos gesture
|
* Settings page for emergency gesture
|
||||||
*/
|
*/
|
||||||
@SearchIndexable
|
@SearchIndexable
|
||||||
public class PanicGestureSettings extends DashboardFragment {
|
public class EmergencyGestureSettings extends DashboardFragment {
|
||||||
|
|
||||||
private static final String TAG = "PanicGestureSettings";
|
private static final String TAG = "EmergencyGestureSetting";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getPreferenceScreenResId() {
|
protected int getPreferenceScreenResId() {
|
||||||
return R.xml.panic_gesture_settings;
|
return R.xml.emergency_gesture_settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -48,12 +48,12 @@ public class PanicGestureSettings extends DashboardFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||||
new BaseSearchIndexProvider(R.xml.panic_gesture_settings) {
|
new BaseSearchIndexProvider(R.xml.emergency_gesture_settings) {
|
||||||
@Override
|
@Override
|
||||||
protected boolean isPageSearchEnabled(Context context) {
|
protected boolean isPageSearchEnabled(Context context) {
|
||||||
final PanicGesturePreferenceController controller =
|
final EmergencyGesturePreferenceController controller =
|
||||||
new PanicGesturePreferenceController(context,
|
new EmergencyGesturePreferenceController(context,
|
||||||
"dummy_panic_gesture_pref_key");
|
"dummy_emergency_gesture_pref_key");
|
||||||
return !controller.isAvailable()
|
return !controller.isAvailable()
|
||||||
|| controller.shouldSuppressFromSearch();
|
|| controller.shouldSuppressFromSearch();
|
||||||
}
|
}
|
@@ -27,7 +27,7 @@ import com.android.settings.core.TogglePreferenceController;
|
|||||||
/**
|
/**
|
||||||
* Preference controller for emergency sos gesture setting
|
* Preference controller for emergency sos gesture setting
|
||||||
*/
|
*/
|
||||||
public class PanicGestureSoundPreferenceController extends TogglePreferenceController {
|
public class EmergencyGestureSoundPreferenceController extends TogglePreferenceController {
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final int ON = 1;
|
static final int ON = 1;
|
||||||
@@ -36,13 +36,13 @@ public class PanicGestureSoundPreferenceController extends TogglePreferenceContr
|
|||||||
|
|
||||||
private static final String SECURE_KEY = Settings.Secure.EMERGENCY_GESTURE_SOUND_ENABLED;
|
private static final String SECURE_KEY = Settings.Secure.EMERGENCY_GESTURE_SOUND_ENABLED;
|
||||||
|
|
||||||
public PanicGestureSoundPreferenceController(Context context, String key) {
|
public EmergencyGestureSoundPreferenceController(Context context, String key) {
|
||||||
super(context, key);
|
super(context, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isGestureAvailable(Context context) {
|
private static boolean isGestureAvailable(Context context) {
|
||||||
return context.getResources()
|
return context.getResources()
|
||||||
.getBoolean(R.bool.config_show_panic_gesture_settings);
|
.getBoolean(R.bool.config_show_emergency_gesture_settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@@ -16,8 +16,9 @@
|
|||||||
|
|
||||||
package com.android.settings.gestures;
|
package com.android.settings.gestures;
|
||||||
|
|
||||||
import static com.android.settings.gestures.PanicGesturePreferenceController.OFF;
|
import static com.android.settings.gestures.EmergencyGesturePreferenceController.ACTION_EMERGENCY_GESTURE_SETTINGS;
|
||||||
import static com.android.settings.gestures.PanicGesturePreferenceController.ON;
|
import static com.android.settings.gestures.EmergencyGesturePreferenceController.OFF;
|
||||||
|
import static com.android.settings.gestures.EmergencyGesturePreferenceController.ON;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
@@ -44,25 +45,25 @@ import org.robolectric.shadows.ShadowPackageManager;
|
|||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
@Config(shadows = SettingsShadowResources.class)
|
@Config(shadows = SettingsShadowResources.class)
|
||||||
public class PanicGesturePreferenceControllerTest {
|
public class EmergencyGesturePreferenceControllerTest {
|
||||||
|
|
||||||
private static final String TEST_PKG_NAME = "test_pkg";
|
private static final String TEST_PKG_NAME = "test_pkg";
|
||||||
private static final String TEST_CLASS_NAME = "name";
|
private static final String TEST_CLASS_NAME = "name";
|
||||||
private static final Intent SETTING_INTENT = new Intent(
|
private static final Intent SETTING_INTENT = new Intent(ACTION_EMERGENCY_GESTURE_SETTINGS)
|
||||||
PanicGesturePreferenceController.ACTION_PANIC_SETTINGS).setPackage(TEST_PKG_NAME);
|
.setPackage(TEST_PKG_NAME);
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private ContentResolver mContentResolver;
|
private ContentResolver mContentResolver;
|
||||||
private ShadowPackageManager mPackageManager;
|
private ShadowPackageManager mPackageManager;
|
||||||
private PanicGesturePreferenceController mController;
|
private EmergencyGesturePreferenceController mController;
|
||||||
private static final String PREF_KEY = "gesture_panic_button";
|
private static final String PREF_KEY = "gesture_emergency_button";
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
mContext = ApplicationProvider.getApplicationContext();
|
mContext = ApplicationProvider.getApplicationContext();
|
||||||
mContentResolver = mContext.getContentResolver();
|
mContentResolver = mContext.getContentResolver();
|
||||||
mPackageManager = Shadows.shadowOf(mContext.getPackageManager());
|
mPackageManager = Shadows.shadowOf(mContext.getPackageManager());
|
||||||
mController = new PanicGesturePreferenceController(mContext, PREF_KEY);
|
mController = new EmergencyGesturePreferenceController(mContext, PREF_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
@@ -80,14 +81,14 @@ public class PanicGesturePreferenceControllerTest {
|
|||||||
mPackageManager.addResolveInfoForIntent(SETTING_INTENT, info);
|
mPackageManager.addResolveInfoForIntent(SETTING_INTENT, info);
|
||||||
|
|
||||||
SettingsShadowResources.overrideResource(
|
SettingsShadowResources.overrideResource(
|
||||||
R.bool.config_show_panic_gesture_settings,
|
R.bool.config_show_emergency_gesture_settings,
|
||||||
Boolean.TRUE);
|
Boolean.TRUE);
|
||||||
|
|
||||||
SettingsShadowResources.overrideResource(
|
SettingsShadowResources.overrideResource(
|
||||||
R.string.panic_gesture_settings_package,
|
R.string.emergency_gesture_settings_package,
|
||||||
TEST_PKG_NAME);
|
TEST_PKG_NAME);
|
||||||
|
|
||||||
mController = new PanicGesturePreferenceController(mContext, PREF_KEY);
|
mController = new EmergencyGesturePreferenceController(mContext, PREF_KEY);
|
||||||
|
|
||||||
assertThat(mController.mIntent).isNotNull();
|
assertThat(mController.mIntent).isNotNull();
|
||||||
}
|
}
|
||||||
@@ -95,16 +96,16 @@ public class PanicGesturePreferenceControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void isAvailable_configIsTrue_shouldReturnTrue() {
|
public void isAvailable_configIsTrue_shouldReturnTrue() {
|
||||||
SettingsShadowResources.overrideResource(
|
SettingsShadowResources.overrideResource(
|
||||||
R.bool.config_show_panic_gesture_settings,
|
R.bool.config_show_emergency_gesture_settings,
|
||||||
Boolean.TRUE);
|
Boolean.TRUE);
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isTrue();
|
assertThat(mController.isAvailable()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isAvailable_configIsTrue_shouldReturnFalse() {
|
public void isAvailable_configIsFalse_shouldReturnFalse() {
|
||||||
SettingsShadowResources.overrideResource(
|
SettingsShadowResources.overrideResource(
|
||||||
R.bool.config_show_panic_gesture_settings,
|
R.bool.config_show_emergency_gesture_settings,
|
||||||
Boolean.FALSE);
|
Boolean.FALSE);
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isFalse();
|
assertThat(mController.isAvailable()).isFalse();
|
||||||
@@ -114,7 +115,7 @@ public class PanicGesturePreferenceControllerTest {
|
|||||||
public void isChecked_configIsNotSet_shouldReturnTrue() {
|
public void isChecked_configIsNotSet_shouldReturnTrue() {
|
||||||
// Set the setting to be enabled.
|
// Set the setting to be enabled.
|
||||||
Settings.Secure.putInt(mContentResolver, Settings.Secure.EMERGENCY_GESTURE_ENABLED, ON);
|
Settings.Secure.putInt(mContentResolver, Settings.Secure.EMERGENCY_GESTURE_ENABLED, ON);
|
||||||
mController = new PanicGesturePreferenceController(mContext, PREF_KEY);
|
mController = new EmergencyGesturePreferenceController(mContext, PREF_KEY);
|
||||||
|
|
||||||
assertThat(mController.isChecked()).isTrue();
|
assertThat(mController.isChecked()).isTrue();
|
||||||
}
|
}
|
||||||
@@ -123,15 +124,15 @@ public class PanicGesturePreferenceControllerTest {
|
|||||||
public void isChecked_configIsSet_shouldReturnFalse() {
|
public void isChecked_configIsSet_shouldReturnFalse() {
|
||||||
// Set the setting to be disabled.
|
// Set the setting to be disabled.
|
||||||
Settings.Secure.putInt(mContentResolver, Settings.Secure.EMERGENCY_GESTURE_ENABLED, OFF);
|
Settings.Secure.putInt(mContentResolver, Settings.Secure.EMERGENCY_GESTURE_ENABLED, OFF);
|
||||||
mController = new PanicGesturePreferenceController(mContext, PREF_KEY);
|
mController = new EmergencyGesturePreferenceController(mContext, PREF_KEY);
|
||||||
|
|
||||||
assertThat(mController.isChecked()).isFalse();
|
assertThat(mController.isChecked()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isSliceableCorrectKey_returnsTrue() {
|
public void isSliceableCorrectKey_returnsTrue() {
|
||||||
final PanicGesturePreferenceController controller =
|
final EmergencyGesturePreferenceController controller =
|
||||||
new PanicGesturePreferenceController(mContext, PREF_KEY);
|
new EmergencyGesturePreferenceController(mContext, PREF_KEY);
|
||||||
assertThat(controller.isSliceable()).isTrue();
|
assertThat(controller.isSliceable()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
@@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
package com.android.settings.gestures;
|
package com.android.settings.gestures;
|
||||||
|
|
||||||
import static com.android.settings.gestures.PanicGesturePreferenceController.OFF;
|
import static com.android.settings.gestures.EmergencyGestureSoundPreferenceController.OFF;
|
||||||
import static com.android.settings.gestures.PanicGesturePreferenceController.ON;
|
import static com.android.settings.gestures.EmergencyGestureSoundPreferenceController.ON;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
@@ -39,17 +39,17 @@ import org.robolectric.annotation.Config;
|
|||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
@Config(shadows = SettingsShadowResources.class)
|
@Config(shadows = SettingsShadowResources.class)
|
||||||
public class PanicGestureSoundPreferenceControllerTest {
|
public class EmergencyGestureSoundPreferenceControllerTest {
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private ContentResolver mContentResolver;
|
private ContentResolver mContentResolver;
|
||||||
private PanicGestureSoundPreferenceController mController;
|
private EmergencyGestureSoundPreferenceController mController;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
mContext = ApplicationProvider.getApplicationContext();
|
mContext = ApplicationProvider.getApplicationContext();
|
||||||
mContentResolver = mContext.getContentResolver();
|
mContentResolver = mContext.getContentResolver();
|
||||||
mController = new PanicGestureSoundPreferenceController(mContext, "test_key");
|
mController = new EmergencyGestureSoundPreferenceController(mContext, "test_key");
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
@@ -60,7 +60,7 @@ public class PanicGestureSoundPreferenceControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void isAvailable_configIsTrue_shouldReturnTrue() {
|
public void isAvailable_configIsTrue_shouldReturnTrue() {
|
||||||
SettingsShadowResources.overrideResource(
|
SettingsShadowResources.overrideResource(
|
||||||
R.bool.config_show_panic_gesture_settings,
|
R.bool.config_show_emergency_gesture_settings,
|
||||||
Boolean.TRUE);
|
Boolean.TRUE);
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isTrue();
|
assertThat(mController.isAvailable()).isTrue();
|
||||||
@@ -69,7 +69,7 @@ public class PanicGestureSoundPreferenceControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void isAvailable_configIsTrue_shouldReturnFalse() {
|
public void isAvailable_configIsTrue_shouldReturnFalse() {
|
||||||
SettingsShadowResources.overrideResource(
|
SettingsShadowResources.overrideResource(
|
||||||
R.bool.config_show_panic_gesture_settings,
|
R.bool.config_show_emergency_gesture_settings,
|
||||||
Boolean.FALSE);
|
Boolean.FALSE);
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isFalse();
|
assertThat(mController.isAvailable()).isFalse();
|
Reference in New Issue
Block a user