ECode BluetoothInputDevice::SendData( /* [in] */ IBluetoothDevice* device, /* [in] */ const String& report, /* [out] */ Boolean* result) { VALIDATE_NOT_NULL(result) *result = FALSE; if (DBG) { String str; IObject::Probe(device)->ToString(&str); Logger::D(TAG, "sendData(%s), report=%s", str.string(), report.string()); } if (mService != NULL && IsEnabled() && IsValidDevice(device)) { // try { return mService->SendData(device, report, result); // } catch (RemoteException e) { // Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable())); // return false; // } } if (mService == NULL) { Logger::W(TAG, "Proxy not attached to service"); } return NOERROR; }
ECode SQLiteSession::Prepare( /* [in] */ const String& sql, /* [in] */ Int32 connectionFlags, /* [in] */ ICancellationSignal* cancellationSignal, /* [in] */ SQLiteStatementInfo* outStatementInfo) { if (sql.IsNullOrEmpty()) { //throw new IllegalArgumentException("sql must not be null."); Slogger::E("SQLiteSession", "sql must not be null."); return E_ILLEGAL_ARGUMENT_EXCEPTION; } if (cancellationSignal != NULL) { FAIL_RETURN(cancellationSignal->ThrowIfCanceled()) } ECode ec = AcquireConnection(sql, connectionFlags, cancellationSignal); // might throw if (FAILED(ec)) { Slogger::E("SQLiteSession", "Failed to AcquireConnection %s", sql.string()); return ec; } //try { ec = mConnection->Prepare(sql, outStatementInfo); // might throw if (FAILED(ec)) { Slogger::E("SQLiteSession", "Failed to Prepare %s", sql.string()); } //} finally { ec = ReleaseConnection(); // might throw if (FAILED(ec)) { Slogger::E("SQLiteSession", "Failed to ReleaseConnection %s", sql.string()); } //} return ec; }
ECode Proxy::SetHttpProxySystemProperty( /* [in] */ const String& host, /* [in] */ const String& port, /* [in] */ const String& exclList, /* [in] */ IUri* pacFileUrl) { AutoPtr<ISystem> system; Elastos::Core::CSystem::AcquireSingleton((ISystem**)&system); String tmpExclList(exclList); if (!(tmpExclList.IsNull())) { tmpExclList = tmpExclList.Replace(',', '|'); } String s; if (FALSE) Logger::D(TAG, "setHttpProxySystemProperty :%s:%s - %s", host.string(), port.string(), tmpExclList.string()); if (host != String(NULL)) { system->SetProperty(String("http.proxyHost"), host, &s); system->SetProperty(String("https.proxyHost"), host, &s); } else { system->ClearProperty(String("http.proxyHost"), &s); system->ClearProperty(String("https.proxyHost"), &s); } if (port != String(NULL)) { system->SetProperty(String("http.proxyPort"), port, &s); system->SetProperty(String("https.proxyPort"), port, &s); } else { system->ClearProperty(String("http.proxyPort"), &s); system->ClearProperty(String("https.proxyPort"), &s); } if (tmpExclList != String(NULL)) { system->SetProperty(String("http.nonProxyHosts"), tmpExclList, &s); system->SetProperty(String("https.nonProxyHosts"), tmpExclList, &s); } else { system->ClearProperty(String("http.nonProxyHosts"), &s); system->ClearProperty(String("https.nonProxyHosts"), &s); } AutoPtr<IUri> empty; Uri::GetEMPTY((IUri**)&empty); AutoPtr<IProxySelectorHelper> helper; Boolean isEquals; IObject::Probe(empty)->Equals(pacFileUrl, &isEquals); if (!isEquals) { AutoPtr<IPacProxySelector> newProxySelector; CPacProxySelector::New((IPacProxySelector**)&newProxySelector); ProxySelector::SetDefault(IProxySelector::Probe(newProxySelector)); } else { ProxySelector::SetDefault(sDefaultProxySelector); } return NOERROR; }
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); }
String::String(String& s) { mLength = s.GetLength(); mBuffer = new char[mLength+1]; memset(mBuffer, 0, mLength+1); strncpy(mBuffer, s.string(), mLength); }
ECode CStatusBarManagerService::SetIconVisibility( /* [in] */ const String& slot, /* [in] */ Boolean visible) { FAIL_RETURN(EnforceStatusBar()); { AutoLock Lock(mIconsLock); Int32 index = 0; assert(mIcons != NULL); mIcons->GetSlotIndex(slot, &index); if (index < 0) { Slogger::E(TAG, "invalid status bar icon slot: %s", slot.string()); return E_SECURITY_EXCEPTION; } AutoPtr<IStatusBarIcon> icon; mIcons->GetIcon(index, (IStatusBarIcon**)&icon); if (icon == NULL) { return E_NULL_POINTER_EXCEPTION; } Boolean v; icon->GetVisible(&v); if (v != visible) { icon->SetVisible(visible); if (mBar != NULL) { mBar->SetIcon(index, icon); } } } return NOERROR; }
ECode CStatusBarManagerService::SetIcon( /* [in] */ const String& slot, /* [in] */ const String& iconPackage, /* [in] */ Int32 iconId, /* [in] */ Int32 iconLevel, /* [in] */ const String& contentDescription) { FAIL_RETURN(EnforceStatusBar()); { AutoLock Lock(mIconsLock); Int32 index = 0; mIcons->GetSlotIndex(slot, &index); if (index < 0) { Slogger::E(TAG, "invalid status bar icon slot: %s", slot.string()); return E_SECURITY_EXCEPTION; } AutoPtr<IStatusBarIcon> icon; AutoPtr<ICharSequence> seq; CString::New(contentDescription, (ICharSequence**)&seq); CStatusBarIcon::New(iconPackage, UserHandle::OWNER, iconId, iconLevel, 0, seq, (IStatusBarIcon**)&icon); mIcons->SetIcon(index, icon); if (mBar != NULL) { mBar->SetIcon(index, icon); } } return NOERROR; }
void testReadZipFile(IZipFile *pZipFile, const String& entryName) { EnterLeaveLog log("test ReadZipFile"); AutoPtr<IZipEntry> pEntry; ECode ec = pZipFile->GetEntry(entryName, (IZipEntry**)&pEntry); if (pEntry == NULL) { printf(" >> Cann't Find entry: [%s]!\n", entryName.string()); return; } AutoPtr<IInputStream> is; Int32 len; AutoPtr<ArrayOf<Byte> > buf; ec = pZipFile->GetInputStream(pEntry, (IInputStream **) &is); if (FAILED(ec)) { printf(" >> Cann't Get ZipFile InputStream!\n"); goto _EXIT_; } buf = ArrayOf<Byte>::Alloc(1024); ec = is->ReadBytesEx(buf, 0, 1024, &len); while(SUCCEEDED(ec) && len > 0) { String tmpStr((const char*)(buf->GetPayload()), len); printf(" >> Read %d bytes: [%s]\n", len, tmpStr.string()); ec = is->ReadBytesEx(buf, 0, 1024, &len); } _EXIT_: if (is != NULL) is->Close(); }
ECode BluetoothInputDevice::SetPriority( /* [in] */ IBluetoothDevice* device, /* [in] */ Int32 priority, /* [out] */ Boolean* result) { VALIDATE_NOT_NULL(result) *result = FALSE; if (DBG) { String str; IObject::Probe(device)->ToString(&str); Logger::D(TAG, "setPriority(%s, %d)", str.string(), priority); } if (mService != NULL && IsEnabled() && IsValidDevice(device)) { if (priority != IBluetoothProfile::PRIORITY_OFF && priority != IBluetoothProfile::PRIORITY_ON) { return NOERROR; } // try { return mService->SetPriority(device, priority, result); // } catch (RemoteException e) { // Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable())); // return false; // } } if (mService == NULL) { Logger::W(TAG, "Proxy not attached to service"); } return NOERROR; }
ECode ProfileManagerService::SetActiveProfileByName( /* [in] */ const String& profileName, /* [out] */ Boolean* result) { VALIDATE_NOT_NULL(result); Boolean flag = FALSE; mProfileNames->ContainsKey(StringUtils::ParseCharSequence(profileName).Get(), &flag); if (!flag) { // Since profileName could not be casted into a UUID, we can call it a string. Logger::W(TAG, "Unable to find profile to set active, based on string: %s", profileName.string()); *result = FALSE; return NOERROR; } if (LOCAL_LOGV) { Logger::V(TAG, "setActiveProfile(String) found profile name in mProfileNames."); } AutoPtr<IInterface> obj; mProfileNames->Get(StringUtils::ParseCharSequence(profileName).Get(), (IInterface**)&obj); AutoPtr<IUUID> uuid = IUUID::Probe(obj); obj = NULL; mProfiles->Get(uuid.Get(), (IInterface**)&obj); SetActiveProfile(IProfile::Probe(obj), TRUE); *result = TRUE; return NOERROR; }
ECode AnimatedStateListDrawable::ParseItem( /* [in] */ /*@NonNull*/ IResources* r, /* [in] */ /*@NonNull*/ IXmlPullParser* parser, /* [in] */ /*@NonNull*/ IAttributeSet* attrs, /* [in] */ /*@Nullable*/ IResourcesTheme* theme, /* [out] */ Int32* result) /*throws XmlPullParserException, IOException*/ { VALIDATE_NOT_NULL(result); Int32 drawableRes = 0; Int32 keyframeId = 0; Int32 j = 0; Int32 numAttrs = 0; attrs->GetAttributeCount(&numAttrs); AutoPtr<ArrayOf<Int32> > states = ArrayOf<Int32>::Alloc(numAttrs); for (Int32 i = 0; i < numAttrs; i++) { Int32 stateResId = 0; attrs->GetAttributeNameResource(i, &stateResId); switch (stateResId) { case 0: break; case R::attr::id: attrs->GetAttributeResourceValue(i, 0, &keyframeId); break; case R::attr::drawable: attrs->GetAttributeResourceValue(i, 0, &drawableRes); break; default: { Boolean hasState = FALSE; attrs->GetAttributeBooleanValue(i, FALSE, &hasState); (*states)[j++] = hasState ? stateResId : -stateResId; break; } } } AutoPtr<ArrayOf<Int32> > temp = StateSet::TrimStateSet(states, j); states = temp; AutoPtr<IDrawable> dr; if (drawableRes != 0) { r->GetDrawable(drawableRes, theme, (IDrawable**)&dr); } else { Int32 type = 0; while ((parser->Next(&type), type) == IXmlPullParser::TEXT) { } if (type != IXmlPullParser::START_TAG) { String str; parser->GetPositionDescription(&str); Logger::E(LOGTAG, "XmlPullParserException: %s: <item> tag requires a 'drawable' attribute or " "child tag defining a drawable", str.string()); return E_XML_PULL_PARSER_EXCEPTION; } FAIL_RETURN(Drawable::CreateFromXmlInner(r, parser, attrs, theme, (IDrawable**)&dr)); } *result = mState->AddStateSet(states, dr, keyframeId); return NOERROR; }
ECode BluetoothInputDevice::GetConnectionState( /* [in] */ IBluetoothDevice* device, /* [out] */ Int32* state) { VALIDATE_NOT_NULL(state) *state = IBluetoothProfile::STATE_DISCONNECTED; if (VDBG) { String str; IObject::Probe(device)->ToString(&str); Logger::D(TAG, "getState(%s)", str.string()); } if (mService != NULL && IsEnabled() && IsValidDevice(device)) { // try { return mService->GetConnectionState(device, state); // } catch (RemoteException e) { // Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable())); // return BluetoothProfile.STATE_DISCONNECTED; // } } if (mService == NULL) { Logger::W(TAG, "Proxy not attached to service"); } return NOERROR; }
/** * Send Set_Idle_Time command to the connected HID input device. * * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} permission. * * @param device Remote Bluetooth Device * @param idleTime Idle time to be set on HID Device * @return false on immediate error, * true otherwise * @hide */ ECode BluetoothInputDevice::SetIdleTime( /* [in] */ IBluetoothDevice* device, /* [in] */ Byte idleTime, /* [out] */ Boolean* result) { if (device != NULL && DBG) { String deviceStr; IObject::Probe(device)->ToString(&deviceStr); Logger::D(TAG, "SetIdleTime(%s), idleTime = %d", deviceStr.string(), idleTime); } if (mService != NULL && IsEnabled() && IsValidDevice(device)) { // try { if (FAILED(mService->SetIdleTime(device, idleTime, result))) { Logger::E(TAG, "GetIdleTime: Remote invoke error: mService->SetIdleTime"); *result = FALSE; return NOERROR; } // } catch (RemoteException e) { // return false; // } } if (mService == NULL) Logger::W(TAG, "Proxy not attached to service"); *result = FALSE; return NOERROR; }
ECode BluetoothInputDevice::GetReport( /* [in] */ IBluetoothDevice* device, /* [in] */ Byte reportType, /* [in] */ Byte reportId, /* [in] */ Int32 bufferSize, /* [out] */ Boolean* result) { VALIDATE_NOT_NULL(result) *result = FALSE; if (VDBG) { String str; IObject::Probe(device)->ToString(&str); Logger::D(TAG, "getReport(%s), reportType=%d reportId=%d bufferSize=%d", str.string(), reportType, reportId, bufferSize); } if (mService != NULL && IsEnabled() && IsValidDevice(device)) { // try { return mService->GetReport(device, reportType, reportId, bufferSize, result); // } catch (RemoteException e) { // Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable())); // return false; // } } if (mService == NULL) { Logger::W(TAG, "Proxy not attached to service"); } return NOERROR; }
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); }
ECode Request::Reset() { /* clear content-length header */ // TODO: Waiting for IBasicHttpRequest assert(0); // mHttpRequest->RemoveHeaders(CONTENT_LENGTH_HEADER); if (mBodyProvider != NULL) { if(FAILED(mBodyProvider->Reset())) { if (HttpLog::LOGV) { String uri; GetUri(&uri); HttpLog::V("failed to reset body provider %s", uri.string()); } } SetBodyProvider(mBodyProvider, mBodyLength); } if (mReceivedBytes > 0) { // reset the fail count as we continue the request mFailCount = 0; // set the "Range" header to indicate that the retry will continue // instead of restarting the request HttpLog::V(String("*** Request.reset() to range:") + StringUtils::ToString(mReceivedBytes)); // TODO: Waiting for IBasicHttpRequest assert(0); // mHttpRequest->SetHeader(String("Range"), String("bytes=") + StringUtils::ToString(mReceivedBytes) + String("-")); } return NOERROR; }
void FieldEditor::field(const String& s) { String old(impl_->editor_->value()); impl_->editor_->region(0, 0, 0, old.length()); impl_->editor_->cut(); impl_->editor_->paste(s.string(), s.length()); }
ECode BluetoothInputDevice::GetPriority( /* [in] */ IBluetoothDevice* device, /* [out] */ Int32* priority) { VALIDATE_NOT_NULL(priority) *priority = IBluetoothProfile::PRIORITY_OFF; if (VDBG) { String str; IObject::Probe(device)->ToString(&str); Logger::D(TAG, "getPriority(%s)", str.string()); } if (mService != NULL && IsEnabled() && IsValidDevice(device)) { // try { return mService->GetPriority(device, priority); // } catch (RemoteException e) { // Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable())); // return BluetoothProfile.PRIORITY_OFF; // } } if (mService == NULL) { Logger::W(TAG, "Proxy not attached to service"); } return NOERROR; }
ECode CRestoreObserver::OnUpdate( /* [in] */ Int32 nowBeingRestored, /* [in] */ const String& curentPackage) { // TODO: Add your code here printf("Backup RestoreObserver::OnUpdate[%d-- %s]\n", nowBeingRestored, curentPackage.string()); return NOERROR; }
ECode CObjInfoList:: RemoveClsModule( /* [in] */ const String& path) { if (path.IsNull()) { return E_INVALID_ARGUMENT; } mClsModule.Remove((PVoid)path.string()); return NOERROR; }
Int32 FileBackupHelperBase::NativeWriteFile( /* [in] */ const String& fileName, /* [in] */ Int32 backupReader) { android::RestoreHelperBase* restore = (android::RestoreHelperBase*)mPtr; android::BackupDataReader* reader = (android::BackupDataReader*)backupReader; char const* filename = fileName.string(); int err = restore->WriteFile(android::String8(filename), reader); return err; }
ECode CInputBindResult::ToString( /* [out] */ String* str) { String strMethod; IObject::Probe(mMethod)->ToString(&strMethod); *str = NULL; str->AppendFormat("InputBindResult{%s %s sequence:%d userActionNotificationSequenceNumber:%d}", strMethod.string(), mId.string(), mSequence, mUserActionNotificationSequenceNumber); return NOERROR; }
ECode EcoFile::OpenEcoFile( /* [in] */ const String& sourceName, /* [out] */ IModuleInfo** ecoModule) { String fileName = sourceName; Int32 start = fileName.LastIndexOf("/"); Int32 end = fileName.LastIndexOf("-"); fileName = fileName.Substring(start >= 0 ? start + 1 : 0, end >= 0 ? end : fileName.GetLength() - 4) + String(".eco"); String path = String("/data/elastos/") + fileName; AutoPtr<IModuleInfo> moduleInfo; if (FAILED(CReflector::AcquireModuleInfo(path.string(), (IModuleInfo**)&moduleInfo))) { *ecoModule = NULL; Slogger::E(TAG, "OpenEcoFile: Cann't Find the Instrumentation path is %s", path.string()); return E_RUNTIME_EXCEPTION; } *ecoModule = moduleInfo; REFCOUNT_ADD(*ecoModule); return NOERROR; }
ECode ActivityInfo::ToString( /* [out] */ String* str) { VALIDATE_NOT_NULL(str) Int32 hashCode; GetHashCode(&hashCode); String pii; PackageItemInfo::ToString(&pii); str->AppendFormat("ActivityInfo{0x%08x %s}", hashCode, pii.string()); return NOERROR; }
void NetInitiatedActivity::HandleNIVerify( /* [in] */ IIntent* intent) { Int32 notifId; intent->GetInt32Extra(IGpsNetInitiatedHandler::NI_INTENT_KEY_NOTIF_ID, -1, ¬ifId); mNotificationId = notifId; String action; intent->GetAction(&action); if (DEBUG) Slogger::D(TAG, "handleNIVerify action: %s", action.string()); }
ECode CGpio::NativeWriteGpio( /* [in] */ const String& path, /* [in] */ const String& value, /* [out] */ Int32* result) { VALIDATE_NOT_NULL(result); if (mGpioService == NULL) { Slogger::E(TAG, "gpio service has not start!"); return E_NULL_POINTER_EXCEPTION; } if (path == NULL) { *result = -1; } else { const char *chars = path.string(); const char *valueStr = value.string(); *result = mGpioService->writeData(valueStr, strlen(valueStr), chars); } return NOERROR; }
Boolean FontFamily::NativeAddFontWeightStyle( /* [in] */ Int64 familyPtr, /* [in] */ const String& path, /* [in] */ Int32 weight, /* [in] */ Boolean isItalic) { 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); MinikinFont* minikinFont = new MinikinFontSkia(face); fontFamily->addFont(minikinFont, android::FontStyle(weight / 100, isItalic)); minikinFont->Unref(); return TRUE; }
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); }
void CRemoteDisplay::StartListening( /* [in] */ const String& iface) { mPtr = NativeListen(iface); if (mPtr == 0) { Logger::E("RemoteDisplay", "Could not start listening for remote display connection on \"%s\"", iface.string()); } mGuard->Open(String("CRemoteDisplay::Dispose")); }
void Observer::ObjectDiscovered( /* [in] */ const String& busname, /* [in] */ const String& path, /* [in] */ ArrayOf<String>* interfaces, /* [in] */ Int32 sessionId) { if (DEBUG) { Logger::I(TAG, " >> ObjectDiscovered: busname: %s, path: %s, sessionId: %08x", busname.string(), path.string(), sessionId); for (Int32 i = 0; i < interfaces->GetLength(); ++i) { Logger::I(TAG, " > interface %d: %s", i, (*interfaces)[i].string()); } } List<AutoPtr<IInterfaceInfo> > intfList; HashMap<String, AutoPtr<IInterfaceInfo> >::Iterator mit; for (Int32 i = 0; i < interfaces->GetLength(); ++i) { mit = mInterfaceMap.Find((*interfaces)[i]); if (mit != mInterfaceMap.End()) { intfList.PushBack(mit->mSecond); } } //TODO figure out what to do with secure bus objects Int32 i = 0; AutoPtr<ArrayOf<IInterfaceInfo*> > infos = ArrayOf<IInterfaceInfo*>::Alloc(intfList.GetSize()); List<AutoPtr<IInterfaceInfo> >::Iterator lit; for (lit = intfList.Begin(); lit != intfList.End(); ++lit) { infos->Set(i++, *lit); } AutoPtr<IProxyBusObject> proxy; mBus->GetProxyBusObject(busname, path, sessionId, infos, (IProxyBusObject**)&proxy); AutoPtr< List<AutoPtr<WrappedListener> > > copiedListeners; { AutoLock lock(this); AutoPtr<ObjectId> oid = new ObjectId(busname, path); mProxies->Put(TO_IINTERFACE(oid), proxy); copiedListeners = new List<AutoPtr<WrappedListener> >(mListeners); } /* we do the listener invocation outside of the critical region to avoid * lock ordering issues */ List<AutoPtr<WrappedListener> >::Iterator wit; for (wit = copiedListeners->Begin(); wit != copiedListeners->End(); ++wit) { if ((*wit)->mEnabled) { // protect against exceptions in listener code. if (DEBUG) { Logger::I(TAG, " >> %s ObjectDiscovered: %s", TO_CSTR((*wit)->mListener), TO_CSTR(proxy)); } (*wit)->mListener->ObjectDiscovered(proxy); } } }