本文整理汇总了C++中String8::size方法的典型用法代码示例。如果您正苦于以下问题:C++ String8::size方法的具体用法?C++ String8::size怎么用?C++ String8::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String8
的用法示例。
在下文中一共展示了String8::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: snprintf
status_t AudioPolicyService::AudioCommandThread::dump(int fd)
{
const size_t SIZE = 256;
char buffer[SIZE];
String8 result;
snprintf(buffer, SIZE, "AudioCommandThread %p Dump\n", this);
result.append(buffer);
write(fd, result.string(), result.size());
bool locked = tryLock(mLock);
if (!locked) {
String8 result2(kCmdDeadlockedString);
write(fd, result2.string(), result2.size());
}
snprintf(buffer, SIZE, "- Commands:\n");
result = String8(buffer);
result.append(" Command Time Wait pParam\n");
for (int i = 0; i < (int)mAudioCommands.size(); i++) {
mAudioCommands[i]->dump(buffer, SIZE);
result.append(buffer);
}
result.append(" Last Command\n");
mLastCommand.dump(buffer, SIZE);
result.append(buffer);
write(fd, result.string(), result.size());
if (locked) mLock.unlock();
return NO_ERROR;
}
示例2: dump
status_t StreamingProcessor::dump(int fd, const Vector<String16>& /*args*/) {
String8 result;
result.append(" Current requests:\n");
if (mPreviewRequest.entryCount() != 0) {
result.append(" Preview request:\n");
write(fd, result.string(), result.size());
mPreviewRequest.dump(fd, 2, 6);
result.clear();
} else {
result.append(" Preview request: undefined\n");
}
if (mRecordingRequest.entryCount() != 0) {
result = " Recording request:\n";
write(fd, result.string(), result.size());
mRecordingRequest.dump(fd, 2, 6);
result.clear();
} else {
result = " Recording request: undefined\n";
}
const char* streamTypeString[] = {
"none", "preview", "record"
};
result.append(String8::format(" Active request: %s (paused: %s)\n",
streamTypeString[mActiveRequest],
mPaused ? "yes" : "no"));
write(fd, result.string(), result.size());
return OK;
}
示例3: DdmHandleNativeHeap_getLeakInfo
/*
* Retrieve the native heap information and the info from /proc/self/maps,
* copy them into a byte[] with a "struct Header" that holds data offsets,
* and return the array.
*/
static jbyteArray DdmHandleNativeHeap_getLeakInfo(JNIEnv* env, jobject) {
Header header;
memset(&header, 0, sizeof(header));
String8 maps;
ReadFile("/proc/self/maps", maps);
header.mapSize = maps.size();
uint8_t* allocBytes;
get_malloc_leak_info(&allocBytes, &header.allocSize, &header.allocInfoSize,
&header.totalMemory, &header.backtraceSize);
ALOGD("*** mapSize: %zu allocSize: %zu allocInfoSize: %zu totalMemory: %zu",
header.mapSize, header.allocSize, header.allocInfoSize, header.totalMemory);
#if defined(__LP64__)
header.signature = DDMS_HEADER_SIGNATURE;
header.version = DDMS_VERSION;
header.pointerSize = sizeof(void*);
#endif
jbyteArray array = env->NewByteArray(sizeof(Header) + header.mapSize + header.allocSize);
if (array != NULL) {
env->SetByteArrayRegion(array, 0,
sizeof(header), reinterpret_cast<jbyte*>(&header));
env->SetByteArrayRegion(array, sizeof(header),
maps.size(), reinterpret_cast<const jbyte*>(maps.string()));
env->SetByteArrayRegion(array, sizeof(header) + maps.size(),
header.allocSize, reinterpret_cast<jbyte*>(allocBytes));
}
free_malloc_leak_info(allocBytes);
return array;
}
示例4: dump
status_t CameraService::dump(int fd, const Vector<String16>& args) {
static const char* kDeadlockedString = "CameraService may be deadlocked\n";
const size_t SIZE = 256;
char buffer[SIZE];
String8 result;
if (checkCallingPermission(String16("android.permission.DUMP")) == false) {
snprintf(buffer, SIZE, "Permission Denial: "
"can't dump CameraService from pid=%d, uid=%d\n",
getCallingPid(),
getCallingUid());
result.append(buffer);
write(fd, result.string(), result.size());
} else {
bool locked = tryLock(mServiceLock);
// failed to lock - CameraService is probably deadlocked
if (!locked) {
String8 result(kDeadlockedString);
write(fd, result.string(), result.size());
}
bool hasClient = false;
for (int i = 0; i < mNumberOfCameras; i++) {
sp<Client> client = mClient[i].promote();
if (client == 0) continue;
hasClient = true;
sprintf(buffer, "Client[%d] (%p) PID: %d\n",
i,
client->getCameraClient()->asBinder().get(),
client->mClientPid);
result.append(buffer);
write(fd, result.string(), result.size());
client->mHardware->dump(fd, args);
}
if (!hasClient) {
result.append("No camera client yet.\n");
write(fd, result.string(), result.size());
}
if (locked) mServiceLock.unlock();
// change logging level
int n = args.size();
for (int i = 0; i + 1 < n; i++) {
if (args[i] == String16("-v")) {
String8 levelStr(args[i+1]);
int level = atoi(levelStr.string());
sprintf(buffer, "Set Log Level to %d", level);
result.append(buffer);
setLogLevel(level);
}
}
}
return NO_ERROR;
}
示例5: write
void Camera3ZslStream::dump(int fd, const Vector<String16> &args) const {
(void) args;
String8 lines;
lines.appendFormat(" Stream[%d]: ZSL\n", mId);
write(fd, lines.string(), lines.size());
Camera3IOStreamBase::dump(fd, args);
lines = String8();
lines.appendFormat(" Input buffers pending: %zu, in flight %zu\n",
mInputBufferQueue.size(), mBuffersInFlight.size());
write(fd, lines.string(), lines.size());
}
示例6: snprintf
status_t AudioHardware::AudioStreamOutMSM72xx::dump(int fd, const Vector<String16>& args)
{
const size_t SIZE = 256;
char buffer[SIZE];
String8 result;
result.append("AudioStreamOutMSM72xx::dump\n");
snprintf(buffer, SIZE, "\tsample rate: %d\n", sampleRate());
result.append(buffer);
snprintf(buffer, SIZE, "\tbuffer size: %d\n", bufferSize());
result.append(buffer);
snprintf(buffer, SIZE, "\tchannels: %d\n", channels());
result.append(buffer);
snprintf(buffer, SIZE, "\tformat: %d\n", format());
result.append(buffer);
snprintf(buffer, SIZE, "\tmHardware: %p\n", mHardware);
result.append(buffer);
snprintf(buffer, SIZE, "\tmFd: %d\n", mFd);
result.append(buffer);
snprintf(buffer, SIZE, "\tmStartCount: %d\n", mStartCount);
result.append(buffer);
snprintf(buffer, SIZE, "\tmRetryCount: %d\n", mRetryCount);
result.append(buffer);
snprintf(buffer, SIZE, "\tmStandby: %s\n", mStandby? "true": "false");
result.append(buffer);
::write(fd, result.string(), result.size());
return NO_ERROR;
}
示例7: dump
void AudioGain::dump(int fd, int spaces, int index) const
{
const size_t SIZE = 256;
char buffer[SIZE];
String8 result;
snprintf(buffer, SIZE, "%*sGain %d:\n", spaces, "", index+1);
result.append(buffer);
snprintf(buffer, SIZE, "%*s- mode: %08x\n", spaces, "", mGain.mode);
result.append(buffer);
snprintf(buffer, SIZE, "%*s- channel_mask: %08x\n", spaces, "", mGain.channel_mask);
result.append(buffer);
snprintf(buffer, SIZE, "%*s- min_value: %d mB\n", spaces, "", mGain.min_value);
result.append(buffer);
snprintf(buffer, SIZE, "%*s- max_value: %d mB\n", spaces, "", mGain.max_value);
result.append(buffer);
snprintf(buffer, SIZE, "%*s- default_value: %d mB\n", spaces, "", mGain.default_value);
result.append(buffer);
snprintf(buffer, SIZE, "%*s- step_value: %d mB\n", spaces, "", mGain.step_value);
result.append(buffer);
snprintf(buffer, SIZE, "%*s- min_ramp_ms: %d ms\n", spaces, "", mGain.min_ramp_ms);
result.append(buffer);
snprintf(buffer, SIZE, "%*s- max_ramp_ms: %d ms\n", spaces, "", mGain.max_ramp_ms);
result.append(buffer);
write(fd, result.string(), result.size());
}
示例8: dump
status_t MemPool::dump(int fd, const Vector<String16>& args) const
{
const size_t SIZE = 256;
char buffer[SIZE];
String8 result;
CAMERA_HAL_UNUSED(args);
snprintf(buffer, 255, "QualcommCameraHardware::AshmemPool::dump\n");
result.append(buffer);
if (mName) {
snprintf(buffer, 255, "mem pool name (%s)\n", mName);
result.append(buffer);
}
if (mHeap != 0) {
snprintf(buffer, 255, "heap base(%p), size(%d), flags(%d), device(%s)\n",
mHeap->getBase(), mHeap->getSize(),
mHeap->getFlags(), mHeap->getDevice());
result.append(buffer);
}
snprintf(buffer, 255,
"buffer size (%d), number of buffers (%d), frame size(%d)",
mBufferSize, mNumBuffers, mFrameSize);
result.append(buffer);
write(fd, result.string(), result.size());
return NO_ERROR;
}
示例9: header
void ZslProcessor3::dumpZslQueue(int fd) const {
String8 header("ZSL queue contents:");
String8 indent(" ");
ALOGV("%s", header.string());
if (fd != -1) {
header = indent + header + "\n";
write(fd, header.string(), header.size());
}
for (size_t i = 0; i < mZslQueue.size(); i++) {
const ZslPair &queueEntry = mZslQueue[i];
nsecs_t bufferTimestamp = queueEntry.buffer.mTimestamp;
camera_metadata_ro_entry_t entry;
nsecs_t frameTimestamp = 0;
int frameAeState = -1;
if (!queueEntry.frame.isEmpty()) {
entry = queueEntry.frame.find(ANDROID_SENSOR_TIMESTAMP);
if (entry.count > 0) frameTimestamp = entry.data.i64[0];
entry = queueEntry.frame.find(ANDROID_CONTROL_AE_STATE);
if (entry.count > 0) frameAeState = entry.data.u8[0];
}
String8 result =
String8::format(" %d: b: %lld\tf: %lld, AE state: %d", i,
bufferTimestamp, frameTimestamp, frameAeState);
ALOGV("%s", result.string());
if (fd != -1) {
result = indent + result + "\n";
write(fd, result.string(), result.size());
}
}
}
示例10: parse
android::status_t InitDataParser::parse(const Vector<uint8_t>& initData,
const String8& type,
Vector<uint8_t>* licenseRequest) {
// Build a list of the key IDs
Vector<const uint8_t*> keyIds;
if (type == kIsoBmffVideoMimeType ||
type == kIsoBmffAudioMimeType ||
type == kCencInitDataFormat) {
android::status_t res = parsePssh(initData, &keyIds);
if (res != android::OK) {
return res;
}
} else if (type == kWebmVideoMimeType ||
type == kWebmAudioMimeType ||
type == kWebmInitDataFormat) {
// WebM "init data" is just a single key ID
if (initData.size() != kKeyIdSize) {
return android::ERROR_DRM_CANNOT_HANDLE;
}
keyIds.push(initData.array());
} else {
return android::ERROR_DRM_CANNOT_HANDLE;
}
// Build the request
String8 requestJson = generateRequest(keyIds);
licenseRequest->clear();
licenseRequest->appendArray(
reinterpret_cast<const uint8_t*>(requestJson.string()),
requestJson.size());
return android::OK;
}
示例11: dumpClient
status_t CameraDeviceClient::dumpClient(int fd, const Vector<String16>& args) {
String8 result;
result.appendFormat("CameraDeviceClient[%d] (%p) dump:\n",
mCameraId,
(getRemoteCallback() != NULL ?
IInterface::asBinder(getRemoteCallback()).get() : NULL) );
result.appendFormat(" Current client UID %u\n", mClientUid);
result.append(" State:\n");
result.appendFormat(" Request ID counter: %d\n", mRequestIdCounter);
if (mInputStream.configured) {
result.appendFormat(" Current input stream ID: %d\n",
mInputStream.id);
} else {
result.append(" No input stream configured.\n");
}
if (!mStreamMap.isEmpty()) {
result.append(" Current output stream IDs:\n");
for (size_t i = 0; i < mStreamMap.size(); i++) {
result.appendFormat(" Stream %d\n", mStreamMap.valueAt(i));
}
} else {
result.append(" No output streams configured.\n");
}
write(fd, result.string(), result.size());
// TODO: print dynamic/request section from most recent requests
mFrameProcessor->dump(fd, args);
return dumpDevice(fd, args);
}
示例12: dump
status_t DrmManagerService::dump(int fd, const Vector<String16>& args)
{
const size_t SIZE = 256;
char buffer[SIZE];
String8 result;
if (checkCallingPermission(String16("android.permission.DUMP")) == false) {
snprintf(buffer, SIZE, "Permission Denial: "
"can't dump DrmManagerService from pid=%d, uid=%d\n",
IPCThreadState::self()->getCallingPid(),
IPCThreadState::self()->getCallingUid());
result.append(buffer);
} else {
#if DRM_MEMORY_LEAK_TRACK
bool dumpMem = false;
for (size_t i = 0; i < args.size(); i++) {
if (args[i] == String16("-m")) {
dumpMem = true;
}
}
if (dumpMem) {
dumpMemoryAddresses(fd);
}
#endif
}
write(fd, result.string(), result.size());
return NO_ERROR;
}
示例13: write
void Camera3InputStream::dump(int fd, const Vector<String16> &args) const {
(void) args;
String8 lines;
lines.appendFormat(" Stream[%d]: Input\n", mId);
write(fd, lines.string(), lines.size());
Camera3IOStreamBase::dump(fd, args);
}
示例14: dumpInternals
status_t TinyAudioHardware::dumpInternals(int fd, const Vector<String16>& args)
{
const size_t SIZE = 256;
char buffer[SIZE];
String8 result;
::write(fd, result.string(), result.size());
return NO_ERROR;
}
示例15: update
status_t CameraMetadata::update(uint32_t tag,
const String8 &string) {
status_t res;
if ( (res = checkType(tag, TYPE_BYTE)) != OK) {
return res;
}
return update(tag, (const void*)string.string(), string.size());
}