• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 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.tv.settings.accessories;
18 
19 import android.bluetooth.BluetoothClass;
20 import android.bluetooth.BluetoothDevice;
21 import android.support.annotation.DrawableRes;
22 
23 import com.android.tv.settings.R;
24 
25 /*
26  * Provide utilities for Remote & Accessories.
27  */
28 public class AccessoryUtils {
getImageIdForDevice(BluetoothDevice dev)29     public static @DrawableRes int getImageIdForDevice(BluetoothDevice dev) {
30         int devClass = dev.getBluetoothClass().getDeviceClass();
31 
32         if (devClass == BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET) {
33             return R.drawable.ic_headset_mic;
34         } else if (devClass == BluetoothClass.Device.AUDIO_VIDEO_HEADPHONES ||
35                 devClass == BluetoothClass.Device.AUDIO_VIDEO_LOUDSPEAKER ||
36                 devClass == BluetoothClass.Device.AUDIO_VIDEO_PORTABLE_AUDIO ||
37                 devClass == BluetoothClass.Device.AUDIO_VIDEO_HIFI_AUDIO) {
38             return R.drawable.ic_headset;
39         } else if ((devClass & InputDeviceCriteria.MINOR_DEVICE_CLASS_POINTING) != 0) {
40             return R.drawable.ic_mouse;
41         } else if ((devClass & InputDeviceCriteria.MINOR_DEVICE_CLASS_JOYSTICK) != 0) {
42             return R.drawable.ic_games;
43         } else if ((devClass & InputDeviceCriteria.MINOR_DEVICE_CLASS_GAMEPAD) != 0) {
44             return R.drawable.ic_games;
45         } else if ((devClass & InputDeviceCriteria.MINOR_DEVICE_CLASS_KEYBOARD) != 0) {
46             return R.drawable.ic_keyboard;
47         }
48 
49         // Default for now
50         return R.drawable.ic_bluetooth;
51     }
52 
AccessoryUtils()53     private AccessoryUtils() {
54         // do not allow instantiation
55     }
56 }
57