Example #1
0
AutoPtr<ITimeZone> TimeZone::GetDefault()
{
    if (sDefaultTimeZone == NULL) {
        AutoPtr<ITimeZoneGetter> tzGetter = TimeZoneGetter::GetInstance();
        String zoneName;
        if (tzGetter != NULL) {
            tzGetter->GetId(&zoneName);
        }
        if (!zoneName.IsNull()) {
            zoneName = zoneName.Trim();
        }
        if (!zoneName.IsNull() || zoneName.IsEmpty()) {
            // try {
                // On the host, we can find the configured timezone here.
            ECode ec = IoUtils::ReadFileAsString(String("/etc/timezone"), &zoneName);
            // } catch (IOException ex) {
                // "vogar --mode device" can end up here.
                // TODO: give libcore access to Android system properties and read "persist.sys.timezone".
            if (FAILED(ec)) {
                zoneName = String("GMT");
            }
            // }
        }
        TimeZone::GetTimeZone(zoneName, (ITimeZone**)&sDefaultTimeZone);
    }

    AutoPtr<ITimeZone> tz;
    sDefaultTimeZone->Clone((ITimeZone**)&tz);
    return tz;
}
Int64 DateIntervalFormat::CreateDateIntervalFormat(
    /* [in] */ const String& skeleton,
    /* [in] */ const String& localeName,
    /* [in] */ const String& tzName)
{
    if (localeName == NULL) {
        return 0;
    }
    NATIVE(Locale) icuLocale;
    icuLocale.setToBogus();
    icuLocale = NATIVE(Locale)::createFromName(localeName);
    if (icuLocale.isBogus()) {
        return 0;
    }

    if (skeleton.IsNull()) {
        return 0;
    }

    UErrorCode status = U_ZERO_ERROR;
    NATIVE(DateIntervalFormat)* formatter(NATIVE(DateIntervalFormat)::createInstance(UnicodeString::fromUTF8(skeleton.string()), icuLocale, status));
    if (!U_SUCCESS(status)) {
        return 0;
    }

    if (tzName.IsNull()) {
        return 0;
    }
    formatter->adoptTimeZone(NATIVE(TimeZone)::createTimeZone(UnicodeString::fromUTF8(tzName.string())));

    return reinterpret_cast<uintptr_t>(formatter);
}
Example #3
0
ECode CKXmlSerializer::SetPrefix(
    /* [in] */ const String& _prefix,
    /* [in] */ const String& _ns)
{
    String prefix = _prefix;
    String ns = _ns;
    FAIL_RETURN(Check(FALSE));
    if (prefix.IsNull()) {
        prefix = "";
    }
    if (ns.IsNull()) {
        ns = "";
    }

    String def;
    FAIL_RETURN(GetPrefix(ns, TRUE, FALSE, &def));

    // boil out if already defined

    if (prefix.Equals(def)) {
        return NOERROR;
    }

    Int32 pos = ((*mNspCounts)[mDepth + 1]++) << 1;

    if (mNspStack->GetLength() < pos + 1) {
        AutoPtr<ArrayOf<String> > hlp = ArrayOf<String>::Alloc(mNspStack->GetLength() + 16);
        hlp->Copy(mNspStack, pos);
        mNspStack = hlp;
    }

    (*mNspStack)[pos++] = prefix;
    (*mNspStack)[pos] = ns;
    return NOERROR;
}
ECode CAuthenticatorDescription::constructor(
    /* [in] */ const String& type,
    /* [in] */ const String& packageName,
    /* [in] */ Int32 labelId,
    /* [in] */ Int32 iconId,
    /* [in] */ Int32 smallIconId,
    /* [in] */ Int32 prefId,
    /* [in] */ Boolean customTokens)
{
    if (type.IsNull()) {
        Slogger::E(TAG, "type cannot be null");
        return E_ILLEGAL_ARGUMENT_EXCEPTION;
        // throw new IllegalArgumentException("type cannot be null");
    }
    if (packageName.IsNull())  {
        Slogger::E(TAG, "packageName cannot be null");
        return E_ILLEGAL_ARGUMENT_EXCEPTION;
        // throw new IllegalArgumentException("packageName cannot be null");
    }
    mType = type;
    mPackageName = packageName;
    mLabelId = labelId;
    mIconId = iconId;
    mSmallIconId = smallIconId;
    mAccountPreferencesId = prefId;
    mCustomTokens = customTokens;
    return NOERROR;
}
Example #5
0
ECode CKXmlSerializer::WriteStartTag(
    /* [in] */ const String& ns,
    /* [in] */ const String& name)
{
    FAIL_RETURN(Check(FALSE));

    //        if (namespace == null)
    //            namespace = "";

    if ((*mIndent)[mDepth]) {
        FAIL_RETURN(IWriter::Probe(mWriter)->Write(String("\r\n")));
        for (Int32 i = 0; i < mDepth; i++) {
            FAIL_RETURN(IWriter::Probe(mWriter)->Write(String("  ")));
        }
    }

    Int32 esp = mDepth * 3;

    if (mElementStack->GetLength() < esp + 3) {
        AutoPtr<ArrayOf<String> > hlp = ArrayOf<String>::Alloc(mElementStack->GetLength() + 12);
        hlp->Copy(mNspStack, esp);
        mElementStack = hlp;
    }

    String prefix("");
    if (!ns.IsNull()) {
        FAIL_RETURN(GetPrefix(ns, TRUE, TRUE, &prefix));
    }

    if (!ns.IsNull() && ns.IsEmpty()) {
        for (Int32 i = (*mNspCounts)[mDepth]; i < (*mNspCounts)[mDepth + 1]; i++) {
            if ((*mNspStack)[i * 2].IsEmpty() && !(*mNspStack)[i * 2 + 1].IsEmpty()) {
//                throw new IllegalStateException("Cannot set default namespace for elements in no namespace");
                return E_ILLEGAL_STATE_EXCEPTION;
            }
        }
    }

    (*mElementStack)[esp++] = ns;
    (*mElementStack)[esp++] = prefix;
    (*mElementStack)[esp] = name;

    FAIL_RETURN(IWriter::Probe(mWriter)->Write('<'));
    if (!prefix.IsEmpty()) {
        FAIL_RETURN(IWriter::Probe(mWriter)->Write(prefix));
        FAIL_RETURN(IWriter::Probe(mWriter)->Write(':'));
    }

    FAIL_RETURN(IWriter::Probe(mWriter)->Write(name));

    mPending = TRUE;

    return NOERROR;
}
Example #6
0
ECode CKXmlSerializer::StartDocument(
    /* [in] */ const String& encoding,
    /* [in] */ Boolean standalone)
{
    FAIL_RETURN(IWriter::Probe(mWriter)->Write(String("<?xml version='1.0' ")));

    if (!encoding.IsNull()) {
        mEncoding = encoding;
        if (encoding.StartWithIgnoreCase("utf")) { /*encoding.ToLowerCase(Locale.US).StartWith("utf")*/
            mUnicode = TRUE;
        }
    }

    if (!mEncoding.IsNull()) {
        FAIL_RETURN(IWriter::Probe(mWriter)->Write(String("encoding='")));
        FAIL_RETURN(IWriter::Probe(mWriter)->Write(mEncoding));
        FAIL_RETURN(IWriter::Probe(mWriter)->Write(String("' ")));
    }

    FAIL_RETURN(IWriter::Probe(mWriter)->Write(String("standalone='")));
    FAIL_RETURN(IWriter::Probe(mWriter)->Write(
        standalone ? String("yes") : String("no")));
    FAIL_RETURN(IWriter::Probe(mWriter)->Write(String("' ")));

    return IWriter::Probe(mWriter)->Write(String("?>"));
}
Example #7
0
Boolean FontFamily::NativeAddFontFromAsset(
    /* [in] */ Int64 familyPtr,
    /* [in] */ IAssetManager* assetMgr,
    /* [in] */ const String& path)
{
    if (assetMgr == NULL || path.IsNull()) {
        return FALSE;
    }

    android::AssetManager* mgr = (android::AssetManager*)((CAssetManager*)assetMgr)->Ni();
    if (NULL == mgr) {
        return FALSE;
    }

    android::Asset* asset = mgr->open(path.string(), android::Asset::ACCESS_BUFFER);
    if (NULL == asset) {
        return FALSE;
    }

    SkStream* stream = new AssetStreamAdaptor(asset,
                                              AssetStreamAdaptor::kYes_OwnAsset,
                                              AssetStreamAdaptor::kYes_HasMemoryBase);
    SkTypeface* face = SkTypeface::CreateFromStream(stream);
    // Note: SkTypeface::CreateFromStream holds its own reference to the stream
    stream->unref();
    if (face == NULL) {
        Logger::E(String("FontFamily"), String("addFontFromAsset failed to create font %s"), path.string());
        return FALSE;
    }
    android::FontFamily* fontFamily = reinterpret_cast<android::FontFamily*>(familyPtr);
    return addSkTypeface(fontFamily, face);
}
Example #8
0
void SettingsHelper::SetRingtone(
    /* [in] */ const String& name,
    /* [in] */ const String& value)
{
    // If it's null, don't change the default
    if (value.IsNull()) return;
    AutoPtr<IUri> ringtoneUri;
    if (SILENT_RINGTONE.Equals(value)) {
    }
    else {
        AutoPtr<IUriHelper> helper;
        CUriHelper::AcquireSingleton((IUriHelper**)&helper);
        AutoPtr<IUri> canonicalUri;
        helper->Parse(value, (IUri**)&canonicalUri);
        AutoPtr<IContentResolver> resolver;
        mContext->GetContentResolver((IContentResolver**)&resolver);
        resolver->Uncanonicalize(canonicalUri, (IUri**)&ringtoneUri);
        if (ringtoneUri == NULL) {
            // Unrecognized or invalid Uri, don't restore
            return;
        }
    }
    const Int32 ringtoneType = ISettingsSystem::RINGTONE.Equals(name)
            ? IRingtoneManager::TYPE_RINGTONE : IRingtoneManager::TYPE_NOTIFICATION;

    AutoPtr<IRingtoneManagerHelper> helper;
    CRingtoneManagerHelper::AcquireSingleton((IRingtoneManagerHelper**)&helper);

    helper->SetActualDefaultRingtoneUri(mContext, ringtoneType, ringtoneUri);
}
Example #9
0
String CdmaMmiCode::MakeEmptyNull(
    /* [in] */ const String& s)
{
    if (!s.IsNull() && s.GetLength() == 0) return String(NULL);

    return s;
}
Example #10
0
ECode CSizeF::ParseSizeF(
    /* [in] */ const String& string,
    /* [out] */ ISizeF** size)
{
    VALIDATE_NOT_NULL(size)
    *size = NULL;

    if (string.IsNull()) {
        return E_ILLEGAL_ARGUMENT_EXCEPTION;
    }
    //checkNotNull(string, "string must not be null");

    Int32 sep_ix = string.IndexOf('*');
    if (sep_ix < 0) {
        sep_ix = string.IndexOf('x');
    }
    if (sep_ix < 0) {
        // throw invalidSize(string);
        return E_NUMBER_FORMAT_EXCEPTION;
    }

    // try {
    Float w, h;
    FAIL_RETURN(StringUtils::Parse(string.Substring(0, sep_ix), &w))
    FAIL_RETURN(StringUtils::Parse(string.Substring(sep_ix + 1), &h))

    AutoPtr<CSizeF> s;
    CSizeF::NewByFriend(w, h, (CSizeF**)&s);
    *size = (ISizeF*)s.Get();
    REFCOUNT_ADD(*size)
    // } catch (NumberFormatException e) {
    //     throw invalidSize(string);
    // }
    return NOERROR;
}
ECode HttpURLConnection::GetResponseCode(
    /* [out] */ Int32* responseCode)
{
    VALIDATE_NOT_NULL(responseCode)

    // Call getInputStream() first since getHeaderField() doesn't return
    // exceptions
    AutoPtr<IInputStream> is;
    FAIL_RETURN(GetInputStream((IInputStream**)&is));
    String response;
    GetHeaderField(0, &response);
    if (response.IsNull()) {
        *responseCode = -1;
        return NOERROR;
    }
    response = response.Trim();
    Int32 mark = response.IndexOf(" ") + 1;
    if (mark == 0) {
        *responseCode = -1;
        return NOERROR;
    }
    Int32 last = mark + 3;
    if (last > response.GetLength()) {
        last = response.GetLength();
    }
    mResponseCode = StringUtils::ParseInt32(response.Substring(mark, last));
    if ((last + 1) <= response.GetLength()) {
        mResponseMessage = response.Substring(last + 1);
    }
    *responseCode = mResponseCode;
    return NOERROR;
}
Example #12
0
ECode CJDBCConnection::SetTransactionIsolation(
    /* [in] */ Int32 level)
{
    Boolean value;
    ECode ec = NOERROR;
    mDb->Is3(&value);

    if (value) {
        String flag;
        if (level == IConnection::TRANSACTION_READ_UNCOMMITTED &&
        mTrmode != IConnection::TRANSACTION_READ_UNCOMMITTED) {
        flag = "on";
        } else if (level == IConnection::TRANSACTION_SERIALIZABLE &&
               mTrmode != IConnection::TRANSACTION_SERIALIZABLE) {
        flag = "off";
        }
        if (!flag.IsNull()) {
            ec = mDb->Exec(String(""), NULL);
            //db.exec("PRAGMA read_uncommitted = " + flag + ";", null);
            mTrmode = level;
        } else {
            return E_SQL_EXCEPTION;
        }
    }
    if (level != mTrmode) {
        return E_SQL_EXCEPTION;
    }

    return ec;
}
ECode RuleBasedBreakIterator::SetText(
    /* [in] */ const String& newText)
{
    if (newText.IsNull()) {
        return E_NULL_POINTER_EXCEPTION;
    }
    return BreakIterator::SetText(newText);
}
ECode CObjInfoList:: RemoveClsModule(
    /* [in] */ const String& path)
{
    if (path.IsNull()) {
        return E_INVALID_ARGUMENT;
    }
    mClsModule.Remove((PVoid)path.string());
    return NOERROR;
}
ECode DateFormatSymbols::SetLocalPatternChars(
    /* [in] */ const String& data)
{
    if (data.IsNull()) {
        return E_NULL_POINTER_EXCEPTION;
    }
    mLocalPatternChars = data;
    return NOERROR;
}
Example #16
0
ECode CKXmlSerializer::WriteEndTag(
    /* [in] */ const String& ns,
    /* [in] */ const String& name)
{
    if (!mPending) {
        mDepth--;
    }
    //        if (namespace == null)
    //          namespace = "";

    if ((ns.IsNull()
        && !(*mElementStack)[mDepth * 3].IsNull())
        || (!ns.IsNull()
            && !ns.Equals((*mElementStack)[mDepth * 3]))
        || !(*mElementStack)[mDepth * 3 + 2].Equals(name)) {
//        throw new IllegalArgumentException("</{"+namespace+"}"+name+"> does not match start");
        return E_ILLEGAL_ARGUMENT_EXCEPTION;
    }

    if (mPending) {
        FAIL_RETURN(Check(TRUE));
        mDepth--;
    }
    else {
        if ((*mIndent)[mDepth + 1]) {
            FAIL_RETURN(IWriter::Probe(mWriter)->Write(String("\r\n")));
            for (Int32 i = 0; i < mDepth; i++) {
                FAIL_RETURN(IWriter::Probe(mWriter)->Write(String("  ")));
            }
        }

        FAIL_RETURN(IWriter::Probe(mWriter)->Write(String("</")));
        String prefix = (*mElementStack)[mDepth * 3 + 1];
        if (!prefix.IsEmpty()) {
            FAIL_RETURN(IWriter::Probe(mWriter)->Write(prefix));
            FAIL_RETURN(IWriter::Probe(mWriter)->Write(':'));
        }
        FAIL_RETURN(IWriter::Probe(mWriter)->Write(name));
        FAIL_RETURN(IWriter::Probe(mWriter)->Write('>'));
    }

    (*mNspCounts)[mDepth + 1] = (*mNspCounts)[mDepth];
    return NOERROR;
}
Char32 CMenuInflater::MenuState::GetShortcut(
    /* [in] */ const String& shortcutString)
{
    if (shortcutString.IsNull()) {
        return 0;
    }
    else {
        return shortcutString.GetChar(0);
    }
}
Example #18
0
ECode TimeZone::SetID(
    /* [in] */ const String& id)
{
    if (id.IsNull()) {
        return E_NULL_POINTER_EXCEPTION;
    }

    mID = id;
    return NOERROR;
}
Example #19
0
ECode CKXmlSerializer::GetPrefix(
    /* [in] */ const String& ns,
    /* [in] */ Boolean includeDefault,
    /* [in] */ Boolean create,
    /* [out] */ String* prefix)
{
    assert(prefix != NULL);

    for (Int32 i = (*mNspCounts)[mDepth + 1] * 2 - 2; i >= 0; i -= 2) {
        if ((*mNspStack)[i + 1].Equals(ns)
            && (includeDefault || !(*mNspStack)[i].IsEmpty())) {
            String cand = (*mNspStack)[i];
            for (Int32 j = i + 2; j < (*mNspCounts)[mDepth + 1] * 2; j++) {
                if ((*mNspStack)[j].Equals(cand)) {
                    cand = NULL;
                    break;
                }
            }
            if (!cand.IsNull()) {
                *prefix = cand;
                return NOERROR;
            }
        }
    }

    if (!create) {
        *prefix = NULL;
        return NOERROR;
    }

    String _prefix;

    if (ns.IsEmpty()) {
        _prefix = "";
    }
    else {
        do {
            _prefix = "n" + (mAuto++);
            for (Int32 i = (*mNspCounts)[mDepth + 1] * 2 - 2; i >= 0; i -= 2) {
                if (_prefix.Equals((*mNspStack)[i])) {
                    _prefix = NULL;
                    break;
                }
            }
        }
        while (_prefix.IsNull());
    }

    Boolean p = mPending;
    mPending = FALSE;
    FAIL_RETURN(SetPrefix(_prefix, ns));
    mPending = p;
    *prefix = _prefix;
    return NOERROR;
}
Example #20
0
Int64 FontFamily::NativeCreateFamily(
    /* [in] */ const String& lang,
    /* [in] */ Int32 variant)
{
    android::FontLanguage fontLanguage;
    if (!lang.IsNull()) {
        fontLanguage = android::FontLanguage(lang.string(), lang.GetLength());
    }
    android::FontFamily* family = new android::FontFamily(fontLanguage, variant);
    return reinterpret_cast<Int64>(family);
}
Example #21
0
ECode CKXmlSerializer::WriteAttribute(
    /* [in] */ const String& _ns,
    /* [in] */ const String& name,
    /* [in] */ const String& value)
{
    String ns = _ns;
    if (!mPending) {
//        throw new IllegalStateException("illegal position for attribute");
        return E_ILLEGAL_STATE_EXCEPTION;
    }

    //        int cnt = nspCounts[depth];

    if (ns.IsNull()) {
        ns = "";
    }

    //        depth--;
    //        pending = false;

    String prefix("");
    if (!ns.IsEmpty()) {
        FAIL_RETURN(GetPrefix(ns, FALSE, TRUE, &prefix));
    }

    //        pending = true;
    //        depth++;

    /*        if (cnt != nspCounts[depth]) {
                mWriter.write(' ');
                mWriter.write("xmlns");
                if (nspStack[cnt * 2] != null) {
                    mWriter.write(':');
                    mWriter.write(nspStack[cnt * 2]);
                }
                mWriter.write("=\"");
                writeEscaped(nspStack[cnt * 2 + 1], '"');
                mWriter.write('"');
            }
            */

    FAIL_RETURN(IWriter::Probe(mWriter)->Write(' '));
    if (!prefix.IsEmpty()) {
        FAIL_RETURN(IWriter::Probe(mWriter)->Write(prefix));
        FAIL_RETURN(IWriter::Probe(mWriter)->Write(':'));
    }
    FAIL_RETURN(IWriter::Probe(mWriter)->Write(name));
    FAIL_RETURN(IWriter::Probe(mWriter)->Write('='));
    Char32 q = value.IndexOf('"') == -1 ? '"' : '\'';
    FAIL_RETURN(IWriter::Probe(mWriter)->Write(q));
    FAIL_RETURN(WriteEscaped(value, q));
    return IWriter::Probe(mWriter)->Write(q);
}
Example #22
0
Boolean Proxy::IsLocalHost(
    /* [in] */ const String& host)
{
    if (host.IsNull()) {
        return FALSE;
    }

    if (!(host.IsNull())) {
        if (host.EqualsIgnoreCase("localhost")) {
            return TRUE;
        }
        AutoPtr<IInetAddress> address;
        NetworkUtils::NumericToInetAddress(host, (IInetAddress**)&address);
        Boolean isLoopback;
        address->IsLoopbackAddress(&isLoopback);
        if (isLoopback == TRUE) {
            return TRUE;
        }
    }

    return FALSE;
}
Example #23
0
String UrlUtils::AuthoritySafePath(
    /* [in] */ const String& authority,
    /* [in] */ const String& path)
{
    if (!authority.IsNull() &&
            !authority.IsEmpty() &&
            !path.IsEmpty() &&
            !path.StartWith(String("/")))
    {
        return String("/") + path;
    }
    return path;
}
Example #24
0
ECode CKXmlSerializer::SetOutput(
    /* [in] */ IOutputStream* os,
    /* [in] */ const String& encoding)
{
    if (os == NULL) {
//        throw new IllegalArgumentException("os == NULL");
        return E_ILLEGAL_ARGUMENT_EXCEPTION;
    }
    AutoPtr<IWriter> writer;
    if (encoding.IsNull()) {
        COutputStreamWriter::New(os, (IOutputStreamWriter**)&writer);
    }
    else {
        COutputStreamWriter::New(os, encoding, (IOutputStreamWriter**)&writer);
    }
    SetOutput(writer);
    mEncoding = encoding;
    if (!encoding.IsNull()
        && encoding.StartWithIgnoreCase("utf")) { /*encoding.ToLowerCase(Locale.US).StartWith("utf")*/
        mUnicode = TRUE;
    }
    return NOERROR;
}
Example #25
0
int CTest::test4(int argc, char* argv[])
{
    String name;
    if (name.IsNull()) {
        printf("NULL **** NULL NULL **** NULL\n");
    }

    name = String("");

    if (name.IsEmpty()) {
        printf("IsEmpty **** IsEmpty IsEmpty **** IsEmpty\n");
    }
    return 0;
}
Example #26
0
ECode CContentService::ObserverNode::CollectObserversLocked(
    /* [in] */ ObserverNode* node,
    /* [in] */ IUri* uri,
    /* [in] */ Int32 index,
    /* [in] */ IContentObserver* observer,
    /* [in] */ Boolean selfNotify,
    /* [in] */ List<AutoPtr<ObserverCall> >* calls)
{
    VALIDATE_NOT_NULL(node);
    VALIDATE_NOT_NULL(observer);
    VALIDATE_NOT_NULL(calls);
    String segment;
    Int32 segmentCount = CountUriSegments(uri);
    List<AutoPtr<ObserverNode> >::Iterator it;

    if (index >= segmentCount) {
        // This is the leaf node, notify all observers
        CollectMyObserversLocked(node, TRUE, observer, selfNotify, calls);
    } 
    else if (index < segmentCount){
        segment = GetUriSegment(uri, index);
        // Notify any observers at this level who are interested in descendents
        CollectMyObserversLocked(node, FALSE, observer, selfNotify, calls);
    }

    for (it = mChildren->Begin(); it != mChildren->End(); it++) {
        AutoPtr<ObserverNode> pNode = *it;
        if (segment.IsNull() || !segment.Compare(pNode->mName)) {
            FAIL_RETURN(pNode->CollectObserversLocked(pNode, uri, index+1, observer, selfNotify, calls));
            if (!segment.IsNull()) {
                break;
            }
        }
    }

    return NOERROR;
}
Example #27
0
void FileObserver::ObserverThread::NativeObserve(
    /* [in] */ Int32 fd)
{
    char event_buf[512];
    struct inotify_event* event;

    while (1)
    {
        int event_pos = 0;
        int num_bytes = read(fd, event_buf, sizeof(event_buf));

        if (num_bytes < (int)sizeof(*event))
        {
            if (errno == EINTR)
                continue;

            Logger::E("ObserverThread","***** ERROR! android_os_fileobserver_observe() got a short event!");
            return;
        }

        while (num_bytes >= (int)sizeof(*event))
        {
            int event_size;
            event = (struct inotify_event *)(event_buf + event_pos);

            String path;

            if (event->len > 0)
            {
                path = String(event->name);
            }

            //env->CallVoidMethod(object, method_onEvent, event->wd, event->mask, path);
            OnEvent(event->wd, event->mask, path);
            // if (env->ExceptionCheck()) {
            //     env->ExceptionDescribe();
            //     env->ExceptionClear();
            // }
            if (!path.IsNull())
            {
                // env->DeleteLocalRef(path);
            }

            event_size = sizeof(*event) + event->len;
            num_bytes -= event_size;
            event_pos += event_size;
        }
    }
}
Example #28
0
Boolean FontFamily::NativeAddFont(
    /* [in] */ Int64 familyPtr,
    /* [in] */ const String& path)
{
    if (path.IsNull()) {
        return FALSE;
    }
    SkTypeface* face = SkTypeface::CreateFromFile(path.string());
    if (face == NULL) {
        Logger::E(String("FontFamily"), String("addFont failed to create font %s"), path.string());
        return FALSE;
    }
    android::FontFamily* fontFamily = reinterpret_cast<android::FontFamily*>(familyPtr);
    return addSkTypeface(fontFamily, face);
}
Example #29
0
/** {@hide} */
String PackageManager::DeleteStatusToString(
    /* [in] */ Int32 status,
    /* [in] */ const String& msg)
{
    String str = DeleteStatusToString(status);
    if (!msg.IsNull()) {
        StringBuilder sb(str);
        sb += ": ";
        sb += msg;
        return sb.ToString();
    }
    else {
        return str;
    }
}
Example #30
0
ECode CWifiInfo::RemoveDoubleQuotes(
    /* [in] */ const String& str,
    /* [out] */ String* value)
{
    VALIDATE_NOT_NULL(value);

    if (str.IsNull()) return NOERROR;
    AutoPtr<ArrayOf<Char32> > charArray = str.GetChars();
    const Int32 length = charArray->GetLength();
    if ((length > 1) && ((*charArray)[0] == '"') && ((*charArray)[length - 1] == '"')) {
        *value = str.Substring(1, length - 1);
        return NOERROR;
    }
    *value = str;
    return NOERROR;
}