diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 3fddf39e544..a1bb9a28682 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -112,6 +112,7 @@ + - - + + @@ -259,14 +257,6 @@ - - - - @@ -549,7 +539,6 @@ diff --git a/res/values/strings.xml b/res/values/strings.xml index 275ffab1df2..d53c417b364 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -5553,11 +5553,17 @@ Auto click time - Vibration & haptic strength - - Notification vibration + Vibration & haptics + + Calls + + Notifications and alarms + + Interactive haptics Ring vibration + + Notification vibration Touch feedback @@ -8269,8 +8275,6 @@ Wi\u2011Fi notification, wifi notification data usage - - Stop vibration, tap, keyboard Use 24-hour format @@ -8406,11 +8410,12 @@ haptics, vibrate, screen, sensitivity - haptics, vibrate, phone, call, sensitivity, ring haptics, vibrate, sensitivity + + haptics, vibrate, vibration battery saver, sticky, persist, power saver, battery @@ -8522,12 +8527,6 @@ Touch sounds - - Touch vibration - - - Haptic feedback for tap, keyboard, and more - Dock speaker plays diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml index 61f527d98dc..8113a9fd1d0 100644 --- a/res/xml/accessibility_settings.xml +++ b/res/xml/accessibility_settings.xml @@ -100,7 +100,8 @@ android:icon="@drawable/ic_vibration" android:persistent="false" android:title="@string/accessibility_vibration_settings_title" - settings:controller="com.android.settings.accessibility.VibrationPreferenceController"/> + settings:controller="com.android.settings.accessibility.VibrationPreferenceController" + settings:keywords="@string/keywords_vibration"/> diff --git a/res/xml/accessibility_vibration_settings.xml b/res/xml/accessibility_vibration_settings.xml index 87c2988ac2a..ff106110946 100644 --- a/res/xml/accessibility_vibration_settings.xml +++ b/res/xml/accessibility_vibration_settings.xml @@ -20,24 +20,49 @@ xmlns:settings="http://schemas.android.com/apk/res-auto" android:title="@string/accessibility_vibration_settings_title"> - + - + + + + + + + + + + + + + + + + + - diff --git a/res/xml/other_sound_settings.xml b/res/xml/other_sound_settings.xml index 7b3f362eec8..d8396a4b644 100644 --- a/res/xml/other_sound_settings.xml +++ b/res/xml/other_sound_settings.xml @@ -44,12 +44,6 @@ android:key="touch_sounds" android:title="@string/touch_sounds_title" /> - - - - + + settings:controller="com.android.settings.accessibility.VibrationPreferenceController" + settings:keywords="@string/keywords_vibration"/> - - - + public ActivityScenarioRule rule = new ActivityScenarioRule<>( new Intent(android.provider.Settings.ACTION_DATA_ROAMING_SETTINGS) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); diff --git a/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java index 78a7a69a2b8..da7516b1fab 100644 --- a/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java +++ b/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java @@ -250,4 +250,22 @@ public class SavedBluetoothDeviceUpdaterTest { verify(mBluetoothDeviceUpdater).addPreference(mCachedBluetoothDevice, BluetoothDevicePreference.SortType.TYPE_NO_SORT); } + + @Test + public void forceUpdate_deviceIsSubDevice_doesNothing() { + final List bluetoothDevices = new ArrayList<>(); + bluetoothDevices.add(mBluetoothDevice); + + when(mBluetoothAdapter.isEnabled()).thenReturn(true); + when(mBluetoothAdapter.getMostRecentlyConnectedDevices()).thenReturn(bluetoothDevices); + when(mBluetoothManager.getCachedDeviceManager()).thenReturn(mDeviceManager); + when(mDeviceManager.findDevice(mBluetoothDevice)).thenReturn(mCachedBluetoothDevice); + when(mDeviceManager.isSubDevice(mBluetoothDevice)).thenReturn(true); + + mBluetoothDeviceUpdater.forceUpdate(); + + verify(mBluetoothDeviceUpdater, never()).removePreference(mCachedBluetoothDevice); + verify(mBluetoothDeviceUpdater, never()).addPreference(mCachedBluetoothDevice, + BluetoothDevicePreference.SortType.TYPE_NO_SORT); + } } diff --git a/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java b/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java index b60bfb83d66..66536a57697 100644 --- a/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java +++ b/tests/robotests/src/com/android/settings/network/MobileNetworkSummaryControllerTest.java @@ -44,7 +44,7 @@ import android.util.FeatureFlagUtils; import androidx.lifecycle.Lifecycle; import androidx.preference.PreferenceScreen; -import com.android.settings.network.telephony.MobileNetworkActivity; +import com.android.settings.Settings.MobileNetworkActivity; import com.android.settings.widget.AddPreference; import com.android.settingslib.RestrictedLockUtils; diff --git a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java deleted file mode 100644 index 5729208ecfe..00000000000 --- a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * 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.settings.network.telephony; - - -import static com.google.common.truth.Truth.assertThat; - -import static org.mockito.Mockito.doReturn; -import static org.robolectric.Shadows.shadowOf; - -import android.content.Context; -import android.content.Intent; -import android.os.Bundle; -import android.os.UserManager; -import android.provider.Settings; -import android.telephony.SubscriptionInfo; -import android.telephony.SubscriptionManager; - -import androidx.test.core.app.ActivityScenario; -import androidx.test.core.app.ApplicationProvider; -import androidx.test.ext.junit.runners.AndroidJUnit4; - -import com.android.settings.SettingsActivity; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.robolectric.RuntimeEnvironment; -import org.robolectric.shadow.api.Shadow; -import org.robolectric.shadows.ShadowContextImpl; -import org.robolectric.shadows.ShadowSubscriptionManager; -import org.robolectric.shadows.ShadowSubscriptionManager.SubscriptionInfoBuilder; - -@RunWith(AndroidJUnit4.class) -public class MobileNetworkActivityTest { - - private static final int SUB_ID = 1; - private static final String DISPLAY_NAME = "SUB_ID"; - - private Context mContext; - private ShadowContextImpl mShadowContextImpl; - private Intent mTestIntent; - @Mock - private UserManager mUserManager; - private ShadowSubscriptionManager mSubscriptionManager; - private SubscriptionInfo mSubscriptionInfo; - private ActivityScenario mMobileNetworkActivity; - - @Before - public void setUp() { - MockitoAnnotations.initMocks(this); - - mContext = ApplicationProvider.getApplicationContext(); - mShadowContextImpl = Shadow.extract(RuntimeEnvironment.application.getBaseContext()); - mSubscriptionManager = shadowOf(mContext.getSystemService(SubscriptionManager.class)); - mShadowContextImpl.setSystemService(Context.USER_SERVICE, mUserManager); - doReturn(true).when(mUserManager).isAdminUser(); - - mTestIntent = new Intent(mContext, MobileNetworkActivity.class); - mSubscriptionInfo = SubscriptionInfoBuilder.newBuilder() - .setId(SUB_ID).setDisplayName(DISPLAY_NAME).buildSubscriptionInfo(); - mTestIntent.putExtra(Settings.EXTRA_SUB_ID, SUB_ID); - mTestIntent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE, - mSubscriptionInfo.getDisplayName()); - } - - @After - public void cleanUp() { - if (mMobileNetworkActivity != null) { - mMobileNetworkActivity.close(); - } - } - - private ActivityScenario createTargetActivity(Intent activityIntent) { - return ActivityScenario.launch(activityIntent); - } - - @Test - public void onCreate_getExtraFromIntent() { - mSubscriptionManager.setActiveSubscriptionInfos(mSubscriptionInfo); - mMobileNetworkActivity = createTargetActivity(mTestIntent); - - mMobileNetworkActivity.onActivity(activity -> { - final Bundle bundle = new Bundle(); - activity.onCreate(bundle); - assertThat(bundle.getInt(Settings.EXTRA_SUB_ID)).isEqualTo(SUB_ID); - assertThat(bundle.getString(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE)).isEqualTo( - DISPLAY_NAME); - }); - } -} diff --git a/tests/robotests/src/com/android/settings/notification/VibrateOnTouchPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/VibrateOnTouchPreferenceControllerTest.java deleted file mode 100644 index 2b2f02c73ca..00000000000 --- a/tests/robotests/src/com/android/settings/notification/VibrateOnTouchPreferenceControllerTest.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (C) 2017 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.notification; - -import static com.google.common.truth.Truth.assertThat; - -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.when; - -import android.content.ContentResolver; -import android.content.Context; -import android.os.Vibrator; -import android.provider.Settings.System; - -import androidx.fragment.app.FragmentActivity; -import androidx.preference.PreferenceScreen; -import androidx.preference.SwitchPreference; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.RuntimeEnvironment; - -@RunWith(RobolectricTestRunner.class) -public class VibrateOnTouchPreferenceControllerTest { - - @Mock - private PreferenceScreen mScreen; - @Mock - private FragmentActivity mActivity; - @Mock - private ContentResolver mContentResolver; - @Mock - private SoundSettings mSetting; - @Mock - private Context mContext; - @Mock - private Vibrator mVibrator; - - private VibrateOnTouchPreferenceController mController; - private SwitchPreference mPreference; - - @Before - public void setUp() { - MockitoAnnotations.initMocks(this); - when(mActivity.getSystemService(Context.VIBRATOR_SERVICE)).thenReturn(mVibrator); - when(mContext.getSystemService(Context.VIBRATOR_SERVICE)).thenReturn(mVibrator); - when(mVibrator.hasVibrator()).thenReturn(true); - when(mSetting.getActivity()).thenReturn(mActivity); - when(mActivity.getContentResolver()).thenReturn(mContentResolver); - mPreference = new SwitchPreference(RuntimeEnvironment.application); - mController = new VibrateOnTouchPreferenceController(mContext, mSetting, null); - when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference); - doReturn(mScreen).when(mSetting).getPreferenceScreen(); - } - - @Test - public void isAvailable_hasHaptic_shouldReturnTrue() { - assertThat(mController.isAvailable()).isTrue(); - } - - @Test - public void isAvailable_noHaptic_shouldReturnFalse() { - when(mVibrator.hasVibrator()).thenReturn(false); - - assertThat(mController.isAvailable()).isFalse(); - } - - @Test - public void displayPreference_hapticEnabled_shouldCheckedPreference() { - System.putInt(mContentResolver, System.HAPTIC_FEEDBACK_ENABLED, 1); - - mController.displayPreference(mScreen); - - assertThat(mPreference.isChecked()).isTrue(); - } - - @Test - public void displayPreference_hapticDisabled_shouldUncheckedPreference() { - System.putInt(mContentResolver, System.HAPTIC_FEEDBACK_ENABLED, 0); - - mController.displayPreference(mScreen); - - assertThat(mPreference.isChecked()).isFalse(); - } - - @Test - public void onPreferenceChanged_preferenceChecked_shouldEnabledHaptic() { - mController.displayPreference(mScreen); - - mPreference.getOnPreferenceChangeListener().onPreferenceChange(mPreference, true); - - assertThat(System.getInt(mContentResolver, System.HAPTIC_FEEDBACK_ENABLED, 1)).isEqualTo(1); - } - - @Test - public void onPreferenceChanged_preferenceUnchecked_shouldDisabledHaptic() { - mController.displayPreference(mScreen); - - mPreference.getOnPreferenceChangeListener().onPreferenceChange(mPreference, false); - - assertThat(System.getInt(mContentResolver, System.HAPTIC_FEEDBACK_ENABLED, 1)).isEqualTo(0); - } -} diff --git a/tests/uitests/src/com/android/settings/ui/SoundSettingsTest.java b/tests/uitests/src/com/android/settings/ui/SoundSettingsTest.java index 9789c5fa720..735992b927d 100644 --- a/tests/uitests/src/com/android/settings/ui/SoundSettingsTest.java +++ b/tests/uitests/src/com/android/settings/ui/SoundSettingsTest.java @@ -153,14 +153,6 @@ public class SoundSettingsTest extends InstrumentationTestCase { "Touch sounds", Settings.System.SOUND_EFFECTS_ENABLED)); } - @MediumTest - public void testOtherSoundsVibrateOnTap() throws Exception { - loadOtherSoundsPage(); - assertTrue("Vibrate on tap not toggled", - mHelper.verifyToggleSetting(SettingsType.SYSTEM, PAGE, - "Vibrate on tap", Settings.System.HAPTIC_FEEDBACK_ENABLED)); - } - private void loadOtherSoundsPage() throws Exception { launchSoundSettings(); mHelper.scrollVert(false);