Snap for 8332931 from 372d74ba71 to tm-release
Change-Id: I0f83c580aaeb5be186340d7233b685b4083f44f0
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
<androidx.slice.widget.SliceView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/slice_view"
|
||||
style="@style/Widget.SliceView.Bluetooth"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="12dp"
|
||||
|
||||
@@ -5293,9 +5293,19 @@
|
||||
<!-- Message for the mail content of the accessibility text reading preview. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_text_reading_preview_mail_from">From: Bill</string>
|
||||
<!-- Content for the mail content of the accessibility text reading preview. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_text_reading_preview_mail_content">Good morning!\n\nI just wanted to check how the designs are coming. Will they be ready before we start building the new balloons?</string>
|
||||
<!-- Title for the reset button of the accessibility text reading page to reset all preferences state. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_text_reading_reset_button_title">Reset</string>
|
||||
<string name="accessibility_text_reading_preview_mail_content">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?</string>
|
||||
<!-- Title for the reset button of the accessibility text reading page to reset all preferences state. [CHAR LIMIT=25] -->
|
||||
<string name="accessibility_text_reading_reset_button_title">Reset settings</string>
|
||||
<!-- Title for the confirm dialog of reset settings. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_text_reading_confirm_dialog_title">Reset display size and text?</string>
|
||||
<!-- Message for the confirm dialog of reset settings. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_text_reading_confirm_dialog_message">Your display size and text preferences will reset to the phone\u2019s original settings</string>
|
||||
<!-- Title for the reset button of the confirm dialog of reset settings. [CHAR LIMIT=25] -->
|
||||
<string name="accessibility_text_reading_confirm_dialog_reset_button">Reset</string>
|
||||
<!-- Conversation message for the messaging app preview screen. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_text_reading_conversation_message_1">Any weekend plans?</string>
|
||||
<!-- Conversation message for the messaging app preview screen. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_text_reading_conversation_message_2">Heading to the beach. Want to join?</string>
|
||||
<!-- Title for the footer text to explain what option accessibility service does. [CHAR LIMIT=35] -->
|
||||
<string name="accessibility_screen_option">Options</string>
|
||||
<!-- Summary for the accessibility preference to enable screen magnification. [CHAR LIMIT=25] -->
|
||||
@@ -8584,6 +8594,24 @@
|
||||
<!-- Setting summary for controlling how caption text display in real time [CHAR LIMIT=NONE]-->
|
||||
<string name="live_caption_summary">Automatically caption media</string>
|
||||
|
||||
<!-- Output device type for the phone speaker that is available for spatializer effect. [CHAR LIMIT=NONE]-->
|
||||
<string name="spatial_audio_speaker">Phone speaker</string>
|
||||
|
||||
<!-- Output device type for the wired headphones that is available for spatializer effect. [CHAR LIMIT=NONE]-->
|
||||
<string name="spatial_audio_wired_headphones">Wired headphones</string>
|
||||
|
||||
<!-- Sound: Summary for the spatializer effect. [CHAR LIMIT=NONE]-->
|
||||
<string name="spatial_audio_text">Spatial Audio creates immersive sound that seems like it’s coming from all around you. Only works with some media.</string>
|
||||
|
||||
<!-- Sound: Summary for the Spatial audio setting when it is off. [CHAR LIMIT=NONE]-->
|
||||
<string name="spatial_summary_off">Off</string>
|
||||
|
||||
<!-- Sound: Summary for the Spatial audio setting when it is on with one output device enabled. [CHAR LIMIT=NONE]-->
|
||||
<string name="spatial_summary_on_one">On / <xliff:g id="output device" example="Phone speaker">%1$s</xliff:g></string>
|
||||
|
||||
<!-- Sound: Summary for the Spatial audio setting when it is on with two output devices enabled. [CHAR LIMIT=NONE]-->
|
||||
<string name="spatial_summary_on_two">On / <xliff:g id="output device" example="Phone speaker">%1$s</xliff:g> and <xliff:g id="output device" example="Wired headphones">%2$s</xliff:g></string>
|
||||
|
||||
<!-- Sound: Summary for the Do not Disturb option that describes how many automatic rules (schedules) are enabled [CHAR LIMIT=NONE]-->
|
||||
<string name="zen_mode_settings_schedules_summary">
|
||||
{count, plural,
|
||||
|
||||
@@ -524,6 +524,13 @@
|
||||
<item name="rowStyle">@style/SliceRow.Slider</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.SliceView.Bluetooth">
|
||||
<item name="titleSize">20dp</item>
|
||||
<item name="subtitleSize">14dp</item>
|
||||
<item name="headerTitleSize">20dp</item>
|
||||
<item name="headerSubtitleSize">14dp</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.SliceView.Panel.Slider.LargeIcon">
|
||||
<item name="rowStyle">@style/SliceRow.Slider.LargeIcon</item>
|
||||
</style>
|
||||
|
||||
@@ -45,8 +45,6 @@
|
||||
<com.android.settingslib.widget.FooterPreference
|
||||
android:order="100"
|
||||
android:key="battery_saver_footer_preference"
|
||||
android:selectable="true"
|
||||
android:title="@*android:string/battery_saver_description"
|
||||
settings:searchable="false"/>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
@@ -111,6 +111,15 @@
|
||||
settings:keywords="@string/sound_settings"/>
|
||||
|
||||
<!-- Live Caption -110 and Now Playing -105-->
|
||||
|
||||
<!-- Spatial audio -->
|
||||
<Preference
|
||||
android:key="spatial_audio_summary"
|
||||
android:title="@string/spatial_audio_title"
|
||||
android:fragment="com.android.settings.notification.SpatialAudioSettings"
|
||||
android:order="-107"
|
||||
settings:controller="com.android.settings.notification.SpatialAudioParentPreferenceController"/>
|
||||
|
||||
<Preference
|
||||
android:key="media_controls_summary"
|
||||
android:title="@string/media_controls_title"
|
||||
@@ -154,13 +163,6 @@
|
||||
android:ringtoneType="alarm"
|
||||
android:order="-60"/>
|
||||
|
||||
<!-- Spatial audio -->
|
||||
<SwitchPreference
|
||||
android:key="spatial_audio"
|
||||
android:title="@string/spatial_audio_title"
|
||||
android:order="-55"
|
||||
settings:controller="com.android.settings.notification.SpatialAudioPreferenceController"/>
|
||||
|
||||
<!-- Dial pad tones -->
|
||||
<SwitchPreference
|
||||
android:key="dial_pad_tones"
|
||||
|
||||
37
res/xml/spatial_audio_settings.xml
Normal file
37
res/xml/spatial_audio_settings.xml
Normal file
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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.
|
||||
-->
|
||||
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:title="@string/spatial_audio_title">
|
||||
|
||||
<com.android.settingslib.widget.TopIntroPreference
|
||||
android:key="spatial_audio_top_intro"
|
||||
android:title="@string/spatial_audio_text"
|
||||
settings:searchable="false"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="spatial_audio"
|
||||
android:title="@string/spatial_audio_speaker"
|
||||
settings:controller="com.android.settings.notification.SpatialAudioPreferenceController"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="spatial_audio_wired_headphones"
|
||||
android:title="@string/spatial_audio_wired_headphones"
|
||||
settings:controller="com.android.settings.notification.SpatialAudioWiredHeadphonesController"/>
|
||||
|
||||
</PreferenceScreen>
|
||||
@@ -138,7 +138,7 @@ public class ResetNetworkConfirm extends InstrumentedFragment {
|
||||
if (btManager != null) {
|
||||
BluetoothAdapter btAdapter = btManager.getAdapter();
|
||||
if (btAdapter != null) {
|
||||
btAdapter.factoryReset();
|
||||
btAdapter.clearBluetooth();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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<DeviceAdminListItem> mAdmins = new ArrayList<>();
|
||||
private final SparseArray<ComponentName> 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<UserHandle> 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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
7
src/com/android/settings/localepicker/OWNERS
Normal file
7
src/com/android/settings/localepicker/OWNERS
Normal file
@@ -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
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user