ECode BluetoothLeScanner::StartTruncatedScan(
    /* [in] */ IList* truncatedFilters,
    /* [in] */ IScanSettings* settings,
    /* [in] */ IScanCallback* callback)
{
    Int32 filterSize;
    truncatedFilters->GetSize(&filterSize);
    //List<ScanFilter> scanFilters = new ArrayList<ScanFilter>(filterSize);
    AutoPtr<IList> scanFilters;
    CArrayList::New((IList**)&scanFilters);
    //List<List<ResultStorageDescriptor>> scanStorages =
    //        new ArrayList<List<ResultStorageDescriptor>>(filterSize);
    AutoPtr<IList> scanStorages;
    CArrayList::New((IList**)&scanStorages);
    //for (TruncatedFilter filter : truncatedFilters) {
    Int32 size;
    truncatedFilters->GetSize(&size);
    for (Int32 i = 0; i < size; ++i) {
        AutoPtr<IInterface> obj;
        truncatedFilters->Get(i, (IInterface**)&obj);
        ITruncatedFilter* filter = ITruncatedFilter::Probe(obj);
        AutoPtr<IScanFilter> scanFilter;
        filter->GetFilter((IScanFilter**)&scanFilter);
        scanFilters->Add(TO_IINTERFACE(scanFilters));
        AutoPtr<IList> list;
        filter->GetStorageDescriptors((IList**)&list);
        scanStorages->Add(TO_IINTERFACE(list));
    }
    StartScan(scanFilters, settings, callback, scanStorages);
    return NOERROR;
}
Exemple #2
0
int CTest::test_trimToSize_02(int argc, char* argv[])
{
    PEL("CTest::test_trimToSize_02")
    // ArrayList list = new ArrayList(Arrays.asList(new String[] { "a", "b", "c",
    //         "d", "e", "f", "g" }));
    Boolean isflag = FALSE;
    AutoPtr<IArrayList> list;
    CArrayList::New((IArrayList**)&list);
    AutoPtr<ICharSequence> csa;
    CString::New(String("a"), (ICharSequence**)&csa);
    AutoPtr<ICharSequence> csb;
    CString::New(String("b"), (ICharSequence**)&csb);
    AutoPtr<ICharSequence> csc;
    CString::New(String("c"), (ICharSequence**)&csc);
    AutoPtr<ICharSequence> csd;
    CString::New(String("d"), (ICharSequence**)&csd);
    AutoPtr<ICharSequence> cse;
    CString::New(String("e"), (ICharSequence**)&cse);
    AutoPtr<ICharSequence> csf;
    CString::New(String("f"), (ICharSequence**)&csf);
    AutoPtr<ICharSequence> csg;
    CString::New(String("g"), (ICharSequence**)&csg);
    list->Add(csa, &isflag);
    list->Add(csb, &isflag);
    list->Add(csc, &isflag);
    list->Add(csd, &isflag);
    list->Add(cse, &isflag);
    list->Add(csf, &isflag);
    list->Add(csg, &isflag);

    list->Remove(csa, &isflag);
    list->Remove(csf, &isflag);
    list->TrimToSize();
    return 0;
}
Exemple #3
0
int CTest::test_removeLjava_lang_Object(int argc, char* argv[])
{
    PEL("CTest::test_removeLjava_lang_Object")
    // List list = new ArrayList(Arrays.asList(new String[] { "a", "b", "c",
    //         "d", "e", "f", "g" }));
    Boolean isflag = FALSE;
    AutoPtr<IArrayList> list;
    CArrayList::New((IArrayList**)&list);
    AutoPtr<ICharSequence> csa;
    CString::New(String("a"), (ICharSequence**)&csa);
    AutoPtr<ICharSequence> csb;
    CString::New(String("b"), (ICharSequence**)&csb);
    AutoPtr<ICharSequence> csc;
    CString::New(String("c"), (ICharSequence**)&csc);
    AutoPtr<ICharSequence> csd;
    CString::New(String("d"), (ICharSequence**)&csd);
    AutoPtr<ICharSequence> cse;
    CString::New(String("e"), (ICharSequence**)&cse);
    AutoPtr<ICharSequence> csf;
    CString::New(String("f"), (ICharSequence**)&csf);
    AutoPtr<ICharSequence> csg;
    CString::New(String("g"), (ICharSequence**)&csg);
    list->Add(csa, &isflag);
    list->Add(csb, &isflag);
    list->Add(csc, &isflag);
    list->Add(csd, &isflag);
    list->Add(cse, &isflag);
    list->Add(csf, &isflag);
    list->Add(csg, &isflag);

    assert((list->Remove(csa, &isflag), isflag));
    assert((list->Remove(csf, &isflag), isflag));
    // String[] result = new String[5];
    AutoPtr< ArrayOf<IInterface*> > result = ArrayOf<IInterface*>::Alloc(5);
    AutoPtr< ArrayOf<IInterface*> > outarr;
    list->ToArrayEx(result, (ArrayOf<IInterface*>**)&outarr);
    String str[5] = {String("b"), String("c"), String("d"), String("e"), String("g") };
    for (int i = 0; i < 5; ++i) {
        AutoPtr<ICharSequence> res = (ICharSequence*) (*outarr)[i]->Probe(EIID_ICharSequence);
        if (res == NULL) {
            assert(0);
        }
        String outstr;
        res->ToString(&outstr);
        assert( outstr == str[i]);
    }
    // assertTrue("Removed wrong element 3", Arrays.equals(result, new String[] { "b", "c", "d", "e", "g" }));
    return 0;
}
ECode CActivityOne::UpdateListView()
{
    Slogger::D(TAG, "Update Wifi Displays, count: %d", mWifiDisplays ? mWifiDisplays->GetLength() : 0);

    if (mWifiDisplays == NULL || mWifiDisplays->GetLength() == 0) {
        mDisplayListView->SetAdapter(NULL);
        return NOERROR;
    }

    AutoPtr<IObjectContainer> dataList;
    CParcelableObjectContainer::New((IObjectContainer**)&dataList);

    String address, name;
    IWifiDisplay* display;
    for (Int32 i = 0; i < mWifiDisplays->GetLength(); ++i) {
        display = (*mWifiDisplays)[i];
        display->GetDeviceAddress(&address);
        display->GetDeviceName(&name);

        StringBuilder sb(name);
        sb += "=";
        sb += address;

        AutoPtr<ICharSequence> seq = sb.ToCharSequence();
        dataList->Add(seq->Probe(EIID_IInterface));
    }

    AutoPtr<IArrayAdapter> adapter;
    CArrayAdapter::New(this, R::layout::list_item, dataList, (IArrayAdapter**)&adapter);
    assert(adapter != NULL);
    mDisplayListView->SetAdapter(adapter.Get());
    return NOERROR;
}
AutoPtr<IEnumeration> CNamespaceSupport::Context::GetPrefixes ()
{
    if (mPrefixTable.IsEmpty()) {
        if (EMPTY_ENUMERATION == NULL) {
            EMPTY_ENUMERATION = InitEMPTY_ENUMERATION();
        }
        return EMPTY_ENUMERATION;
    }
    else {
        AutoPtr<IArrayList> prefixes;
        CArrayList::New((IArrayList**)&prefixes);

        HashMap<String, String>::Iterator iter = mPrefixTable.Begin();
        while (iter != mPrefixTable.End()) {
            AutoPtr<ICharSequence> csq;
            CString::New(iter->mFirst, (ICharSequence**)&csq);
            prefixes->Add(csq);
            iter++;
        }

        AutoPtr<IEnumeration> enu;
        Collections::Enumeration(ICollection::Probe(prefixes), (IEnumeration**)&enu);
        return enu;
    }
}
ECode CNamespaceSupport::GetPrefixes(
    /* [in] */ const String& uri,
    /* [out] */ IEnumeration** result)
{
    VALIDATE_NOT_NULL(result)

    AutoPtr<IArrayList> prefixes;
    CArrayList::New((IArrayList**)&prefixes);

    AutoPtr<IEnumeration> allPrefixes;
    GetPrefixes((IEnumeration**)&allPrefixes);

    Boolean hasMore;
    while (allPrefixes->HasMoreElements(&hasMore), hasMore) {
        AutoPtr<IInterface> obj;
        allPrefixes->GetNextElement((IInterface**)&obj);
        ICharSequence* seq =  ICharSequence::Probe(obj);
        String prefix, us;
        seq->ToString(&prefix);
        GetURI(prefix, &us);
        if (uri.Equals(us)) {
            AutoPtr<ICharSequence> csq;
            CString::New(prefix, (ICharSequence**)&csq);
            prefixes->Add(csq);
        }
    }

    *result = IEnumeration::Probe(prefixes);
    REFCOUNT_ADD(*result)

    return NOERROR;
}
AutoPtr<ArrayOf<IEncodedStringValue*> > EncodedStringValue::Extract(
    /* [in] */ const String& src)
{
    AutoPtr<ArrayOf<String> > values;
    StringUtils::Split(src, String(";"), (ArrayOf<String>**)&values);

    AutoPtr<IArrayList> list;
    CArrayList::New((IArrayList**)&list);
    for (Int32 i = 0; i < values->GetLength(); i++) {
        if ((*values)[i].GetLength() > 0) {
            AutoPtr<IEncodedStringValue> p;
            CEncodedStringValue::New((*values)[i], (IEncodedStringValue**)&p);
            list->Add(p);
        }
    }

    Int32 len = 0;
    list->GetSize(&len);
    if (len > 0) {
        AutoPtr<ArrayOf<IEncodedStringValue*> > arr = ArrayOf<IEncodedStringValue*>::Alloc(len);
        AutoPtr<ArrayOf<IInterface*> > res;
        list->ToArray((ArrayOf<IInterface*>*)arr.Get(), (ArrayOf<IInterface*>**)&res);
        return (ArrayOf<IEncodedStringValue*>*)res.Get();
    }
    else {
        return NULL;
    }
}
ECode RegisteredServicesCache::GetAllServices(
    /* [in] */ Int32 userId,
    /* [out] */ IList** list)
{
    VALIDATE_NOT_NULL(list)

    AutoLock lock(mServicesLock);
    // Find user and lazily populate cache
    AutoPtr<UserServices> user = FindOrCreateUserLocked(userId);
    if (user->mServices == NULL) {
        GenerateServicesMap(userId);
    }

    AutoPtr<IArrayList> infos;
    CArrayList::New((IArrayList**)&infos);

    HashMap<AutoPtr<IInterface>, AutoPtr<IRegisteredServicesCacheServiceInfo> >::Iterator itr = user->mServices->Begin();
    for (; itr != user->mServices->End(); ++itr) {
        infos->Add(TO_IINTERFACE(itr->mSecond));
    }

    *list = IList::Probe(infos);
    REFCOUNT_ADD(*list)
    return NOERROR;
}
Exemple #9
0
ECode LinkProperties::GetAllAddresses(
    /* [out] */ IList** result)
{
    VALIDATE_NOT_NULL(result)

    AutoPtr<IList> addresses;
    CArrayList::New((IList**)&addresses);
    AutoPtr<IIterator> it;
    mLinkAddresses->GetIterator((IIterator**)&it);
    Boolean hasNext;
    while (it->HasNext(&hasNext), hasNext) {
        AutoPtr<IInterface> obj;
        it->GetNext((IInterface**)&obj);
        AutoPtr<IInetAddress> address;
        ILinkAddress::Probe(obj)->GetAddress((IInetAddress**)&address);
        addresses->Add(address);
    }
    AutoPtr<ICollection> links;
    mStackedLinks->GetValues((ICollection**)&links);
    it = NULL;
    links->GetIterator((IIterator**)&it);
    while (it->HasNext(&hasNext), hasNext) {
        AutoPtr<IInterface> obj;
        it->GetNext((IInterface**)&obj);
        AutoPtr<IList> allAddresses;
        ILinkProperties::Probe(obj)->GetAllAddresses((IList**)&allAddresses);
        addresses->AddAll(ICollection::Probe(allAddresses));
    }
    *result = addresses;
    REFCOUNT_ADD(*result)
    return NOERROR;
}
ECode CAccessibleDateAnimator::DispatchPopulateAccessibilityEvent(
    /* [in] */ IAccessibilityEvent* event,
    /* [out] */ Boolean* result)
{
    VALIDATE_NOT_NULL(result);
    Int32 type = 0;
    event->GetEventType(&type);
    if (type == IAccessibilityEvent::TYPE_WINDOW_STATE_CHANGED) {
        // Clear the event's current text so that only the current date will be spoken.
        AutoPtr<IList> list;
        IAccessibilityRecord::Probe(event)->GetText((IList**)&list);
        list->Clear();
        Int32 flags = IDateUtils::FORMAT_SHOW_DATE | IDateUtils::FORMAT_SHOW_YEAR |
                IDateUtils::FORMAT_SHOW_WEEKDAY;

        AutoPtr<IContext> context;
        GetContext((IContext**)&context);
        String dateString = DateUtils::FormatDateTime(context, mDateMillis, flags);
        AutoPtr<ICharSequence> seq;
        CString::New(dateString, (ICharSequence**)&seq);
        list->Add(seq);
        *result = TRUE;
        return NOERROR;
    }
    return ViewAnimator::DispatchPopulateAccessibilityEvent(event, result);
}
Exemple #11
0
ECode CActivityOne::OnCreate(
    /* [in] */ IBundle* savedInstanceState)
{
    Activity::OnCreate(savedInstanceState);
    PRINT_ENTER_LEAVE("CActivityOne::OnCreate");
    SetContentView(R::layout::main);
    AutoPtr<IObjectContainer> dataList;
    CParcelableObjectContainer::New((IObjectContainer**)&dataList);
    for (Int32 i = 0; i < 2; ++i) {
        StringBuilder sb("测试 ");
        sb += i;
        AutoPtr<ICharSequence> seq = sb.ToCharSequence();
        dataList->Add(seq.Get());
    }

    AutoPtr<IArrayAdapter> adapter;
    CArrayAdapter::New(this, R::layout::list_item, dataList, (IArrayAdapter**)&adapter);
    assert(adapter != NULL);
    AutoPtr<IView> temp = FindViewById(R::id::autoCompleteTextView1);
    mView = IAutoCompleteTextView::Probe(temp);
    AutoPtr<IListAdapter> tempAdapter = IListAdapter::Probe(adapter.Get());
    mView->SetAdapter(tempAdapter);
    AutoPtr<IViewOnFocusChangeListener> li = new FocusChange(this);
    //mView->SetOnFocusChangeListener(li);
    return NOERROR;
}
ECode OpenSSLX509Certificate::FromPkcs7PemInputStream(
    /* [in] */ IInputStream* is,
    /* [out] */ IList** result)
{
    VALIDATE_NOT_NULL(result)
    AutoPtr<IOpenSSLBIOInputStream> bis;
    COpenSSLBIOInputStream::New(is, (IOpenSSLBIOInputStream**)&bis);

    AutoPtr<ArrayOf<Int64> > certRefs;
    // try {
        Int64 context = 0;
        bis->GetBioContext(&context);
        NativeCrypto::PEM_read_bio_PKCS7(context,
                INativeCrypto::PKCS7_CERTS, (ArrayOf<Int64>**)&certRefs);
    // } catch (Exception e) {
    //     throw new ParsingException(e);
    // } finally {
        bis->Release();
    // }

    AutoPtr<IList> certs;
    CArrayList::New(
            certRefs->GetLength(), (IList**)&certs);
    for (Int32 i = 0; i < certRefs->GetLength(); i++) {
        if ((*certRefs)[i] == 0) {
            continue;
        }
        AutoPtr<IOpenSSLX509Certificate> p;
        COpenSSLX509Certificate::New((*certRefs)[i], (IOpenSSLX509Certificate**)&p);
        certs->Add(p);
    }
    *result = certs;
    REFCOUNT_ADD(*result)
    return NOERROR;
}
Exemple #13
0
int CTest::testIPv6(int argc, char* argv[])
{
    AutoPtr<INetworkInterfaceHelper> help;
    CNetworkInterfaceHelper::AcquireSingleton((INetworkInterfaceHelper**)&help);
    AutoPtr<INetworkInterface> lo;
    help->GetByName(String("lo"), (INetworkInterface**)&lo);
    AutoPtr<IEnumeration> enu;
    lo->GetInetAddresses((IEnumeration**)&enu);
    AutoPtr<IArrayList> al;
    CArrayList::New((IArrayList**)&al);
    Boolean hasNext;
    while (enu->HasMoreElements(&hasNext), hasNext) {
        AutoPtr<IInterface> p;
        enu->NextElement((IInterface**)&p);
        Boolean b;
        al->Add(p, &b);
    }

    AutoPtr<ISet> actual;
    CHashSet::New((ICollection*)al, (ISet**)&actual);

    AutoPtr<ISet> expected;
    CHashSet::New((ISet**)&expected);
    Boolean b = FALSE;
    AutoPtr<IInet4AddressHelper> net4Hlp;
    CInet4AddressHelper::AcquireSingleton((IInet4AddressHelper**)&net4Hlp);
    AutoPtr<IInetAddress> loopback;
    net4Hlp->GetLOOPBACK((IInetAddress**)&loopback);
    expected->Add(loopback, &b);
    AutoPtr<IInet6AddressHelper> net6Hlp;
    CInet6AddressHelper::AcquireSingleton((IInet6AddressHelper**)&net6Hlp);
    AutoPtr<ArrayOf<Byte> > arr = ArrayOf<Byte>::Alloc(16);
    for (int i = 0; i < 15; ++i)
    {
        arr->Set(i, 0);
    }
    arr->Set(15, 1);
    AutoPtr<IInet6Address> addr;
    net6Hlp->GetByAddressEx(String("localhost"), arr, NULL, (IInet6Address**)&addr);
    expected->Add(addr, &b);

    expected->Equals(actual, &b);
    assert(b);
    return 0;
}
AutoPtr< ArrayOf<String> > AbstractVerifier::GetDNSSubjectAlts(
    /* [in] */ IX509Certificate* cert)
{
    AutoPtr<ILinkedList> subjectAltList;
    CLinkedList::New((ILinkedList**)&subjectAltList);
    AutoPtr<ICollection> subjectAltCol = ICollection::Probe(subjectAltList);
    AutoPtr<ICollection> c;
    // try {
    if (FAILED(cert->GetSubjectAlternativeNames((ICollection**)&c))) {
        Logger::E("AbstractVerifier", "Error parsing certificate.");
    }
    // }
    // catch(CertificateParsingException cpe) {
    //     Logger.getLogger(AbstractVerifier.class.getName())
    //             .log(Level.FINE, "Error parsing certificate.", cpe);
    // }
    if(c != NULL) {
        AutoPtr<IIterable> iterable = IIterable::Probe(c);
        AutoPtr<IIterator> it;
        iterable->GetIterator((IIterator**)&it);
        Boolean hasNext;
        while (it->HasNext(&hasNext), hasNext) {
            AutoPtr<IList> aC;
            it->GetNext((IInterface**)&aC);
            AutoPtr<IInteger32> value;
            aC->Get(0, (IInterface**)&value);
            Int32 type;
            value->GetValue(&type);
            // If type is 2, then we've got a dNSName
            if (type == 2) {
                AutoPtr<ICharSequence> cs;
                aC->Get(1, (IInterface**)&cs);
                subjectAltCol->Add(cs);
            }
        }
    }
    Boolean isEmpty;
    if(subjectAltList->IsEmpty(&isEmpty), !isEmpty) {
        Int32 size;
        subjectAltCol->GetSize(&size);
        AutoPtr< ArrayOf<String> > subjectAlts = ArrayOf<String>::Alloc(size);
        AutoPtr< ArrayOf<IInterface*> > array;
        subjectAltCol->ToArray((ArrayOf<IInterface*>**)&array);
        for (Int32 i = 0; i < array->GetLength(); ++i) {
            AutoPtr<ICharSequence> cs = ICharSequence::Probe((*array)[i]);
            String str;
            cs->ToString(&str);
            (*subjectAlts)[i] = str;
        }
        return subjectAlts;
    }
    else {
        return NULL;
    }
}
AutoPtr<IObjectContainer> ActivityChooserModel::TransfromList(
        /* [in] */ List<AutoPtr<T> >& list)
{
    AutoPtr<IObjectContainer> container;
    CObjectContainer::New((IObjectContainer**)&container);
    typename List<AutoPtr<T> >::Iterator it = list.Begin();
    for(; it != list.End(); it++)
    {
        container->Add(*it);
    }
    return container;
}
Exemple #16
0
Boolean AwHashSet::Add(
    /* [in] */ IInterface* obj,
    /* [in] */ IInterface* p0)
{
    AutoPtr<ISet> mObj = ISet::Probe(obj);
    if (NULL == mObj)
    {
        Logger::E("AwHashSet", "AwHashSet::Add, mObj is NULL");
        return FALSE;
    }
    return mObj->Add(p0);
}
Exemple #17
0
int CTest::test_trimToSize_01(int argc, char* argv[])
{
    PEL("CTest::test_trimToSize_01")
    // Test for method void java.util.ArrayList.trimToSize()
    Boolean isflag = FALSE;
    AutoPtr<IInterface> outface;
    for (int i = 99; i > 24; i--) {
        alist->RemoveEx(i, (IInterface**)&outface);
    }
    alist->TrimToSize();
    Int32 sizelen  = 0;
    assert(25 == (alist->GetSize(&sizelen), sizelen));
    for (int i = 0; i < (alist->GetSize(&sizelen), sizelen); i++) {
        assert((alist->Get(i, (IInterface**)&outface), outface) == (*objArray)[i]);
    }
    AutoPtr<IVector> v;
    CVector::New((IVector**)&v);
    AutoPtr<ICharSequence> csa;
    CString::New(String("a"), (ICharSequence**)&csa);
    v->Add(csa, &isflag);

    AutoPtr<ICharSequence> csb;
    CString::New(String("b"), (ICharSequence**)&csb);
    v->Add(csb, &isflag);
    AutoPtr<IArrayList> al;
    CArrayList::New(v, (IArrayList**)&al);
    AutoPtr<IIterator> it;
    al->GetIterator((IIterator**)&it);
    al->Remove(0, &isflag);
    al->TrimToSize();
    // try {
    ECode ec = it->Next((IInterface**)&outface);
    if (ec != NOERROR) {
        printf("should throw a ConcurrentModificationException\n");
    }
    // } catch (ConcurrentModificationException ioobe) {
    //     // expected
    // }
    return 0;
}
Exemple #18
0
int CTest::test_caseInsensitiveButCasePreserving(int argc, char* argv[])
{
    AutoPtr<IRawHeaders> h;
    CRawHeaders::New((IRawHeaders**)&h);
    String str0("Content-Type");
    String str1("text/plain");
    h->Add(str0, str1);
    // Case-insensitive:
    String strOut;
    h->Get(str0, &strOut);
    Boolean flag = strOut.Equals(str1);
    assert(flag == TRUE);

    String str2("Content-type");
    h->Get(str2, &strOut);
    flag = strOut.Equals(str1);
    assert(flag == TRUE);

    String str3("content-type");
    h->Get(str3, &strOut);
    flag = strOut.Equals(str1);
    assert(flag == TRUE);

    String str4("CONTENT-TYPE");
    h->Get(str4, &strOut);
    flag = strOut.Equals(str1);
    assert(flag == TRUE);

    // ...but case-preserving:
    AutoPtr<IMap> innerMap;
    h->ToMultimap((IMap**)&innerMap);
    AutoPtr<ISet> keyset;
    innerMap->KeySet((ISet**)&keyset);
    AutoPtr<ArrayOf<IInterface*> > array;
    keyset->ToArray((ArrayOf<IInterface*>**)&array);
    AutoPtr<ICharSequence> cs = (ICharSequence*)ICharSequence::Probe((*array)[0]);
    String str5(String("Content-Type"));
    cs->ToString(&strOut);
    flag = strOut.Equals(str5);
    assert(flag == TRUE);

    // We differ from the RI in that the Map we return is also case-insensitive.
    // Our behavior seems more consistent. (And code that works on the RI will work on Android.)
    // AutoPtr<ICharSequence> cs1;
    // CString::New(String("Content-Type"), (ICharSequence**)&cs1);
    // AutoPtr<IInterface> value;
    // innerMap->Get(cs1, (IInterface**)&value);
    // assertEquals(Arrays.asList("text/plain"), h.toMultimap().get("Content-Type"));
    // assertEquals(Arrays.asList("text/plain"), h.toMultimap().get("Content-type")); // RI fails this.
}
ECode ActionMenuItemView::OnPopulateAccessibilityEvent(
    /* [in] */ IAccessibilityEvent* event)
{
    FAIL_RETURN(TextView::OnPopulateAccessibilityEvent(event))
    AutoPtr<ICharSequence> cdesc;
    GetContentDescription((ICharSequence**)&cdesc);
    if (!TextUtils::IsEmpty(cdesc)) {
        AutoPtr<IList> texts;
        IAccessibilityRecord::Probe(event)->GetText((IList**)&texts);
        assert(texts != NULL);
        texts->Add(cdesc);
    }

    return NOERROR;
}
Exemple #20
0
ECode CMediaController::CallbackStub::OnUpdateNowPlayingEntries(
    /* [in] */ ArrayOf<Int64>* playList)
{
    Logger::D(TAG, "CallBackStub: onUpdateNowPlayingEntries");
    if (mController != NULL) {
        AutoPtr<IList> listTmp;
        CArrayList::New((IList**)&listTmp);
        for (Int32 idx=0; idx<playList->GetLength(); ++idx) {
            AutoPtr<IInteger64> intTmp = CoreUtils::Convert((*playList)[idx]);
            listTmp->Add(TO_IINTERFACE(intTmp));
        }
        mController->PostMessage(MSG_UPDATE_NOWPLAYING_ENTRIES, TO_IINTERFACE(listTmp), NULL);
    }
    return NOERROR;
}
ECode CRestoreObserverWrapper::RestoreSetsAvailable(
    /* [in] */ ArrayOf<IRestoreSet*>* result)
{
    AutoPtr<IObjectContainer> container;
    if (result != NULL) {
        CObjectContainer::New((IObjectContainer**)&container);
        for (Int32 i = 0; i < result->GetLength(); ++i) {
            container->Add((*result)[i]);
        }
    }
    AutoPtr<IMessage> msg;
    mHandler->ObtainMessage(MSG_RESTORE_SETS_AVAILABLE, container, (IMessage**)&msg);
    Boolean r;
    return  mHandler->SendMessage(msg, &r);
}
AutoPtr<ISimpleAdapter> CBrowserActivity::GetSimpleAdapter()
{
    Logger::D(TAG, "GetSimpleAdapter()---");
    AutoPtr<ISimpleAdapter> simpleAdapter;
    if (!mPictureEntryList.IsEmpty()) {
        Logger::D(TAG, "GetSimpleAdapter()---PictureEntry count: %d", mPictureEntryList.GetSize());
        AutoPtr<IObjectContainer> dataList;
        CParcelableObjectContainer::New((IObjectContainer**)&dataList);

        AutoPtr<PictureEntry> entry;
        String key1("image");
        String key2("checkbox");
        String key3("thumbLayout");

        List< AutoPtr<PictureEntry> >::Iterator it = mPictureEntryList.Begin();
        for (; it != mPictureEntryList.End(); ++it) {
            entry = *it;
            AutoPtr<IObjectStringMap> map;
            CObjectStringMap::New((IObjectStringMap**)&map);
            AutoPtr<IFile> file;
            CFile::New(entry->sourcePath, (IFile**)&file);
            Int64 last = 0;
            file->LastModified(&last);
            Logger::D(TAG, "GetSimpleAdapter()---sort--last:%lld,--path:%s", last, entry->sourcePath.string());
            AutoPtr<ICharSequence> cs;
            CStringWrapper::New(entry->sourcePath, (ICharSequence**)&cs);
            map->Put(key1, cs->Probe(EIID_ICharSequence));
            AutoPtr<IBoolean> boolValue;
            CBoolean::New(FALSE, (IBoolean**)&boolValue);
            map->Put(key2, boolValue->Probe(EIID_IBoolean));
            dataList->Add(map);
        }

        AutoPtr< ArrayOf<String> > from = ArrayOf<String>::Alloc(3);
        (*from)[0] = key1;
        (*from)[1] = key2;
        (*from)[2] = key3;
        AutoPtr< ArrayOf<Int32> > to = ArrayOf<Int32>::Alloc(3);
        (*to)[0] = R::id::pic_thumb;
        (*to)[1] = R::id::pic_check;
        (*to)[2] = R::id::pic_thumb_layout;
        CSimpleAdapter::New(this, dataList, R::layout::pic_item, from, to, (ISimpleAdapter**)&simpleAdapter);
        AutoPtr<MyViewBinder> myViewBinder = new MyViewBinder(this);
        simpleAdapter->SetViewBinder(ISimpleAdapterViewBinder::Probe(myViewBinder));
    }

    return simpleAdapter;
}
ECode CLinkProperties::GetRoutes(
    /* [out] */ IObjectContainer** result)
{
    VALIDATE_NOT_NULL(result);
    *result = NULL;
    AutoPtr<IObjectContainer> out;
    FAIL_RETURN(CParcelableObjectContainer::New((IObjectContainer**)&out));

    List< AutoPtr<IRouteInfo> >::Iterator iter;
    for (iter = mRoutes.Begin(); iter != mRoutes.End(); ++iter) {
        out->Add(*iter);
    }
    *result = out.Get();
    REFCOUNT_ADD(*result);
    return NOERROR;
}
ECode CGestureStore::GetGestureEntries(
    /* [out] */ IObjectContainer **entries)
{
    VALIDATE_NOT_NULL(entries);

    AutoPtr<IObjectContainer> container;
    HashMap<String, AutoPtr<GestureList> >::Iterator iter = mNamedGestures.Begin();
    for (; iter != mNamedGestures.End(); ++iter) {
        AutoPtr<ICharSequence> keystr = NULL;
        CString::New(iter->mFirst, (ICharSequence**)&keystr);
        container->Add(keystr);

    }
    *entries = container;
    REFCOUNT_ADD(*entries);
    return NOERROR;
}
ECode CApplicationThread::DispatchPackageBroadcast(
    /* [in] */ Int32 cmd,
    /* [in] */ ArrayOf<String>* packages)
{
    AutoPtr<IObjectContainer> container;
    if (packages != NULL) {
        CObjectContainer::New((IObjectContainer**)&container);
        for (Int32 i = 0; i < packages->GetLength(); ++i) {
            AutoPtr<ICharSequence> seq;
            CStringWrapper::New((*packages)[i], (ICharSequence**)&seq);
            container->Add(seq);
        }
    }

    return mAThread->QueueOrSendMessage(CActivityThread::H::DISPATCH_PACKAGE_BROADCAST,
        container, cmd);
}
Exemple #26
0
AutoPtr<IArrayList> VoiceInteractor::MakeRequestList()
{
    Int32 N = mActiveRequests.GetSize();
    if (N < 1) {
        return NULL;
    }

    AutoPtr<IArrayList> list;
    CArrayList::New(N, (IArrayList**)&list);

    HashMap<AutoPtr<IBinder>, AutoPtr<IVoiceInteractorRequest> >::Iterator it;
    for (it = mActiveRequests.Begin(); it != mActiveRequests.End(); ++it) {
        list->Add(it->mSecond.Get());
    }

    return list;
}
ECode DatePicker::OnPopulateAccessibilityEvent(
    /* [in] */ IAccessibilityEvent* event)
{
    FrameLayout::OnPopulateAccessibilityEvent(event);
    const Int32 flags = IDateUtils::FORMAT_SHOW_TIME | IDateUtils::FORMAT_SHOW_YEAR;
    AutoPtr<IDateUtils> dateUtils;
    Int64 timeInMillis = 0;
    mCurrentDate->GetTimeInMillis(&timeInMillis);
    String selectedDateUtterance = DateUtils::FormatDateTime(mContext, timeInMillis, flags);
    AutoPtr<IObjectContainer> container;
    event->GetText((IObjectContainer**)&container);

    AutoPtr<ICharSequence> seq;
    FAIL_RETURN(CStringWrapper::New(selectedDateUtterance, (ICharSequence**)&seq));
    container->Add(seq);
    return NOERROR;
}
Exemple #28
0
int CTest::test_Constructor(int argc, char* argv[])
{
    PEL("CTest::test_Constructor")
    // Test for method java.util.ArrayList()
    // new Support_ListTest("", alist).runTest();

    AutoPtr<IArrayList> subList;
    CArrayList::New((IArrayList**)&subList);
    for (int i = -50; i < 150; i++) {
        AutoPtr<IInteger32> intface;
        CInteger32::New(i, (IInteger32**)&intface);
        Boolean isflag =  FALSE;
        subList->Add(intface, &isflag);
    }
    // new Support_ListTest("", subList.subList(50, 150)).runTest();
    return 0;
}
ECode GestureStroke::Deserialize(
    /* [in] */ IDataInputStream *in,
    /* [out] */ IGestureStroke **stroke)
{
    VALIDATE_NOT_NULL(stroke);

    // Number of points
    Int32 count = 0;
    IDataInput::Probe(in)->ReadInt32(&count);

    AutoPtr<IArrayList> points;
    for (Int32 i = 0; i < count; i++) {
        AutoPtr<IGesturePoint> point = CGesturePoint::Deserialize(in);
        points->Add((IGesturePoint*)point);
    }
    CGestureStroke::New(points, stroke);
    return NOERROR;
}
ECode CLinkProperties::GetAddresses(
    /* [out] */ IObjectContainer** result)
{
    VALIDATE_NOT_NULL(result);
    *result = NULL;
    AutoPtr<IObjectContainer> addresses;
    FAIL_RETURN(CParcelableObjectContainer::New((IObjectContainer**)&addresses));

    List< AutoPtr<ILinkAddress> >::Iterator iter;
    for (iter = mLinkAddresses.Begin(); iter != mLinkAddresses.End(); ++iter) {
        AutoPtr<IInetAddress> InetAddr;
        (*iter)->GetAddress((IInetAddress**)&InetAddr);
        addresses->Add(InetAddr);
    }
    *result = addresses.Get();
    REFCOUNT_ADD(*result);
    return NOERROR;
}