From 25c2e3124264275f60d7e204b54a6bd9d6ce0952 Mon Sep 17 00:00:00 2001 From: Alice Kuo Date: Fri, 11 Mar 2022 07:35:46 +0800 Subject: [PATCH 01/11] Add LE audio hardware offload development option Bug: 197296692 Bug: 215492586 Test: make RunSettingsRoboTests ROBOTEST_FILTER=BluetoothLeAudioHwOffloadPreferenceControllerTest Test: make RunSettingsRoboTests ROBOTEST_FILTER=BluetoothA2dpHwOffloadPreferenceControllerTest Change-Id: If1203c50d1d94ac9ed377293b5cb389b7b6f54a1 Merged-In: If1203c50d1d94ac9ed377293b5cb389b7b6f54a1 --- res/values/strings.xml | 18 +-- res/xml/development_settings.xml | 4 + ...oothA2dpHwOffloadPreferenceController.java | 27 +++- ...va => BluetoothHwOffloadRebootDialog.java} | 47 ++++--- ...hLeAudioHwOffloadPreferenceController.java | 127 ++++++++++++++++++ .../DevelopmentSettingsDashboardFragment.java | 36 ++++- .../DisableDevSettingsDialogFragment.java | 10 +- ...A2dpHwOffloadPreferenceControllerTest.java | 34 ++++- ...udioHwOffloadPreferenceControllerTest.java | 94 +++++++++++++ ...elopmentSettingsDashboardFragmentTest.java | 4 +- 10 files changed, 357 insertions(+), 44 deletions(-) rename src/com/android/settings/development/{BluetoothA2dpHwOffloadRebootDialog.java => BluetoothHwOffloadRebootDialog.java} (60%) create mode 100644 src/com/android/settings/development/BluetoothLeAudioHwOffloadPreferenceController.java create mode 100644 tests/robotests/src/com/android/settings/development/BluetoothLeAudioHwOffloadPreferenceControllerTest.java diff --git a/res/values/strings.xml b/res/values/strings.xml index 5042302d8aa..2303364b006 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -329,14 +329,16 @@ Disable Bluetooth A2DP hardware offload - - Restart Device? - - You need to restart your device to change this setting. - - Restart - - Cancel + + Disable Bluetooth LE AUDIO hardware offload + + Restart Device? + + You need to restart your device to change this setting. + + Restart + + Cancel Media devices diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml index 831c190a5f6..e33fc0957dc 100644 --- a/res/xml/development_settings.xml +++ b/res/xml/development_settings.xml @@ -317,6 +317,10 @@ android:key="bluetooth_disable_a2dp_hw_offload" android:title="@string/bluetooth_disable_a2dp_hw_offload" /> + + Date: Wed, 16 Mar 2022 16:14:11 +0100 Subject: [PATCH 02/11] API Review: factoryReset->clearBluetooth MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit > Consider renaming the factoryReset method to “clearBluetooth”. Bug: 222725037 Test: TH Tag; #refactor Change-Id: Id42a3344b6ae1a42d0128d2a055b9710f81c4b81 --- src/com/android/settings/ResetNetworkConfirm.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/android/settings/ResetNetworkConfirm.java b/src/com/android/settings/ResetNetworkConfirm.java index f79bdb2e360..eff487b9348 100644 --- a/src/com/android/settings/ResetNetworkConfirm.java +++ b/src/com/android/settings/ResetNetworkConfirm.java @@ -138,7 +138,7 @@ public class ResetNetworkConfirm extends InstrumentedFragment { if (btManager != null) { BluetoothAdapter btAdapter = btManager.getAdapter(); if (btAdapter != null) { - btAdapter.factoryReset(); + btAdapter.clearBluetooth(); } } From d00463834309cbb395d57e8b2d29b1a95fe8c3c9 Mon Sep 17 00:00:00 2001 From: Hugh Chen Date: Thu, 17 Mar 2022 06:59:12 +0000 Subject: [PATCH 03/11] Fix connected device detail page slice items are in smaller font size - Increase font size of slice items Bug: 223502042 Test: build pass Change-Id: I48ac0ff9734c467cc9c1cd0fa0e2b40ea02ecfa3 --- res/layout/slice_preference_layout.xml | 1 + res/values/styles.xml | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/res/layout/slice_preference_layout.xml b/res/layout/slice_preference_layout.xml index f78b1cfd46f..ff4e6137fd5 100644 --- a/res/layout/slice_preference_layout.xml +++ b/res/layout/slice_preference_layout.xml @@ -18,6 +18,7 @@ @style/SliceRow.Slider + + From 12f2a7df0adbdb5bca05f71faf832105f8348a02 Mon Sep 17 00:00:00 2001 From: menghanli Date: Fri, 18 Mar 2022 12:12:55 +0800 Subject: [PATCH 04/11] Migrate SuW new flag isMNStyle into Accessibility Bug: 223265372 Test: Manual testing Change-Id: I0b7f4fb02a35c5e0638ddac7b6b49c622c52fbc1 --- .../settings/accessibility/AccessibilitySetupWizardUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/android/settings/accessibility/AccessibilitySetupWizardUtils.java b/src/com/android/settings/accessibility/AccessibilitySetupWizardUtils.java index 95b689b73eb..c5302143182 100644 --- a/src/com/android/settings/accessibility/AccessibilitySetupWizardUtils.java +++ b/src/com/android/settings/accessibility/AccessibilitySetupWizardUtils.java @@ -47,7 +47,7 @@ class AccessibilitySetupWizardUtils { layout.setIcon(icon); layout.setDividerInsets(Integer.MAX_VALUE, 0); - if (ThemeHelper.shouldApplyExtendedPartnerConfig(context)) { + if (ThemeHelper.shouldApplyMaterialYouStyle(context)) { final LinearLayout headerLayout = layout.findManagedViewById(R.id.sud_layout_header); if (headerLayout != null) { headerLayout.setPadding(0, layout.getPaddingTop(), 0, From 17ef3359383d917c67034e15cb1d8ae376a1f898 Mon Sep 17 00:00:00 2001 From: Tsung-Mao Fang Date: Fri, 18 Mar 2022 19:00:46 +0800 Subject: [PATCH 05/11] Clean up footer preference on battery saver page. We set selectable as false in the footer preference library now, so developers don't need to customize it. Test: Same behavior on battery saver page. Bug: 216516546 Change-Id: I188054ef2b317e6df1f54dc89d5c57c644e20ad7 --- res/xml/battery_saver_settings.xml | 2 -- .../settings/fuelgauge/batterysaver/BatterySaverSettings.java | 1 - 2 files changed, 3 deletions(-) diff --git a/res/xml/battery_saver_settings.xml b/res/xml/battery_saver_settings.xml index 862bcd7fbdb..52b8b1acb93 100644 --- a/res/xml/battery_saver_settings.xml +++ b/res/xml/battery_saver_settings.xml @@ -45,8 +45,6 @@ - diff --git a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverSettings.java b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverSettings.java index 3943ac570b7..2ea99549480 100644 --- a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverSettings.java +++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverSettings.java @@ -83,7 +83,6 @@ public class BatterySaverSettings extends DashboardFragment { void addHelpLink() { FooterPreference pref = getPreferenceScreen().findPreference(KEY_FOOTER_PREFERENCE); if (pref != null) { - pref.setSelectable(false); pref.setLearnMoreAction(v -> { mMetricsFeatureProvider.action(getContext(), SettingsEnums.ACTION_APP_BATTERY_LEARN_MORE); From 50d9224a4cfd22719516069a3317425926350d8a Mon Sep 17 00:00:00 2001 From: Chaohui Wang Date: Fri, 18 Mar 2022 21:26:42 +0800 Subject: [PATCH 06/11] Fix flicker for Device admin apps. Security ->Advanced settings-> Device admin apps updateState() is called in DashboardFragment.onResume(), which after the view is visible to the user. Rendering the items in updateState() caused the flicker. Bug: 225283414 Test: On Pixel device Change-Id: I7175c966fbbfbf5d6331f5ac26c06b60d59a4e0d --- .../DeviceAdminListPreferenceController.java | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java index 25b3abdb153..dd160061939 100644 --- a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java +++ b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java @@ -37,7 +37,6 @@ import android.os.UserManager; import android.text.TextUtils; import android.util.ArrayMap; import android.util.Log; -import android.util.SparseArray; import androidx.annotation.VisibleForTesting; import androidx.preference.Preference; @@ -79,7 +78,6 @@ public class DeviceAdminListPreferenceController extends BasePreferenceControlle * user. */ private final ArrayList mAdmins = new ArrayList<>(); - private final SparseArray mProfileOwnerComponents = new SparseArray<>(); private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { @Override @@ -118,6 +116,8 @@ public class DeviceAdminListPreferenceController extends BasePreferenceControlle super.displayPreference(screen); mPreferenceGroup = screen.findPreference(getPreferenceKey()); mFooterPreference = mPreferenceGroup.findPreference(KEY_DEVICE_ADMIN_FOOTER); + + updateList(); } @Override @@ -127,19 +127,6 @@ public class DeviceAdminListPreferenceController extends BasePreferenceControlle null /* broadcastPermission */, null /* scheduler */); } - @Override - public void updateState(Preference preference) { - super.updateState(preference); - mProfileOwnerComponents.clear(); - final List profiles = mUm.getUserProfiles(); - final int profilesSize = profiles.size(); - for (int i = 0; i < profilesSize; ++i) { - final int profileId = profiles.get(i).getIdentifier(); - mProfileOwnerComponents.put(profileId, mDPM.getProfileOwnerAsUser(profileId)); - } - updateList(); - } - @Override public void onStop() { mContext.unregisterReceiver(mBroadcastReceiver); From 31f3dca871494b084e2a66ecdc67dd3d4bb008e2 Mon Sep 17 00:00:00 2001 From: Peter_Liang Date: Fri, 18 Mar 2022 12:02:42 +0800 Subject: [PATCH 07/11] Polish and humanize the strings for the confirm dialog of "Display size and text". Extra action: Add new strings. Bug: 219163254 Test: manual test Change-Id: Icaa8d4dd446872da665895b3343d8436717e22ed --- res/values/strings.xml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 950a7991766..8b80353e26b 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -5293,9 +5293,15 @@ From: Bill - Good morning!\n\nI just wanted to check how the designs are coming. Will they be ready before we start building the new balloons? - - Reset + Good morning! Following up on our last conversation, I\u2019d like to check in on the progress of your time machine development plan. Will you be able to have a prototype ready to demo at E3 this year? + + Reset settings + + Reset display size and text? + + Your display size and text preferences will reset to the phone\u2019s original settings + + Reset Options From d6b2b705ec400e1b4d174b0a51bb3e14af4965bd Mon Sep 17 00:00:00 2001 From: Peter_Liang Date: Fri, 18 Mar 2022 14:59:18 +0800 Subject: [PATCH 08/11] Polish and humanize the strings for the preview of the conversation message. New strings will replace the current strings of the conversation message. Bug: 219163254 Test: manual test Change-Id: I54d6563a04af2eb3e216d5b371d10a72c5d98c12 --- res/values/strings.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/res/values/strings.xml b/res/values/strings.xml index 8b80353e26b..d3f8499d5bd 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -5302,6 +5302,10 @@ Your display size and text preferences will reset to the phone\u2019s original settings Reset + + Any weekend plans? + + Heading to the beach. Want to join? Options From 616b0925acde7effc48508a26789bb4c08d68ce4 Mon Sep 17 00:00:00 2001 From: Alan Huang Date: Tue, 22 Feb 2022 08:44:47 +0000 Subject: [PATCH 09/11] DO NOT MERGE Add setting page for the Spatial audio The Spatial audio settings page control the state for the phone speaker and the wired headphones Test: make RunSettingsRoboTests Bug: 220811398 Change-Id: I49e3fab48186d09357a8481652bdccb4aa5d044a --- res/values/strings.xml | 18 ++++ res/xml/sound_settings.xml | 16 ++-- res/xml/spatial_audio_settings.xml | 37 ++++++++ ...patialAudioParentPreferenceController.java | 77 ++++++++++++++++ .../SpatialAudioPreferenceController.java | 29 +++--- .../notification/SpatialAudioSettings.java | 51 +++++++++++ ...SpatialAudioWiredHeadphonesController.java | 72 +++++++++++++++ ...alAudioParentPreferenceControllerTest.java | 77 ++++++++++++++++ .../SpatialAudioPreferenceControllerTest.java | 26 +++--- ...redHeadphonesPreferenceControllerTest.java | 89 +++++++++++++++++++ 10 files changed, 461 insertions(+), 31 deletions(-) create mode 100644 res/xml/spatial_audio_settings.xml create mode 100644 src/com/android/settings/notification/SpatialAudioParentPreferenceController.java create mode 100644 src/com/android/settings/notification/SpatialAudioSettings.java create mode 100644 src/com/android/settings/notification/SpatialAudioWiredHeadphonesController.java create mode 100644 tests/robotests/src/com/android/settings/notification/SpatialAudioParentPreferenceControllerTest.java create mode 100644 tests/robotests/src/com/android/settings/notification/SpatialAudioWiredHeadphonesPreferenceControllerTest.java diff --git a/res/values/strings.xml b/res/values/strings.xml index cd5f71aafae..eb6e0129049 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -8561,6 +8561,24 @@ Automatically caption media + + Phone speaker + + + Wired headphones + + + Spatial Audio creates immersive sound that seems like it’s coming from all around you. Only works with some media. + + + Off + + + On / %1$s + + + On / %1$s and %2$s + {count, plural, diff --git a/res/xml/sound_settings.xml b/res/xml/sound_settings.xml index d79594c19a9..f25b6ec54b0 100644 --- a/res/xml/sound_settings.xml +++ b/res/xml/sound_settings.xml @@ -111,6 +111,15 @@ settings:keywords="@string/sound_settings"/> + + + + - - - + + + + + + + + + + + diff --git a/src/com/android/settings/notification/SpatialAudioParentPreferenceController.java b/src/com/android/settings/notification/SpatialAudioParentPreferenceController.java new file mode 100644 index 00000000000..c9eaa65d76d --- /dev/null +++ b/src/com/android/settings/notification/SpatialAudioParentPreferenceController.java @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2022 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 android.content.Context; +import android.media.AudioManager; +import android.media.Spatializer; +import android.util.Log; + +import com.android.settings.R; +import com.android.settings.core.BasePreferenceController; + +/** + * Parent menu summary of the Spatial audio settings + */ +public class SpatialAudioParentPreferenceController extends BasePreferenceController { + private static final String TAG = "SpatialAudioSetting"; + private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); + + private final Spatializer mSpatializer; + private SpatialAudioPreferenceController mSpatialAudioPreferenceController; + private SpatialAudioWiredHeadphonesController mSpatialAudioWiredHeadphonesController; + + public SpatialAudioParentPreferenceController(Context context, String key) { + super(context, key); + AudioManager audioManager = context.getSystemService(AudioManager.class); + mSpatializer = audioManager.getSpatializer(); + mSpatialAudioPreferenceController = new SpatialAudioPreferenceController(context, "unused"); + mSpatialAudioWiredHeadphonesController = new SpatialAudioWiredHeadphonesController(context, + "unused"); + } + + @Override + public int getAvailabilityStatus() { + int level = mSpatializer.getImmersiveAudioLevel(); + if (DEBUG) { + Log.d(TAG, "spatialization level: " + level); + } + return level == Spatializer.SPATIALIZER_IMMERSIVE_LEVEL_NONE + ? UNSUPPORTED_ON_DEVICE : AVAILABLE; + } + + @Override + public CharSequence getSummary() { + boolean speakerOn = mSpatialAudioPreferenceController.isAvailable() + && mSpatialAudioWiredHeadphonesController.isChecked(); + boolean wiredHeadphonesOn = mSpatialAudioWiredHeadphonesController.isAvailable() + && mSpatialAudioWiredHeadphonesController.isChecked(); + if (speakerOn && wiredHeadphonesOn) { + return mContext.getString(R.string.spatial_summary_on_two, + mContext.getString(R.string.spatial_audio_speaker), + mContext.getString(R.string.spatial_audio_wired_headphones)); + } else if (speakerOn) { + return mContext.getString(R.string.spatial_summary_on_one, + mContext.getString(R.string.spatial_audio_speaker)); + } else if (wiredHeadphonesOn) { + return mContext.getString(R.string.spatial_summary_on_one, + mContext.getString(R.string.spatial_audio_wired_headphones)); + } else { + return mContext.getString(R.string.spatial_summary_off); + } + } +} diff --git a/src/com/android/settings/notification/SpatialAudioPreferenceController.java b/src/com/android/settings/notification/SpatialAudioPreferenceController.java index 7bca516f1c3..707340f0dd7 100644 --- a/src/com/android/settings/notification/SpatialAudioPreferenceController.java +++ b/src/com/android/settings/notification/SpatialAudioPreferenceController.java @@ -17,46 +17,55 @@ package com.android.settings.notification; import android.content.Context; +import android.media.AudioDeviceAttributes; +import android.media.AudioDeviceInfo; import android.media.AudioManager; import android.media.Spatializer; +import androidx.annotation.VisibleForTesting; + import com.android.settings.R; import com.android.settings.core.TogglePreferenceController; /** - * The controller of the Spatial audio setting in the SoundSettings. + * The controller of the Spatial audio setting for speaker in the SoundSettings. */ public class SpatialAudioPreferenceController extends TogglePreferenceController { - private static final String KEY_SPATIAL_AUDIO = "spatial_audio"; - private final Spatializer mSpatializer; + @VisibleForTesting + final AudioDeviceAttributes mSpeaker = new AudioDeviceAttributes( + AudioDeviceAttributes.ROLE_OUTPUT, AudioDeviceInfo.TYPE_BUILTIN_SPEAKER, "" + ); - public SpatialAudioPreferenceController(Context context) { - super(context, KEY_SPATIAL_AUDIO); + public SpatialAudioPreferenceController(Context context, String preferenceKey) { + super(context, preferenceKey); AudioManager audioManager = context.getSystemService(AudioManager.class); mSpatializer = audioManager.getSpatializer(); } @Override public int getAvailabilityStatus() { - return mSpatializer.getImmersiveAudioLevel() == Spatializer.SPATIALIZER_IMMERSIVE_LEVEL_NONE - ? UNSUPPORTED_ON_DEVICE : AVAILABLE; + return mSpatializer.isAvailableForDevice(mSpeaker) ? AVAILABLE : UNSUPPORTED_ON_DEVICE; } @Override public boolean isChecked() { - return mSpatializer.isEnabled(); + return mSpatializer.getCompatibleAudioDevices().contains(mSpeaker); } @Override public boolean setChecked(boolean isChecked) { - mSpatializer.setEnabled(isChecked); + if (isChecked) { + mSpatializer.addCompatibleAudioDevice(mSpeaker); + } else { + mSpatializer.removeCompatibleAudioDevice(mSpeaker); + } return isChecked == isChecked(); } @Override public int getSliceHighlightMenuRes() { - return R.string.menu_key_notifications; + return R.string.menu_key_sound; } } diff --git a/src/com/android/settings/notification/SpatialAudioSettings.java b/src/com/android/settings/notification/SpatialAudioSettings.java new file mode 100644 index 00000000000..001c6176dbc --- /dev/null +++ b/src/com/android/settings/notification/SpatialAudioSettings.java @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2022 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 android.app.settings.SettingsEnums; + +import com.android.settings.R; +import com.android.settings.dashboard.DashboardFragment; +import com.android.settings.search.BaseSearchIndexProvider; +import com.android.settingslib.search.SearchIndexable; + +/** + * Spatial audio settings located in the sound menu + */ +@SearchIndexable +public class SpatialAudioSettings extends DashboardFragment { + + private static final String TAG = "SpatialAudioSettings"; + + @Override + public int getMetricsCategory() { + return SettingsEnums.SETTINGS_SPATIAL_AUDIO; + } + + @Override + protected int getPreferenceScreenResId() { + return R.xml.spatial_audio_settings; + } + + @Override + protected String getLogTag() { + return TAG; + } + + public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = + new BaseSearchIndexProvider(R.xml.spatial_audio_settings); +} diff --git a/src/com/android/settings/notification/SpatialAudioWiredHeadphonesController.java b/src/com/android/settings/notification/SpatialAudioWiredHeadphonesController.java new file mode 100644 index 00000000000..9ff6a7f6f3f --- /dev/null +++ b/src/com/android/settings/notification/SpatialAudioWiredHeadphonesController.java @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2022 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 android.content.Context; +import android.media.AudioDeviceAttributes; +import android.media.AudioDeviceInfo; +import android.media.AudioManager; +import android.media.Spatializer; + +import androidx.annotation.VisibleForTesting; + +import com.android.settings.R; +import com.android.settings.core.TogglePreferenceController; + +/** + * The controller of the Spatial audio setting for wired headphones in the SoundSettings. + */ +public class SpatialAudioWiredHeadphonesController extends TogglePreferenceController { + + private final Spatializer mSpatializer; + @VisibleForTesting + final AudioDeviceAttributes mWiredHeadphones = new AudioDeviceAttributes( + AudioDeviceAttributes.ROLE_OUTPUT, AudioDeviceInfo.TYPE_WIRED_HEADPHONES, "" + ); + + public SpatialAudioWiredHeadphonesController(Context context, String preferenceKey) { + super(context, preferenceKey); + AudioManager audioManager = context.getSystemService(AudioManager.class); + mSpatializer = audioManager.getSpatializer(); + } + + @Override + public int getAvailabilityStatus() { + return mSpatializer.isAvailableForDevice(mWiredHeadphones) ? AVAILABLE + : UNSUPPORTED_ON_DEVICE; + } + + @Override + public boolean isChecked() { + return mSpatializer.getCompatibleAudioDevices().contains(mWiredHeadphones); + } + + @Override + public boolean setChecked(boolean isChecked) { + if (isChecked) { + mSpatializer.addCompatibleAudioDevice(mWiredHeadphones); + } else { + mSpatializer.removeCompatibleAudioDevice(mWiredHeadphones); + } + return isChecked == isChecked(); + } + + @Override + public int getSliceHighlightMenuRes() { + return R.string.menu_key_sound; + } +} diff --git a/tests/robotests/src/com/android/settings/notification/SpatialAudioParentPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/SpatialAudioParentPreferenceControllerTest.java new file mode 100644 index 00000000000..21fcea38276 --- /dev/null +++ b/tests/robotests/src/com/android/settings/notification/SpatialAudioParentPreferenceControllerTest.java @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2021 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.android.settings.core.BasePreferenceController.AVAILABLE; +import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE; + +import static com.google.common.truth.Truth.assertThat; + +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.when; + +import android.content.Context; +import android.media.AudioManager; +import android.media.Spatializer; + +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 SpatialAudioParentPreferenceControllerTest { + + private static final String KEY = "spatial_audio_summary"; + + @Mock + private Context mContext; + @Mock + private AudioManager mAudioManager; + @Mock + private Spatializer mSpatializer; + + private SpatialAudioParentPreferenceController mController; + + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + mContext = spy(RuntimeEnvironment.application); + when(mContext.getSystemService(AudioManager.class)).thenReturn(mAudioManager); + when(mAudioManager.getSpatializer()).thenReturn(mSpatializer); + mController = new SpatialAudioParentPreferenceController(mContext, KEY); + } + + @Test + public void getAvailabilityStatus_levelNone_shouldReturnUnsupported() { + when(mSpatializer.getImmersiveAudioLevel()).thenReturn( + Spatializer.SPATIALIZER_IMMERSIVE_LEVEL_NONE); + + assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE); + } + + @Test + public void getAvailabilityStatus_levelMultiChannel_shouldReturnAvailable() { + when(mSpatializer.getImmersiveAudioLevel()).thenReturn( + Spatializer.SPATIALIZER_IMMERSIVE_LEVEL_MULTICHANNEL); + + assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE); + } +} diff --git a/tests/robotests/src/com/android/settings/notification/SpatialAudioPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/SpatialAudioPreferenceControllerTest.java index 66d18ec8308..e88b75872f6 100644 --- a/tests/robotests/src/com/android/settings/notification/SpatialAudioPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/notification/SpatialAudioPreferenceControllerTest.java @@ -30,7 +30,6 @@ import android.media.AudioManager; import android.media.Spatializer; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Answers; @@ -39,7 +38,6 @@ import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; -@Ignore("b/200896161") @RunWith(RobolectricTestRunner.class) public class SpatialAudioPreferenceControllerTest { @@ -56,36 +54,36 @@ public class SpatialAudioPreferenceControllerTest { public void setUp() { MockitoAnnotations.initMocks(this); mContext = spy(RuntimeEnvironment.application); - when((Object) mContext.getSystemService(AudioManager.class)).thenReturn(mAudioManager); + when(mContext.getSystemService(AudioManager.class)).thenReturn(mAudioManager); when(mAudioManager.getSpatializer()).thenReturn(mSpatializer); - mController = new SpatialAudioPreferenceController(mContext); + mController = new SpatialAudioPreferenceController(mContext, "unused"); } @Test - public void getAvailabilityStatus_levelNone_shouldReturnUnsupported() { - when(mSpatializer.getImmersiveAudioLevel()).thenReturn( - Spatializer.SPATIALIZER_IMMERSIVE_LEVEL_NONE); + public void getAvailabilityStatus_unavailable_shouldReturnUnavailable() { + when(mSpatializer.isAvailableForDevice(mController.mSpeaker)).thenReturn(false); + assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE); } @Test - public void getAvailabilityStatus_levelMultiChannel_shouldReturnAvailable() { - when(mSpatializer.getImmersiveAudioLevel()).thenReturn( - Spatializer.SPATIALIZER_IMMERSIVE_LEVEL_MULTICHANNEL); + public void getAvailabilityStatus_available_shouldReturnAvailable() { + when(mSpatializer.isAvailableForDevice(mController.mSpeaker)).thenReturn(true); + assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE); } @Test - public void setChecked_withTrue_shouldEnableSpatializer() { + public void setChecked_withTrue_enablesDeviceSpatializer() { mController.setChecked(true); - verify(mSpatializer).setEnabled(true); + verify(mSpatializer).addCompatibleAudioDevice(mController.mSpeaker); } @Test - public void setChecked_withFalse_shouldDisableSpatializer() { + public void setChecked_withFalse_disablesDeviceSpatializer() { mController.setChecked(false); - verify(mSpatializer).setEnabled(false); + verify(mSpatializer).removeCompatibleAudioDevice(mController.mSpeaker); } } diff --git a/tests/robotests/src/com/android/settings/notification/SpatialAudioWiredHeadphonesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/SpatialAudioWiredHeadphonesPreferenceControllerTest.java new file mode 100644 index 00000000000..14d70cab815 --- /dev/null +++ b/tests/robotests/src/com/android/settings/notification/SpatialAudioWiredHeadphonesPreferenceControllerTest.java @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2021 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.android.settings.core.BasePreferenceController.AVAILABLE; +import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE; + +import static com.google.common.truth.Truth.assertThat; + +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import android.content.Context; +import android.media.AudioManager; +import android.media.Spatializer; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Answers; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.robolectric.RobolectricTestRunner; +import org.robolectric.RuntimeEnvironment; + +@RunWith(RobolectricTestRunner.class) +public class SpatialAudioWiredHeadphonesPreferenceControllerTest { + + @Mock(answer = Answers.RETURNS_DEEP_STUBS) + private Context mContext; + @Mock + private AudioManager mAudioManager; + @Mock + private Spatializer mSpatializer; + + private SpatialAudioWiredHeadphonesController mController; + + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + mContext = spy(RuntimeEnvironment.application); + when(mContext.getSystemService(AudioManager.class)).thenReturn(mAudioManager); + when(mAudioManager.getSpatializer()).thenReturn(mSpatializer); + mController = new SpatialAudioWiredHeadphonesController(mContext, "unused"); + } + + @Test + public void getAvailabilityStatus_unavailable_shouldReturnUnavailable() { + when(mSpatializer.isAvailableForDevice(mController.mWiredHeadphones)).thenReturn(false); + + assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE); + } + + @Test + public void getAvailabilityStatus_available_shouldReturnAvailable() { + when(mSpatializer.isAvailableForDevice(mController.mWiredHeadphones)).thenReturn(true); + + assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE); + } + + @Test + public void setChecked_withTrue_enablesDeviceSpatializer() { + mController.setChecked(true); + + verify(mSpatializer).addCompatibleAudioDevice(mController.mWiredHeadphones); + } + + @Test + public void setChecked_withFalse_disablesDeviceSpatializer() { + mController.setChecked(false); + + verify(mSpatializer).removeCompatibleAudioDevice(mController.mWiredHeadphones); + } +} From fa18f4de06bbdeedf759c20d5adcb8fff667f4fa Mon Sep 17 00:00:00 2001 From: Bonian Chen Date: Mon, 21 Mar 2022 01:05:23 +0000 Subject: [PATCH 10/11] Revert "[Settings] Resolves unsynced infomation between status bar and settings" This reverts commit 4f3ac2fcbd733fcf96633ac610e403259c94666b. Reason for revert: Should be fixed by ag/15270340, and removing this one helps to avoid UI from shifting when user click on buttons within "Internet" settings UI (b/222805255). Change-Id: I149f4beab329a6ba69434c6d923e1d6bc054b27d --- .../network/SubscriptionsPreferenceController.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/com/android/settings/network/SubscriptionsPreferenceController.java b/src/com/android/settings/network/SubscriptionsPreferenceController.java index 87c46974fb9..218e3ecb4ba 100644 --- a/src/com/android/settings/network/SubscriptionsPreferenceController.java +++ b/src/com/android/settings/network/SubscriptionsPreferenceController.java @@ -41,7 +41,6 @@ import android.telephony.TelephonyDisplayInfo; import android.telephony.TelephonyManager; import android.text.Html; import android.util.ArraySet; -import android.util.Log; import androidx.annotation.VisibleForTesting; import androidx.collection.ArrayMap; @@ -194,7 +193,6 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl mSignalStrengthListener.pause(); mTelephonyDisplayInfoListener.pause(); unRegisterReceiver(); - resetProviderPreferenceSummary(); } @Override @@ -276,7 +274,6 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl String result = mSubsPrefCtrlInjector.getNetworkType( mContext, mConfig, mTelephonyDisplayInfo, subId, isCarrierNetworkActive); if (mSubsPrefCtrlInjector.isActiveCellularNetwork(mContext) || isCarrierNetworkActive) { - Log.i(TAG, "Active cellular network or active carrier network."); result = mContext.getString(R.string.preference_summary_default_combination, mContext.getString(R.string.mobile_data_connection_active), result); } else if (!isDataInService) { @@ -327,13 +324,6 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl return icon; } - private void resetProviderPreferenceSummary() { - if (mSubsGearPref == null) { - return; - } - mSubsGearPref.setSummary(""); - } - @VisibleForTesting boolean shouldInflateSignalStrength(int subId) { return SignalStrengthUtil.shouldInflateSignalStrength(mContext, subId); From 1fd5f8ff5c127c1db8bf9215eb9abbf1bebae885 Mon Sep 17 00:00:00 2001 From: Calvin Pan Date: Mon, 21 Mar 2022 05:40:58 +0000 Subject: [PATCH 11/11] Add i18n team to localepicker OWNER Change-Id: I5769d5040958b62d9f29f3a802bf06e10a40ea1d --- src/com/android/settings/localepicker/OWNERS | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/com/android/settings/localepicker/OWNERS diff --git a/src/com/android/settings/localepicker/OWNERS b/src/com/android/settings/localepicker/OWNERS new file mode 100644 index 00000000000..12ab32f90da --- /dev/null +++ b/src/com/android/settings/localepicker/OWNERS @@ -0,0 +1,7 @@ +allenwtsu@google.com +calvinpan@google.com +danielwbhuang@google.com +goldmanj@google.com +jamescflin@google.com +joshhou@google.com +tomhsu@google.com \ No newline at end of file