Home | History | Annotate | Download | only in bluetooth
      1 /*
      2  * Copyright (C) 2010-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 
     18 package android.bluetooth;
     19 
     20 import java.util.List;
     21 
     22 /**
     23  * Public APIs for the Bluetooth Profiles.
     24  *
     25  * <p> Clients should call {@link BluetoothAdapter#getProfileProxy},
     26  * to get the Profile Proxy. Each public profile implements this
     27  * interface.
     28  */
     29 public interface BluetoothProfile {
     30 
     31     /**
     32      * Extra for the connection state intents of the individual profiles.
     33      *
     34      * This extra represents the current connection state of the profile of the
     35      * Bluetooth device.
     36      */
     37     public static final String EXTRA_STATE = "android.bluetooth.profile.extra.STATE";
     38 
     39     /**
     40      * Extra for the connection state intents of the individual profiles.
     41      *
     42      * This extra represents the previous connection state of the profile of the
     43      * Bluetooth device.
     44      */
     45     public static final String EXTRA_PREVIOUS_STATE =
     46         "android.bluetooth.profile.extra.PREVIOUS_STATE";
     47 
     48     /** The profile is in disconnected state */
     49     public static final int STATE_DISCONNECTED  = 0;
     50     /** The profile is in connecting state */
     51     public static final int STATE_CONNECTING    = 1;
     52     /** The profile is in connected state */
     53     public static final int STATE_CONNECTED     = 2;
     54     /** The profile is in disconnecting state */
     55     public static final int STATE_DISCONNECTING = 3;
     56 
     57     /**
     58      * Headset and Handsfree profile
     59      */
     60     public static final int HEADSET = 1;
     61 
     62     /**
     63      * A2DP profile.
     64      */
     65     public static final int A2DP = 2;
     66 
     67     /**
     68      * Health Profile
     69      */
     70     public static final int HEALTH = 3;
     71 
     72     /**
     73      * Input Device Profile
     74      * @hide
     75      */
     76     public static final int INPUT_DEVICE = 4;
     77 
     78     /**
     79      * PAN Profile
     80      * @hide
     81      */
     82     public static final int PAN = 5;
     83 
     84     /**
     85      * PBAP
     86      * @hide
     87      */
     88     public static final int PBAP = 6;
     89 
     90     /**
     91      * GATT
     92      */
     93     static public final int GATT = 7;
     94 
     95     /**
     96      * GATT_SERVER
     97      */
     98     static public final int GATT_SERVER = 8;
     99 
    100     /**
    101      * MAP Profile
    102      * @hide
    103      */
    104     public static final int MAP = 9;
    105 
    106     /**
    107      * A2DP Sink Profile
    108      * @hide
    109      */
    110     public static final int A2DP_SINK = 10;
    111 
    112     /**
    113      * AVRCP Controller Profile
    114      * @hide
    115      */
    116     public static final int AVRCP_CONTROLLER = 11;
    117 
    118     /**
    119      * Headset Client - HFP HF Role
    120      * @hide
    121      */
    122     public static final int HEADSET_CLIENT = 16;
    123 
    124     /**
    125      * Default priority for devices that we try to auto-connect to and
    126      * and allow incoming connections for the profile
    127      * @hide
    128      **/
    129     public static final int PRIORITY_AUTO_CONNECT = 1000;
    130 
    131     /**
    132      *  Default priority for devices that allow incoming
    133      * and outgoing connections for the profile
    134      * @hide
    135      **/
    136     public static final int PRIORITY_ON = 100;
    137 
    138     /**
    139      * Default priority for devices that does not allow incoming
    140      * connections and outgoing connections for the profile.
    141      * @hide
    142      **/
    143     public static final int PRIORITY_OFF = 0;
    144 
    145     /**
    146      * Default priority when not set or when the device is unpaired
    147      * @hide
    148      * */
    149     public static final int PRIORITY_UNDEFINED = -1;
    150 
    151     /**
    152      * Get connected devices for this specific profile.
    153      *
    154      * <p> Return the set of devices which are in state {@link #STATE_CONNECTED}
    155      *
    156      * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
    157      *
    158      * @return List of devices. The list will be empty on error.
    159      */
    160     public List<BluetoothDevice> getConnectedDevices();
    161 
    162     /**
    163      * Get a list of devices that match any of the given connection
    164      * states.
    165      *
    166      * <p> If none of the devices match any of the given states,
    167      * an empty list will be returned.
    168      *
    169      * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
    170      *
    171      * @param states Array of states. States can be one of
    172      *              {@link #STATE_CONNECTED}, {@link #STATE_CONNECTING},
    173      *              {@link #STATE_DISCONNECTED}, {@link #STATE_DISCONNECTING},
    174      * @return List of devices. The list will be empty on error.
    175      */
    176     public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states);
    177 
    178     /**
    179      * Get the current connection state of the profile
    180      *
    181      * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
    182      *
    183      * @param device Remote bluetooth device.
    184      * @return State of the profile connection. One of
    185      *               {@link #STATE_CONNECTED}, {@link #STATE_CONNECTING},
    186      *               {@link #STATE_DISCONNECTED}, {@link #STATE_DISCONNECTING}
    187      */
    188     public int getConnectionState(BluetoothDevice device);
    189 
    190     /**
    191      * An interface for notifying BluetoothProfile IPC clients when they have
    192      * been connected or disconnected to the service.
    193      */
    194     public interface ServiceListener {
    195         /**
    196          * Called to notify the client when the proxy object has been
    197          * connected to the service.
    198          * @param profile - One of {@link #HEALTH}, {@link #HEADSET} or
    199          *                  {@link #A2DP}
    200          * @param proxy - One of {@link BluetoothHealth}, {@link BluetoothHeadset} or
    201          *                {@link BluetoothA2dp}
    202          */
    203         public void onServiceConnected(int profile, BluetoothProfile proxy);
    204 
    205         /**
    206          * Called to notify the client that this proxy object has been
    207          * disconnected from the service.
    208          * @param profile - One of {@link #HEALTH}, {@link #HEADSET} or
    209          *                  {@link #A2DP}
    210          */
    211         public void onServiceDisconnected(int profile);
    212     }
    213 }
    214