BtStatus handle_profile_disconnect(bt_addr_struct *bd_addr, PROFILE_enum id) { int state = PROFILE_STATE_DISCONNECTED; dev_op *devOp = getDeviceOpList(bd_addr); profile_op_queue_t *opNode = NULL; if(devOp == NULL) { ALOGW("%s null devOp list!\n", __FUNCTION__); return BT_STATUS_FAILED; } ALOGI("%s addr:[0x%lX:0x%X:0x%X], profile[%d], old[%d]!\n", __FUNCTION__, bd_addr->lap, bd_addr->uap, bd_addr->nap, id, state); memcpy(&devOp->bd_addr, bd_addr, sizeof(bt_addr_struct)); memcpy(&g_cur_dev, bd_addr, sizeof(bt_addr_struct)); removeOp(bd_addr, id, PROFILE_OP_CONNECT); state = getProfileState(bd_addr, id); if(((state == PROFILE_STATE_CONNECTED) && !isBusy(bd_addr)) || ((state == PROFILE_STATE_CONNECTING) && isBusy(bd_addr))) { disconnect_profile_int(bd_addr, id); } else { insertOp(bd_addr, id, PROFILE_OP_DISCONNECT); } /* if((state == PROFILE_STATE_CONNECTING) || (state == PROFILE_STATE_CONNECTED)) { disconnect_profile_int(bd_addr, id); }*/ return BT_STATUS_SUCCESS; }
void removeGCompound(GCompound compound, GObject gobj) { Vector contents; int i, n; if (compound->type != GCOMPOUND) { error("remove: First argument is not a GCompound"); } contents = compound->u.compoundRep.contents; n = sizeVector(contents); for (i = 0; i < n; i++) { if (gobj == getVector(contents, i)) { removeVector(contents, i); break; } } removeOp(gobj); }
void splitWorkload2 (int range) { // find the index of the max index int maxti_index = find_max(); // Remove ops from workload1 and place to workload 2 while (1) { // The max ti in the workload is now less than the range. We are done if ( ti[maxti_index] <= range ) { break; } // remove the operation from the workload maxti_index = removeOp ( maxti_index ); } }
BtStatus handle_profile_connect(bt_addr_struct *bd_addr, PROFILE_enum id) { int state = PROFILE_STATE_DISCONNECTED; dev_op *devOp = getDeviceOpList(bd_addr); int dev_id = 0; if(devOp == NULL) { ALOGW("%s null devOp list!\n", __FUNCTION__); return BT_STATUS_FAILED; } ALOGI("%s addr:[0x%lX:0x%X:0x%X], profile[%d], old[%d]!\n", __FUNCTION__, bd_addr->lap, bd_addr->uap, bd_addr->nap, id, state); memcpy(&devOp->bd_addr, bd_addr, sizeof(bt_addr_struct)); if(isSingleConnection(id)) { for( dev_id = 0; dev_id < MAX_DEV_NUM; dev_id++ ) { if(!btmtk_util_equal_bdaddr(&g_dev_oplist[dev_id].bd_addr, bd_addr)) { removeOp(&g_dev_oplist[dev_id].bd_addr, id, PROFILE_OP_CONNECT); if((g_dev_state[dev_id].state[id] == PROFILE_STATE_CONNECTED) || (g_dev_state[dev_id].state[id] == PROFILE_STATE_CONNECTING)) { disconnect_profile_int(&g_dev_oplist[dev_id].bd_addr, id); } } } } state = getProfileState(bd_addr, id); if((state == PROFILE_STATE_DISCONNECTING) || isBusy(bd_addr)) { insertOp(bd_addr, id, PROFILE_OP_CONNECT); } else if(state == PROFILE_STATE_DISCONNECTED) { connect_profile_int(bd_addr, id); } memcpy(&g_cur_dev, bd_addr, sizeof(bt_addr_struct)); return BT_STATUS_SUCCESS; }
void notifyProfileStateChanged(bt_addr_struct *bd_addr, PROFILE_enum id, ProfileStatus state) { dev_op *devOp = getDeviceOpList(bd_addr); int old_state = getProfileState(bd_addr, id); int new_state = state; profile_op_queue_t *opCur = NULL; profile_op_queue_t *opNext = NULL; if(devOp == NULL) { return; } ALOGI("%s addr:[0x%lX:0x%X:0x%X], profile[%d], old[%d] ==> new[%d]!\n", __FUNCTION__, bd_addr->lap, bd_addr->uap, bd_addr->nap, id, old_state, new_state); setProfileState(bd_addr, id, new_state); if(isCurrentDevice(bd_addr)) { int state = PROFILE_STATE_DISCONNECTED; if(new_state == PROFILE_STATE_CONNECTED || new_state == PROFILE_STATE_DISCONNECTED) { setBusy(bd_addr, 0); if(!isEmpty((btmtk_list_header_struct **)&devOp->op_list)) { opCur = (profile_op_queue_t *)getHeader((btmtk_list_header_struct **)&devOp->op_list); if(opCur->node.op == PROFILE_OP_CONNECT) { state = getProfileState(bd_addr, opCur->node.profile_id); if(state == PROFILE_STATE_DISCONNECTED) connect_profile_int(bd_addr, opCur->node.profile_id); } else if(opCur->node.op == PROFILE_OP_DISCONNECT) { state = getProfileState(bd_addr, opCur->node.profile_id); if(state == PROFILE_STATE_CONNECTED) disconnect_profile_int(bd_addr, opCur->node.profile_id); else if(state == PROFILE_STATE_DISCONNECTED) { PROFILE_enum profile_id = opCur->node.profile_id; ProfileOpType profile_op = opCur->node.op; removeOp(bd_addr, profile_id, profile_op); notifyProfileStateChanged(bd_addr, profile_id, PROFILE_STATE_DISCONNECTED); return; } } removeOp(bd_addr, opCur->node.profile_id, opCur->node.op); } } } else { removeAll((btmtk_list_header_struct **)&devOp->op_list); if(new_state == PROFILE_STATE_CONNECTED || new_state == PROFILE_STATE_DISCONNECTED) { setBusy(bd_addr, 0); } } ProfileStateChangedCB(bd_addr, id, new_state); }