void Scanner::finalizeReply() { const SerializationInfo* s = _deserializer->si().findMember("error"); if (s && !s->isNull()) { log_debug("remote error detected category=" << s->category() << " type=" << s->typeName()); std::string msg; if (s->category() == SerializationInfo::Object) { int rc = 0; s->getMember("code", rc); s->getMember("message", msg); throw RemoteException(msg, rc); } else { s->getValue(msg); if (msg.empty()) msg = "remote exception"; throw RemoteException(msg); } } _composer->fixup( _deserializer->si().getMember("result")); }
void Binder::transact(int32_t what, int32_t arg1, int32_t arg2, const sp<Object>& obj, const sp<Awaitable>& result, int32_t flags) { sp<Message> message = mMessenger->obtainMessage(what, arg1, arg2, obj); if (flags == FLAG_ONEWAY) { message->sendToTarget(); } else { message->result = result; message->sendToTarget(); try { result->await(); } catch (const CancellationException& e) { throw RemoteException(EXCEPTION_MESSAGE); } catch (const ExecutionException& e) { throw RemoteException(EXCEPTION_MESSAGE); } } }
void Parcel::putShort(short value) { checkOutput(); try { mDataOutputStream->writeShort(value); } catch (const IOException& e) { throw RemoteException(e); } }
void Parcel::putChar(char value) { checkOutput(); try { mDataOutputStream->writeChar(value); } catch (const IOException& e) { throw RemoteException(e); } }
void Parcel::putByte(uint8_t value) { checkOutput(); try { mDataOutputStream->writeByte(value); } catch (const IOException& e) { throw RemoteException(e); } }
void Parcel::putBoolean(bool value) { checkOutput(); try { mDataOutputStream->writeBoolean(value); } catch (const IOException& e) { throw RemoteException(e); } }
sp<String> Parcel::getString() { checkInput(); try { return mDataInputStream->readUTF(); } catch (const IOException& e) { throw RemoteException(e); } }
double Parcel::getDouble() { checkInput(); try { return mDataInputStream->readDouble(); } catch (const IOException& e) { throw RemoteException(e); } }
uint64_t Parcel::getLong() { checkInput(); try { return mDataInputStream->readLong(); } catch (const IOException& e) { throw RemoteException(e); } }
bool Parcel::getBoolean() { checkInput(); try { return mDataInputStream->readBoolean(); } catch (const IOException& e) { throw RemoteException(e); } }
void Parcel::putString(const sp<String>& value) { checkOutput(); try { mDataOutputStream->writeUTF(value); } catch (const IOException& e) { throw RemoteException(e); } }
void Parcel::putDouble(double value) { checkOutput(); try { mDataOutputStream->writeDouble(value); } catch (const IOException& e) { throw RemoteException(e); } }
sp<URI> Parcel::toUri(const sp<IBinder>& base, const sp<IBinder>& binder) { try { sp<URI> descriptor = new URI(binder->getInterfaceDescriptor()); sp<URI> uri = new URI(base->getUri()->getScheme(), binder->getUri()->getAuthority(), String::format("/if=%s", descriptor->getPath()->substring(1)->c_str()), descriptor->getQuery(), nullptr); return uri; } catch (const URISyntaxException& e) { throw RemoteException(e); } }
void ControlMessage::checkRetCode() { UINT32 messageId = m_gate->readUInt32(); switch (messageId) { case ControlProto::REPLY_ERROR: { StringStorage message; m_gate->readUTF8(&message); throw RemoteException(message.getString()); } break; case ControlProto::REPLY_OK: break; default: _ASSERT(FALSE); throw RemoteException(_T("Unknown ret code.")); } }
void ControlMessage::checkRetCode() { UINT32 messageId = m_gate->readUInt32(); switch (messageId) { case ControlProto::REPLY_ERROR: { StringStorage message; m_gate->readUTF8(&message); throw RemoteException(message.getString()); } break; case ControlProto::REPLY_AUTH_NEEDED: if (m_passwordFile.getLength() != 0) { authFromFile(); } else if (m_getPassFromConfigEnabled) { authFromRegistry(); } else { ControlAuthDialog authDialog; int retCode = authDialog.showModal(); switch (retCode) { case IDCANCEL: throw ControlAuthException(StringTable::getString(IDS_USER_CANCEL_CONTROL_AUTH), true); case IDOK: ControlAuth auth(m_gate, authDialog.getPassword()); send(); break; } } break; case ControlProto::REPLY_OK: break; default: _ASSERT(FALSE); throw RemoteException(_T("Unknown ret code.")); } }
void ClientStub::requestTransportFilters(const std::vector<FilterPtr> &filters) { if (getRuntimeVersion() <= 11) { requestTransportFilters_Legacy(filters); return; } ClientStub stub(*this); stub.setTransport( releaseTransport()); stub.setTargetToken( Token()); RestoreClientTransportGuard guard(*this, stub); // Set OOB request. OobRequestTransportFilters msg(getRuntimeVersion(), filters); ByteBuffer controlRequest; msg.encodeRequest(controlRequest); stub.setOutofBandRequest(controlRequest); stub.ping(RCF::Twoway); // Get OOB response. ByteBuffer controlResponse = stub.getOutOfBandResponse(); stub.setOutofBandRequest(ByteBuffer()); stub.setOutofBandResponse(ByteBuffer()); msg.decodeResponse(controlResponse); int ret = msg.mResponseError; RCF_VERIFY(ret == RcfError_Ok, RemoteException( Error(ret) )); for (std::size_t i=0; i<filters.size(); ++i) { filters[i]->resetState(); } stub.getTransport().setTransportFilters(filters); }