blob: cbdd13851806c738a45d361a861a435568752ece [file] [log] [blame]
Joe Onoratofce2bf32011-02-01 17:00:29 -08001/*
John Spurlockaf8d6c42014-05-07 17:49:08 -04002 * Copyright (C) 2014 The Android Open Source Project
Joe Onoratofce2bf32011-02-01 17:00:29 -08003 *
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
17package com.android.systemui.statusbar.policy;
18
John Spurlock486b78e2014-07-07 08:37:56 -040019import java.util.Set;
20
John Spurlockaf8d6c42014-05-07 17:49:08 -040021public interface BluetoothController {
John Spurlockd1c86e22014-06-01 00:04:53 -040022 void addStateChangedCallback(Callback callback);
23 void removeStateChangedCallback(Callback callback);
Winson Chung5f623012012-09-14 14:58:43 -070024
John Spurlockaf8d6c42014-05-07 17:49:08 -040025 boolean isBluetoothSupported();
26 boolean isBluetoothEnabled();
27 boolean isBluetoothConnected();
John Spurlockd1c86e22014-06-01 00:04:53 -040028 boolean isBluetoothConnecting();
29 String getLastDeviceName();
John Spurlockaf8d6c42014-05-07 17:49:08 -040030 void setBluetoothEnabled(boolean enabled);
John Spurlock486b78e2014-07-07 08:37:56 -040031 Set<PairedDevice> getPairedDevices();
32 void connect(PairedDevice device);
33 void disconnect(PairedDevice device);
John Spurlockd1c86e22014-06-01 00:04:53 -040034
35 public interface Callback {
36 void onBluetoothStateChange(boolean enabled, boolean connecting);
John Spurlock486b78e2014-07-07 08:37:56 -040037 void onBluetoothPairedDevicesChanged();
38 }
39
40 public static final class PairedDevice {
41 public static int STATE_DISCONNECTED = 0;
42 public static int STATE_CONNECTING = 1;
43 public static int STATE_CONNECTED = 2;
44 public static int STATE_DISCONNECTING = 3;
45
46 public String id;
47 public String name;
48 public int state = STATE_DISCONNECTED;
49 public Object tag;
50
51 public static String stateToString(int state) {
52 if (state == STATE_DISCONNECTED) return "STATE_DISCONNECTED";
53 if (state == STATE_CONNECTING) return "STATE_CONNECTING";
54 if (state == STATE_CONNECTED) return "STATE_CONNECTED";
55 if (state == STATE_DISCONNECTING) return "STATE_DISCONNECTING";
56 return "UNKNOWN";
57 }
John Spurlockd1c86e22014-06-01 00:04:53 -040058 }
Joe Onoratofce2bf32011-02-01 17:00:29 -080059}