Move 'Audio Output' to Accessibility hearing device page
* Extract the common part into HearingAidHelper. * Remove abstract getHearingDevice(). Change to get the hearing device when needed. * Move several classes from Bluetooth into Accessibility Bug: 281783079 Test: make RunSettingsRoboTests ROBOTEST_FILTER="(HearingDeviceAudioRoutingBasePreferenceControllerTest|AccessibilityHearingAidPreferenceControllerTest|HearingAidHelperTest|HearingAidAudioRoutingPreferenceControllerTest|HearingDeviceCallRoutingPreferenceControllerTest)" Change-Id: I79049107409b7086c6dcc8d48a6323e171ed1535
This commit is contained in:
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
* 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.bluetooth;
|
||||
|
||||
import static com.android.settings.bluetooth.BluetoothDeviceDetailsFragment.KEY_DEVICE_ADDRESS;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.FeatureFlagUtils;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
|
||||
/**
|
||||
* The controller of the audio routing in the bluetooth detail settings.
|
||||
*/
|
||||
public class BluetoothDetailsAudioRoutingController extends BluetoothDetailsController {
|
||||
|
||||
private static final String KEY_DEVICE_CONTROLS_SPECIFIC_GROUP = "device_controls_specific";
|
||||
@VisibleForTesting
|
||||
static final String KEY_AUDIO_ROUTING = "audio_routing";
|
||||
|
||||
public BluetoothDetailsAudioRoutingController(Context context,
|
||||
PreferenceFragmentCompat fragment, CachedBluetoothDevice device, Lifecycle lifecycle) {
|
||||
super(context, fragment, device, lifecycle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return mCachedDevice.isHearingAidDevice() && FeatureFlagUtils.isEnabled(mContext,
|
||||
FeatureFlagUtils.SETTINGS_AUDIO_ROUTING);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init(PreferenceScreen screen) {
|
||||
if (!mCachedDevice.isHearingAidDevice()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final PreferenceCategory prefCategory = screen.findPreference(getPreferenceKey());
|
||||
final Preference pref = createAudioRoutingPreference(prefCategory.getContext());
|
||||
prefCategory.addPreference(pref);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void refresh() {}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return KEY_DEVICE_CONTROLS_SPECIFIC_GROUP;
|
||||
}
|
||||
|
||||
private Preference createAudioRoutingPreference(Context context) {
|
||||
final Preference preference = new Preference(context);
|
||||
|
||||
preference.setKey(KEY_AUDIO_ROUTING);
|
||||
preference.setTitle(context.getString(R.string.bluetooth_audio_routing_title));
|
||||
preference.setSummary(context.getString(R.string.bluetooth_audio_routing_summary));
|
||||
final Bundle extras = preference.getExtras();
|
||||
extras.putString(KEY_DEVICE_ADDRESS, mCachedDevice.getAddress());
|
||||
preference.setFragment(BluetoothDetailsAudioRoutingFragment.class.getName());
|
||||
|
||||
return preference;
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2023 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.bluetooth;
|
||||
|
||||
import static android.os.UserManager.DISALLOW_CONFIG_BLUETOOTH;
|
||||
|
||||
import static com.android.settings.bluetooth.BluetoothDeviceDetailsFragment.KEY_DEVICE_ADDRESS;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.RestrictedDashboardFragment;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||
|
||||
/** Settings fragment containing bluetooth audio routing. */
|
||||
public class BluetoothDetailsAudioRoutingFragment extends RestrictedDashboardFragment {
|
||||
|
||||
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider(R.xml.bluetooth_audio_routing_fragment);
|
||||
private static final String TAG = "BluetoothDetailsAudioRoutingFragment";
|
||||
@VisibleForTesting
|
||||
CachedBluetoothDevice mCachedDevice;
|
||||
|
||||
public BluetoothDetailsAudioRoutingFragment() {
|
||||
super(DISALLOW_CONFIG_BLUETOOTH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
final LocalBluetoothManager localBtMgr = Utils.getLocalBtManager(context);
|
||||
final CachedBluetoothDeviceManager cachedDeviceMgr = localBtMgr.getCachedDeviceManager();
|
||||
final BluetoothDevice bluetoothDevice = localBtMgr.getBluetoothAdapter().getRemoteDevice(
|
||||
getArguments().getString(KEY_DEVICE_ADDRESS));
|
||||
|
||||
mCachedDevice = cachedDeviceMgr.findDevice(bluetoothDevice);
|
||||
if (mCachedDevice == null) {
|
||||
// Close this page if device is null with invalid device mac address
|
||||
Log.w(TAG, "onAttach() CachedDevice is null! Can not find address: "
|
||||
+ bluetoothDevice.getAnonymizedAddress());
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
use(HearingDeviceRingtoneRoutingPreferenceController.class).init(mCachedDevice);
|
||||
use(HearingDeviceCallRoutingPreferenceController.class).init(mCachedDevice);
|
||||
use(HearingDeviceMediaRoutingPreferenceController.class).init(mCachedDevice);
|
||||
use(HearingDeviceSystemSoundsRoutingPreferenceController.class).init(mCachedDevice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return SettingsEnums.BLUETOOTH_AUDIO_ROUTING;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.bluetooth_audio_routing_fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLogTag() {
|
||||
return TAG;
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
|
||||
/**
|
||||
* The controller of the hearing device controls in the bluetooth detail settings.
|
||||
* The controller of the hearing device settings to launch Hearing device page.
|
||||
*/
|
||||
public class BluetoothDetailsHearingDeviceControlsController extends BluetoothDetailsController
|
||||
implements Preference.OnPreferenceClickListener {
|
||||
@@ -87,6 +87,7 @@ public class BluetoothDetailsHearingDeviceControlsController extends BluetoothDe
|
||||
final Preference preference = new Preference(context);
|
||||
preference.setKey(KEY_HEARING_DEVICE_CONTROLS);
|
||||
preference.setTitle(context.getString(R.string.bluetooth_device_controls_title));
|
||||
preference.setSummary(context.getString(R.string.bluetooth_device_controls_summary));
|
||||
preference.setOnPreferenceClickListener(this);
|
||||
|
||||
return preference;
|
||||
|
||||
@@ -314,8 +314,6 @@ public class BluetoothDeviceDetailsFragment extends RestrictedDashboardFragment
|
||||
lifecycle));
|
||||
controllers.add(new BluetoothDetailsHearingDeviceControlsController(context, this,
|
||||
mCachedDevice, lifecycle));
|
||||
controllers.add(new BluetoothDetailsAudioRoutingController(context, this, mCachedDevice,
|
||||
lifecycle));
|
||||
}
|
||||
return controllers;
|
||||
}
|
||||
|
||||
@@ -1,146 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2023 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.bluetooth;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.media.AudioAttributes;
|
||||
import android.media.AudioDeviceAttributes;
|
||||
import android.media.audiopolicy.AudioProductStrategy;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||
import com.android.settingslib.bluetooth.HearingAidAudioRoutingConstants;
|
||||
import com.android.settingslib.bluetooth.HearingAidAudioRoutingHelper;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.primitives.Ints;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Abstract class for providing audio routing {@link ListPreference} common control for hearing
|
||||
* device specifically.
|
||||
*/
|
||||
public abstract class HearingDeviceAudioRoutingBasePreferenceController extends
|
||||
BasePreferenceController implements Preference.OnPreferenceChangeListener {
|
||||
|
||||
private static final String TAG = "HARoutingBasePreferenceController";
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
private final HearingAidAudioRoutingHelper mHelper;
|
||||
|
||||
public HearingDeviceAudioRoutingBasePreferenceController(Context context,
|
||||
String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
mHelper = new HearingAidAudioRoutingHelper(context);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public HearingDeviceAudioRoutingBasePreferenceController(Context context,
|
||||
String preferenceKey, HearingAidAudioRoutingHelper helper) {
|
||||
super(context, preferenceKey);
|
||||
mHelper = helper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
super.updateState(preference);
|
||||
|
||||
final ListPreference listPreference = (ListPreference) preference;
|
||||
final int routingValue = restoreRoutingValue(mContext);
|
||||
listPreference.setValue(String.valueOf(routingValue));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
final Integer routingValue = Ints.tryParse((String) newValue);
|
||||
|
||||
saveRoutingValue(mContext, routingValue);
|
||||
trySetAudioRoutingConfig(getSupportedAttributeList(), getHearingDevice(), routingValue);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void trySetAudioRoutingConfig(int[] audioAttributes,
|
||||
CachedBluetoothDevice hearingDevice,
|
||||
@HearingAidAudioRoutingConstants.RoutingValue int routingValue) {
|
||||
final List<AudioProductStrategy> supportedStrategies = mHelper.getSupportedStrategies(
|
||||
audioAttributes);
|
||||
final AudioDeviceAttributes hearingDeviceAttributes =
|
||||
mHelper.getMatchedHearingDeviceAttributes(hearingDevice);
|
||||
if (hearingDeviceAttributes == null) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG,
|
||||
"Can not find expected AudioDeviceAttributes to config audio routing "
|
||||
+ "maybe device is offline: "
|
||||
+ hearingDevice.getDevice().getAnonymizedAddress());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean status = mHelper.setPreferredDeviceRoutingStrategies(supportedStrategies,
|
||||
hearingDeviceAttributes, routingValue);
|
||||
|
||||
if (!status) {
|
||||
final List<String> strategiesName = supportedStrategies.stream()
|
||||
.map(AudioProductStrategy::getName)
|
||||
.collect(Collectors.toList());
|
||||
Log.w(TAG, "routingMode: " + strategiesName + " routingValue: " + routingValue
|
||||
+ " fail to configure AudioProductStrategy");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of usage values defined in {@link AudioAttributes} that are used to identify
|
||||
* {@link AudioProductStrategy} to configure audio routing.
|
||||
*/
|
||||
protected abstract int[] getSupportedAttributeList();
|
||||
|
||||
/**
|
||||
* Gets the {@link CachedBluetoothDevice} hearing device that is used to configure audio
|
||||
* routing.
|
||||
*/
|
||||
protected abstract CachedBluetoothDevice getHearingDevice();
|
||||
|
||||
/**
|
||||
* Saves the routing value.
|
||||
*
|
||||
* @param context the valid context used to get the {@link ContentResolver}
|
||||
* @param routingValue one of the value defined in
|
||||
* {@link HearingAidAudioRoutingConstants.RoutingValue}
|
||||
*/
|
||||
protected abstract void saveRoutingValue(Context context, int routingValue);
|
||||
|
||||
/**
|
||||
* Restores the routing value and used to reflect status on ListPreference.
|
||||
*
|
||||
* @param context the valid context used to get the {@link ContentResolver}
|
||||
* @return one of the value defined in {@link HearingAidAudioRoutingConstants.RoutingValue}
|
||||
*/
|
||||
protected abstract int restoreRoutingValue(Context context);
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2023 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.bluetooth;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||
import com.android.settingslib.bluetooth.HearingAidAudioRoutingConstants;
|
||||
|
||||
/**
|
||||
* The controller of the hearing device call routing list preference.
|
||||
*/
|
||||
public class HearingDeviceCallRoutingPreferenceController extends
|
||||
HearingDeviceAudioRoutingBasePreferenceController {
|
||||
|
||||
private CachedBluetoothDevice mHearingDevice;
|
||||
|
||||
public HearingDeviceCallRoutingPreferenceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes objects in this controller. Need to call this before using the controller.
|
||||
*
|
||||
* @param cachedBluetoothDevice the hearing device to configure audio routing
|
||||
*/
|
||||
public void init(CachedBluetoothDevice cachedBluetoothDevice) {
|
||||
mHearingDevice = cachedBluetoothDevice;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return Utils.isVoiceCapable(mContext) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int[] getSupportedAttributeList() {
|
||||
return HearingAidAudioRoutingConstants.CALL_ROUTING_ATTRIBUTES;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CachedBluetoothDevice getHearingDevice() {
|
||||
return mHearingDevice;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void saveRoutingValue(Context context, int routingValue) {
|
||||
Settings.Secure.putInt(context.getContentResolver(),
|
||||
Settings.Secure.HEARING_AID_CALL_ROUTING, routingValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int restoreRoutingValue(Context context) {
|
||||
return Settings.Secure.getInt(context.getContentResolver(),
|
||||
Settings.Secure.HEARING_AID_CALL_ROUTING,
|
||||
HearingAidAudioRoutingConstants.RoutingValue.AUTO);
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2023 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.bluetooth;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||
import com.android.settingslib.bluetooth.HearingAidAudioRoutingConstants;
|
||||
|
||||
/**
|
||||
* The controller of the hearing device media routing list preference.
|
||||
*/
|
||||
public class HearingDeviceMediaRoutingPreferenceController extends
|
||||
HearingDeviceAudioRoutingBasePreferenceController {
|
||||
|
||||
private CachedBluetoothDevice mHearingDevice;
|
||||
|
||||
public HearingDeviceMediaRoutingPreferenceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes objects in this controller. Need to call this before using the controller.
|
||||
*
|
||||
* @param cachedBluetoothDevice the hearing device to configure audio routing
|
||||
*/
|
||||
public void init(CachedBluetoothDevice cachedBluetoothDevice) {
|
||||
mHearingDevice = cachedBluetoothDevice;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int[] getSupportedAttributeList() {
|
||||
return HearingAidAudioRoutingConstants.MEDIA_ROUTING_ATTRIBUTES;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CachedBluetoothDevice getHearingDevice() {
|
||||
return mHearingDevice;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void saveRoutingValue(Context context, int routingValue) {
|
||||
Settings.Secure.putInt(context.getContentResolver(),
|
||||
Settings.Secure.HEARING_AID_MEDIA_ROUTING, routingValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int restoreRoutingValue(Context context) {
|
||||
return Settings.Secure.getInt(context.getContentResolver(),
|
||||
Settings.Secure.HEARING_AID_MEDIA_ROUTING,
|
||||
HearingAidAudioRoutingConstants.RoutingValue.AUTO);
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2023 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.bluetooth;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||
import com.android.settingslib.bluetooth.HearingAidAudioRoutingConstants;
|
||||
|
||||
/**
|
||||
* The controller of the hearing device ringtone routing list preference.
|
||||
*/
|
||||
public class HearingDeviceRingtoneRoutingPreferenceController extends
|
||||
HearingDeviceAudioRoutingBasePreferenceController {
|
||||
|
||||
private CachedBluetoothDevice mHearingDevice;
|
||||
|
||||
public HearingDeviceRingtoneRoutingPreferenceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes objects in this controller. Need to call this before using the controller.
|
||||
*
|
||||
* @param cachedBluetoothDevice the hearing device to configure audio routing
|
||||
*/
|
||||
public void init(CachedBluetoothDevice cachedBluetoothDevice) {
|
||||
mHearingDevice = cachedBluetoothDevice;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int[] getSupportedAttributeList() {
|
||||
return HearingAidAudioRoutingConstants.RINGTONE_ROUTING_ATTRIBUTE;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CachedBluetoothDevice getHearingDevice() {
|
||||
return mHearingDevice;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void saveRoutingValue(Context context, int routingValue) {
|
||||
Settings.Secure.putInt(context.getContentResolver(),
|
||||
Settings.Secure.HEARING_AID_RINGTONE_ROUTING, routingValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int restoreRoutingValue(Context context) {
|
||||
return Settings.Secure.getInt(context.getContentResolver(),
|
||||
Settings.Secure.HEARING_AID_RINGTONE_ROUTING,
|
||||
HearingAidAudioRoutingConstants.RoutingValue.AUTO);
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2023 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.bluetooth;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||
import com.android.settingslib.bluetooth.HearingAidAudioRoutingConstants;
|
||||
|
||||
/**
|
||||
* The controller of the hearing device system sounds routing list preference.
|
||||
*/
|
||||
public class HearingDeviceSystemSoundsRoutingPreferenceController extends
|
||||
HearingDeviceAudioRoutingBasePreferenceController {
|
||||
|
||||
private CachedBluetoothDevice mHearingDevice;
|
||||
|
||||
public HearingDeviceSystemSoundsRoutingPreferenceController(Context context,
|
||||
String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes objects in this controller. Need to call this before using the controller.
|
||||
*
|
||||
* @param cachedBluetoothDevice the hearing device to configure audio routing
|
||||
*/
|
||||
public void init(CachedBluetoothDevice cachedBluetoothDevice) {
|
||||
mHearingDevice = cachedBluetoothDevice;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int[] getSupportedAttributeList() {
|
||||
return HearingAidAudioRoutingConstants.SYSTEM_SOUNDS_ROUTING_ATTRIBUTES;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CachedBluetoothDevice getHearingDevice() {
|
||||
return mHearingDevice;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void saveRoutingValue(Context context, int routingValue) {
|
||||
Settings.Secure.putInt(context.getContentResolver(),
|
||||
Settings.Secure.HEARING_AID_SYSTEM_SOUNDS_ROUTING, routingValue);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int restoreRoutingValue(Context context) {
|
||||
return Settings.Secure.getInt(context.getContentResolver(),
|
||||
Settings.Secure.HEARING_AID_SYSTEM_SOUNDS_ROUTING,
|
||||
HearingAidAudioRoutingConstants.RoutingValue.AUTO);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user