Home | History | Annotate | Download | only in policy
      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.systemui.statusbar.policy;
     18 
     19 import java.util.Set;
     20 
     21 public interface BluetoothController {
     22     void addStateChangedCallback(Callback callback);
     23     void removeStateChangedCallback(Callback callback);
     24 
     25     boolean isBluetoothSupported();
     26     boolean isBluetoothEnabled();
     27     boolean isBluetoothConnected();
     28     boolean isBluetoothConnecting();
     29     String getLastDeviceName();
     30     void setBluetoothEnabled(boolean enabled);
     31     Set<PairedDevice> getPairedDevices();
     32     void connect(PairedDevice device);
     33     void disconnect(PairedDevice device);
     34 
     35     public interface Callback {
     36         void onBluetoothStateChange(boolean enabled, boolean connecting);
     37         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         }
     58     }
     59 }
     60