• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.settingslib.bluetooth;
18 
19 import android.media.AudioAttributes;
20 import android.media.AudioDeviceAttributes;
21 import android.media.AudioDeviceInfo;
22 import android.media.MediaRecorder;
23 
24 import androidx.annotation.IntDef;
25 
26 import java.lang.annotation.Retention;
27 import java.lang.annotation.RetentionPolicy;
28 
29 /**
30  * Constant values used to configure hearing aid audio routing.
31  *
32  * {@link HearingAidAudioRoutingHelper}
33  */
34 public final class HearingAidAudioRoutingConstants {
35     public static final int[] CALL_ROUTING_ATTRIBUTES = new int[] {
36             // Stands for STRATEGY_PHONE
37             AudioAttributes.USAGE_VOICE_COMMUNICATION,
38     };
39 
40     public static final int[] MEDIA_ROUTING_ATTRIBUTES = new int[] {
41             // Stands for STRATEGY_MEDIA, including USAGE_GAME, USAGE_ASSISTANT,
42             // USAGE_ASSISTANCE_NAVIGATION_GUIDANCE, USAGE_ASSISTANCE_SONIFICATION
43             AudioAttributes.USAGE_MEDIA,
44             // Stands for STRATEGY_ACCESSIBILITY
45             AudioAttributes.USAGE_ASSISTANCE_ACCESSIBILITY,
46             // Stands for STRATEGY_DTMF
47             AudioAttributes.USAGE_VOICE_COMMUNICATION_SIGNALLING,
48     };
49 
50     public static final int[] RINGTONE_ROUTING_ATTRIBUTES = new int[] {
51             // Stands for STRATEGY_SONIFICATION, including USAGE_ALARM
52             AudioAttributes.USAGE_NOTIFICATION_RINGTONE
53     };
54 
55     public static final int[] NOTIFICATION_ROUTING_ATTRIBUTES = new int[] {
56             // Stands for STRATEGY_SONIFICATION_RESPECTFUL, including USAGE_NOTIFICATION_EVENT
57             AudioAttributes.USAGE_NOTIFICATION,
58 
59     };
60 
61     @Retention(RetentionPolicy.SOURCE)
62     @IntDef({
63             RoutingValue.AUTO,
64             RoutingValue.HEARING_DEVICE,
65             RoutingValue.BUILTIN_DEVICE,
66     })
67 
68     public @interface RoutingValue {
69         int AUTO = 0;
70         int HEARING_DEVICE = 1;
71         int BUILTIN_DEVICE = 2;
72     }
73 
74     public static final AudioDeviceAttributes BUILTIN_SPEAKER = new AudioDeviceAttributes(
75             AudioDeviceAttributes.ROLE_OUTPUT, AudioDeviceInfo.TYPE_BUILTIN_SPEAKER, "");
76     public static final AudioDeviceAttributes BUILTIN_MIC = new AudioDeviceAttributes(
77             AudioDeviceAttributes.ROLE_INPUT, AudioDeviceInfo.TYPE_BUILTIN_MIC, "");
78 
79     public static final int MICROPHONE_SOURCE_VOICE_COMMUNICATION =
80             MediaRecorder.AudioSource.VOICE_COMMUNICATION;
81 }
82