• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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.bluetooth.audio_util;
18 
19 import android.bluetooth.BluetoothAvrcp;
20 import android.view.KeyEvent;
21 
22 class AvrcpPassthrough {
toKeyCode(int operation)23     public static int toKeyCode(int operation) {
24         switch (operation) {
25             case BluetoothAvrcp.PASSTHROUGH_ID_UP:
26                 return KeyEvent.KEYCODE_DPAD_UP;
27             case BluetoothAvrcp.PASSTHROUGH_ID_DOWN:
28                 return KeyEvent.KEYCODE_DPAD_DOWN;
29             case BluetoothAvrcp.PASSTHROUGH_ID_LEFT:
30                 return KeyEvent.KEYCODE_DPAD_LEFT;
31             case BluetoothAvrcp.PASSTHROUGH_ID_RIGHT:
32                 return KeyEvent.KEYCODE_DPAD_RIGHT;
33             case BluetoothAvrcp.PASSTHROUGH_ID_RIGHT_UP:
34                 return KeyEvent.KEYCODE_DPAD_UP_RIGHT;
35             case BluetoothAvrcp.PASSTHROUGH_ID_RIGHT_DOWN:
36                 return KeyEvent.KEYCODE_DPAD_DOWN_RIGHT;
37             case BluetoothAvrcp.PASSTHROUGH_ID_LEFT_UP:
38                 return KeyEvent.KEYCODE_DPAD_UP_LEFT;
39             case BluetoothAvrcp.PASSTHROUGH_ID_LEFT_DOWN:
40                 return KeyEvent.KEYCODE_DPAD_DOWN_LEFT;
41             case BluetoothAvrcp.PASSTHROUGH_ID_0:
42                 return KeyEvent.KEYCODE_NUMPAD_0;
43             case BluetoothAvrcp.PASSTHROUGH_ID_1:
44                 return KeyEvent.KEYCODE_NUMPAD_1;
45             case BluetoothAvrcp.PASSTHROUGH_ID_2:
46                 return KeyEvent.KEYCODE_NUMPAD_2;
47             case BluetoothAvrcp.PASSTHROUGH_ID_3:
48                 return KeyEvent.KEYCODE_NUMPAD_3;
49             case BluetoothAvrcp.PASSTHROUGH_ID_4:
50                 return KeyEvent.KEYCODE_NUMPAD_4;
51             case BluetoothAvrcp.PASSTHROUGH_ID_5:
52                 return KeyEvent.KEYCODE_NUMPAD_5;
53             case BluetoothAvrcp.PASSTHROUGH_ID_6:
54                 return KeyEvent.KEYCODE_NUMPAD_6;
55             case BluetoothAvrcp.PASSTHROUGH_ID_7:
56                 return KeyEvent.KEYCODE_NUMPAD_7;
57             case BluetoothAvrcp.PASSTHROUGH_ID_8:
58                 return KeyEvent.KEYCODE_NUMPAD_8;
59             case BluetoothAvrcp.PASSTHROUGH_ID_9:
60                 return KeyEvent.KEYCODE_NUMPAD_9;
61             case BluetoothAvrcp.PASSTHROUGH_ID_DOT:
62                 return KeyEvent.KEYCODE_NUMPAD_DOT;
63             case BluetoothAvrcp.PASSTHROUGH_ID_ENTER:
64                 return KeyEvent.KEYCODE_NUMPAD_ENTER;
65             case BluetoothAvrcp.PASSTHROUGH_ID_CLEAR:
66                 return KeyEvent.KEYCODE_CLEAR;
67             case BluetoothAvrcp.PASSTHROUGH_ID_CHAN_UP:
68                 return KeyEvent.KEYCODE_CHANNEL_UP;
69             case BluetoothAvrcp.PASSTHROUGH_ID_CHAN_DOWN:
70                 return KeyEvent.KEYCODE_CHANNEL_DOWN;
71             case BluetoothAvrcp.PASSTHROUGH_ID_PREV_CHAN:
72                 return KeyEvent.KEYCODE_LAST_CHANNEL;
73             case BluetoothAvrcp.PASSTHROUGH_ID_INPUT_SEL:
74                 return KeyEvent.KEYCODE_TV_INPUT;
75             case BluetoothAvrcp.PASSTHROUGH_ID_DISP_INFO:
76                 return KeyEvent.KEYCODE_INFO;
77             case BluetoothAvrcp.PASSTHROUGH_ID_HELP:
78                 return KeyEvent.KEYCODE_HELP;
79             case BluetoothAvrcp.PASSTHROUGH_ID_PAGE_UP:
80                 return KeyEvent.KEYCODE_PAGE_UP;
81             case BluetoothAvrcp.PASSTHROUGH_ID_PAGE_DOWN:
82                 return KeyEvent.KEYCODE_PAGE_DOWN;
83             case BluetoothAvrcp.PASSTHROUGH_ID_POWER:
84                 return KeyEvent.KEYCODE_POWER;
85             case BluetoothAvrcp.PASSTHROUGH_ID_VOL_UP:
86                 return KeyEvent.KEYCODE_VOLUME_UP;
87             case BluetoothAvrcp.PASSTHROUGH_ID_VOL_DOWN:
88                 return KeyEvent.KEYCODE_VOLUME_DOWN;
89             case BluetoothAvrcp.PASSTHROUGH_ID_MUTE:
90                 return KeyEvent.KEYCODE_MUTE;
91             case BluetoothAvrcp.PASSTHROUGH_ID_PLAY:
92                 return KeyEvent.KEYCODE_MEDIA_PLAY;
93             case BluetoothAvrcp.PASSTHROUGH_ID_STOP:
94                 return KeyEvent.KEYCODE_MEDIA_STOP;
95             case BluetoothAvrcp.PASSTHROUGH_ID_PAUSE:
96                 return KeyEvent.KEYCODE_MEDIA_PAUSE;
97             case BluetoothAvrcp.PASSTHROUGH_ID_RECORD:
98                 return KeyEvent.KEYCODE_MEDIA_RECORD;
99             case BluetoothAvrcp.PASSTHROUGH_ID_REWIND:
100                 return KeyEvent.KEYCODE_MEDIA_REWIND;
101             case BluetoothAvrcp.PASSTHROUGH_ID_FAST_FOR:
102                 return KeyEvent.KEYCODE_MEDIA_FAST_FORWARD;
103             case BluetoothAvrcp.PASSTHROUGH_ID_EJECT:
104                 return KeyEvent.KEYCODE_MEDIA_EJECT;
105             case BluetoothAvrcp.PASSTHROUGH_ID_FORWARD:
106                 return KeyEvent.KEYCODE_MEDIA_NEXT;
107             case BluetoothAvrcp.PASSTHROUGH_ID_BACKWARD:
108                 return KeyEvent.KEYCODE_MEDIA_PREVIOUS;
109             case BluetoothAvrcp.PASSTHROUGH_ID_F1:
110                 return KeyEvent.KEYCODE_F1;
111             case BluetoothAvrcp.PASSTHROUGH_ID_F2:
112                 return KeyEvent.KEYCODE_F2;
113             case BluetoothAvrcp.PASSTHROUGH_ID_F3:
114                 return KeyEvent.KEYCODE_F3;
115             case BluetoothAvrcp.PASSTHROUGH_ID_F4:
116                 return KeyEvent.KEYCODE_F4;
117             case BluetoothAvrcp.PASSTHROUGH_ID_F5:
118                 return KeyEvent.KEYCODE_F5;
119             // Fallthrough for all unknown key mappings
120             case BluetoothAvrcp.PASSTHROUGH_ID_SELECT:
121             case BluetoothAvrcp.PASSTHROUGH_ID_ROOT_MENU:
122             case BluetoothAvrcp.PASSTHROUGH_ID_SETUP_MENU:
123             case BluetoothAvrcp.PASSTHROUGH_ID_CONT_MENU:
124             case BluetoothAvrcp.PASSTHROUGH_ID_FAV_MENU:
125             case BluetoothAvrcp.PASSTHROUGH_ID_EXIT:
126             case BluetoothAvrcp.PASSTHROUGH_ID_SOUND_SEL:
127             case BluetoothAvrcp.PASSTHROUGH_ID_ANGLE:
128             case BluetoothAvrcp.PASSTHROUGH_ID_SUBPICT:
129             case BluetoothAvrcp.PASSTHROUGH_ID_VENDOR:
130             default:
131                 return KeyEvent.KEYCODE_UNKNOWN;
132         }
133     }
134 }
135