1 package com.android.server.telecom;
2 
3 import android.bluetooth.BluetoothDevice;
4 import android.os.Handler;
5 import android.telecom.CallAudioState;
6 import android.util.SparseArray;
7 
8 import com.android.internal.util.IndentingPrintWriter;
9 
10 public interface CallAudioRouteAdapter {
11     /** Valid values for msg.what */
12     int CONNECT_WIRED_HEADSET = 1;
13     int DISCONNECT_WIRED_HEADSET = 2;
14     int CONNECT_DOCK = 5;
15     int DISCONNECT_DOCK = 6;
16     int BLUETOOTH_DEVICE_LIST_CHANGED = 7;
17     int BT_ACTIVE_DEVICE_PRESENT = 8;
18     int BT_ACTIVE_DEVICE_GONE = 9;
19     int BT_DEVICE_ADDED = 10;
20     int BT_DEVICE_REMOVED = 11;
21 
22     int SWITCH_EARPIECE = 1001;
23     int SWITCH_BLUETOOTH = 1002;
24     int SWITCH_HEADSET = 1003;
25     int SWITCH_SPEAKER = 1004;
26     // Wired headset, earpiece, or speakerphone, in that order of precedence.
27     int SWITCH_BASELINE_ROUTE = 1005;
28 
29     // Messages denoting that the speakerphone was turned on/off. Used to update state when we
30     // weren't the ones who turned it on/off
31     int SPEAKER_ON = 1006;
32     int SPEAKER_OFF = 1007;
33 
34     // Messages denoting that the streaming route switch request was sent.
35     int STREAMING_FORCE_ENABLED = 1008;
36     int STREAMING_FORCE_DISABLED = 1009;
37 
38     int USER_SWITCH_EARPIECE = 1101;
39     int USER_SWITCH_BLUETOOTH = 1102;
40     int USER_SWITCH_HEADSET = 1103;
41     int USER_SWITCH_SPEAKER = 1104;
42     int USER_SWITCH_BASELINE_ROUTE = 1105;
43 
44     int UPDATE_SYSTEM_AUDIO_ROUTE = 1201;
45 
46     // These three messages indicate state changes that come from BluetoothRouteManager.
47     // They may be triggered by the BT stack doing something on its own or they may be sent after
48     // we request that the BT stack do something. Any logic for these messages should take into
49     // account the possibility that the event indicated has already been processed (i.e. handling
50     // should be idempotent).
51     int BT_AUDIO_DISCONNECTED = 1301;
52     int BT_AUDIO_CONNECTED = 1302;
53     int BT_AUDIO_PENDING = 1303;
54 
55     int MUTE_ON = 3001;
56     int MUTE_OFF = 3002;
57     int TOGGLE_MUTE = 3003;
58     int MUTE_EXTERNALLY_CHANGED = 3004;
59 
60     int SWITCH_FOCUS = 4001;
61 
62     // Used in testing to execute verifications. Not compatible with subsessions.
63     int RUN_RUNNABLE = 9001;
64 
65     // Used for PendingAudioRoute to notify audio switch success
66     int EXIT_PENDING_ROUTE = 10001;
67     // Used for PendingAudioRoute to notify audio switch timeout
68     int PENDING_ROUTE_TIMEOUT = 10002;
69     // Used for PendingAudioRoute to notify audio switch failed
70     int PENDING_ROUTE_FAILED = 10003;
71 
72     /** Valid values for mAudioFocusType */
73     int NO_FOCUS = 1;
74     int ACTIVE_FOCUS = 2;
75     int RINGING_FOCUS = 3;
76 
77     /** Valid arg for BLUETOOTH_DEVICE_LIST_CHANGED */
78     int DEVICE_CONNECTED = 1;
79     int DEVICE_DISCONNECTED = 2;
80 
81     SparseArray<String> MESSAGE_CODE_TO_NAME = new SparseArray<String>() {{
82         put(CONNECT_WIRED_HEADSET, "CONNECT_WIRED_HEADSET");
83         put(DISCONNECT_WIRED_HEADSET, "DISCONNECT_WIRED_HEADSET");
84         put(CONNECT_DOCK, "CONNECT_DOCK");
85         put(DISCONNECT_DOCK, "DISCONNECT_DOCK");
86         put(BLUETOOTH_DEVICE_LIST_CHANGED, "BLUETOOTH_DEVICE_LIST_CHANGED");
87         put(BT_ACTIVE_DEVICE_PRESENT, "BT_ACTIVE_DEVICE_PRESENT");
88         put(BT_ACTIVE_DEVICE_GONE, "BT_ACTIVE_DEVICE_GONE");
89         put(BT_DEVICE_ADDED, "BT_DEVICE_ADDED");
90         put(BT_DEVICE_REMOVED, "BT_DEVICE_REMOVED");
91 
92         put(SWITCH_EARPIECE, "SWITCH_EARPIECE");
93         put(SWITCH_BLUETOOTH, "SWITCH_BLUETOOTH");
94         put(SWITCH_HEADSET, "SWITCH_HEADSET");
95         put(SWITCH_SPEAKER, "SWITCH_SPEAKER");
96         put(SWITCH_BASELINE_ROUTE, "SWITCH_BASELINE_ROUTE");
97         put(SPEAKER_ON, "SPEAKER_ON");
98         put(SPEAKER_OFF, "SPEAKER_OFF");
99 
100         put(STREAMING_FORCE_ENABLED, "STREAMING_FORCE_ENABLED");
101         put(STREAMING_FORCE_DISABLED, "STREAMING_FORCE_DISABLED");
102 
103         put(USER_SWITCH_EARPIECE, "USER_SWITCH_EARPIECE");
104         put(USER_SWITCH_BLUETOOTH, "USER_SWITCH_BLUETOOTH");
105         put(USER_SWITCH_HEADSET, "USER_SWITCH_HEADSET");
106         put(USER_SWITCH_SPEAKER, "USER_SWITCH_SPEAKER");
107         put(USER_SWITCH_BASELINE_ROUTE, "USER_SWITCH_BASELINE_ROUTE");
108 
109         put(UPDATE_SYSTEM_AUDIO_ROUTE, "UPDATE_SYSTEM_AUDIO_ROUTE");
110 
111         put(BT_AUDIO_DISCONNECTED, "BT_AUDIO_DISCONNECTED");
112         put(BT_AUDIO_CONNECTED, "BT_AUDIO_CONNECTED");
113         put(BT_AUDIO_PENDING, "BT_AUDIO_PENDING");
114 
115         put(MUTE_ON, "MUTE_ON");
116         put(MUTE_OFF, "MUTE_OFF");
117         put(TOGGLE_MUTE, "TOGGLE_MUTE");
118         put(MUTE_EXTERNALLY_CHANGED, "MUTE_EXTERNALLY_CHANGED");
119 
120         put(SWITCH_FOCUS, "SWITCH_FOCUS");
121 
122         put(RUN_RUNNABLE, "RUN_RUNNABLE");
123 
124         put(EXIT_PENDING_ROUTE, "EXIT_PENDING_ROUTE");
125     }};
126 
initialize()127     void initialize();
sendMessageWithSessionInfo(int message)128     void sendMessageWithSessionInfo(int message);
sendMessageWithSessionInfo(int message, int arg)129     void sendMessageWithSessionInfo(int message, int arg);
sendMessageWithSessionInfo(int message, int arg, String data)130     void sendMessageWithSessionInfo(int message, int arg, String data);
sendMessageWithSessionInfo(int message, int arg, BluetoothDevice bluetoothDevice)131     void sendMessageWithSessionInfo(int message, int arg, BluetoothDevice bluetoothDevice);
sendMessage(int message, Runnable r)132     void sendMessage(int message, Runnable r);
setCallAudioManager(CallAudioManager callAudioManager)133     void setCallAudioManager(CallAudioManager callAudioManager);
getCurrentCallAudioState()134     CallAudioState getCurrentCallAudioState();
isHfpDeviceAvailable()135     boolean isHfpDeviceAvailable();
getAdapterHandler()136     Handler getAdapterHandler();
getPendingAudioRoute()137     PendingAudioRoute getPendingAudioRoute();
dump(IndentingPrintWriter pw)138     void dump(IndentingPrintWriter pw);
139 }
140