Hearing aid constants defined differently across different hearing aid related profiles. For hearing aid device mode, HearingAidProfile and HapClientProfile have different values for mode definition and there is also a new BANDED hearing aid type in HapClientProfile spec. For hearing aid device side, HearingAidProfile has only 2 kinds of side which is left and right whereas BLE hearing aid can retrieve 27 different kinds of audio location. We therefore introduce a new class HearingAidInfo for mapping these different constants across these profiles into a single unified set of constants. Bug: 253192350 Test: make RunSettingsRoboTests ROBOTEST_FILTER=AccessibilityHearingAidPreferenceControllerTest Test: make RunSettingsRoboTests ROBOTEST_FILTER=HearingAidPairingDialogFragmentTest Test: make RunSettingsRoboTests ROBOTEST_FILTER=HearingAidUtilsTest Test: make RunSettingsRoboTests ROBOTEST_FILTER=BluetoothDetailsPairOtherControllerTest Test: make RunSettingsRoboTests ROBOTEST_FILTER=AvailableMediaDeviceGroupControllerTest Change-Id: Id14928dbc051fcf76fe0d66b43aefefb1b5f7baf
60 lines
2.3 KiB
Java
60 lines
2.3 KiB
Java
/*
|
|
* 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.accessibility;
|
|
|
|
import android.util.Log;
|
|
|
|
import androidx.annotation.NonNull;
|
|
import androidx.fragment.app.FragmentManager;
|
|
|
|
import com.android.settings.bluetooth.HearingAidPairingDialogFragment;
|
|
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
|
import com.android.settingslib.bluetooth.HearingAidInfo;
|
|
|
|
/** Provides utility methods related hearing aids. */
|
|
public final class HearingAidUtils {
|
|
private static final String TAG = "HearingAidUtils";
|
|
|
|
private HearingAidUtils(){}
|
|
|
|
/**
|
|
* Launches pairing dialog when hearing aid device needs other side of hearing aid device to
|
|
* work.
|
|
*
|
|
* @param fragmentManager The {@link FragmentManager} used to show dialog fragment
|
|
* @param device The {@link CachedBluetoothDevice} need to be hearing aid device
|
|
*/
|
|
public static void launchHearingAidPairingDialog(FragmentManager fragmentManager,
|
|
@NonNull CachedBluetoothDevice device) {
|
|
if (device.isConnectedAshaHearingAidDevice()
|
|
&& device.getDeviceMode() == HearingAidInfo.DeviceMode.MODE_BINAURAL
|
|
&& device.getSubDevice() == null) {
|
|
launchHearingAidPairingDialogInternal(fragmentManager, device);
|
|
}
|
|
}
|
|
|
|
private static void launchHearingAidPairingDialogInternal(FragmentManager fragmentManager,
|
|
@NonNull CachedBluetoothDevice device) {
|
|
if (device.getDeviceSide() == HearingAidInfo.DeviceSide.SIDE_INVALID) {
|
|
Log.w(TAG, "Can not launch hearing aid pairing dialog for invalid side");
|
|
return;
|
|
}
|
|
HearingAidPairingDialogFragment.newInstance(device.getAddress()).show(fragmentManager,
|
|
HearingAidPairingDialogFragment.TAG);
|
|
}
|
|
}
|