From 5b90dfad345a3d6170e28268133ccb4c9eae37cf Mon Sep 17 00:00:00 2001 From: bvineeth Date: Tue, 16 Nov 2021 06:44:41 +0000 Subject: [PATCH 1/4] Typo fix in media settings title variable Fixed the typo in variable for media settings title, due to which the title was not being fetched from configuration. Bug: 199012697 Test: Manual Change-Id: I256e55a13f2f06ca0b2800ceb01900d5e12d9834 --- AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index dad91d85e39..321beb4eba1 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -4156,7 +4156,7 @@ + android:label="@string/media_controls_title"> From 7fea5bd54f3c3d1c9a2619c0bd044acc24671e32 Mon Sep 17 00:00:00 2001 From: Sergey Nikolaienkov Date: Wed, 27 Oct 2021 15:41:25 +0200 Subject: [PATCH 2/4] Fix usage of the updated CDM APIs Bug: 194301022 Test: make Change-Id: I70633f43d37fdeec8329e0c58f7cffa402dba689 --- ...uetoothDetailsCompanionAppsController.java | 5 +-- .../notification/NotificationBackend.java | 5 ++- ...othDetailsCompanionAppsControllerTest.java | 9 +++-- .../notification/NotificationBackendTest.java | 35 ++++++++++++++----- 4 files changed, 37 insertions(+), 17 deletions(-) diff --git a/src/com/android/settings/bluetooth/BluetoothDetailsCompanionAppsController.java b/src/com/android/settings/bluetooth/BluetoothDetailsCompanionAppsController.java index 73360f13a88..272d142e3e8 100644 --- a/src/com/android/settings/bluetooth/BluetoothDetailsCompanionAppsController.java +++ b/src/com/android/settings/bluetooth/BluetoothDetailsCompanionAppsController.java @@ -29,6 +29,7 @@ import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.RemoteException; import android.os.ServiceManager; +import android.os.UserHandle; import android.provider.DeviceConfig; import android.text.TextUtils; import android.util.Log; @@ -126,8 +127,8 @@ public class BluetoothDetailsCompanionAppsController extends BluetoothDetailsCon try { java.util.Objects.requireNonNull(ICompanionDeviceManager.Stub.asInterface( ServiceManager.getService( - Context.COMPANION_DEVICE_SERVICE))).disassociate( - address, packageName); + Context.COMPANION_DEVICE_SERVICE))).legacyDisassociate( + address, packageName, UserHandle.myUserId()); } catch (RemoteException e) { throw new RuntimeException(e); } diff --git a/src/com/android/settings/notification/NotificationBackend.java b/src/com/android/settings/notification/NotificationBackend.java index 1af8867acd5..cae3cae9286 100644 --- a/src/com/android/settings/notification/NotificationBackend.java +++ b/src/com/android/settings/notification/NotificationBackend.java @@ -54,6 +54,7 @@ import android.util.Log; import androidx.annotation.VisibleForTesting; +import com.android.internal.util.CollectionUtils; import com.android.settingslib.R; import com.android.settingslib.Utils; import com.android.settingslib.bluetooth.CachedBluetoothDevice; @@ -159,7 +160,9 @@ public class NotificationBackend { StringBuilder sb = new StringBuilder(); try { - List associatedMacAddrs = cdm.getAssociations(pkg, userId); + List associatedMacAddrs = CollectionUtils.mapNotNull( + cdm.getAssociations(pkg, userId), + a -> a.isSelfManaged() ? null : a.getDeviceMacAddress().toString()); if (associatedMacAddrs != null) { for (String assocMac : associatedMacAddrs) { final Collection cachedDevices = diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsCompanionAppsControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsCompanionAppsControllerTest.java index 1d5aa549ac5..0f7bf20b9f7 100644 --- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsCompanionAppsControllerTest.java +++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsCompanionAppsControllerTest.java @@ -24,9 +24,9 @@ import static org.mockito.Mockito.when; import android.companion.AssociationInfo; import android.companion.CompanionDeviceManager; -import android.companion.DeviceId; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; +import android.net.MacAddress; import androidx.preference.Preference; import androidx.preference.PreferenceCategory; @@ -100,15 +100,14 @@ public class BluetoothDetailsCompanionAppsControllerTest extends setupFakeLabelAndInfo(packageName, appName); final int associationId = mAssociations.size() + 1; - final DeviceId deviceId = - new DeviceId(DeviceId.TYPE_MAC_ADDRESS, mCachedDevice.getAddress()); final AssociationInfo association = new AssociationInfo( associationId, /* userId */ 0, packageName, - Arrays.asList(deviceId), + MacAddress.fromString(mCachedDevice.getAddress()), + /* displayName */ null, /* deviceProfile */ "", - /* managedByCompanionApp */ false, + /* selfManaged */ false, /* notifyOnDeviceNearby */ true, /* timeApprovedMs */ System.currentTimeMillis()); diff --git a/tests/robotests/src/com/android/settings/notification/NotificationBackendTest.java b/tests/robotests/src/com/android/settings/notification/NotificationBackendTest.java index 063be35fe77..71fab426e9d 100644 --- a/tests/robotests/src/com/android/settings/notification/NotificationBackendTest.java +++ b/tests/robotests/src/com/android/settings/notification/NotificationBackendTest.java @@ -31,11 +31,13 @@ import android.app.INotificationManager; import android.app.role.RoleManager; import android.app.usage.UsageEvents; import android.bluetooth.BluetoothAdapter; +import android.companion.AssociationInfo; import android.companion.ICompanionDeviceManager; import android.content.ComponentName; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; +import android.net.MacAddress; import android.os.Parcel; import android.provider.Settings; @@ -234,8 +236,9 @@ public class NotificationBackendTest { @Test public void getDeviceList_associationsButNoDevice() throws Exception { - List macs = ImmutableList.of("00:00:00:00:00:10", "00:00:00:00:00:20"); - when(mCdm.getAssociations(mCn.getPackageName(), 0)).thenReturn(macs); + List associations = + mockAssociations("00:00:00:00:00:10", "00:00:00:00:00:20"); + when(mCdm.getAssociations(mCn.getPackageName(), 0)).thenReturn(associations); when(mCbm.getCachedDevicesCopy()).thenReturn(new ArrayList<>()); @@ -245,12 +248,13 @@ public class NotificationBackendTest { @Test public void getDeviceList_singleDevice() throws Exception { - List macs = ImmutableList.of("00:00:00:00:00:10", "00:00:00:00:00:20"); - when(mCdm.getAssociations(mCn.getPackageName(), 0)).thenReturn(macs); + String[] macs = { "00:00:00:00:00:10", "00:00:00:00:00:20" }; + List associations = mockAssociations(macs); + when(mCdm.getAssociations(mCn.getPackageName(), 0)).thenReturn(associations); Collection cachedDevices = new ArrayList<>(); CachedBluetoothDevice cbd1 = mock(CachedBluetoothDevice.class); - when(cbd1.getAddress()).thenReturn(macs.get(0)); + when(cbd1.getAddress()).thenReturn(macs[0]); when(cbd1.getName()).thenReturn("Device 1"); cachedDevices.add(cbd1); when(mCbm.getCachedDevicesCopy()).thenReturn(cachedDevices); @@ -261,17 +265,18 @@ public class NotificationBackendTest { @Test public void getDeviceList_multipleDevices() throws Exception { - List macs = ImmutableList.of("00:00:00:00:00:10", "00:00:00:00:00:20"); - when(mCdm.getAssociations(mCn.getPackageName(), 0)).thenReturn(macs); + String[] macs = { "00:00:00:00:00:10", "00:00:00:00:00:20" }; + List associations = mockAssociations(macs); + when(mCdm.getAssociations(mCn.getPackageName(), 0)).thenReturn(associations); Collection cachedDevices = new ArrayList<>(); CachedBluetoothDevice cbd1 = mock(CachedBluetoothDevice.class); - when(cbd1.getAddress()).thenReturn(macs.get(0)); + when(cbd1.getAddress()).thenReturn(macs[0]); when(cbd1.getName()).thenReturn("Device 1"); cachedDevices.add(cbd1); CachedBluetoothDevice cbd2 = mock(CachedBluetoothDevice.class); - when(cbd2.getAddress()).thenReturn(macs.get(1)); + when(cbd2.getAddress()).thenReturn(macs[1]); when(cbd2.getName()).thenReturn("Device 2"); cachedDevices.add(cbd2); when(mCbm.getCachedDevicesCopy()).thenReturn(cachedDevices); @@ -279,4 +284,16 @@ public class NotificationBackendTest { assertThat(new NotificationBackend().getDeviceList( mCdm, mBm, mCn.getPackageName(), 0).toString()).isEqualTo("Device 1, Device 2"); } + + private ImmutableList mockAssociations(String... macAddresses) { + final AssociationInfo[] associations = new AssociationInfo[macAddresses.length]; + for (int index = 0; index < macAddresses.length; index++) { + final AssociationInfo association = mock(AssociationInfo.class); + when(association.isSelfManaged()).thenReturn(false); + when(association.getDeviceMacAddress()) + .thenReturn(MacAddress.fromString(macAddresses[index])); + associations[index] = association; + } + return ImmutableList.copyOf(associations); + } } From 24b2d9e5a12c78b1b7f81cbb27d0892fd2069f99 Mon Sep 17 00:00:00 2001 From: Lais Andrade Date: Thu, 4 Nov 2021 12:10:49 +0000 Subject: [PATCH 3/4] Move APPLY_RAMPING_RINGER from Global to System This configuration should be user-scoped. Bug: 184165158 Test: AccessibilitySettingsTest RingVibrationPreferenceFragmentTest VibrateForCallsPreferenceControllerTest VibrateForCallsPreferenceFragmentTest Change-Id: I7b8684fb1cf03d41872a700fd8732c76422e37c3 --- .../accessibility/AccessibilitySettings.java | 4 ++-- .../RingVibrationPreferenceFragment.java | 2 +- .../VibrationPreferenceFragment.java | 6 +++--- .../VibrateForCallsPreferenceController.java | 4 ++-- .../VibrateForCallsPreferenceFragment.java | 16 ++++++++-------- .../AccessibilitySettingsTest.java | 8 ++++---- .../RingVibrationPreferenceFragmentTest.java | 12 ++++++------ ...ibrateForCallsPreferenceControllerTest.java | 6 +++--- .../VibrateForCallsPreferenceFragmentTest.java | 18 +++++++++--------- 9 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java index 56f3e9ffeff..4030e0dd777 100644 --- a/src/com/android/settings/accessibility/AccessibilitySettings.java +++ b/src/com/android/settings/accessibility/AccessibilitySettings.java @@ -295,8 +295,8 @@ public class AccessibilitySettings extends DashboardFragment { } static boolean isRampingRingerEnabled(final Context context) { - return Settings.Global.getInt( - context.getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, 0) == 1; + return Settings.System.getInt( + context.getContentResolver(), Settings.System.APPLY_RAMPING_RINGER, 0) == 1; } @VisibleForTesting diff --git a/src/com/android/settings/accessibility/RingVibrationPreferenceFragment.java b/src/com/android/settings/accessibility/RingVibrationPreferenceFragment.java index babfb9a2000..5d19a9b4166 100644 --- a/src/com/android/settings/accessibility/RingVibrationPreferenceFragment.java +++ b/src/com/android/settings/accessibility/RingVibrationPreferenceFragment.java @@ -47,7 +47,7 @@ public class RingVibrationPreferenceFragment extends VibrationPreferenceFragment @Override protected String getVibrationEnabledSetting() { if (AccessibilitySettings.isRampingRingerEnabled(getContext())) { - return Settings.Global.APPLY_RAMPING_RINGER; + return Settings.System.APPLY_RAMPING_RINGER; } else { return Settings.System.VIBRATE_WHEN_RINGING; } diff --git a/src/com/android/settings/accessibility/VibrationPreferenceFragment.java b/src/com/android/settings/accessibility/VibrationPreferenceFragment.java index 1803a8bafe2..2ef8f660079 100644 --- a/src/com/android/settings/accessibility/VibrationPreferenceFragment.java +++ b/src/com/android/settings/accessibility/VibrationPreferenceFragment.java @@ -116,12 +116,12 @@ public abstract class VibrationPreferenceFragment extends RadioButtonPickerFragm // Update vibration enabled setting final String vibrationEnabledSetting = getVibrationEnabledSetting(); final boolean wasEnabled = TextUtils.equals( - vibrationEnabledSetting, Settings.Global.APPLY_RAMPING_RINGER) + vibrationEnabledSetting, Settings.System.APPLY_RAMPING_RINGER) ? true : (Settings.System.getInt( getContext().getContentResolver(), vibrationEnabledSetting, 1) == 1); if (vibrationEnabled != wasEnabled) { - if (vibrationEnabledSetting.equals(Settings.Global.APPLY_RAMPING_RINGER)) { + if (vibrationEnabledSetting.equals(Settings.System.APPLY_RAMPING_RINGER)) { Settings.Global.putInt(getContext().getContentResolver(), vibrationEnabledSetting, 0); } else { @@ -212,7 +212,7 @@ public abstract class VibrationPreferenceFragment extends RadioButtonPickerFragm getVibrationIntensitySetting(), getDefaultVibrationIntensity()); final String vibrationEnabledSetting = getVibrationEnabledSetting(); final boolean vibrationEnabled = TextUtils.equals( - vibrationEnabledSetting, Settings.Global.APPLY_RAMPING_RINGER) + vibrationEnabledSetting, Settings.System.APPLY_RAMPING_RINGER) ? true : (Settings.System.getInt( getContext().getContentResolver(), vibrationEnabledSetting, 1) == 1); diff --git a/src/com/android/settings/sound/VibrateForCallsPreferenceController.java b/src/com/android/settings/sound/VibrateForCallsPreferenceController.java index 31abd8a4534..58c6ba5e707 100644 --- a/src/com/android/settings/sound/VibrateForCallsPreferenceController.java +++ b/src/com/android/settings/sound/VibrateForCallsPreferenceController.java @@ -51,9 +51,9 @@ public class VibrateForCallsPreferenceController extends BasePreferenceControlle @Override public CharSequence getSummary() { - if (Settings.Global.getInt( + if (Settings.System.getInt( mContext.getContentResolver(), - Settings.Global.APPLY_RAMPING_RINGER, OFF) == ON) { + Settings.System.APPLY_RAMPING_RINGER, OFF) == ON) { return mContext.getText(R.string.vibrate_when_ringing_option_ramping_ringer); } else if (Settings.System.getInt( mContext.getContentResolver(), diff --git a/src/com/android/settings/sound/VibrateForCallsPreferenceFragment.java b/src/com/android/settings/sound/VibrateForCallsPreferenceFragment.java index 73b9f2fbd8e..a769de15ee8 100644 --- a/src/com/android/settings/sound/VibrateForCallsPreferenceFragment.java +++ b/src/com/android/settings/sound/VibrateForCallsPreferenceFragment.java @@ -78,18 +78,18 @@ public class VibrateForCallsPreferenceFragment extends RadioButtonPickerFragment if (TextUtils.equals(key, KEY_ALWAYS_VIBRATE)) { Settings.System.putInt( getContext().getContentResolver(), Settings.System.VIBRATE_WHEN_RINGING, ON); - Settings.Global.putInt( - getContext().getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, OFF); + Settings.System.putInt( + getContext().getContentResolver(), Settings.System.APPLY_RAMPING_RINGER, OFF); } else if (TextUtils.equals(key, KEY_RAMPING_RINGER)) { Settings.System.putInt( getContext().getContentResolver(), Settings.System.VIBRATE_WHEN_RINGING, OFF); - Settings.Global.putInt( - getContext().getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, ON); + Settings.System.putInt( + getContext().getContentResolver(), Settings.System.APPLY_RAMPING_RINGER, ON); } else { Settings.System.putInt( getContext().getContentResolver(), Settings.System.VIBRATE_WHEN_RINGING, OFF); - Settings.Global.putInt( - getContext().getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, OFF); + Settings.System.putInt( + getContext().getContentResolver(), Settings.System.APPLY_RAMPING_RINGER, OFF); } } @@ -104,9 +104,9 @@ public class VibrateForCallsPreferenceFragment extends RadioButtonPickerFragment @Override protected String getDefaultKey() { - if (Settings.Global.getInt( + if (Settings.System.getInt( getContext().getContentResolver(), - Settings.Global.APPLY_RAMPING_RINGER, OFF) == ON) { + Settings.System.APPLY_RAMPING_RINGER, OFF) == ON) { return KEY_RAMPING_RINGER; } else if (Settings.System.getInt( getContext().getContentResolver(), diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java index 74f27900266..c9f1b660cae 100644 --- a/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java @@ -146,16 +146,16 @@ public class AccessibilitySettingsTest { @Test @Config(shadows = {ShadowDeviceConfig.class}) public void isRampingRingerEnabled_settingsFlagOn_Enabled() { - Settings.Global.putInt( - mContext.getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, ON); + Settings.System.putInt( + mContext.getContentResolver(), Settings.System.APPLY_RAMPING_RINGER, ON); assertThat(AccessibilitySettings.isRampingRingerEnabled(mContext)).isTrue(); } @Test @Config(shadows = {ShadowDeviceConfig.class}) public void isRampingRingerEnabled_settingsFlagOff_Disabled() { - Settings.Global.putInt( - mContext.getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, OFF); + Settings.System.putInt( + mContext.getContentResolver(), Settings.System.APPLY_RAMPING_RINGER, OFF); assertThat(AccessibilitySettings.isRampingRingerEnabled(mContext)).isFalse(); } diff --git a/tests/robotests/src/com/android/settings/accessibility/RingVibrationPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/RingVibrationPreferenceFragmentTest.java index cd1d17eb003..e2b1051d25d 100644 --- a/tests/robotests/src/com/android/settings/accessibility/RingVibrationPreferenceFragmentTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/RingVibrationPreferenceFragmentTest.java @@ -50,17 +50,17 @@ public class RingVibrationPreferenceFragmentTest { @Config(shadows = {ShadowDeviceConfig.class}) public void getVibrationEnabledSetting_rampingRingerEnabled_returnApplyRampingRinger() { // Turn on both flags to enable ramping ringer. - Settings.Global.putInt( - mContext.getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, 1 /* ON */); + Settings.System.putInt( + mContext.getContentResolver(), Settings.System.APPLY_RAMPING_RINGER, 1 /* ON */); assertThat(mFragment.getVibrationEnabledSetting()).isEqualTo( - Settings.Global.APPLY_RAMPING_RINGER); + Settings.System.APPLY_RAMPING_RINGER); } @Test public void getVibrationEnabledSetting_rampingRingerDisabled_returnVibrationWhenRinging() { - // Turn off Settings.Global.APPLY_RAMPING_RINGER to disable ramping ringer. - Settings.Global.putInt( - mContext.getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, 0 /* OFF */); + // Turn off Settings.System.APPLY_RAMPING_RINGER to disable ramping ringer. + Settings.System.putInt( + mContext.getContentResolver(), Settings.System.APPLY_RAMPING_RINGER, 0 /* OFF */); assertThat(mFragment.getVibrationEnabledSetting()).isEqualTo( Settings.System.VIBRATE_WHEN_RINGING); } diff --git a/tests/robotests/src/com/android/settings/sound/VibrateForCallsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/sound/VibrateForCallsPreferenceControllerTest.java index bf2b0f36bb8..1f4ba96f7a9 100644 --- a/tests/robotests/src/com/android/settings/sound/VibrateForCallsPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/sound/VibrateForCallsPreferenceControllerTest.java @@ -94,7 +94,7 @@ public class VibrateForCallsPreferenceControllerTest { @Test public void getSummary_applyRampingRinger_rampingRingerSummary() { Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF); - Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, ON); + Settings.System.putInt(mContentResolver, Settings.System.APPLY_RAMPING_RINGER, ON); assertThat(mController.getSummary()).isEqualTo( mContext.getText(R.string.vibrate_when_ringing_option_ramping_ringer)); @@ -103,7 +103,7 @@ public class VibrateForCallsPreferenceControllerTest { @Test public void getSummary_enableVibrateWhenRinging_alwaysVibrateSummary() { Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, ON); - Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF); + Settings.System.putInt(mContentResolver, Settings.System.APPLY_RAMPING_RINGER, OFF); assertThat(mController.getSummary()).isEqualTo( mContext.getText(R.string.vibrate_when_ringing_option_always_vibrate)); @@ -112,7 +112,7 @@ public class VibrateForCallsPreferenceControllerTest { @Test public void getSummary_notApplyRampingRingerDisableVibrateWhenRinging_neverVibrateSummary() { Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF); - Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF); + Settings.System.putInt(mContentResolver, Settings.System.APPLY_RAMPING_RINGER, OFF); assertThat(mController.getSummary()).isEqualTo( mContext.getText(R.string.vibrate_when_ringing_option_never_vibrate)); diff --git a/tests/robotests/src/com/android/settings/sound/VibrateForCallsPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/sound/VibrateForCallsPreferenceFragmentTest.java index 0a766d68414..889e5a6f9d6 100644 --- a/tests/robotests/src/com/android/settings/sound/VibrateForCallsPreferenceFragmentTest.java +++ b/tests/robotests/src/com/android/settings/sound/VibrateForCallsPreferenceFragmentTest.java @@ -52,7 +52,7 @@ public class VibrateForCallsPreferenceFragmentTest { @Test public void getDefaultKey_applyRampingRinger_keyRampingRinger() { Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF); - Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, ON); + Settings.System.putInt(mContentResolver, Settings.System.APPLY_RAMPING_RINGER, ON); assertThat(mFragment.getDefaultKey()).isEqualTo( VibrateForCallsPreferenceFragment.KEY_RAMPING_RINGER); @@ -61,7 +61,7 @@ public class VibrateForCallsPreferenceFragmentTest { @Test public void getDefaultKey_enableVibrateWhenRinging_keyAlwaysVibrate() { Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, ON); - Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF); + Settings.System.putInt(mContentResolver, Settings.System.APPLY_RAMPING_RINGER, OFF); assertThat(mFragment.getDefaultKey()).isEqualTo( VibrateForCallsPreferenceFragment.KEY_ALWAYS_VIBRATE); @@ -70,7 +70,7 @@ public class VibrateForCallsPreferenceFragmentTest { @Test public void getDefaultKey_notApplyRampingRingerDisableVibrateWhenRinging_keyNeverVibrate() { Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF); - Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF); + Settings.System.putInt(mContentResolver, Settings.System.APPLY_RAMPING_RINGER, OFF); assertThat(mFragment.getDefaultKey()).isEqualTo( VibrateForCallsPreferenceFragment.KEY_NEVER_VIBRATE); @@ -80,8 +80,8 @@ public class VibrateForCallsPreferenceFragmentTest { public void setDefaultKey_keyRampingRinger_applyRampingRingerDisableVibrateWhenRinging() { mFragment.setDefaultKey(VibrateForCallsPreferenceFragment.KEY_RAMPING_RINGER); - assertThat(Settings.Global.getInt( - mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF)).isEqualTo(ON); + assertThat(Settings.System.getInt( + mContentResolver, Settings.System.APPLY_RAMPING_RINGER, OFF)).isEqualTo(ON); assertThat(Settings.System.getInt( mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF)).isEqualTo(OFF); } @@ -90,8 +90,8 @@ public class VibrateForCallsPreferenceFragmentTest { public void setDefaultKey_keyAlwaysVibrate_notApplyRampingRingerEnableVibrateWhenRinging() { mFragment.setDefaultKey(VibrateForCallsPreferenceFragment.KEY_ALWAYS_VIBRATE); - assertThat(Settings.Global.getInt( - mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF)).isEqualTo(OFF); + assertThat(Settings.System.getInt( + mContentResolver, Settings.System.APPLY_RAMPING_RINGER, OFF)).isEqualTo(OFF); assertThat(Settings.System.getInt( mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF)).isEqualTo(ON); } @@ -100,8 +100,8 @@ public class VibrateForCallsPreferenceFragmentTest { public void setDefaultKey_keyNeverVibrate_notApplyRampingRingerDisableVibrateWhenRinging() { mFragment.setDefaultKey(VibrateForCallsPreferenceFragment.KEY_NEVER_VIBRATE); - assertThat(Settings.Global.getInt( - mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF)).isEqualTo(OFF); + assertThat(Settings.System.getInt( + mContentResolver, Settings.System.APPLY_RAMPING_RINGER, OFF)).isEqualTo(OFF); assertThat(Settings.System.getInt( mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF)).isEqualTo(OFF); } From 144f295d7aa66bae8556ba030553a49615eab0b2 Mon Sep 17 00:00:00 2001 From: Bonian Chen Date: Thu, 18 Nov 2021 10:27:34 +0800 Subject: [PATCH 4/4] [Settings] Move display of VPN version into summary text Move the display of version text within VPN into summary part of the display, and limit the height of summary area. Bug: 205460459 Test: local Change-Id: I666b9db356feeebf04e3be688897c2d9110a5275 --- res/values/strings.xml | 2 +- res/values/styles.xml | 10 ++++ res/xml/vpn_app_management.xml | 14 ++++- .../settings/vpn2/AppManagementFragment.java | 51 +++++++++++++++++-- 4 files changed, 71 insertions(+), 6 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 0b7a3d5fccb..6b264d51dd1 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -7462,7 +7462,7 @@ Disconnect - Version %s + Version Forget VPN diff --git a/res/values/styles.xml b/res/values/styles.xml index eaebd85b952..8402dec73ca 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -237,6 +237,16 @@ @android:style/TextAppearance.DeviceDefault.Small + + + +