• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2015, 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 * Binder IPC API for talking with the Bluetooth service and perform high-level
19 * operations on the adapter.
20 */
21interface IBluetooth {
22  /**
23   * Returns true if the Bluetooth adapter is powered and ready to use. This
24   * is equivalent to "getState() == ADAPTER_STATE_ON".
25   */
26  boolean isEnabled();
27
28  /**
29   * Returns the current Bluetooth adapter state. The return value can be one of
30   * the following:
31   *
32   *  - ADAPTER_STATE_OFF = 10
33   *  - ADAPTER_STATE_TURNING_ON = 11
34   *  - ADAPTER_STATE_ON = 12
35   *  - ADAPTER_STATE_TURNING_OFF = 13
36   */
37  int getState();
38
39  /**
40   * Turns on the Bluetooth radio. This function initiates the procedure to
41   * bring the adapter state from ADAPTER_STATE_OFF to ADAPTER_STATE_ON. Returns
42   * false, if the state is not ADAPTER_STATE_OFF or if there is an error while
43   * initiating the operation. On success, the adapter state will be
44   * asynchronously updated to ADAPTER_STATE_TURNING_ON and eventually to
45   * ADAPTER_STATE_ON. Callers can monitor the status of this call by observing
46   * the IBluetoothCallback.onBluetoothStateChange callback.
47   */
48  boolean enable();
49
50  /**
51   * Turns off the Bluetooth radio. This function initiates the procedure to
52   * bring the adapter state from ADAPTER_STATE_ON to ADAPTER_STATE_OFF. Returns
53   * false, if the state is not ADAPTER_STATE_ON or if there is an error while
54   * initiating the operation. On success, the adapter state will be
55   * asynchronously updated to ADAPTER_STATE_TURNING_OFF and eventually to
56   * ADAPTER_STATE_OFF. Callers can monitor the status of this call by observing
57   * the IBluetoothCallback.onBluetoothStateChange callback.
58   */
59  boolean disable();
60
61  /**
62   * Returns the identity Bluetooth Device Address (BD_ADDR) assigned to the
63   * underlying Bluetooth controller. Returns a string of the form
64   * "XX:XX:XX:XX:XX:XX", where each "X" is a hexadecimal digit. Returns
65   * "00:00:00:00:00:00" if the address is not known, which is usually the case
66   * before the adapter is enabled for the first time.
67   */
68  String getAddress();
69
70  /**
71   * Sets the name assigned to the Bluetooth adapter. This is the name that will
72   * be seen by remote devices during discovery. Returns false if the operation
73   * fails.
74   */
75  boolean setName(in String name);
76
77  /**
78   * Returns the current name assigned to the Bluetooth adapter. This is the
79   * name that is seen by remote devices during discovery. If the controller has
80   * not been initialized yet (before the first time it gets enabled), this will
81   * return "not-initialized".
82   */
83  String getName();
84
85  /**
86   * Registers a callback receiver which can be used to listen to state updates
87   * from the adapter. The Bluetooth daemon will automatically register this if
88   * the owning process dies.
89   */
90  void registerCallback(in IBluetoothCallback callback);
91
92  /**
93   * Unregisters a previously registered callback.
94   */
95  void unregisterCallback(in IBluetoothCallback callback);
96
97  /**
98   * Returns true, if the multi-advertisement feature is supported. Returns
99   * false, if this device can only advertise a single instance.
100   */
101  boolean isMultiAdvertisementSupported();
102
103  /**
104   * Returns a binder that can be used to interact with Low-Energy features.
105   */
106  IBluetoothLowEnergy getLowEnergyInterface();
107
108  /**
109   * Returns a binder that can be used to interact with GATT client-role
110   * features.
111   */
112  IBluetoothGattClient getGattClientInterface();
113
114  /**
115   * Returns a binder that can be used to interact with GATT server-role
116   * features.
117   */
118  IBluetoothGattServer getGattServerInterface();
119}
120