// Path: btutillib/src/main/java/com/devpaul/bluetoothutillib/handlers/BluetoothHandler.java
// public class BluetoothHandler extends Handler {
//     public static final int MESSAGE_READ = 121;
//     public static final int MESSAGE_WAIT_FOR_CONNECTION = 143;
//     public static final int MESSAGE_CONNECTION_MADE = 155;
//     public static final int MESSAGE_A2DP_PROXY_RECEIVED = 157;
//     public SimpleBluetoothListener mListener;
//     public Activity mActivity;
//     public ProgressDialog dialog;
//     public boolean shouldShowSnackbars;
// 
//     /**
//      * Bluetooth Handler class for handling messages from the bluetooth device.
//      * @param listener listener for simple bluetooth.
//      * @param context reference context.
//      */
//     public BluetoothHandler(SimpleBluetoothListener listener, Context context) {
//         this.mListener = listener;
//         if(context instanceof Activity) {
//             this.mActivity = (Activity) context;
//         }
//         dialog = new ProgressDialog(context);
//     }
// 
//     public void setShowSnackbars(boolean show) {
//         this.shouldShowSnackbars = show;
//     }
// }


import android.app.NotificationManager;
import android.app.Service;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import com.devpaul.bluetoothutillib.handlers.BluetoothHandler;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.UUID;
package com.devpaul.bluetoothutillib.utils;




/**
 * Created by Paul T.
 *
 * Bluetooth service class so you can connect to bluetooth devices persistently in an app
 * background.
 */
public class BluetoothService extends Service {

    /**
     * Callback for the service.
     */
    public interface BluetoothServiceCallback {
        public void onDeviceConnected(BluetoothDevice device);
    }

    /**
     * Local binder
     */
    private LocalBinder mLocalBinder = new LocalBinder();

    /**
     * Bluetooth device.
     */
    private BluetoothDevice device;

    /**
     * BluetoothAdapter instance for the service.
     */
    private BluetoothAdapter adapter;

    /**
     * The connect device thread for connecting to a device.
     */
    private ConnectDeviceThread connectDeviceThread;

    /**
     * Connected thread for when handling when the device is connected.
     */
    private ConnectedThread connectedThread;

    /**
     * Bluetooth socket holder for the created socket.
     */
    private BluetoothSocket bluetoothSocket;

    /**
     * Instance of a callback.
     */
    private BluetoothServiceCallback callback;

    /**
     * Notification Manager for if the service is sticky.
     */
    private NotificationManager notificationManager;

    /**
     * Handler for bluetooth.
     */
// Path: btutillib/src/main/java/com/devpaul/bluetoothutillib/handlers/BluetoothHandler.java
// public class BluetoothHandler extends Handler {
//     public static final int MESSAGE_READ = 121;
//     public static final int MESSAGE_WAIT_FOR_CONNECTION = 143;
//     public static final int MESSAGE_CONNECTION_MADE = 155;
//     public static final int MESSAGE_A2DP_PROXY_RECEIVED = 157;
//     public SimpleBluetoothListener mListener;
//     public Activity mActivity;
//     public ProgressDialog dialog;
//     public boolean shouldShowSnackbars;
// 
//     /**
//      * Bluetooth Handler class for handling messages from the bluetooth device.
//      * @param listener listener for simple bluetooth.
//      * @param context reference context.
//      */
//     public BluetoothHandler(SimpleBluetoothListener listener, Context context) {
//         this.mListener = listener;
//         if(context instanceof Activity) {
//             this.mActivity = (Activity) context;
//         }
//         dialog = new ProgressDialog(context);
//     }
// 
//     public void setShowSnackbars(boolean show) {
//         this.shouldShowSnackbars = show;
//     }
// }


// Path: btutillib/src/main/java/com/devpaul/bluetoothutillib/utils/BluetoothService.java
import android.app.NotificationManager;
import android.app.Service;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import com.devpaul.bluetoothutillib.handlers.BluetoothHandler;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.UUID;

package com.devpaul.bluetoothutillib.utils;




/**
 * Created by Paul T.
 *
 * Bluetooth service class so you can connect to bluetooth devices persistently in an app
 * background.
 */
public class BluetoothService extends Service {

    /**
     * Callback for the service.
     */
    public interface BluetoothServiceCallback {
        public void onDeviceConnected(BluetoothDevice device);
    }

    /**
     * Local binder
     */
    private LocalBinder mLocalBinder = new LocalBinder();

    /**
     * Bluetooth device.
     */
    private BluetoothDevice device;

    /**
     * BluetoothAdapter instance for the service.
     */
    private BluetoothAdapter adapter;

    /**
     * The connect device thread for connecting to a device.
     */
    private ConnectDeviceThread connectDeviceThread;

    /**
     * Connected thread for when handling when the device is connected.
     */
    private ConnectedThread connectedThread;

    /**
     * Bluetooth socket holder for the created socket.
     */
    private BluetoothSocket bluetoothSocket;

    /**
     * Instance of a callback.
     */
    private BluetoothServiceCallback callback;

    /**
     * Notification Manager for if the service is sticky.
     */
    private NotificationManager notificationManager;

    /**
     * Handler for bluetooth.
     */
    private BluetoothHandler bluetoothHandler;