本文整理汇总了C++中String8类的典型用法代码示例。如果您正苦于以下问题:C++ String8类的具体用法?C++ String8怎么用?C++ String8使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了String8类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
const char* CameraProperties::Properties::get(const char * prop)
{
String8 value = mProperties->valueFor(String8(prop));
return value.string();
}
示例2: snprintf
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;
}
示例3: getCallingPid
status_t CameraService::dump(int fd, const Vector<String16>& args) {
String8 result;
if (checkCallingPermission(String16("android.permission.DUMP")) == false) {
result.appendFormat("Permission Denial: "
"can't dump CameraService from pid=%d, uid=%d\n",
getCallingPid(),
getCallingUid());
write(fd, result.string(), result.size());
} else {
bool locked = tryLock(mServiceLock);
// failed to lock - CameraService is probably deadlocked
if (!locked) {
result.append("CameraService may be deadlocked\n");
write(fd, result.string(), result.size());
}
bool hasClient = false;
if (!mModule) {
result = String8::format("No camera module available!\n");
write(fd, result.string(), result.size());
return NO_ERROR;
}
result = String8::format("Camera module HAL API version: 0x%x\n",
mModule->common.hal_api_version);
result.appendFormat("Camera module API version: 0x%x\n",
mModule->common.module_api_version);
result.appendFormat("Camera module name: %s\n",
mModule->common.name);
result.appendFormat("Camera module author: %s\n",
mModule->common.author);
result.appendFormat("Number of camera devices: %d\n\n", mNumberOfCameras);
write(fd, result.string(), result.size());
for (int i = 0; i < mNumberOfCameras; i++) {
result = String8::format("Camera %d static information:\n", i);
camera_info info;
status_t rc = mModule->get_camera_info(i, &info);
if (rc != OK) {
result.appendFormat(" Error reading static information!\n");
write(fd, result.string(), result.size());
} else {
result.appendFormat(" Facing: %s\n",
info.facing == CAMERA_FACING_BACK ? "BACK" : "FRONT");
result.appendFormat(" Orientation: %d\n", info.orientation);
int deviceVersion;
if (mModule->common.module_api_version <
CAMERA_MODULE_API_VERSION_2_0) {
deviceVersion = CAMERA_DEVICE_API_VERSION_1_0;
} else {
deviceVersion = info.device_version;
}
result.appendFormat(" Device version: 0x%x\n", deviceVersion);
if (deviceVersion >= CAMERA_DEVICE_API_VERSION_2_0) {
result.appendFormat(" Device static metadata:\n");
write(fd, result.string(), result.size());
dump_indented_camera_metadata(info.static_camera_characteristics,
fd, 2, 4);
} else {
write(fd, result.string(), result.size());
}
}
sp<Client> client = mClient[i].promote();
if (client == 0) {
result = String8::format(" Device is closed, no client instance\n");
write(fd, result.string(), result.size());
continue;
}
hasClient = true;
result = String8::format(" Device is open. Client instance dump:\n");
write(fd, result.string(), result.size());
client->dump(fd, args);
}
if (!hasClient) {
result = String8::format("\nNo active camera clients 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++) {
String16 verboseOption("-v");
if (args[i] == verboseOption) {
String8 levelStr(args[i+1]);
int level = atoi(levelStr.string());
result = String8::format("\nSetting log level to %d.\n", level);
setLogLevel(level);
write(fd, result.string(), result.size());
}
}
}
return NO_ERROR;
}
示例4: dump
status_t AudioStreamInMotorola::dump(int fd, const Vector<String16>& args)
{
const size_t SIZE = 256;
char buffer[SIZE];
String8 result;
result.append("AudioStreamInMotorola::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 count: %d\n", mFd);
result.append(buffer);
snprintf(buffer, SIZE, "\tmStandby: %d\n", mStandby);
result.append(buffer);
snprintf(buffer, SIZE, "\tmRetryCount: %d\n", mRetryCount);
result.append(buffer);
::write(fd, result.string(), result.size());
return NO_ERROR;
}
示例5: setParameter
status_t StagefrightRecorder::setParameter(
const String8 &key, const String8 &value) {
LOGV("setParameter: key (%s) => value (%s)", key.string(), value.string());
if (key == "max-duration") {
int64_t max_duration_ms;
if (safe_strtoi64(value.string(), &max_duration_ms)) {
return setParamMaxFileDurationUs(1000LL * max_duration_ms);
}
} else if (key == "max-filesize") {
int64_t max_filesize_bytes;
if (safe_strtoi64(value.string(), &max_filesize_bytes)) {
return setParamMaxFileSizeBytes(max_filesize_bytes);
}
} else if (key == "interleave-duration-us") {
int32_t durationUs;
if (safe_strtoi32(value.string(), &durationUs)) {
return setParamInterleaveDuration(durationUs);
}
} else if (key == "param-movie-time-scale") {
int32_t timeScale;
if (safe_strtoi32(value.string(), &timeScale)) {
return setParamMovieTimeScale(timeScale);
}
} else if (key == "param-use-64bit-offset") {
int32_t use64BitOffset;
if (safe_strtoi32(value.string(), &use64BitOffset)) {
return setParam64BitFileOffset(use64BitOffset != 0);
}
} else if (key == "param-track-time-status") {
int64_t timeDurationUs;
if (safe_strtoi64(value.string(), &timeDurationUs)) {
return setParamTrackTimeStatus(timeDurationUs);
}
} else if (key == "audio-param-sampling-rate") {
int32_t sampling_rate;
if (safe_strtoi32(value.string(), &sampling_rate)) {
return setParamAudioSamplingRate(sampling_rate);
}
} else if (key == "audio-param-number-of-channels") {
int32_t number_of_channels;
if (safe_strtoi32(value.string(), &number_of_channels)) {
return setParamAudioNumberOfChannels(number_of_channels);
}
} else if (key == "audio-param-encoding-bitrate") {
int32_t audio_bitrate;
if (safe_strtoi32(value.string(), &audio_bitrate)) {
return setParamAudioEncodingBitRate(audio_bitrate);
}
} else if (key == "audio-param-time-scale") {
int32_t timeScale;
if (safe_strtoi32(value.string(), &timeScale)) {
return setParamAudioTimeScale(timeScale);
}
} else if (key == "video-param-encoding-bitrate") {
int32_t video_bitrate;
if (safe_strtoi32(value.string(), &video_bitrate)) {
return setParamVideoEncodingBitRate(video_bitrate);
}
} else if (key == "video-param-rotation-angle-degrees") {
int32_t degrees;
if (safe_strtoi32(value.string(), °rees)) {
return setParamVideoRotation(degrees);
}
} else if (key == "video-param-i-frames-interval") {
int32_t seconds;
if (safe_strtoi32(value.string(), &seconds)) {
return setParamVideoIFramesInterval(seconds);
}
} else if (key == "video-param-encoder-profile") {
int32_t profile;
if (safe_strtoi32(value.string(), &profile)) {
return setParamVideoEncoderProfile(profile);
}
} else if (key == "video-param-encoder-level") {
int32_t level;
if (safe_strtoi32(value.string(), &level)) {
return setParamVideoEncoderLevel(level);
}
} else if (key == "video-param-camera-id") {
int32_t cameraId;
if (safe_strtoi32(value.string(), &cameraId)) {
return setParamVideoCameraId(cameraId);
}
} else if (key == "video-param-time-scale") {
int32_t timeScale;
if (safe_strtoi32(value.string(), &timeScale)) {
return setParamVideoTimeScale(timeScale);
}
} else {
LOGE("setParameter: failed to find key %s", key.string());
}
return BAD_VALUE;
}
示例6: audio_volume_control_handler
int audio_volume_control_handler(char* cmdline, ATOP_t at_op, char* response)
{
ALOGD("audio cmd handler handles cmdline:%s", cmdline);
int actinoID = 0;
int mStreamVolumeIndex = 0;
int mPhoneMode = 0;
float mVoiceVolume = 0.0;
bool bMusic_FM_Mute = false;
char sKeyParams[64];
char *pParam = sKeyParams;
String8 keyValuePairs;
// five level for voice music and FM stream type
int mStreamVolumeValue[5][3] = {{0,0,0},{1,1,1},{4,8,4},{5,12,12},{6,13,13}};
float mVoiceVolumeValue[5] = {0.0,0.1,0.45,0.9,1.0};
int mVoiceVolumeLevelValue[6] = {0,0,3,6,4,5};
keyValuePairs = AudioSystem::getParameters(0, String8("GetPhoneMode"));
ALOGD("audio cmd handler get phone mode:%s", keyValuePairs.string());
strcpy(sKeyParams, keyValuePairs.string());
at_tok_start_flag(&pParam, '=');
at_tok_nextint(&pParam, &mPhoneMode);
switch(at_op){
case AT_ACTION_OP:
case AT_READ_OP:
case AT_TEST_OP:
if (mPhoneMode==AUDIO_MODE_IN_CALL || mPhoneMode==AUDIO_MODE_IN_COMMUNICATION || Acoustic_Loopback_On){
keyValuePairs = AudioSystem::getParameters(0, String8("AT_GetVolumeMute"));
ALOGD("audio cmd handler get voice mute:%s", keyValuePairs.string());
strcpy(sKeyParams, keyValuePairs.string());
pParam = sKeyParams;
at_tok_start_flag(&pParam, '=');
bMusic_FM_Mute = strcmp(pParam,"true")==0?true:false;
if (!bMusic_FM_Mute) {
AudioSystem::getStreamVolumeIndex(AUDIO_STREAM_VOICE_CALL, &mStreamVolumeIndex, AUDIO_DEVICE_OUT_EARPIECE);
ALOGD("audio cmd handler get voice volume index:%d", mStreamVolumeIndex);
if (mStreamVolumeIndex==1) {
sprintf(response,"\r\n1\r\n\r\nOK\r\n");
}else if (mStreamVolumeIndex==4) {
sprintf(response,"\r\n2\r\n\r\nOK\r\n");
}else if (mStreamVolumeIndex==5) {
sprintf(response,"\r\n3\r\n\r\nOK\r\n");
}else if (mStreamVolumeIndex==6) {
sprintf(response,"\r\n4\r\n\r\nOK\r\n");
}else {
sprintf(response,"\r\nNot Min/Default/Max Volume\r\n\r\nOK\r\n");
}
}else {
sprintf(response,"\r\n0\r\n\r\nOK\r\n");
}
}else{
AudioSystem::getStreamVolumeIndex(AUDIO_STREAM_MUSIC, &mStreamVolumeIndex, AUDIO_DEVICE_OUT_SPEAKER);
if(mStreamVolumeIndex==0) {
sprintf(response,"\r\n0\r\n\r\nOK\r\n");
}else if (mStreamVolumeIndex==1){
sprintf(response,"\r\n1\r\n\r\nOK\r\n");
}else if (mStreamVolumeIndex==8){
sprintf(response,"\r\n2\r\n\r\nOK\r\n");
}else if (mStreamVolumeIndex==12){
sprintf(response,"\r\n3\r\n\r\nOK\r\n");
}else if (mStreamVolumeIndex==13){
sprintf(response,"\r\n4\r\n\r\nOK\r\n");
} else {
sprintf(response,"\r\nNot Min/Default/Max Volume\r\n\r\nOK\r\n");
}
}
break;
case AT_SET_OP:
at_tok_nextint(&cmdline, &actinoID);
if (actinoID<0 || actinoID>4) {
sprintf(response,"\r\nVLC ERROR\r\n");
break;
}
if (mPhoneMode==AUDIO_MODE_IN_CALL || mPhoneMode==AUDIO_MODE_IN_COMMUNICATION || Acoustic_Loopback_On) {
if (actinoID==0) {
AudioSystem::setParameters(0, String8("AT_SetVolumeMute=1"));
}else{
AudioSystem::setParameters(0, String8("AT_SetVolumeMute=0"));
#if 0
if (Acoustic_Loopback_On) {
sprintf(sKeyParams, "AT_SetACSVolume=%f", mVoiceVolumeValue[actinoID]);
AudioSystem::setParameters(0, String8(sKeyParams));
}
AudioSystem::setStreamVolumeIndex(AUDIO_STREAM_VOICE_CALL, mStreamVolumeValue[actinoID][0],AUDIO_DEVICE_OUT_EARPIECE);
AudioSystem::setStreamVolumeIndex(AUDIO_STREAM_VOICE_CALL, mStreamVolumeValue[actinoID][0],AUDIO_DEVICE_OUT_SPEAKER);
AudioSystem::setStreamVolumeIndex(AUDIO_STREAM_VOICE_CALL, mStreamVolumeValue[actinoID][0],AUDIO_DEVICE_OUT_WIRED_HEADSET);
AudioSystem::setStreamVolumeIndex(AUDIO_STREAM_VOICE_CALL, mStreamVolumeValue[actinoID][0],AUDIO_DEVICE_OUT_WIRED_HEADPHONE);
#endif
}
}else{
// unmute music stream, and set music volume
AudioSystem::setStreamMute(AUDIO_STREAM_MUSIC, false);
AudioSystem::setStreamVolumeIndex(AUDIO_STREAM_MUSIC, mStreamVolumeValue[actinoID][1],AUDIO_DEVICE_OUT_SPEAKER);
AudioSystem::setStreamVolumeIndex(AUDIO_STREAM_MUSIC, mStreamVolumeValue[actinoID][1],AUDIO_DEVICE_OUT_WIRED_HEADSET);
AudioSystem::setStreamVolumeIndex(AUDIO_STREAM_MUSIC, mStreamVolumeValue[actinoID][1],AUDIO_DEVICE_OUT_WIRED_HEADPHONE);
//unmute FM stream, and set FM volume
//.........这里部分代码省略.........
示例7: getBooleanField
bool BatteryMonitor::update(void) {
bool logthis;
props.chargerAcOnline = false;
props.chargerUsbOnline = false;
props.chargerWirelessOnline = false;
props.batteryStatus = BATTERY_STATUS_UNKNOWN;
props.batteryHealth = BATTERY_HEALTH_UNKNOWN;
if (!mHealthdConfig->batteryPresentPath.isEmpty())
props.batteryPresent = getBooleanField(mHealthdConfig->batteryPresentPath);
else
props.batteryPresent = mBatteryDevicePresent;
props.batteryLevel = mBatteryFixedCapacity ?
mBatteryFixedCapacity :
getIntField(mHealthdConfig->batteryCapacityPath);
props.batteryVoltage = getIntField(mHealthdConfig->batteryVoltagePath) / 1000;
props.batteryTemperature = mBatteryFixedTemperature ?
mBatteryFixedTemperature :
getIntField(mHealthdConfig->batteryTemperaturePath);
const int SIZE = 128;
char buf[SIZE];
String8 btech;
if (readFromFile(mHealthdConfig->batteryStatusPath, buf, SIZE) > 0)
props.batteryStatus = getBatteryStatus(buf);
if (readFromFile(mHealthdConfig->batteryHealthPath, buf, SIZE) > 0)
props.batteryHealth = getBatteryHealth(buf);
if (readFromFile(mHealthdConfig->batteryTechnologyPath, buf, SIZE) > 0)
props.batteryTechnology = String8(buf);
unsigned int i;
for (i = 0; i < mChargerNames.size(); i++) {
String8 path;
path.appendFormat("%s/%s/online", POWER_SUPPLY_SYSFS_PATH,
mChargerNames[i].string());
if (readFromFile(path, buf, SIZE) > 0) {
if (buf[0] != '0') {
path.clear();
path.appendFormat("%s/%s/type", POWER_SUPPLY_SYSFS_PATH,
mChargerNames[i].string());
switch(readPowerSupplyType(path)) {
case ANDROID_POWER_SUPPLY_TYPE_AC:
props.chargerAcOnline = true;
break;
case ANDROID_POWER_SUPPLY_TYPE_USB:
props.chargerUsbOnline = true;
break;
case ANDROID_POWER_SUPPLY_TYPE_WIRELESS:
props.chargerWirelessOnline = true;
break;
default:
KLOG_WARNING(LOG_TAG, "%s: Unknown power supply type\n",
mChargerNames[i].string());
}
}
}
}
logthis = !healthd_board_battery_update(&props);
if (logthis) {
char dmesgline[256];
if (props.batteryPresent) {
snprintf(dmesgline, sizeof(dmesgline),
"battery l=%d v=%d t=%s%d.%d h=%d st=%d",
props.batteryLevel, props.batteryVoltage,
props.batteryTemperature < 0 ? "-" : "",
abs(props.batteryTemperature / 10),
abs(props.batteryTemperature % 10), props.batteryHealth,
props.batteryStatus);
if (!mHealthdConfig->batteryCurrentNowPath.isEmpty()) {
int c = getIntField(mHealthdConfig->batteryCurrentNowPath);
char b[20];
snprintf(b, sizeof(b), " c=%d", c / 1000);
strlcat(dmesgline, b, sizeof(dmesgline));
}
} else {
snprintf(dmesgline, sizeof(dmesgline),
"battery none");
}
KLOG_WARNING(LOG_TAG, "%s chg=%s%s%s\n", dmesgline,
props.chargerAcOnline ? "a" : "",
props.chargerUsbOnline ? "u" : "",
props.chargerWirelessOnline ? "w" : "");
}
healthd_mode_ops->battery_update(&props);
return props.chargerAcOnline | props.chargerUsbOnline |
//.........这里部分代码省略.........
示例8: LCHLOGD1
// static
sp<MediaExtractor> MediaExtractor::Create(
const sp<DataSource> &source, const char *mime) {
sp<AMessage> meta;
LCHLOGD1("mime=%s, MIME=%s", mime, source->getMIMEType().string());
String8 tmp;
if (mime == NULL) {
float confidence;
if (!source->sniff(&tmp, &confidence, &meta)) {
LOGV("FAILED to autodetect media content.");
return NULL;
}
mime = tmp.string();
LOGV("Autodetected media content as '%s' with confidence %.2f",
mime, confidence);
}
bool isDrm = false;
// DRM MIME type syntax is "drm+type+original" where
// type is "es_based" or "container_based" and
// original is the content's cleartext MIME type
if (!strncmp(mime, "drm+", 4)) {
const char *originalMime = strchr(mime+4, '+');
if (originalMime == NULL) {
// second + not found
return NULL;
}
++originalMime;
if (!strncmp(mime, "drm+es_based+", 13)) {
// DRMExtractor sets container metadata kKeyIsDRM to 1
return new DRMExtractor(source, originalMime);
} else if (!strncmp(mime, "drm+container_based+", 20)) {
mime = originalMime;
isDrm = true;
} else {
return NULL;
}
}
MediaExtractor *ret = NULL;
/* [email protected] begin */
/*
if (source->getUri() &&
strlen(source->getUri()) &&
!isSystemMedia(source->getUri())) {
using namespace FFMPEG;
ret = new FFmpegExtractor(source);
LOGD("zx, create FFmpegExtractor.");
}
else {
*/
/* [email protected] end */
#if !defined(USE_FFMPEG_EXTRACTOR)
ZXLOGD("not use FFmpegExtractor.");
#warning "not defined USE_FFMPEG_EXTRACTOR"
#endif
LCHLOGD1("mime=%s, file=%s", mime, source->getUri().string());
if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPEG4)
|| !strcasecmp(mime, "audio/mp4")) {
ret = new MPEG4Extractor(source);
} else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_MPEG)) {
ret = new MP3Extractor(source, meta);
} else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AMR_NB)
|| !strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AMR_WB)) {
ret = new AMRExtractor(source);
} else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_FLAC)) {
ret = new FLACExtractor(source);
} else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_WAV)) {
ret = new WAVExtractor(source);
} else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_OGG)) {
ret = new OggExtractor(source);
} else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MATROSKA)) {
ret = new MatroskaExtractor(source);
} else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPEG2TS)) {
ret = new MPEG2TSExtractor(source);
} else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_WVM)) {
ret = new WVMExtractor(source);
} else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AAC_ADTS)) {
ret = new AACExtractor(source);
} else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPEG2PS)) {
ret = new MPEG2PSExtractor(source);
}
#if defined(USE_FFMPEG_EXTRACTOR)
#warning "defined USE_FFMPEG_EXTRACTOR"
else {
using namespace FFMPEG;
ret = new FFmpegExtractor(source);
ZXLOGD("use FFmpegExtractor.");
/*[email protected] start: add open status check*/
if (((FFmpegExtractor*)ret)->IsOpenFailed()) {
delete ret;
ret = NULL;
}
/*[email protected] end*/
}
#endif
//.........这里部分代码省略.........
示例9: ALOGV
bool DrmPassthruPlugIn::onCanHandle(int uniqueId, const String8& path) {
ALOGV("DrmPassthruPlugIn::canHandle: %s ", path.string());
String8 extension = path.getPathExtension();
extension.toLower();
return (String8(".passthru") == extension);
}
示例10: onParseCommand
/******************************************************************************
* Command
* test_engineer <-h> <-shot-mode=testshot> <-shot-count=1> <-picture-size=2560x1920> <-preview-size=640x480> <-display-orientation=90>
*
* -h: help
* -shot-count: shot count; 1 by default.
* -picture-size: picture size; 2560x1920 by default.
* -preview-size: preview size; 640x480 by default.
* -shot-mode: shot mode; testshot by default.
* For example: "normal", "hdr", "continuousshot", ......
* -display-orientation: display orientation; 90 by default.
*
******************************************************************************/
bool
CmdImp::
onParseCommand(Vector<String8>& rvCmd)
{
// (1) Set default.
mShotMode = "testshot";
mShotCount = 1;
mPictureSize = Size(2560, 1920);
mPreviewSize = Size(640, 480);
mDisplayOrientation = 90;
mPictureOrientation = 0;
// (2) Start to parse commands.
for (size_t i = 1; i < rvCmd.size(); i++)
{
if ( rvCmd[i] == "-h" ) {
String8 text;
text += "\n";
text += "\n test_engineer <-h> <-shot-mode=testshot> <-shot-count=1> <-picture-size=2560x1920> <-preview-size=640x480> <-display-orientation=90 -jpeg-orienation=0>";
text += "\n -h: help";
text += "\n -shot-count: shot count; 1 by default.";
text += "\n -picture-size: picture size; 2560x1920 by default.";
text += "\n -preview-size: preview size; 640x480 by default.";
text += "\n -shot-mode: shot mode; testshot by default.";
text += "\n For example: normal, hdr, continuousshot, ......";
text += "\n -display-orientation: display orientation; 90 by default.";
text += "\n -pic-orientation: jpeg orienation; 0 by default.";
text += "\n -engineer-capture-size: preview, capture, video.";
text += "\n -engineer-capture-type: pure-raw, processed-raw, jpeg-only.";
text += "\n -engineer-raw-save-path: /sdcard/preview.raw, for example";
text += "\n -flicker: 50, 60.";
MY_LOGD("%s", text.string());
return false;
}
//
String8 key, val;
parseOneCmdArgument(rvCmd[i], key, val);
// MY_LOGD("<key/val>=<%s/%s>", key.string(), val.string());
//
//
if ( key == "-engineer-raw-save-path" ) {
ms8RawSavePath = val;
MY_LOGD("ms8RawSavePath = %s", ms8RawSavePath.string());
continue;
}
if ( key == "-engineer-capture-size" ) {
ms8CaptureSize = val;
MY_LOGD("ms8CaptureSize = %s", ms8CaptureSize.string());
continue;
}
if ( key == "-engineer-capture-type" ) {
ms8CaptureType = val;
MY_LOGD("ms8CaptureType = %s", ms8CaptureType.string());
continue;
}
if ( key == "-flicker" ) {
ms8Flicker = val;
MY_LOGD("ms8Flicker = %s", ms8Flicker.string());
continue;
}
if ( key == "-shot-mode" ) {
mShotMode = val; // In engineer mode, use EngShot only
continue;
}
//
if ( key == "-shot-count" ) {
mShotCount = ::atoi(val);
continue;
}
//
if ( key == "-picture-size" ) {
::sscanf(val.string(), "%dx%d", &mPictureSize.width, &mPictureSize.height);
MY_LOGD("picture-size : %d %d", mPictureSize.width, mPictureSize.height);
continue;
}
//
if ( key == "-preview-size" ) {
::sscanf(val.string(), "%dx%d", &mPreviewSize.width, &mPreviewSize.height);
MY_LOGD("preview-size : %d %d", mPreviewSize.width, mPreviewSize.height);
continue;
}
//
if ( key == "-display-orientation" ) {
//.........这里部分代码省略.........
示例11: parseScanResults
void parseScanResults(String16& str, const char *reply)
{
unsigned int lineBeg = 0, lineEnd = 0;
size_t replyLen = strlen(reply);
char *pos = NULL;
char ssid[BUF_SIZE] = {0};
char ssid_utf8[BUF_SIZE] = {0};
char ssid_txt[BUF_SIZE] ={0};
bool isUTF8 = false, isCh = false;
char buf[BUF_SIZE] = {0};
String8 line;
UConverterType conType = UCNV_UTF8;
char dest[CONVERT_LINE_LEN] = {0};
UErrorCode err = U_ZERO_ERROR;
UConverter* pConverter = ucnv_open(CHARSET_CN, &err);
if (U_FAILURE(err)) {
ALOGE("ucnv_open error");
return;
}
/* Parse every line of the reply to construct accessPointObjectItem list */
for (lineBeg = 0, lineEnd = 0; lineEnd <= replyLen; ++lineEnd) {
if (lineEnd == replyLen || '\n' == reply[lineEnd]) {
line.setTo(reply + lineBeg, lineEnd - lineBeg + 1);
if (DBG)
ALOGD("%s, line=%s ", __FUNCTION__, line.string());
if (strncmp(line.string(), "ssid=", 5) == 0) {
sscanf(line.string() + 5, "%[^\n]", ssid);
ssid_decode(buf,BUF_SIZE,ssid);
isUTF8 = isUTF8String(buf,sizeof(buf));
isCh = false;
for (pos = buf; '\0' != *pos; pos++) {
if (0x80 == (*pos & 0x80)) {
isCh = true;
break;
}
}
if (DBG)
ALOGD("%s, ssid = %s, buf = %s,isUTF8= %d, isCh = %d",
__FUNCTION__, ssid, buf ,isUTF8, isCh);
if (!isUTF8 && isCh) {
ucnv_toAlgorithmic(conType, pConverter, dest, CONVERT_LINE_LEN,
buf, strlen(buf), &err);
if (U_FAILURE(err)) {
ALOGE("ucnv_toUChars error");
goto EXIT;
}
ssid_encode(ssid_txt, BUF_SIZE, dest, strlen(dest));
if (DBG)
ALOGD("%s, ssid_txt = %s", __FUNCTION__,ssid_txt);
str += String16("ssid=");
str += String16(ssid_txt);
str += String16("\n");
strncpy(ssid_utf8, dest, strlen(dest));
memset(dest, 0, CONVERT_LINE_LEN);
memset(ssid_txt, 0, BUF_SIZE);
} else {
memset(buf, 0, BUF_SIZE);
str += String16(line.string());
}
} else if (strncmp(line.string(), "====", 4) == 0) {
if (DBG)
ALOGD("After sscanf,ssid:%s, isCh:%d",
ssid, isCh);
if( !isUTF8 && isCh){
if (DBG)
ALOGD("add AP Object Item, ssid:%s l=%d, UTF8:%s, l=%d",
ssid, strlen(ssid), ssid_utf8, strlen(ssid_utf8));
addAPObjectItem(buf, ssid_utf8);
memset(buf, 0, BUF_SIZE);
}
}
if (strncmp(line.string(), "ssid=", 5) != 0)
str += String16(line.string());
lineBeg = lineEnd + 1;
}
}
EXIT:
ucnv_close(pConverter);
}
示例12: android_media_MediaDrm_getKeyRequest
static jobject android_media_MediaDrm_getKeyRequest(
JNIEnv *env, jobject thiz, jbyteArray jsessionId, jbyteArray jinitData,
jstring jmimeType, jint jkeyType, jobject joptParams) {
sp<IDrm> drm = GetDrm(env, thiz);
if (!CheckSession(env, drm, jsessionId)) {
return NULL;
}
Vector<uint8_t> sessionId(JByteArrayToVector(env, jsessionId));
Vector<uint8_t> initData;
if (jinitData != NULL) {
initData = JByteArrayToVector(env, jinitData);
}
String8 mimeType;
if (jmimeType != NULL) {
mimeType = JStringToString8(env, jmimeType);
}
DrmPlugin::KeyType keyType;
if (jkeyType == gKeyTypes.kKeyTypeStreaming) {
keyType = DrmPlugin::kKeyType_Streaming;
} else if (jkeyType == gKeyTypes.kKeyTypeOffline) {
keyType = DrmPlugin::kKeyType_Offline;
} else if (jkeyType == gKeyTypes.kKeyTypeRelease) {
keyType = DrmPlugin::kKeyType_Release;
} else {
jniThrowException(env, "java/lang/IllegalArgumentException",
"invalid keyType");
return NULL;
}
KeyedVector<String8, String8> optParams;
if (joptParams != NULL) {
optParams = HashMapToKeyedVector(env, joptParams);
}
Vector<uint8_t> request;
String8 defaultUrl;
status_t err = drm->getKeyRequest(sessionId, initData, mimeType,
keyType, optParams, request, defaultUrl);
if (throwExceptionAsNecessary(env, err, "Failed to get key request")) {
return NULL;
}
// Fill out return obj
jclass clazz;
FIND_CLASS(clazz, "android/media/MediaDrm$KeyRequest");
jobject keyObj = NULL;
if (clazz) {
keyObj = env->AllocObject(clazz);
jbyteArray jrequest = VectorToJByteArray(env, request);
env->SetObjectField(keyObj, gFields.keyRequest.data, jrequest);
jstring jdefaultUrl = env->NewStringUTF(defaultUrl.string());
env->SetObjectField(keyObj, gFields.keyRequest.defaultUrl, jdefaultUrl);
}
return keyObj;
}
示例13: throwExceptionAsNecessary
static bool throwExceptionAsNecessary(
JNIEnv *env, status_t err, const char *msg = NULL) {
const char *drmMessage = NULL;
switch(err) {
case ERROR_DRM_UNKNOWN:
drmMessage = "General DRM error";
break;
case ERROR_DRM_NO_LICENSE:
drmMessage = "No license";
break;
case ERROR_DRM_LICENSE_EXPIRED:
drmMessage = "License expired";
break;
case ERROR_DRM_SESSION_NOT_OPENED:
drmMessage = "Session not opened";
break;
case ERROR_DRM_DECRYPT_UNIT_NOT_INITIALIZED:
drmMessage = "Not initialized";
break;
case ERROR_DRM_DECRYPT:
drmMessage = "Decrypt error";
break;
case ERROR_DRM_CANNOT_HANDLE:
drmMessage = "Unsupported scheme or data format";
break;
case ERROR_DRM_TAMPER_DETECTED:
drmMessage = "Invalid state";
break;
default:
break;
}
String8 vendorMessage;
if (err >= ERROR_DRM_VENDOR_MIN && err <= ERROR_DRM_VENDOR_MAX) {
vendorMessage.format("DRM vendor-defined error: %d", err);
drmMessage = vendorMessage.string();
}
if (err == BAD_VALUE) {
jniThrowException(env, "java/lang/IllegalArgumentException", msg);
return true;
} else if (err == ERROR_DRM_NOT_PROVISIONED) {
jniThrowException(env, "android/media/NotProvisionedException", msg);
return true;
} else if (err == ERROR_DRM_DEVICE_REVOKED) {
jniThrowException(env, "android/media/DeniedByServerException", msg);
return true;
} else if (err != OK) {
String8 errbuf;
if (drmMessage != NULL) {
if (msg == NULL) {
msg = drmMessage;
} else {
errbuf.format("%s: %s", msg, drmMessage);
msg = errbuf.string();
}
}
ALOGE("Illegal state exception: %s", msg);
jniThrowException(env, "java/lang/IllegalStateException", msg);
return true;
}
return false;
}
示例14: zip
bool BootAnimation::movie()
{
ZipFileRO& zip(mZip);
size_t numEntries = zip.getNumEntries();
ZipEntryRO desc = zip.findEntryByName("desc.txt");
FileMap* descMap = zip.createEntryFileMap(desc);
LOGE_IF(!descMap, "descMap is null");
if (!descMap) {
return false;
}
String8 desString((char const*)descMap->getDataPtr(),
descMap->getDataLength());
char const* s = desString.string();
Animation animation;
// Parse the description file
for (;;) {
const char* endl = strstr(s, "\n");
if (!endl) break;
String8 line(s, endl - s);
const char* l = line.string();
int fps, width, height, count, pause;
char path[256];
if (sscanf(l, "%d %d %d", &width, &height, &fps) == 3) {
//LOGD("> w=%d, h=%d, fps=%d", fps, width, height);
animation.width = width;
animation.height = height;
animation.fps = fps;
}
if (sscanf(l, "p %d %d %s", &count, &pause, path) == 3) {
//LOGD("> count=%d, pause=%d, path=%s", count, pause, path);
Animation::Part part;
part.count = count;
part.pause = pause;
part.path = path;
animation.parts.add(part);
}
s = ++endl;
}
// read all the data structures
const size_t pcount = animation.parts.size();
for (size_t i=0 ; i<numEntries ; i++) {
char name[256];
ZipEntryRO entry = zip.findEntryByIndex(i);
if (zip.getEntryFileName(entry, name, 256) == 0) {
const String8 entryName(name);
const String8 path(entryName.getPathDir());
const String8 leaf(entryName.getPathLeaf());
if (leaf.size() > 0) {
for (int j=0 ; j<pcount ; j++) {
if (path == animation.parts[j].path) {
int method;
// supports only stored png files
if (zip.getEntryInfo(entry, &method, 0, 0, 0, 0, 0)) {
if (method == ZipFileRO::kCompressStored) {
FileMap* map = zip.createEntryFileMap(entry);
if (map) {
Animation::Frame frame;
frame.name = leaf;
frame.map = map;
Animation::Part& part(animation.parts.editItemAt(j));
part.frames.add(frame);
}
}
}
}
}
}
}
}
// clear screen
glShadeModel(GL_FLAT);
glDisable(GL_DITHER);
glDisable(GL_SCISSOR_TEST);
glDisable(GL_BLEND);
glClearColor(0,0,0,1);
glClear(GL_COLOR_BUFFER_BIT);
eglSwapBuffers(mDisplay, mSurface);
glBindTexture(GL_TEXTURE_2D, 0);
glEnable(GL_TEXTURE_2D);
glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
const int xc = (mWidth - animation.width) / 2;
const int yc = ((mHeight - animation.height) / 2);
nsecs_t lastFrame = systemTime();
nsecs_t frameDuration = s2ns(1) / animation.fps;
Region clearReg(Rect(mWidth, mHeight));
clearReg.subtractSelf(Rect(xc, yc, xc+animation.width, yc+animation.height));
//.........这里部分代码省略.........
示例15: applyRelease
MVOID
MAIN_CLASS_NAME::
applyRelease(UserId_T userId)
{
NodeId_T const nodeId = userId;
sp<IAppCallback> pAppCallback;
List<MyListener> listeners;
BitSet32 nodeStatusUpdated;
NodeStatusUpdater updater(getFrameNo(), mLogLevel);
//
String8 const logTag = String8::format("frameNo:%u nodeId:%#"PRIxPTR, getFrameNo(), nodeId);
MY_LOG1("%s +", logTag.string());
//
{
RWLock::AutoWLock _lRWLock(mRWLock);
Mutex::Autolock _lMapLock(mItemMapLock);
//
// Update
MBOOL isAnyUpdate = updater.run(nodeId, mNodeStatusMap, nodeStatusUpdated);
//
// Is the entire frame released?
if ( isAnyUpdate && 0 == mNodeStatusMap.mInFlightNodeCount )
{
nodeStatusUpdated.markBit(IPipelineFrameListener::eMSG_FRAME_RELEASED);
//
mTimestampFrameDone = ::elapsedRealtimeNano();
//
#if 1
// mpPipelineNodeMap = 0;
// mpPipelineDAG = 0;
mpStreamInfoSet = 0;
#endif
MY_LOG1(
"Done frameNo:%u @ nodeId:%#"PRIxPTR" - timestamp:%"PRIu64"=%"PRIu64"-%"PRIu64,
getFrameNo(), nodeId,
(mTimestampFrameDone-mTimestampFrameCreated),
mTimestampFrameDone, mTimestampFrameCreated
);
}
//
if ( ! nodeStatusUpdated.isEmpty() ) {
listeners = mListeners;
}
//
pAppCallback = mpAppCallback.promote();
}
//
// Release (Hal) Buffers.
updater.handleResult();
//
// Callback to App.
if ( pAppCallback == 0 ) {
MY_LOGW("Caonnot promote AppCallback for frameNo:%u, userId:%#"PRIxPTR, getFrameNo(), userId);
}
else {
pAppCallback->updateFrame(getFrameNo(), userId);
}
//
// Callback to listeners if needed.
if ( ! nodeStatusUpdated.isEmpty() )
{
NSCam::Utils::CamProfile profile(__FUNCTION__, logTag.string());
//
List<MyListener>::iterator it = listeners.begin();
for (; it != listeners.end(); ++it) {
sp<MyListener::IListener> p = it->mpListener.promote();
if ( p == 0 ) {
continue;
}
//
if ( nodeStatusUpdated.hasBit(IPipelineFrameListener::eMSG_ALL_OUT_META_BUFFERS_RELEASED) ) {
MY_LOG2("%s O Meta Buffers Released", logTag.string());
p->onPipelineFrame(
getFrameNo(),
nodeId,
IPipelineFrameListener::eMSG_ALL_OUT_META_BUFFERS_RELEASED,
it->mpCookie
);
}
//
if ( nodeStatusUpdated.hasBit(IPipelineFrameListener::eMSG_ALL_OUT_IMAGE_BUFFERS_RELEASED) ) {
MY_LOG2("%s O Image Buffers Released", logTag.string());
p->onPipelineFrame(
getFrameNo(),
nodeId,
IPipelineFrameListener::eMSG_ALL_OUT_IMAGE_BUFFERS_RELEASED,
it->mpCookie
);
}
//
if ( nodeStatusUpdated.hasBit(IPipelineFrameListener::eMSG_FRAME_RELEASED) ) {
MY_LOG2("%s Frame Done", logTag.string());
p->onPipelineFrame(
getFrameNo(),
IPipelineFrameListener::eMSG_FRAME_RELEASED,
it->mpCookie
);
}
}
//
//.........这里部分代码省略.........