/** * Settings class constructor from a key=value; pairs formatted string. The string is * typically returned by Settings.toString() method. * @throws IllegalArgumentException if the string is not correctly formatted. */ ECode CPresetReverbSettings::constructor( /* [in] */ const String& settings) { AutoPtr<ArrayOf<String> > values; StringUtils::Split(settings, String("=;"), (ArrayOf<String>**)&values); Int32 tokens = values ? values->GetLength() : 0; if (tokens != 3) { // throw new IllegalArgumentException("settings: " + settings); return E_ILLEGAL_ARGUMENT_EXCEPTION; } Int32 index = 0; String key = (*values)[index++]; if (!key.Equals("PresetReverb")) { // throw new IllegalArgumentException("invalid settings for PresetReverb: " + key); return E_ILLEGAL_ARGUMENT_EXCEPTION; } // try { key = (*values)[index++]; if (!key.Equals("preset")) { // throw new IllegalArgumentException("invalid key name: " + key); return E_ILLEGAL_ARGUMENT_EXCEPTION; } mPreset = StringUtils::ParseInt16((*values)[index++]); // } catch (NumberFormatException nfe) { // throw new IllegalArgumentException("invalid value for key: " + key); // } return NOERROR; }
void ProjectGiraffeTab4::OnAppControlCompleteResponseReceived(const AppId &appId, const String &operationId, AppCtrlResult appControlResult, const IMap *extraData) { AppLogTag("camera1", "appid %ls opid %ls", appId.GetPointer(), operationId.GetPointer()); if (appId.Equals(L"tizen.filemanager", true) && operationId.Equals(L"http://tizen.org/appcontrol/operation/pick", true)) { if (appControlResult == APP_CTRL_RESULT_SUCCEEDED) { AppLogTag("camera1", "Media list success."); String pathKey = L"path"; String *filePath = (String *)extraData->GetValue(pathKey); AppLogTag("camera1", "filepath: %ls", filePath->GetPointer()); HttpMultipartEntity* userParameters = new HttpMultipartEntity(); userParameters->Construct(); userParameters->AddFilePart(L"avatar", *filePath); HttpConnection *connection = HttpConnection::userUpdatePutConnection(this, userParameters); connection->begin(); // TODO: figure out when to free // delete userParameters; } else if (appControlResult == APP_CTRL_RESULT_CANCELED) { AppLogTag("camera1", "Media list canceled."); } else if (appControlResult == APP_CTRL_RESULT_FAILED) { AppLogTag("camera1", "Media list failed."); } } else if (appId.Equals(L"tizen.camera", true) && operationId.Equals(L"http://tizen.org/appcontrol/operation/createcontent", true)) { AppLogTag("camera1", "camcam"); if (appControlResult == APP_CTRL_RESULT_SUCCEEDED) { AppLogTag("camera1", "Camera capture success."); String pathKey = L"path"; String *filePath = (String *)extraData->GetValue(pathKey); AppLogTag("camera1", "filepath: %ls", filePath->GetPointer()); HttpMultipartEntity* userParameters = new HttpMultipartEntity(); userParameters->Construct(); userParameters->AddFilePart(L"avatar", *filePath); HttpConnection *connection = HttpConnection::userUpdatePutConnection(this, userParameters); connection->begin(); // TODO: figure out when to free // delete userParameters; } else if (appControlResult == APP_CTRL_RESULT_CANCELED) { AppLogTag("camera1", "Camera capture canceled."); } else if (appControlResult == APP_CTRL_RESULT_FAILED) { AppLogTag("camera1", "Camera capture failed."); } else if (appControlResult == APP_CTRL_RESULT_TERMINATED) { AppLogTag("camera1", "Camera capture terminated."); } else if (appControlResult == APP_CTRL_RESULT_ABORTED) { AppLogTag("camera1", "Camera capture aborted."); } } }
ECode CNamespaceSupport::Context::DeclarePrefix( /* [in] */ const String& prefix, /* [in] */ const String& uri) { // Lazy processing... if (!mDeclsOK) { // throw new IllegalStateException ("can't declare any more prefixes in this context"); return E_ILLEGAL_STATE_EXCEPTION; } if (!mDeclSeen) { CopyTables(); } if (mDeclarations == NULL) { CArrayList::New((IArrayList**)&mDeclarations); } if (prefix.Equals("")) { if (uri.Equals("")) { mDefaultNS = String(NULL); } else { mDefaultNS = uri; } } else { mPrefixTable[prefix] = uri; mUriTable[uri] = prefix; // may wipe out another prefix } AutoPtr<ICharSequence> seq; CString::New(prefix, (ICharSequence**)&seq); return mDeclarations->Add(seq); }
void MapForm::OnAppControlCompleted(const String& appControlId, const String& operationId, const IList* pResultList) { String* pResult = null; if (appControlId.Equals(APPCONTROL_PROVIDER_SETTINGS)) { pResult = (Osp::Base::String*)pResultList->GetAt(0); if (pResult->Equals(APPCONTROL_RESULT_SUCCEEDED)) { pResult = (Osp::Base::String*)pResultList->GetAt(1); if (pResult->Equals(String(L"category:Location"))) { pResult = (Osp::Base::String*)pResultList->GetAt(2); if (pResult->Equals(String(L"GPSEnabled"))) { AppLog("LocationServices are enabled."); } else { AppLog("LocationServices are disabled."); } } } } }
/** * See state strings defined in ril.h RIL_REQUEST_QUERY_AVAILABLE_NETWORKS */ ECode COperatorInfo::RilStateToState( /* [in] */ const String& s, /* [out] */ IOperatorInfoState* result) { VALIDATE_NOT_NULL(result); if (s.Equals("unknown")) { *result = OperatorInfoState_UNKNOWN; return NOERROR; } else if (s.Equals("available")) { *result = OperatorInfoState_AVAILABLE; return NOERROR; } else if (s.Equals("current")) { *result = OperatorInfoState_CURRENT; return NOERROR; } else if (s.Equals("forbidden")) { *result = OperatorInfoState_FORBIDDEN; return NOERROR; } // throw new RuntimeException( // "RIL impl error: Invalid network state '" + s + "'"); return E_RUNTIME_EXCEPTION; }
ECode Provider::GetService( /* [in] */ const String& type, /* [out] */ IProviderService** retService) { VALIDATE_NOT_NULL(retService) AutoLock lock(this); UpdatePropertyServiceTable(); if (mLastServicesByType != NULL && type.Equals(mLastType)) { *retService = mLastServicesByType; REFCOUNT_ADD(*retService); return NOERROR; } AutoPtr<ISet> services; GetServices((ISet**)&services); AutoPtr<IIterator> it; services->GetIterator((IIterator**)&it); Boolean hasNext; while (it->HasNext(&hasNext), hasNext) { AutoPtr<IProviderService> service; it->GetNext((IInterface**)&service); String srvType; service->GetType(&srvType); if (type.Equals(srvType)) { mLastType = type; mLastServicesByType = service; *retService = service; REFCOUNT_ADD(*retService); return NOERROR; } } *retService = NULL; return NOERROR; }
Boolean CBatchedScanSettings::ChannelSetIsValid() { Boolean bIsEmpty; if (mChannelSet == NULL || (mChannelSet->IsEmpty(&bIsEmpty), bIsEmpty)) { return TRUE; } AutoPtr<IIterator> iter; mChannelSet->GetIterator((IIterator**)&iter); Boolean bNext; iter->HasNext(&bNext); for (; bNext; iter->HasNext(&bNext)) { AutoPtr<ICharSequence> iChannel; iter->GetNext((IInterface**)&iChannel); String channel; iChannel->ToString(&channel); // try { Int32 i = StringUtils::ParseInt32(channel); if (i > 0 && i <= MAX_WIFI_CHANNEL) continue; // } catch (NumberFormatException e) {} if (channel.Equals("A") || channel.Equals("B")) continue; return FALSE; } return TRUE; }
static ProfileGroupMode ValueOf(const String& modeStr) { if (modeStr.Equals("SUPPRESS")) return ProfileGroupMode_SUPPRESS; else if (modeStr.Equals("DEFAULT")) return ProfileGroupMode_DEFAULT; else if (modeStr.Equals("OVERRIDE")) return ProfileGroupMode_OVERRIDE; else return ProfileGroupMode_DEFAULT; }
ECode VersionInfo::FromMap( /* [in] */ const String& pckg, /* [in] */ IMap* info, /* [in] */ IClassLoader* clsldr, /* [out] */ IVersionInfo** versionInfo) { VALIDATE_NOT_NULL(versionInfo) *versionInfo = NULL; if (pckgs == NULL) { Logger::E("VersionInfo", "Package identifier list must not be null."); return E_ILLEGAL_ARGUMENT_EXCEPTION; } String module = String(NULL); String release = String(NULL); String timestamp = String(NULL); if (info != NULL) { AutoPtr<ICharSequence> cs; CStringWrapper::New(PROPERTY_MODULE, (ICharSequence**)&cs); AutoPtr<IInterface> value; info->Get(cs, (IInterface**)&value); AutoPtr<ICharSequence> v = ICharSequence::Probe(value); v->ToString(&module); if ((!module.IsNull()) && (module.GetLength() < 1)) { module = String(NULL); } cs = NULL; CStringWrapper::New(PROPERTY_RELEASE, (ICharSequence**)&cs); value = NULL; info->Get(cs, (IInterface**)&value); v = ICharSequence::Probe(value); v->ToString(&release); if ((!release.IsNull()) && ((release.GetLength() < 1) || (release.Equals("${pom.version}")))) { release = String(NULL); } cs = NULL; CStringWrapper::New(PROPERTY_TIMESTAMP, (ICharSequence**)&cs); value = NULL; info->Get(cs, (IInterface**)&value); v = ICharSequence::Probe(value); v->ToString(×tamp); if ((!timestamp.IsNull()) && ((timestamp.GetLength() < 1) || (timestamp.Equals("${mvn.timestamp}")))) { timestamp = String(NULL); } } // if info String clsldrstr = String(NULL); if (clsldr != NULL) { IObject::Probe(clsldr)->ToString(&clsldrstr); } *info = (IVersionInfo*)new VersionInfo(pckg, module, release, timestamp, clsldrstr); REFCOUNT_ADD(*info) return NOERROR; }
/** * Settings class constructor from a key=value; pairs formatted string. The string is * typically returned by Settings.toString() method. * @throws IllegalArgumentException if the string is not correctly formatted. */ ECode CEqualizerSettings::constructor( /* [in] */ const String& settings) { AutoPtr<ArrayOf<String> > values; StringUtils::Split(settings, String("=;"), (ArrayOf<String>**)&values); Int32 tokens = values ? values->GetLength() : 0; if (tokens < 5) { // throw new IllegalArgumentException("settings: " + settings); return E_ILLEGAL_ARGUMENT_EXCEPTION; } Int32 index = 0; String key = (*values)[index++]; if (!key.Equals("Equalizer")) { // throw new IllegalArgumentException("invalid settings for Equalizer: " + key); return E_ILLEGAL_ARGUMENT_EXCEPTION; } // try { key = (*values)[index++]; if (!key.Equals("curPreset")) { // throw new IllegalArgumentException("invalid key name: " + key); return E_ILLEGAL_ARGUMENT_EXCEPTION; } mCurPreset = StringUtils::ParseInt32((*values)[index++]); key = (*values)[index++]; if (!key.Equals("numBands")) { // throw new IllegalArgumentException("invalid key name: " + key); return E_ILLEGAL_ARGUMENT_EXCEPTION; } mNumBands = StringUtils::ParseInt32((*values)[index++]); if (StringUtils::ParseInt32((*values)[index++]) != mNumBands*2) { // throw new IllegalArgumentException("settings: " + settings); return E_ILLEGAL_ARGUMENT_EXCEPTION; } // try { mBandLevels = ArrayOf<Int16>::Alloc(mNumBands); for (int i = 0; i < mNumBands; i++) { key = (*values)[index++]; if (!key.Equals(String("band") + StringUtils::Int32ToString(i+1) + String("Level"))) { // throw new IllegalArgumentException("invalid key name: " + key); return E_ILLEGAL_ARGUMENT_EXCEPTION; } (*mBandLevels)[i] = StringUtils::ParseInt32((*values)[index++]); } // } catch (NumberFormatException nfe) { // throw new IllegalArgumentException("invalid value for key: " + key); // } return NOERROR; }
/** * Open a stream on to the content associated with a content URI. If there * is no data associated with the URI, FileNotFoundException is thrown. * * <h5>Accepts the following URI schemes:</h5> * <ul> * <li>content ({@link #SCHEME_CONTENT})</li> * <li>android.resource ({@link #SCHEME_ANDROID_RESOURCE})</li> * <li>file ({@link #SCHEME_FILE})</li> * </ul> * * <p>See {@link #openAssetFileDescriptor(Uri, String)} for more information * on these schemes. * * @param uri The desired URI. * @return InputStream * @throws FileNotFoundException if the provided URI could not be opened. * @see #openAssetFileDescriptor(Uri, String) */ ECode ContentResolver::OpenInputStream( /* [in] */ IUri* uri, /* [out] */ IInputStream** istream) { VALIDATE_NOT_NULL(istream); String scheme; FAIL_RETURN(uri->GetScheme(&scheme)); if (scheme.Equals(SCHEME_ELASTOS_RESOURCE)) { // Note: left here to avoid breaking compatibility. May be removed // with sufficient testing. AutoPtr<IOpenResourceIdResult> r; FAIL_RETURN(GetResourceId(uri, (IOpenResourceIdResult**)&r)); // try { AutoPtr<IResources> resources; FAIL_RETURN(r->GetResources((IResources**)&resources)); Int32 id; FAIL_RETURN(r->GetResourceId(&id)); return resources->OpenRawResource(id, istream); // } catch (Resources.NotFoundException ex) { // throw new FileNotFoundException("Resource does not exist: " + uri); // } } else if (scheme.Equals(SCHEME_FILE)) { // Note: left here to avoid breaking compatibility. May be removed // with sufficient testing. String path; FAIL_RETURN(uri->GetPath(&path)); return CFileInputStream::New(path, (IFileInputStream**)&istream); } else { AutoPtr<IAssetFileDescriptor> fd; FAIL_RETURN(OpenAssetFileDescriptor( uri, String("r"), (IAssetFileDescriptor**)&fd)); // try { if (fd == NULL) { *istream = NULL; return NOERROR; } else { // TODO: ALEX // return fd->CreateInputStream(istream); return E_NOT_IMPLEMENTED; } // } catch (IOException e) { // throw new FileNotFoundException("Unable to create stream"); // } } }
ECode PreferenceInflater::OnCreateCustomFromTag( /* [in] */ IXmlPullParser* parser, /* [in] */ IInterface* _parentPreference, /* [in] */ IAttributeSet* attrs, /* [out] */ Boolean* res) { VALIDATE_NOT_NULL(res) *res = FALSE; AutoPtr<IPreference> parentPreference = IPreference::Probe(_parentPreference); assert(parentPreference != NULL); String tag; parser->GetName(&tag); if (tag.Equals(INTENT_TAG_NAME)) { AutoPtr<IIntent> intent; AutoPtr<IContext> ctx; GetContext((IContext**)&ctx); AutoPtr<IResources> resource; ctx->GetResources((IResources**)&resource); if (Intent::ParseIntent(resource, parser, attrs, (IIntent**)&intent) == (ECode)E_IO_EXCEPTION) { Slogger::D("PreferenceInflater", "Error parsing preference"); return E_XML_PULL_PARSER_EXCEPTION; } if (intent != NULL) { parentPreference->SetIntent(intent); } *res = TRUE; return NOERROR; } else if (tag.Equals(EXTRA_TAG_NAME)) { AutoPtr<IContext> ctx; GetContext((IContext**)&ctx); AutoPtr<IResources> resource; ctx->GetResources((IResources**)&resource); AutoPtr<IBundle> data; parentPreference->GetExtras((IBundle**)&data); resource->ParseBundleExtra(EXTRA_TAG_NAME, attrs, data); if (XmlUtils::SkipCurrentTag(parser) == (ECode)E_IO_EXCEPTION) { Slogger::D("PreferenceInflater", "Error parsing preference"); return E_XML_PULL_PARSER_EXCEPTION; } *res = TRUE; return NOERROR; } return NOERROR; }
ECode CLockSettingsService::GetBoolean( /* [in] */ const String& key, /* [in] */ Boolean defaultValue, /* [in] */ Int32 userId, /* [out] */ Boolean* res) { //checkReadPermission(userId); VALIDATE_NOT_NULL(res); String value; FAIL_RETURN(ReadFromDb(key, String(NULL), userId, &value)) *res = TextUtils::IsEmpty(value) ? defaultValue : (value.Equals("1") || value.Equals("TRUE")); return NOERROR; }
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. }
void Kamera::OnAppControlCompleted (const String &appControlId, const String &operationId, const IList *pResultList) { //This method is invoked when an application control callback event occurs. String* pCaptureResult = null; if (appControlId.Equals(APPCONTROL_CAMERA) && operationId.Equals(OPERATION_CAPTURE)) { pCaptureResult = (Osp::Base::String*)pResultList->GetAt(0); if (pCaptureResult->Equals(String(APPCONTROL_RESULT_SUCCEEDED))) { String eval; AppLog("Camera capture success."); String* pCapturePath = (String*)pResultList->GetAt(1); // copying to app Home Folder String homeFilename; homeFilename.Format(128, L"/Home/%S", File::GetFileName(*pCapturePath).GetPointer()); result r = File::Copy(*pCapturePath, homeFilename, true); if(IsFailed(r)) { AppLogException("Could not copy picture"); eval.Format(512, L"PhoneGap.callbacks['%S'].fail('Could not copy picture')", callbackId.GetPointer()); AppLogDebug("%S", eval.GetPointer()); pWeb->EvaluateJavascriptN(eval); } // Uri imageUri; // imageUri.setUri(homeFilename); eval.Clear(); eval.Format(512, L"PhoneGap.callbacks['%S'].success('file://%S')", callbackId.GetPointer(), homeFilename.GetPointer()); AppLogDebug("%S", eval.GetPointer()); pWeb->EvaluateJavascriptN(eval); } else if (pCaptureResult->Equals(String(APPCONTROL_RESULT_CANCELED))) { AppLog("Camera capture canceled."); String eval; eval.Format(512, L"PhoneGap.callbacks['%S'].fail('Camera capture canceled')", callbackId.GetPointer()); pWeb->EvaluateJavascriptN(eval); } else if (pCaptureResult->Equals(String(APPCONTROL_RESULT_FAILED))) { AppLog("Camera capture failed."); String eval; eval.Format(512, L"PhoneGap.callbacks['%S'].fail('Camera capture failed')", callbackId.GetPointer()); pWeb->EvaluateJavascriptN(eval); } } }
AutoPtr<ICursor> CRingtoneManager::GetMediaRingtones() { // Get the external media cursor. First check to see if it is mounted. String status = Environment::GetExternalStorageState(); AutoPtr<IMediaStoreAudioMedia> am; CMediaStoreAudioMedia::AcquireSingleton((IMediaStoreAudioMedia**)&am); AutoPtr<IUri> uri; am->GetEXTERNAL_CONTENT_URI((IUri**)&uri); return (status.Equals(IEnvironment::MEDIA_MOUNTED) || status.Equals(IEnvironment::MEDIA_MOUNTED_READ_ONLY)) ? Query(uri, MEDIA_COLUMNS, ConstructBooleanTrueWhereClause(&mFilterColumns, mIncludeDrm), NULL, IMediaStoreAudioMedia::DEFAULT_SORT_ORDER) : NULL; }
Int32 ImeAdapter::ShouldSendKeyEventWithKeyCode( /* [in] */ String text) { if (text.GetLength() != 1) return COMPOSITION_KEY_CODE; if (text.Equals("\n")) { return IKeyEvent::KEYCODE_ENTER; } else if (text.Equals("\t")) { return IKeyEvent::KEYCODE_TAB; } else { return COMPOSITION_KEY_CODE; } }
ECode CResources::ParseBundleExtras( /* [in] */ IXmlResourceParser* parser, /* [in, out] */ IBundle* outBundle) { VALIDATE_NOT_NULL(outBundle); Int32 outerDepth; FAIL_RETURN(parser->GetDepth(&outerDepth)); Int32 type; Int32 depth; while ((parser->Next(&type), type != IXmlPullParser_END_DOCUMENT) && (type != IXmlPullParser_END_TAG || (parser->GetDepth(&depth), depth > outerDepth))) { if (type == IXmlPullParser_END_TAG || type == IXmlPullParser_TEXT) { continue; } String nodeName; FAIL_RETURN(parser->GetName(&nodeName)); if (nodeName.Equals("extra")) { FAIL_RETURN(ParseBundleExtra(nodeName, IAttributeSet::Probe(parser), outBundle)); XmlUtils::SkipCurrentTag(parser); } else { XmlUtils::SkipCurrentTag(parser); } } return NOERROR; }
ECode SubInfoRecordUpdater::SetDisplayNameForNewSub( /* [in] */ const String& newSubName, /* [in] */ Int32 subId, /* [in] */ Int32 newNameSource) { AutoPtr<ISubInfoRecord> subInfo; SubscriptionManager::GetSubInfoForSubscriber(subId, (ISubInfoRecord**)&subInfo); if (subInfo != NULL) { // overwrite SIM display name if it is not assigned by user assert(0 && "TODO"); Int32 oldNameSource;// = subInfo.nameSource; String oldSubName;// = subInfo.displayName; Logd(String("[setDisplayNameForNewSub] mSubInfoIdx = ") + /*IntegralToString::ToString(subInfo.subId) + */String(", oldSimName = ") + oldSubName + String(", oldNameSource = ") + IntegralToString::ToString(oldNameSource) + String(", newSubName = ") + newSubName + String(", newNameSource = ") + IntegralToString::ToString(newNameSource)); if (oldSubName == NULL || (oldNameSource == ISubscriptionManager::NAME_SOURCE_DEFAULT_SOURCE && newSubName != NULL) || (oldNameSource == ISubscriptionManager::NAME_SOURCE_SIM_SOURCE && newSubName != NULL && !newSubName.Equals(oldSubName))) { assert(0 && "TODO"); // SubscriptionManager::SetDisplayName(newSubName, subInfo.subId, newNameSource); } } else { Logd(String("SUB") + IntegralToString::ToString(subId + 1) + String(" SubInfo not created yet")); } return NOERROR; }
ECode DataConnectionStats::OnReceive( /* [in] */ IContext* context, /* [in] */ IIntent* intent) { String action; intent->GetAction(&action); if (action.Equals(ITelephonyIntents::ACTION_SIM_STATE_CHANGED)) { UpdateSimState(intent); NotePhoneDataConnectionState(); } else if (action.Equals(IConnectivityManager::CONNECTIVITY_ACTION) || action.Equals(IConnectivityManager::INET_CONDITION_ACTION)) { NotePhoneDataConnectionState(); } return NOERROR; }
ECode MediaItem::RemoveOverlay( /* [in] */ const String& overlayId, /* [out] */ IOverlay** result) { VALIDATE_NOT_NULL(result); List<AutoPtr<IOverlay> >::Iterator it = mOverlays.Begin(); for(; it != mOverlays.End(); it++) { AutoPtr<IOverlay> overlay = *it; String id; overlay->GetId(&id); if(id.Equals(overlayId)) { mMANativeHelper->SetGeneratePreview(TRUE); mOverlays.Remove(overlay); Int64 sTime, eDuration; overlay->GetStartTime(&sTime); overlay->GetDuration(&eDuration); InvalidateTransitions(sTime, eDuration); *result = overlay; REFCOUNT_ADD(*result); return NOERROR; } } *result = NULL; return NOERROR; }
FontFamily::FontFamily( /* [in] */ const String& lang, /* [in] */ const String& variant) { Int32 varEnum = 0; if (variant.Equals("compact")) { varEnum = 1; } else if (variant.Equals("elegant")) { varEnum = 2; } mNativePtr = NativeCreateFamily(lang, varEnum); if (mNativePtr == 0) { // throw new IllegalStateException("error creating native FontFamily"); assert(0 && "error creating native FontFamily"); } }
Boolean MobileDirectController::IsNetworkEnable() { AutoPtr<IFile> file; CFile::New(ENTWORK_ENABLE_PATH, (IFile**)&file); AutoPtr<IBufferedReader> reader; // try { AutoPtr<IFileReader> fr; CFileReader::New(file, (IFileReader**)&fr); CBufferedReader::New(IReader::Probe(fr.Get()), (IBufferedReader**)&reader); String networkEnable; if (FAILED(reader->ReadLine(&networkEnable))) { goto failed; } if(!networkEnable.IsNull() && networkEnable.Equals("1")) { return TRUE; } // } catch (IOException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } finally { failed: // try { if(reader != NULL) ICloseable::Probe(reader.Get())->Close(); // } catch (IOException e) { // e.printStackTrace(); // } // } return FALSE; }
ECode ContentProvider::OpenTypedAssetFile( /* [in] */ IUri* uri, /* [in] */ const String& mimeTypeFilter, /* [in] */ IBundle* opts, /* [out] */ IAssetFileDescriptor** fileDescriptor) { VALIDATE_NOT_NULL(fileDescriptor) *fileDescriptor = NULL; if (mimeTypeFilter.Equals("*/*")) { // If they can take anything, the untyped open call is good enough. return OpenAssetFile(uri, String("r"), fileDescriptor); } String baseType; GetType(uri, &baseType); if (!baseType.IsNull()) { AutoPtr<IClipDescriptionHelper> descriptionHelper; CClipDescriptionHelper::AcquireSingleton((IClipDescriptionHelper**)&descriptionHelper); Boolean result = FALSE; descriptionHelper->CompareMimeTypes(baseType, mimeTypeFilter, &result); // Use old untyped open call if this provider has a type for this // URI and it matches the request. if (result) return OpenAssetFile(uri, String("r"), fileDescriptor); } // throw new FileNotFoundException("Can't open " + uri + " as type " + mimeTypeFilter); String str = Object::ToString(uri); Logger::E(TAG, "Can't open %s as type %s", str.string(), mimeTypeFilter.string()); return E_FILE_NOT_FOUND_EXCEPTION; }
ECode AllAppsList::RemovePackage( /* [in] */ const String& packageName, /* [in] */ IUserHandle* user) { AutoPtr<IList> data = mData; Int32 size; data->GetSize(&size); for (Int32 i = size - 1; i >= 0; i--) { AutoPtr<IInterface> obj; data->Get(i, (IInterface**)&obj); AutoPtr<ApplicationInfo> info = (ApplicationInfo*)IObject::Probe(obj); AutoPtr<IComponentName> component; info->mIntent->GetComponent((IComponentName**)&component); Boolean res; info->mUser->Equals(user, &res); if (res) { String name; component->GetPackageName(&name); Boolean tmp; packageName.Equals(name, &tmp); if (tmp) { removed->Add(info); data->Remove(i); } } } // This is more aggressive than it needs to be. return mIconCache->Flush(); }
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; }
/** * Return the next command line option. This has a number of special cases * which closely, but not exactly, follow the POSIX command line options * patterns: * * <pre> * -- means to stop processing additional options * -z means option z * -z ARGS means option z with (non-optional) arguments ARGS * -zARGS means option z with (optional) arguments ARGS * --zz means option zz * --zz ARGS means option zz with (non-optional) arguments ARGS * </pre> * * Note that you cannot combine single letter options; -abc != -a -b -c * * @return Returns the option string, or null if there are no more options. */ String Monkey::NextOption() { if (mNextArg >= mArgs->GetLength()) { return String(); } String arg = (*mArgs)[mNextArg]; if (!arg.StartWith("-")) { return String(); } mNextArg++; if (arg.Equals("--")) { return String(); } if (arg.GetLength() > 1 && arg.GetChar(1) != '-') { if (arg.GetLength() > 2) { mCurArgData = arg.Substring(2); return arg.Substring(0, 2); } else { mCurArgData = String(); return arg; } } mCurArgData = String(); return arg; }
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 CProxyProperties::IsExcluded( /* [in] */ const String& url, /* [out] */ Boolean* result) { VALIDATE_NOT_NULL(result); Int32 length; length = mParsedExclusionList->GetLength(); AutoPtr<ICharSequence> chars; CStringWrapper::New(url, (ICharSequence**)&chars); if (TextUtils::IsEmpty((ICharSequence*)&chars) || mParsedExclusionList == NULL ||length == 0) { *result = FALSE; return NOERROR; } AutoPtr<IUri> u; Uri::Parse(url, (IUri**)&u); String urlDomain; u->GetHost(&urlDomain); if (urlDomain.IsNull()) { *result = FALSE; return NOERROR; } Int32 length2; length2 = mParsedExclusionList->GetLength(); for (Int32 i = 0; i< length2; i+=2) { if (urlDomain.Equals((*mParsedExclusionList)[i]) || urlDomain.EndWith((*mParsedExclusionList)[i+1])) { *result = TRUE; return NOERROR; } } *result = FALSE; return NOERROR; }
ECode CVpnObserver::InterfaceRemoved( /* [in] */ const String& interfaze) { { AutoLock lock(mOwner->mLock); if (interfaze.Equals(mOwner->mInterface) && mOwner->NativeCheck(interfaze) == 0) { Int64 token = Binder::ClearCallingIdentity(); // try { mOwner->mCallback->Restore(); mOwner->HideNotification(); // } finally { Binder::RestoreCallingIdentity(token); // } mOwner->mInterface = NULL; if (mOwner->mConnection != NULL) { mOwner->mContext->UnbindService(mOwner->mConnection); mOwner->mConnection = NULL; mOwner->UpdateState(NetworkInfoDetailedState_DISCONNECTED, String("interfaceRemoved")); } else if (mOwner->mLegacyVpnRunner != NULL) { mOwner->mLegacyVpnRunner->Exit(); mOwner->mLegacyVpnRunner = NULL; } } } return NOERROR; }