1fce2bf3735177828ccf823b49d3396dfaccc8fd4Joe Onorato/* 2af8d6c44f06d2f8baac2c5774a9efdae3fc36797John Spurlock * Copyright (C) 2014 The Android Open Source Project 3fce2bf3735177828ccf823b49d3396dfaccc8fd4Joe Onorato * 4fce2bf3735177828ccf823b49d3396dfaccc8fd4Joe Onorato * Licensed under the Apache License, Version 2.0 (the "License"); 5fce2bf3735177828ccf823b49d3396dfaccc8fd4Joe Onorato * you may not use this file except in compliance with the License. 6fce2bf3735177828ccf823b49d3396dfaccc8fd4Joe Onorato * You may obtain a copy of the License at 7fce2bf3735177828ccf823b49d3396dfaccc8fd4Joe Onorato * 8fce2bf3735177828ccf823b49d3396dfaccc8fd4Joe Onorato * http://www.apache.org/licenses/LICENSE-2.0 9fce2bf3735177828ccf823b49d3396dfaccc8fd4Joe Onorato * 10fce2bf3735177828ccf823b49d3396dfaccc8fd4Joe Onorato * Unless required by applicable law or agreed to in writing, software 11fce2bf3735177828ccf823b49d3396dfaccc8fd4Joe Onorato * distributed under the License is distributed on an "AS IS" BASIS, 12fce2bf3735177828ccf823b49d3396dfaccc8fd4Joe Onorato * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13fce2bf3735177828ccf823b49d3396dfaccc8fd4Joe Onorato * See the License for the specific language governing permissions and 14fce2bf3735177828ccf823b49d3396dfaccc8fd4Joe Onorato * limitations under the License. 15fce2bf3735177828ccf823b49d3396dfaccc8fd4Joe Onorato */ 16fce2bf3735177828ccf823b49d3396dfaccc8fd4Joe Onorato 17fce2bf3735177828ccf823b49d3396dfaccc8fd4Joe Onoratopackage com.android.systemui.statusbar.policy; 18fce2bf3735177828ccf823b49d3396dfaccc8fd4Joe Onorato 19486b78e42652466f6241eb87d5bed60040db7a25John Spurlockimport java.util.Set; 20486b78e42652466f6241eb87d5bed60040db7a25John Spurlock 21af8d6c44f06d2f8baac2c5774a9efdae3fc36797John Spurlockpublic interface BluetoothController { 22d1c86e2cb272f8b8be5b9b47aa4ec7084fe61c22John Spurlock void addStateChangedCallback(Callback callback); 23d1c86e2cb272f8b8be5b9b47aa4ec7084fe61c22John Spurlock void removeStateChangedCallback(Callback callback); 245f623011db42fc7bd6fb8e57becd7a8eeb23a915Winson Chung 25af8d6c44f06d2f8baac2c5774a9efdae3fc36797John Spurlock boolean isBluetoothSupported(); 26af8d6c44f06d2f8baac2c5774a9efdae3fc36797John Spurlock boolean isBluetoothEnabled(); 27af8d6c44f06d2f8baac2c5774a9efdae3fc36797John Spurlock boolean isBluetoothConnected(); 28d1c86e2cb272f8b8be5b9b47aa4ec7084fe61c22John Spurlock boolean isBluetoothConnecting(); 29d1c86e2cb272f8b8be5b9b47aa4ec7084fe61c22John Spurlock String getLastDeviceName(); 30af8d6c44f06d2f8baac2c5774a9efdae3fc36797John Spurlock void setBluetoothEnabled(boolean enabled); 31486b78e42652466f6241eb87d5bed60040db7a25John Spurlock Set<PairedDevice> getPairedDevices(); 32486b78e42652466f6241eb87d5bed60040db7a25John Spurlock void connect(PairedDevice device); 33486b78e42652466f6241eb87d5bed60040db7a25John Spurlock void disconnect(PairedDevice device); 34d1c86e2cb272f8b8be5b9b47aa4ec7084fe61c22John Spurlock 35d1c86e2cb272f8b8be5b9b47aa4ec7084fe61c22John Spurlock public interface Callback { 36d1c86e2cb272f8b8be5b9b47aa4ec7084fe61c22John Spurlock void onBluetoothStateChange(boolean enabled, boolean connecting); 37486b78e42652466f6241eb87d5bed60040db7a25John Spurlock void onBluetoothPairedDevicesChanged(); 38486b78e42652466f6241eb87d5bed60040db7a25John Spurlock } 39486b78e42652466f6241eb87d5bed60040db7a25John Spurlock 40486b78e42652466f6241eb87d5bed60040db7a25John Spurlock public static final class PairedDevice { 41486b78e42652466f6241eb87d5bed60040db7a25John Spurlock public static int STATE_DISCONNECTED = 0; 42486b78e42652466f6241eb87d5bed60040db7a25John Spurlock public static int STATE_CONNECTING = 1; 43486b78e42652466f6241eb87d5bed60040db7a25John Spurlock public static int STATE_CONNECTED = 2; 44486b78e42652466f6241eb87d5bed60040db7a25John Spurlock public static int STATE_DISCONNECTING = 3; 45486b78e42652466f6241eb87d5bed60040db7a25John Spurlock 46486b78e42652466f6241eb87d5bed60040db7a25John Spurlock public String id; 47486b78e42652466f6241eb87d5bed60040db7a25John Spurlock public String name; 48486b78e42652466f6241eb87d5bed60040db7a25John Spurlock public int state = STATE_DISCONNECTED; 49486b78e42652466f6241eb87d5bed60040db7a25John Spurlock public Object tag; 50486b78e42652466f6241eb87d5bed60040db7a25John Spurlock 51486b78e42652466f6241eb87d5bed60040db7a25John Spurlock public static String stateToString(int state) { 52486b78e42652466f6241eb87d5bed60040db7a25John Spurlock if (state == STATE_DISCONNECTED) return "STATE_DISCONNECTED"; 53486b78e42652466f6241eb87d5bed60040db7a25John Spurlock if (state == STATE_CONNECTING) return "STATE_CONNECTING"; 54486b78e42652466f6241eb87d5bed60040db7a25John Spurlock if (state == STATE_CONNECTED) return "STATE_CONNECTED"; 55486b78e42652466f6241eb87d5bed60040db7a25John Spurlock if (state == STATE_DISCONNECTING) return "STATE_DISCONNECTING"; 56486b78e42652466f6241eb87d5bed60040db7a25John Spurlock return "UNKNOWN"; 57486b78e42652466f6241eb87d5bed60040db7a25John Spurlock } 58d1c86e2cb272f8b8be5b9b47aa4ec7084fe61c22John Spurlock } 59fce2bf3735177828ccf823b49d3396dfaccc8fd4Joe Onorato} 60