Java 类android.bluetooth.BluetoothHealth 实例源码

项目:buildAPKsSamples    文件:BluetoothHDPService.java   
public void onHealthChannelStateChange(BluetoothHealthAppConfiguration config,
        BluetoothDevice device, int prevState, int newState, ParcelFileDescriptor fd,
        int channelId) {
    if (Log.isLoggable(TAG, Log.DEBUG))
        Log.d(TAG, String.format("prevState\t%d ----------> newState\t%d",
                prevState, newState));
    if (prevState == BluetoothHealth.STATE_CHANNEL_DISCONNECTED &&
            newState == BluetoothHealth.STATE_CHANNEL_CONNECTED) {
        if (config.equals(mHealthAppConfig)) {
            mChannelId = channelId;
            sendMessage(STATUS_CREATE_CHANNEL, RESULT_OK);
            (new ReadThread(fd)).start();
        } else {
            sendMessage(STATUS_CREATE_CHANNEL, RESULT_FAIL);
        }
    } else if (prevState == BluetoothHealth.STATE_CHANNEL_CONNECTING &&
               newState == BluetoothHealth.STATE_CHANNEL_DISCONNECTED) {
        sendMessage(STATUS_CREATE_CHANNEL, RESULT_FAIL);
    } else if (newState == BluetoothHealth.STATE_CHANNEL_DISCONNECTED) {
        if (config.equals(mHealthAppConfig)) {
            sendMessage(STATUS_DESTROY_CHANNEL, RESULT_OK);
        } else {
            sendMessage(STATUS_DESTROY_CHANNEL, RESULT_FAIL);
        }
    }
}
项目:AndroidthingsStudy    文件:BluetoothHDPService.java   
public void onHealthChannelStateChange(BluetoothHealthAppConfiguration config,
        BluetoothDevice device, int prevState, int newState, ParcelFileDescriptor fd,
        int channelId) {
    if (Log.isLoggable(TAG, Log.DEBUG))
        Log.d(TAG, String.format("prevState\t%d ----------> newState\t%d",
                prevState, newState));
    if (prevState == BluetoothHealth.STATE_CHANNEL_DISCONNECTED &&
            newState == BluetoothHealth.STATE_CHANNEL_CONNECTED) {
        if (config.equals(mHealthAppConfig)) {
            mChannelId = channelId;
            sendMessage(STATUS_CREATE_CHANNEL, RESULT_OK);
            (new ReadThread(fd)).start();
        } else {
            sendMessage(STATUS_CREATE_CHANNEL, RESULT_FAIL);
        }
    } else if (prevState == BluetoothHealth.STATE_CHANNEL_CONNECTING &&
               newState == BluetoothHealth.STATE_CHANNEL_DISCONNECTED) {
        sendMessage(STATUS_CREATE_CHANNEL, RESULT_FAIL);
    } else if (newState == BluetoothHealth.STATE_CHANNEL_DISCONNECTED) {
        if (config.equals(mHealthAppConfig)) {
            sendMessage(STATUS_DESTROY_CHANNEL, RESULT_OK);
        } else {
            sendMessage(STATUS_DESTROY_CHANNEL, RESULT_FAIL);
        }
    }
}
项目:opentele-client-android    文件:AndroidHdpController.java   
@Override
public void onServiceConnected(int profile, BluetoothProfile proxy) {
    if (profile != BluetoothProfile.HEALTH) {
        Log.d(TAG, "onServiceConnected profile==" + profile);
        return;
    }

    Log.d(TAG, "onServiceConnected");
    synchronized (stateSemaphore) {
        bluetoothHealth = (BluetoothHealth) proxy;
        goFromStateToState(State.SERVICE_NOT_CONNECTED, State.SERVICE_CONNECTED);
        Log.d(TAG, "onServiceConnected to profile: " + profile);

        if (shuttingDown) {
            closeProfileProxy();
        } else {
            registerApplication();
        }
    }
}
项目:buildAPKsSamples    文件:BluetoothHDPService.java   
public void onServiceConnected(int profile, BluetoothProfile proxy) {
    if (profile == BluetoothProfile.HEALTH) {
        mBluetoothHealth = (BluetoothHealth) proxy;
        if (Log.isLoggable(TAG, Log.DEBUG))
            Log.d(TAG, "onServiceConnected to profile: " + profile);
    }
}
项目:buildAPKsSamples    文件:BluetoothHDPService.java   
public void onHealthAppConfigurationStatusChange(BluetoothHealthAppConfiguration config,
        int status) {
    if (status == BluetoothHealth.APP_CONFIG_REGISTRATION_FAILURE) {
        mHealthAppConfig = null;
        sendMessage(STATUS_HEALTH_APP_REG, RESULT_FAIL);
    } else if (status == BluetoothHealth.APP_CONFIG_REGISTRATION_SUCCESS) {
        mHealthAppConfig = config;
        sendMessage(STATUS_HEALTH_APP_REG, RESULT_OK);
    } else if (status == BluetoothHealth.APP_CONFIG_UNREGISTRATION_FAILURE ||
            status == BluetoothHealth.APP_CONFIG_UNREGISTRATION_SUCCESS) {
        sendMessage(STATUS_HEALTH_APP_UNREG,
                status == BluetoothHealth.APP_CONFIG_UNREGISTRATION_SUCCESS ?
                RESULT_OK : RESULT_FAIL);
    }
}
项目:AndroidthingsStudy    文件:BluetoothHDPService.java   
public void onServiceConnected(int profile, BluetoothProfile proxy) {
    if (profile == BluetoothProfile.HEALTH) {
        mBluetoothHealth = (BluetoothHealth) proxy;
        if (Log.isLoggable(TAG, Log.DEBUG))
            Log.d(TAG, "onServiceConnected to profile: " + profile);
    }
}
项目:AndroidthingsStudy    文件:BluetoothHDPService.java   
public void onHealthAppConfigurationStatusChange(BluetoothHealthAppConfiguration config,
        int status) {
    if (status == BluetoothHealth.APP_CONFIG_REGISTRATION_FAILURE) {
        mHealthAppConfig = null;
        sendMessage(STATUS_HEALTH_APP_REG, RESULT_FAIL);
    } else if (status == BluetoothHealth.APP_CONFIG_REGISTRATION_SUCCESS) {
        mHealthAppConfig = config;
        sendMessage(STATUS_HEALTH_APP_REG, RESULT_OK);
    } else if (status == BluetoothHealth.APP_CONFIG_UNREGISTRATION_FAILURE ||
            status == BluetoothHealth.APP_CONFIG_UNREGISTRATION_SUCCESS) {
        sendMessage(STATUS_HEALTH_APP_UNREG,
                status == BluetoothHealth.APP_CONFIG_UNREGISTRATION_SUCCESS ?
                RESULT_OK : RESULT_FAIL);
    }
}
项目:HDPDeviceAdapter    文件:HDPDriverService.java   
public void onHealthAppConfigurationStatusChange(BluetoothHealthAppConfiguration config,
        int status) {
    if (status == BluetoothHealth.APP_CONFIG_REGISTRATION_FAILURE) {
        sendMessage(STATUS_HEALTH_APP_REG, RESULT_FAIL, null);
    } else if (status == BluetoothHealth.APP_CONFIG_REGISTRATION_SUCCESS) {
        configs.add(config);
        sendMessage(STATUS_HEALTH_APP_REG, RESULT_OK, null);
    } else if (status == BluetoothHealth.APP_CONFIG_UNREGISTRATION_FAILURE ||
            status == BluetoothHealth.APP_CONFIG_UNREGISTRATION_SUCCESS) {
        sendMessage(STATUS_HEALTH_APP_UNREG,
                status == BluetoothHealth.APP_CONFIG_UNREGISTRATION_SUCCESS ?
                        RESULT_OK : RESULT_FAIL,
                        null);
    }
}
项目:HDPDeviceAdapter    文件:HDPDriverService.java   
public void onHealthChannelStateChange(BluetoothHealthAppConfiguration config,
        BluetoothDevice device, int prevState, int newState, ParcelFileDescriptor fd,
        int channelId) {
    Log.w(TAG, String.format("prevState\t%d ----------> newState\t%d",
            prevState, newState));
    if (prevState == BluetoothHealth.STATE_CHANNEL_DISCONNECTED &&
            newState == BluetoothHealth.STATE_CHANNEL_CONNECTED) {
        if (acceptsConfiguration(config)) {
            insertDeviceConfiguration(device, config);
            insertChannelId(device, channelId);
            sendMessage(STATUS_CREATE_CHANNEL, RESULT_OK, device);
            FileOutputStream wr = new FileOutputStream(fd.getFileDescriptor());
            insertWriter(device, wr);
            (new ReadThread(device, fd)).start();
        } else {
            sendMessage(STATUS_CREATE_CHANNEL, RESULT_FAIL, device);
        }
    } else if (prevState == BluetoothHealth.STATE_CHANNEL_CONNECTING &&
            newState == BluetoothHealth.STATE_CHANNEL_DISCONNECTED) {
        sendMessage(STATUS_CREATE_CHANNEL, RESULT_FAIL, device);
        removeWriter(device);
    } else if (newState == BluetoothHealth.STATE_CHANNEL_DISCONNECTED) {
        if (acceptsConfiguration(config)) {
            sendMessage(STATUS_DESTROY_CHANNEL, RESULT_OK, device);
            removeWriter(device);
        } else {
            sendMessage(STATUS_DESTROY_CHANNEL, RESULT_FAIL, device);
            removeWriter(device);
        }
    }
}
项目:HDPDeviceAdapter    文件:HDPDriverService.java   
public void onServiceConnected(int profile, BluetoothProfile proxy) {
    if (profile == BluetoothProfile.HEALTH) {
        mBluetoothHealth = (BluetoothHealth) proxy;
        Log.w(TAG, "onServiceConnected to profile: " + profile);
    }
}
项目:opentele-client-android    文件:BluetoothConnector.java   
public void closeHdp(BluetoothHealth bluetoothHealth) {
    bluetoothAdapter.closeProfileProxy(BluetoothProfile.HEALTH, bluetoothHealth);
}