int bt_enable() {
    LOGV(__FUNCTION__);

    int ret = bt_chip_enable();

    if (ret)
        goto out;

    if ((ret = do_btd_enable()) != 0)
        bt_chip_disable();

out:
    return ret;
}
Exemplo n.º 2
0
static int nativeJFmRx_Create(JNIEnv *env,jobject obj,jobject jContextValue)
{
    FmRxStatus fmStatus;
    FmRxContext *fmRxContext =NULL;
    jclass contextCls = NULL;
    jmethodID setValueMethodId = NULL;

	int ret = 0;
	static int g_fmapp_hci_dev = 0;

	char prop[PROPERTY_VALUE_MAX];


	FM_LOGD("%s: Entered", __func__);


	property_get("ro.semc.fm_stack.debug", prop, "0");

	if (0 == strncmp("1", prop, PROPERTY_VALUE_MAX)) {
		ret = fm_trace_init();
		fm_stack_debug = true;
	}

	if (bt_chip_enable() < 0) {

		FM_LOGD("bt_chip_enable() failed");

		goto CLEANUP;
	} else {

		FM_LOGD("bt_chip_enable() done");

	}

	register_fmsig_handlers();
	ret = fm_open_cmd_socket(g_fmapp_hci_dev);
	if (ret) {
		LOGE("failed to open cmd socket ret %d",ret);
		goto CLEANUP;
	}


		FM_LOGD("nativeJFmRx_Create(): Calling FM_RX_Init");



	fmStatus = FM_RX_Init(fmrx_error_callback);
	if (fmStatus) {
	LOGE("failed to init FM rx stack context");
	goto CLEANUP;

	}
		
	fmStatus = FM_RX_Create(NULL, fmapp_rx_callback, &fmRxContext);

	if (fmStatus) {
		LOGE("failed to create FM rx stack context");
		goto CLEANUP;
	} else {

		FM_LOGD("create FM rx stack context ret = %x",
		     (unsigned int)fmRxContext);

	}

	FM_LOGD("%s: FM_RX_Create returned %d, context: %x", __func__,
	     (int)fmStatus,
	     (unsigned int)fmRxContext);


	FM_LOGD("%s: Setting context value in jContext out parm", __func__);


	/* Pass received fmContext via the jContextValue object */
	contextCls = env->GetObjectClass(jContextValue);
	if (contextCls == NULL)	{

		FM_LOGD("%s: Failed obtaining class for JBtlProfileContext",
		     __func__);

		goto CLEANUP;
	}

	setValueMethodId = env->GetMethodID(contextCls, "setValue", "(I)V");
	if (setValueMethodId == NULL)
	{
	   	LOGE("nativeJFmRx_create: Failed getting setValue method id");
		goto CLEANUP;
	}
	
	FM_LOGD("nativeJFmRx_create: Calling Java setValue(ox%x) in context's class", (unsigned int)fmRxContext);


	env->CallVoidMethod(jContextValue, setValueMethodId, (unsigned int)fmRxContext);
	if (env->ExceptionOccurred())
	{
		LOGE("nativeJFmRx_create: Calling CallVoidMethod(setValue) failed");
		env->ExceptionDescribe();
		goto CLEANUP;
	}

	FM_LOGD("nativeJFmRx_create:Exiting Successfully");


	return fmStatus;


CLEANUP:
	
	LOGE("nativeJFmRx_create(): Exiting With a Failure indication");
	return FMC_STATUS_FAILED;
}