Exemplo n.º 1
0
MBOOL
FeatureStream::
queryGroupMember(
    MINT32 portIdx,
    MBOOL& beforeCRZ,
    android::Vector<MINT32>& vGroupPortIdx)
{
    FUNCTION_LOG_START;
    bool isGet=false;
    //default set the dma is before crz
    beforeCRZ=true;

    //parsing data
    for(int i=0;i<mCropPaths.size();i++)
    {
        //[1] check there is vipi in this scenario or not
        isGet=false;
        for(int j=0;j<mCropPaths[i].PortIdxVec.size();j++)
        {
            if(mCropPaths[i].PortIdxVec[j]== portIdx)
            {
                isGet=true;
            }
            else
            {}
            if(isGet)
            {
                break;
            }
        }

        //[2]add index of port in the same group
        if(isGet)
        {
            //update the dma position before/after crz
            if(mCropPaths[i].u4CropGroup != ECropGroupIndex_NONE)
            {
                beforeCRZ=false;
            }
            for(int j=0;j<mCropPaths[i].PortIdxVec.size();j++)
            {

                if((mCropPaths[i].PortIdxVec[j]== portIdx) || (portIdx == -1))
                {}
                else
                {
                    vGroupPortIdx.push_back(mCropPaths[i].PortIdxVec[j]);
                }
            }
            //suppose the dma should be only included in one group
            break;
        }
    }
    LOG_INF("return bcrz(%d)/size(%d)",beforeCRZ,vGroupPortIdx.size());
    FUNCTION_LOG_END;
    return true;
}
Exemplo n.º 2
0
MERROR
UsersManager::
MyUserGraph::
getInUsers(size_t userId, android::Vector<android::sp<MyUser> >& result) const
{
    result.clear();
    UserNode const& usr = mUserVector.valueFor(userId);
    for (size_t i = 0; i < usr.mIn.size(); i++)
    {
        result.add(mUserVector.valueFor(usr.mIn.itemAt(i)).mMyUser);
    }
    return OK;
}
bool CameraArea::areAreasDifferent(android::Vector< android::sp<CameraArea> > &area1,
                                    android::Vector< android::sp<CameraArea> > &area2) {
    if (area1.size() != area2.size()) {
        return true;
    }

    // not going to care about sorting order for now
    for (int i = 0; i < area1.size(); i++) {
        if (!area1.itemAt(i)->compare(area2.itemAt(i))) {
            return true;
        }
    }

    return false;
}
void assert_serialized_data(void* original, size_t length, android::Vector<char>& serialized) {
  ASSERT_EQ(length, serialized.size());
  for (size_t i = 0; i < length; i++) {
    auto actual = *((char*) original + i);
    ASSERT_EQ(actual, serialized[i]);
  }
}
int Fpc1020Sensor::getEnrolledIds(android::Vector<uint32_t>& ids)
{
    if (!isIdle()) {
        return -EINVAL;
    }

    ALOGV("getEnrolledIds()");
    int ret = activate(false);
    if (ret) {
        return ret;
    }

    ret = sendCommand(CLIENT_CMD_GET_IDS_LIST);
    if (ret == 0) {
        fingerprint_get_ids_list_rsp_t *resp =
                (fingerprint_get_ids_list_rsp_t *) mQseecom.getReceiveBuffer();
        ALOGD("getEnrolledIds(): result %d, count %d", resp->result, resp->count);

        if (resp->result == 0) {
            for (uint32_t i = 0; i < resp->count; i++) {
                ids.push_back(resp->ids[i]);
            }
        }
    }

    deactivate();

    return ret;
}
Exemplo n.º 6
0
MVOID
PipelineModelBase::
dump(
    android::Vector<android::String8>& rLogs,
    InfoIOMapSet const& rIOMapSet
) const
{
    rLogs.resize(rIOMapSet.mImageInfoIOMapSet.size() + rIOMapSet.mMetaInfoIOMapSet.size());
    android::Vector<android::String8>::iterator it = rLogs.begin();
    {
        typedef IImageStreamInfo IStreamInfoT;
        typedef InfoIOMapSet::ImageInfoIOMapSet MapSetT;
        MapSetT const& rSet = rIOMapSet.mImageInfoIOMapSet;
        for (size_t j = 0; j < rSet.size(); j++) {
            String8& str = *it++;
            //
            for (size_t k = 0; k < rSet[j].vIn.size(); k++) {
                IStreamInfoT* p = rSet[j].vIn[k].get();
                str += String8::format("%#"PRIxPTR":%s ", p->getStreamId(), p->getStreamName());
            }
            str += " -> ";
            for (size_t k = 0; k < rSet[j].vOut.size(); k++) {
                IStreamInfoT* p = rSet[j].vOut[k].get();
                str += String8::format("%#"PRIxPTR":%s ", p->getStreamId(), p->getStreamName());
            }
        }
    }
    //
    {
        typedef IMetaStreamInfo IStreamInfoT;
        typedef InfoIOMapSet::MetaInfoIOMapSet MapSetT;
        MapSetT const& rSet = rIOMapSet.mMetaInfoIOMapSet;
        for (size_t j = 0; j < rSet.size(); j++) {
            String8& str = *it++;
            //
            for (size_t k = 0; k < rSet[j].vIn.size(); k++) {
                IStreamInfoT* p = rSet[j].vIn[k].get();
                str += String8::format("%#"PRIxPTR":%s ", p->getStreamId(), p->getStreamName());
            }
            str += " -> ";
            for (size_t k = 0; k < rSet[j].vOut.size(); k++) {
                IStreamInfoT* p = rSet[j].vOut[k].get();
                str += String8::format("%#"PRIxPTR":%s ", p->getStreamId(), p->getStreamName());
            }
        }
    }
}
Exemplo n.º 7
0
MERROR
UsersManager::
MyUserGraph::
getPriorUsers(size_t userId, android::Vector<android::sp<MyUser> >& result) const
{
    result.clear();
    //
    //It also contains the current user.
    if(0 > DFS(userId, result))
    {
        return UNKNOWN_ERROR;
    }
    return OK;
}
Exemplo n.º 8
0
MERROR
UsersManager::
MyUserGraph::
DFS(size_t userId, android::Vector<android::sp<MyUser> >& result) const
{
    ssize_t const idx = mUserVector.indexOfKey(userId);
    for (size_t i = 0; i < mUserVector.valueAt(idx).mIn.size(); i++)
    {
        if  ( 0 > DFS(mUserVector.valueAt(idx).mIn.itemAt(i), result) )
        {
            return UNKNOWN_ERROR;
        }
    }
    result.add(mUserVector.valueAt(idx).mMyUser);
    return OK;
}
Exemplo n.º 9
0
MBOOL
NormalStream::
queryCropInfo(
    android::Vector<MCropPathInfo>& mvCropPathInfo)
{
    for(int i=0;i<mCropPaths.size();i++)
    {

        MCropPathInfo crop;
        crop.mGroupIdx=mCropPaths[i].u4CropGroup;
        for(int j=0;j<mCropPaths[i].PortIdxVec.size();j++)
        {
            crop.mvPorts.push_back(mCropPaths[i].PortIdxVec[j]);
        }
        mvCropPathInfo.push_back(crop);
    }
    return true;
}
Exemplo n.º 10
0
MBOOL
FeatureStream::
queryCropInfo(
    android::Vector<MCropPathInfo>& mvCropPathInfo)
{
    #if 0//CHRISTOPHER, do not need in current stage
    for(int i=0;i<mCropPaths.size();i++)
    {

        MCropPathInfo crop;
        crop.mGroupIdx=mCropPaths[i].u4CropGroup;
        for(int j=0;j<mCropPaths[i].PortIdxVec.size();j++)
        {
            crop.mvPorts.push_back(mCropPaths[i].PortIdxVec[j]);
        }
        mvCropPathInfo.push_back(crop);
    }
    #else
    LOG_ERR("do not support this function now");
    #endif
    return true;
}
android::status_t AesCtrDecryptor::decrypt(const android::Vector<uint8_t>& key,
        const Iv iv, const uint8_t* source,
        uint8_t* destination,
        const SubSample* subSamples,
        size_t numSubSamples,
        size_t* bytesDecryptedOut) {
    uint32_t blockOffset = 0;
    uint8_t previousEncryptedCounter[kBlockSize];
    memset(previousEncryptedCounter, 0, kBlockSize);

    size_t offset = 0;
    AES_KEY opensslKey;
    AES_set_encrypt_key(key.array(), kBlockBitCount, &opensslKey);
    Iv opensslIv;
    memcpy(opensslIv, iv, sizeof(opensslIv));

    for (size_t i = 0; i < numSubSamples; ++i) {
        const SubSample& subSample = subSamples[i];

        if (subSample.mNumBytesOfClearData > 0) {
            memcpy(destination + offset, source + offset,
                    subSample.mNumBytesOfClearData);
            offset += subSample.mNumBytesOfClearData;
        }

        if (subSample.mNumBytesOfEncryptedData > 0) {
            AES_ctr128_encrypt(source + offset, destination + offset,
                    subSample.mNumBytesOfEncryptedData, &opensslKey,
                    opensslIv, previousEncryptedCounter,
                    &blockOffset);
            offset += subSample.mNumBytesOfEncryptedData;
        }
    }

    *bytesDecryptedOut = offset;
    return android::OK;
}
status_t CameraArea::parseAreas(const char *area,
                                size_t areaLength,
                                android::Vector<android::sp<CameraArea> > &areas)
{
    status_t ret = NO_ERROR;
    char *ctx;
    char *pArea = NULL;
    char *pStart = NULL;
    char *pEnd = NULL;
    const char *startToken = "(";
    const char endToken = ')';
    const char sep = ',';
    ssize_t top, left, bottom, right, weight;
    char *tmpBuffer = NULL;
    android::sp<CameraArea> currentArea;

    LOG_FUNCTION_NAME

    if ( ( NULL == area ) ||
         ( 0 >= areaLength ) )
        {
        return -EINVAL;
        }

    tmpBuffer = ( char * ) malloc(areaLength);
    if ( NULL == tmpBuffer )
        {
        return -ENOMEM;
        }

    memcpy(tmpBuffer, area, areaLength);

    pArea = strtok_r(tmpBuffer, startToken, &ctx);

    do
        {

        pStart = pArea;
        if ( NULL == pStart )
            {
            CAMHAL_LOGEA("Parsing of the left area coordinate failed!");
            ret = -EINVAL;
            break;
            }
        else
            {
            left = static_cast<ssize_t>(strtol(pStart, &pEnd, 10));
            }

        if ( sep != *pEnd )
            {
            CAMHAL_LOGEA("Parsing of the top area coordinate failed!");
            ret = -EINVAL;
            break;
            }
        else
            {
            top = static_cast<ssize_t>(strtol(pEnd+1, &pEnd, 10));
            }

        if ( sep != *pEnd )
            {
            CAMHAL_LOGEA("Parsing of the right area coordinate failed!");
            ret = -EINVAL;
            break;
            }
        else
            {
            right = static_cast<ssize_t>(strtol(pEnd+1, &pEnd, 10));
            }

        if ( sep != *pEnd )
            {
            CAMHAL_LOGEA("Parsing of the bottom area coordinate failed!");
            ret = -EINVAL;
            break;
            }
        else
            {
            bottom = static_cast<ssize_t>(strtol(pEnd+1, &pEnd, 10));
            }

        if ( sep != *pEnd )
            {
            CAMHAL_LOGEA("Parsing of the weight area coordinate failed!");
            ret = -EINVAL;
            break;
            }
        else
            {
            weight = static_cast<ssize_t>(strtol(pEnd+1, &pEnd, 10));
            }

        if ( endToken != *pEnd )
            {
            CAMHAL_LOGEA("Malformed area!");
            ret = -EINVAL;
            break;
            }

        ret = checkArea(top, left, bottom, right, weight);
        if ( NO_ERROR != ret ) {
            break;
        }

        currentArea = new CameraArea(top, left, bottom, right, weight);
        CAMHAL_LOGDB("Area parsed [%dx%d, %dx%d] %d",
                     ( int ) top,
                     ( int ) left,
                     ( int ) bottom,
                     ( int ) right,
                     ( int ) weight);
        if ( NULL != currentArea.get() )
            {
            areas.add(currentArea);
            }
        else
            {
            ret = -ENOMEM;
            break;
            }

        pArea = strtok_r(NULL, startToken, &ctx);

        }
    while ( NULL != pArea );

    if ( NULL != tmpBuffer )
        {
        free(tmpBuffer);
        }

    LOG_FUNCTION_NAME_EXIT

    return ret;
}
Exemplo n.º 13
0
void CombinedModel::update(const android::Vector<android::ConfiguredStation>& update)
{
    QMutexLocker locker(&sWifiMutex);

    // Mark stations with a non-negative network id
    QListIterator<Station *> it(mStations);
    while (it.hasNext()) {
	Station *s = it.next();
	if (s->network_id != -1)
	    s->network_id = -2;
    }

    for (size_t i = 0 ; i < update.size() ; i++) {
	const android::ConfiguredStation& config(update[i]);
	Station *s = findBySsid(QString::fromLocal8Bit(config.ssid.string()));
	s->network_id = config.network_id;
	s->status     = static_cast<Station::Status>(config.status);
	s->key_mgmt   = Station::flagsToKeyMgmt(QString::fromLocal8Bit(config.key_mgmt.string()));
	s->pre_shared_key = config.pre_shared_key;
	int row = mStations.indexOf(s);
	emit dataChanged(createIndex(row, 0), createIndex(row, 0));
    }

    // Remove stations that didn't show up in the list and don't have scan results
    int row = 0;
    while (row < mStations.size()) {
	Station *s = mStations[row];
	if (s->network_id == -2) {
	    if (s->rssi != -9999) {
		s->network_id = -1;
		s->status = Station::UNKNOWN;
		row += 1;
	    }
	    else {
		beginRemoveRows(QModelIndex(), row, row);
		delete mStations.takeAt(row);
		endRemoveRows();
	    }
	}
	else {
	    row += 1;
	}
    }

    emit layoutAboutToBeChanged();
    QList<Station *> mOldList(mStations);
    qStableSort(mStations.begin(), mStations.end(), Station::lessThan);
    for (int row = 0 ; row < mStations.size() ; row++) {
	int old_row = mOldList.indexOf(mStations[row]);
	if (row != old_row)
	    changePersistentIndex(createIndex(old_row, 0), createIndex(row, 0));
    }
    emit layoutChanged();

    // qDebug() << " > After update, combined list is";
    // for (int row = 0 ; row < mStations.size() ; row++) {
    // 	Station *s = mStations[row];
    // 	qDebug("   id=%d ssid='%s' rssi=%d status=%d", s->network_id, 
    // 	       s->ssid.toLocal8Bit().constData(), s->rssi, s->status);
    // }
}
Exemplo n.º 14
0
void CombinedModel::update(const android::Vector<android::ScannedStation>& update)
{
    // qDebug() << "[" << Q_FUNC_INFO;
    QMutexLocker locker(&sWifiMutex);

    // Remove all current RSSI values
    QListIterator<Station *> it(mStations);
    while (it.hasNext()) {
	Station *s = it.next();
	s->rssi = -9999;
	s->station_count = 0;
    }

    for (size_t i = 0 ; i < update.size() ; i++) {
	const android::ScannedStation& scanned(update[i]);
	Station *s = findBySsid(QString::fromLocal8Bit(scanned.ssid.string()));
	QSet<int> changed;
	changed << CombinedModel::RssiRole << CombinedModel::SignalLevelRole << CombinedModel::StationCountRole;

	if (scanned.rssi > s->rssi) 
	    s->rssi = scanned.rssi;  // Might be more than one station

	if (s->frequency != scanned.frequency) {
	    s->frequency = scanned.frequency;
	    changed << CombinedModel::FrequencyRole;
	}

	if (s->flags != scanned.flags) {
	    s->flags = scanned.flags;
	    s->key_mgmt = Station::flagsToKeyMgmt(QString::fromLocal8Bit(scanned.flags.string()));
	    changed << CombinedModel::FlagsRole << CombinedModel::KeyMgmtRole;
	}
	
	s->station_count += 1;
	int row = mStations.indexOf(s);
	// qDebug() << " ...data changed row" << row;
	emit dataChanged(createIndex(row, 0), createIndex(row, 0), changed);
    }

    // Remove stations that didn't show up on the scan
    int row = 0;
    while (row < mStations.size()) {
	Station *s = mStations[row];
	if (s->rssi == -9999 && s->network_id == -1) {
	    beginRemoveRows(QModelIndex(), row, row);
	    delete mStations.takeAt(row);
	    // qDebug() << " ...remove row" << row;
	    endRemoveRows();
	}
	else {
	    row += 1;
	}
    }

    emit layoutAboutToBeChanged();
    QList<Station *> mOldList(mStations);
    qStableSort(mStations.begin(), mStations.end(), Station::lessThan);
    for (int row = 0 ; row < mStations.size() ; row++) {
	int old_row = mOldList.indexOf(mStations[row]);
	if (row != old_row) {
	    changePersistentIndex(createIndex(old_row, 0), createIndex(row, 0));
	    // qDebug() << " ...move row" << old_row << "to" << row;
	}
    }
    emit layoutChanged();

    // qDebug() << " > After scan update, combined list is";
    // for (int row = 0 ; row < mStations.size() ; row++) {
    // 	Station *s = mStations[row];
    // 	qDebug("   id=%d ssid='%s' rssi=%d status=%d", s->network_id, 
    // 	       s->ssid.toLocal8Bit().constData(), s->rssi, s->status);
    // }
}