本文整理汇总了C++中LOGV函数的典型用法代码示例。如果您正苦于以下问题:C++ LOGV函数的具体用法?C++ LOGV怎么用?C++ LOGV使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LOGV函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LOGV
void AudioSystem::AudioFlingerClient::ioConfigChanged(int event, int ioHandle, void *param2) {
LOGV("ioConfigChanged() event %d", event);
OutputDescriptor *desc;
uint32_t stream;
if (ioHandle == 0) return;
Mutex::Autolock _l(AudioSystem::gLock);
switch (event) {
case STREAM_CONFIG_CHANGED:
if (param2 == 0) break;
stream = *(uint32_t *)param2;
LOGV("ioConfigChanged() STREAM_CONFIG_CHANGED stream %d, output %d", stream, ioHandle);
if (gStreamOutputMap.indexOfKey(stream) >= 0) {
gStreamOutputMap.replaceValueFor(stream, ioHandle);
}
break;
case OUTPUT_OPENED: {
if (gOutputs.indexOfKey(ioHandle) >= 0) {
LOGV("ioConfigChanged() opening already existing output! %d", ioHandle);
break;
}
if (param2 == 0) break;
desc = (OutputDescriptor *)param2;
OutputDescriptor *outputDesc = new OutputDescriptor(*desc);
gOutputs.add(ioHandle, outputDesc);
LOGV("ioConfigChanged() new output samplingRate %d, format %d channels %d frameCount %d latency %d",
outputDesc->samplingRate, outputDesc->format, outputDesc->channels, outputDesc->frameCount, outputDesc->latency);
} break;
case OUTPUT_CLOSED: {
if (gOutputs.indexOfKey(ioHandle) < 0) {
LOGW("ioConfigChanged() closing unknow output! %d", ioHandle);
break;
}
LOGV("ioConfigChanged() output %d closed", ioHandle);
gOutputs.removeItem(ioHandle);
for (int i = gStreamOutputMap.size() - 1; i >= 0 ; i--) {
if (gStreamOutputMap.valueAt(i) == ioHandle) {
gStreamOutputMap.removeItemsAt(i);
}
}
} break;
case OUTPUT_CONFIG_CHANGED: {
int index = gOutputs.indexOfKey(ioHandle);
if (index < 0) {
LOGW("ioConfigChanged() modifying unknow output! %d", ioHandle);
break;
}
if (param2 == 0) break;
desc = (OutputDescriptor *)param2;
LOGV("ioConfigChanged() new config for output %d samplingRate %d, format %d channels %d frameCount %d latency %d",
ioHandle, desc->samplingRate, desc->format,
desc->channels, desc->frameCount, desc->latency);
OutputDescriptor *outputDesc = gOutputs.valueAt(index);
delete outputDesc;
outputDesc = new OutputDescriptor(*desc);
gOutputs.replaceValueFor(ioHandle, outputDesc);
} break;
case INPUT_OPENED:
case INPUT_CLOSED:
case INPUT_CONFIG_CHANGED:
break;
}
}
示例2: open_inputs
static int open_inputs(int mode, int *akm_fd, int *p_fd, int *l_fd)
{
/* scan all input drivers and look for "compass" */
int fd = -1;
const char *dirname = "/dev/input";
char devname[PATH_MAX];
char *filename;
DIR *dir;
struct dirent *de;
dir = opendir(dirname);
if(dir == NULL)
return -1;
strcpy(devname, dirname);
filename = devname + strlen(devname);
*filename++ = '/';
*akm_fd = *p_fd = *l_fd = -1;
while((de = readdir(dir))) {
if(de->d_name[0] == '.' &&
(de->d_name[1] == '\0' ||
(de->d_name[1] == '.' && de->d_name[2] == '\0')))
continue;
strcpy(filename, de->d_name);
fd = open(devname, mode);
if (fd>=0) {
char name[80];
if (ioctl(fd, EVIOCGNAME(sizeof(name) - 1), &name) < 1) {
name[0] = '\0';
}
if (!strcmp(name, "compass")) {
LOGV("using %s (name=%s)", devname, name);
*akm_fd = fd;
}
else if (!strcmp(name, "proximity")) {
LOGV("using %s (name=%s)", devname, name);
*p_fd = fd;
}
else if (!strcmp(name, "LightSensor")) {
LOGV("using %s (name=%s)", devname, name);
*l_fd = fd;
}
else
close(fd);
}
}
closedir(dir);
fd = 0;
if (*akm_fd < 0) {
LOGE("Couldn't find or open 'compass' driver (%s)", strerror(errno));
fd = -1;
}
if (*p_fd < 0) {
LOGE("Couldn't find or open 'proximity' driver (%s)", strerror(errno));
fd = -1;
}
if (*l_fd < 0) {
LOGE("Couldn't find or open 'light' driver (%s)", strerror(errno));
fd = -1;
}
return fd;
}
示例3: data__poll
static int data__poll(struct sensors_data_context_t *dev, sensors_data_t* values)
{
int akm_fd = dev->events_fd[0];
int gp_fd = dev->events_fd[1];
int ls_fd = dev->events_fd[2];
if (akm_fd < 0) {
LOGE("invalid compass file descriptor, fd=%d", akm_fd);
return -1;
}
if (gp_fd < 0) {
LOGE("invalid proximity-sensor file descriptor, fd=%d", gp_fd);
return -1;
}
if (ls_fd < 0) {
LOGE("invalid light-sensor file descriptor, fd=%d", ls_fd);
return -1;
}
// there are pending sensors, returns them now...
if (dev->pendingSensors) {
LOGV("pending sensors 0x%08x", dev->pendingSensors);
return pick_sensor(dev, values);
}
// wait until we get a complete event for an enabled sensor
uint32_t new_sensors = 0;
while (1) {
/* read the next event; first, read the compass event, then the
proximity event */
struct input_event event;
int got_syn = 0;
int exit = 0;
int nread;
fd_set rfds;
int n;
FD_ZERO(&rfds);
FD_SET(akm_fd, &rfds);
FD_SET(gp_fd, &rfds);
FD_SET(ls_fd, &rfds);
n = select(__MAX(akm_fd, __MAX(gp_fd, ls_fd)) + 1, &rfds,
NULL, NULL, NULL);
LOGV("return from select: %d\n", n);
if (n < 0) {
LOGE("%s: error from select(%d, %d): %s",
__FUNCTION__,
akm_fd, gp_fd, strerror(errno));
return -1;
}
if (FD_ISSET(akm_fd, &rfds)) {
nread = read(akm_fd, &event, sizeof(event));
if (nread == sizeof(event)) {
new_sensors |= data__poll_process_akm_abs(dev, akm_fd, &event);
LOGV("akm abs %08x", new_sensors);
got_syn = event.type == EV_SYN;
exit = got_syn && event.code == SYN_CONFIG;
if (got_syn) {
LOGV("akm syn %08x", new_sensors);
data__poll_process_syn(dev, &event, new_sensors);
new_sensors = 0;
}
}
else LOGE("akm read too small %d", nread);
}
else LOGV("akm fd is not set");
if (FD_ISSET(gp_fd, &rfds)) {
nread = read(gp_fd, &event, sizeof(event));
if (nread == sizeof(event)) {
new_sensors |= data__poll_process_gp_abs(dev, gp_fd, &event);
LOGV("gp abs %08x", new_sensors);
got_syn |= event.type == EV_SYN;
exit |= got_syn && event.code == SYN_CONFIG;
if (got_syn) {
LOGV("gp syn %08x", new_sensors);
data__poll_process_syn(dev, &event, new_sensors);
new_sensors = 0;
}
}
else LOGE("gp read too small %d", nread);
}
else LOGV("gp fd is not set");
if (FD_ISSET(ls_fd, &rfds)) {
nread = read(ls_fd, &event, sizeof(event));
if (nread == sizeof(event)) {
new_sensors |= data__poll_process_ls_abs(dev, ls_fd, &event);
LOGV("ls abs %08x", new_sensors);
got_syn |= event.type == EV_SYN;
exit |= got_syn && event.code == SYN_CONFIG;
if (got_syn) {
LOGV("ls syn %08x", new_sensors);
data__poll_process_syn(dev, &event, new_sensors);
new_sensors = 0;
}
}
//.........这里部分代码省略.........
示例4: LOGV
//-------------------------------------------------------------------------------------------------
int JetPlayer::clearQueue()
{
LOGV("JetPlayer::clearQueue");
Mutex::Autolock lock(mMutex);
return JET_Clear_Queue(mEasData);
}
示例5: EAS_Config
//-------------------------------------------------------------------------------------------------
int JetPlayer::init()
{
//Mutex::Autolock lock(&mMutex);
EAS_RESULT result;
// retrieve the EAS library settings
if (pLibConfig == NULL)
pLibConfig = EAS_Config();
if (pLibConfig == NULL) {
LOGE("JetPlayer::init(): EAS library configuration could not be retrieved, aborting.");
return EAS_FAILURE;
}
// init the EAS library
result = EAS_Init(&mEasData);
if( result != EAS_SUCCESS) {
LOGE("JetPlayer::init(): Error initializing Sonivox EAS library, aborting.");
mState = EAS_STATE_ERROR;
return result;
}
// init the JET library with the default app event controller range
result = JET_Init(mEasData, NULL, sizeof(S_JET_CONFIG));
if( result != EAS_SUCCESS) {
LOGE("JetPlayer::init(): Error initializing JET library, aborting.");
mState = EAS_STATE_ERROR;
return result;
}
// create the output AudioTrack
mAudioTrack = new AudioTrack();
mAudioTrack->set(AUDIO_STREAM_MUSIC, //TODO parametrize this
pLibConfig->sampleRate,
1, // format = PCM 16bits per sample,
(pLibConfig->numChannels == 2) ? AUDIO_CHANNEL_OUT_STEREO : AUDIO_CHANNEL_OUT_MONO,
mTrackBufferSize,
#ifdef WITH_QCOM_LPA
0,
0,
#endif
0);
// create render and playback thread
{
Mutex::Autolock l(mMutex);
LOGV("JetPlayer::init(): trying to start render thread");
createThreadEtc(renderThread, this, "jetRenderThread", ANDROID_PRIORITY_AUDIO);
mCondition.wait(mMutex);
}
if (mTid > 0) {
// render thread started, we're ready
LOGV("JetPlayer::init(): render thread(%d) successfully started.", mTid);
mState = EAS_STATE_READY;
} else {
LOGE("JetPlayer::init(): failed to start render thread.");
mState = EAS_STATE_ERROR;
return EAS_FAILURE;
}
return EAS_SUCCESS;
}
示例6: onNativeWindowDestroyed
static void onNativeWindowDestroyed(ANativeActivity* activity, ANativeWindow* window) {
LOGV("NativeWindowDestroyed: %p -- %p\n", activity, window);
android_app_set_window((struct android_app*)activity->instance, NULL);
}
示例7: LOGV
void AndroidAudioRenderer::stop()
{
LOGV("AndroidAudioRenderer::stop");
OpenSLShutdown();
LOGV("AndroidAudioRenderer::stop complete");
}
示例8: acceptConnection
/*
* Block forever, waiting for a debugger to connect to us. Called from the
* JDWP thread.
*
* This needs to un-block and return "false" if the VM is shutting down. It
* should return "true" when it successfully accepts a connection.
*/
static bool acceptConnection(struct JdwpState* state)
{
JdwpNetState* netState = state->netState;
int retryCount = 0;
/* first, ensure that we get a connection to the ADB daemon */
retry:
if (netState->shuttingDown)
return false;
if (netState->controlSock < 0) {
int sleep_ms = 500;
const int sleep_max_ms = 2*1000;
char buff[5];
netState->controlSock = socket(PF_UNIX, SOCK_STREAM, 0);
if (netState->controlSock < 0) {
LOGE("Could not create ADB control socket:%s\n",
strerror(errno));
return false;
}
if (pipe(netState->wakeFds) < 0) {
LOGE("pipe failed");
return false;
}
snprintf(buff, sizeof(buff), "%04x", getpid());
buff[4] = 0;
for (;;) {
/*
* If adbd isn't running, because USB debugging was disabled or
* perhaps the system is restarting it for "adb root", the
* connect() will fail. We loop here forever waiting for it
* to come back.
*
* Waking up and polling every couple of seconds is generally a
* bad thing to do, but we only do this if the application is
* debuggable *and* adbd isn't running. Still, for the sake
* of battery life, we should consider timing out and giving
* up after a few minutes in case somebody ships an app with
* the debuggable flag set.
*/
int ret = connect(netState->controlSock,
&netState->controlAddr.controlAddrPlain,
netState->controlAddrLen);
if (!ret) {
/* now try to send our pid to the ADB daemon */
do {
ret = send( netState->controlSock, buff, 4, 0 );
} while (ret < 0 && errno == EINTR);
if (ret >= 0) {
LOGV("PID sent as '%.*s' to ADB\n", 4, buff);
break;
}
LOGE("Weird, can't send JDWP process pid to ADB: %s\n",
strerror(errno));
return false;
}
LOGV("Can't connect to ADB control socket:%s\n",
strerror(errno));
usleep( sleep_ms*1000 );
sleep_ms += (sleep_ms >> 1);
if (sleep_ms > sleep_max_ms)
sleep_ms = sleep_max_ms;
}
}
示例9: LOGV
MetadataRetrieverClient::~MetadataRetrieverClient()
{
LOGV("MetadataRetrieverClient destructor");
disconnect();
}
示例10: handle_keydown
static void handle_keydown(DisplayState *ds, SDL_Event *ev)
{
int mod_state;
int keycode;
if (alt_grab) {
// LOGV("Found alt grab\n");
mod_state = (SDL_GetModState() & (gui_grab_code | KMOD_LSHIFT)) ==
(gui_grab_code | KMOD_LSHIFT);
} else if (ctrl_grab) {
// LOGV("Found ctrl grab\n");
mod_state = (SDL_GetModState() & KMOD_RCTRL) == KMOD_RCTRL;
} else {
// LOGV("Default grab\n");
mod_state = (SDL_GetModState() & gui_grab_code) == gui_grab_code;
}
gui_key_modifier_pressed = mod_state;
if (gui_key_modifier_pressed) {
keycode = sdl_keyevent_to_keycode(&ev->key);
// LOGV("Found modifier pressed for key/keycode = %d/%d\n", ev->key.keysym.sym, keycode);
switch (keycode) {
case 1: /* 'f' key on US keyboard */
LOGV("Keycode Pressed 'f' Fullscreen\n");
toggle_full_screen(ds);
gui_keysym = 1;
break;
case 16: /* 'u' key on US keyboard */
LOGV("Keycode Pressed 'u' unset Scale\n");
if (scaling_active) {
LOGV("Found scaling active Unsetting...\n");
scaling_active = 0;
sdl_resize(ds);
vga_hw_invalidate();
vga_hw_update();
reset_keys();
}
gui_keysym = 1;
break;
case 22 ... 23: /* '1' to '9' keys */ //MK hack
/* Reset the modifiers sent to the current console */
LOGV("Keycode Pressed '1-9' console\n");
reset_keys();
console_select(keycode - 22);
gui_keysym = 1;
// if (gui_fullscreen) {
// LOGV("Found fullscreen breaking...\n");
// break;
// }
if (!is_graphic_console()) {
/* release grab if going to a text console */
LOGV("Found text console releasing grab...\n");
if (gui_grab) {
LOGV("Found grab, grab ending...\n");
sdl_grab_end();
} else if (absolute_enabled) {
LOGV("Found absolute_enabled, show cursor...\n");
sdl_show_cursor();
}
} else if (absolute_enabled) {
LOGV("Found absolute_enabled, hiding cursor and grabing mouse...\n");
sdl_hide_cursor();
absolute_mouse_grab();
}
break;
case 24: /* '4' Zoom In */
case 25: /* '3' Zoom Out*/
LOGV("Keycode Pressed '3/4' Zoom\n");
// if (!gui_fullscreen) {
{
int width = MAX(real_screen->w + (keycode == 25 ? 50 : -50),
160);
int height = (ds_get_height(ds) * width) / ds_get_width(ds);
LOGV("Found no fullscreen, scaling to: %dx%d \n", width, height);
sdl_scale(ds, width, height);
vga_hw_invalidate();
vga_hw_update();
reset_keys();
gui_keysym = 1;
}
// }
break;
case 26: /* Fit to Screen */
LOGV("Keycode Pressed '5' Fit to Screen\n");
// if (!gui_fullscreen) {
{
int width;
int height;
AndroidGetWindowSize(&width, &height);
LOGV("Got Android window size=%dx%d", width, height);
LOGV("Got VM resolution=%dx%d", ds_get_width(ds), ds_get_height(ds));
float aspectRatio = (float) ds_get_height(ds) / (float) ds_get_width(ds);
LOGV("Got aspectRatio=%f", aspectRatio);
int new_width = (int) (height / aspectRatio);
if(new_width > width){
LOGV("Width is overrun, modifying height");
new_width = width;
height = width * aspectRatio;
//.........这里部分代码省略.........
示例11: STexture
void SObjModel::LoadTextures() {
texDiffuse = (new STexture("AssetBase/empty_texture.png"));
if (!texDiffuse->IsReady) {
LOGE(" diffuse texture file not found");
return;
}
texNormal = (new STexture("AssetBase/empty_normal.png",false));
if (!texNormal->IsReady) {
LOGE("normal texture file not found");
return;
}
for (auto it = d_sm.begin(); it != d_sm.end();++it) {
auto &submesh = (*it);
if (d_materials.find(submesh->m_name) == d_materials.end()) {
LOGE("no material found - \"%s\" ",submesh->m_name.c_str());
} else {
auto &material = d_materials[submesh->m_name];
std::string &diffuse = material.albedoTexFileName;
if (d_textures.find(diffuse) == d_textures.end()) {
LOGV("material %s Diffuse %s Bump %s Alpha %s",submesh->m_name.c_str(),
material.albedoTexFileName.c_str(),
material.bumpMapTexFileName.c_str(),
material.alphaMaskTexFileName.c_str());
d_materials[submesh->m_name].albedoTex = new STexture(submesh->m_dir+diffuse);
d_textures[diffuse].reset( d_materials[submesh->m_name].albedoTex);
if (!d_textures[diffuse]->IsReady) {
LOGE("OBJ:Diffuse texture load failed %s",(submesh->m_dir+diffuse).c_str());
}
}
std::string &bump = material.bumpMapTexFileName;
if (d_textures.find(bump) == d_textures.end()) {
d_materials[submesh->m_name].bumpMapTex = new STexture(submesh->m_dir+bump,false);
d_textures[bump].reset(d_materials[submesh->m_name].bumpMapTex);
if (!d_textures[bump]->IsReady) {
LOGE("OBJ:Bump texture load failed %s",(submesh->m_dir+bump).c_str());
}
}
std::string &alpha = material.alphaMaskTexFileName;
if (d_textures.find(alpha) == d_textures.end()) {
d_materials[submesh->m_name].alphaMaskTex = new STexture(submesh->m_dir+alpha);
d_textures[alpha].reset(d_materials[submesh->m_name].alphaMaskTex);
if (!d_textures[alpha]->IsReady) {
LOGE("OBJ:Alpha mask texture load failed %s",(submesh->m_dir+alpha).c_str());
}
}
}
}
}
示例12: SsbSipMfcEncInit
SSBSIP_MFC_ERROR_CODE SsbSipMfcEncInit(void *openHandle, void *param)
{
int ret_code;
int dpbBufSize;
_MFCLIB *pCTX;
mfc_common_args EncArg;
mfc_common_args user_addr_arg, phys_addr_arg;
SSBSIP_MFC_ENC_H264_PARAM *h264_arg;
SSBSIP_MFC_ENC_MPEG4_PARAM *mpeg4_arg;
SSBSIP_MFC_ENC_H263_PARAM *h263_arg;
SSBSIP_MFC_CODEC_TYPE codec_type;
pCTX = (_MFCLIB *)openHandle;
memset(&EncArg, 0, sizeof(mfc_common_args));
LOGV("SsbSipMfcEncInit: Encode Init start\n");
mpeg4_arg = (SSBSIP_MFC_ENC_MPEG4_PARAM *)param;
codec_type = mpeg4_arg->codecType;
if ((codec_type != MPEG4_ENC) &&
(codec_type != H264_ENC) &&
(codec_type != H263_ENC)) {
LOGE("SsbSipMfcEncOpen: Undefined codec type.\n");
return MFC_RET_INVALID_PARAM;
}
pCTX->codec_type = codec_type;
switch (pCTX->codec_type) {
case MPEG4_ENC:
LOGV("SsbSipMfcEncInit: MPEG4 Encode\n");
mpeg4_arg = (SSBSIP_MFC_ENC_MPEG4_PARAM *)param;
pCTX->width = mpeg4_arg->SourceWidth;
pCTX->height = mpeg4_arg->SourceHeight;
break;
case H263_ENC:
LOGV("SsbSipMfcEncInit: H263 Encode\n");
h263_arg = (SSBSIP_MFC_ENC_H263_PARAM *)param;
pCTX->width = h263_arg->SourceWidth;
pCTX->height = h263_arg->SourceHeight;
break;
case H264_ENC:
LOGV("SsbSipMfcEncInit: H264 Encode\n");
h264_arg = (SSBSIP_MFC_ENC_H264_PARAM *)param;
pCTX->width = h264_arg->SourceWidth;
pCTX->height = h264_arg->SourceHeight;
break;
default:
break;
}
switch (pCTX->codec_type) {
case MPEG4_ENC:
mpeg4_arg = (SSBSIP_MFC_ENC_MPEG4_PARAM*)param;
EncArg.args.enc_init_mpeg4.in_codec_type = pCTX->codec_type;
EncArg.args.enc_init_mpeg4.in_profile_level = ENC_PROFILE_LEVEL(mpeg4_arg->ProfileIDC, mpeg4_arg->LevelIDC);
EncArg.args.enc_init_mpeg4.in_width = mpeg4_arg->SourceWidth;
EncArg.args.enc_init_mpeg4.in_height = mpeg4_arg->SourceHeight;
EncArg.args.enc_init_mpeg4.in_gop_num = mpeg4_arg->IDRPeriod;
if (mpeg4_arg->DisableQpelME)
EncArg.args.enc_init_mpeg4.in_qpelME_enable = 0;
else
EncArg.args.enc_init_mpeg4.in_qpelME_enable = 1;
EncArg.args.enc_init_mpeg4.in_MS_mode = mpeg4_arg->SliceMode;
EncArg.args.enc_init_mpeg4.in_MS_size = mpeg4_arg->SliceArgument;
if (mpeg4_arg->NumberBFrames > 2) {
LOGE("SsbSipMfcEncInit: No such BframeNum is supported.\n");
return MFC_RET_INVALID_PARAM;
}
EncArg.args.enc_init_mpeg4.in_BframeNum = mpeg4_arg->NumberBFrames;
EncArg.args.enc_init_mpeg4.in_mb_refresh = mpeg4_arg->RandomIntraMBRefresh;
/* rate control*/
EncArg.args.enc_init_mpeg4.in_RC_frm_enable = mpeg4_arg->EnableFRMRateControl;
if ((mpeg4_arg->QSCodeMin > 51) || (mpeg4_arg->QSCodeMax > 51)) {
LOGE("SsbSipMfcEncInit: No such Min/Max QP is supported.\n");
return MFC_RET_INVALID_PARAM;
}
EncArg.args.enc_init_mpeg4.in_RC_qbound = ENC_RC_QBOUND(mpeg4_arg->QSCodeMin, mpeg4_arg->QSCodeMax);
EncArg.args.enc_init_mpeg4.in_RC_rpara = mpeg4_arg->CBRPeriodRf;
/* pad control */
EncArg.args.enc_init_mpeg4.in_pad_ctrl_on = mpeg4_arg->PadControlOn;
if ((mpeg4_arg->LumaPadVal > 255) || (mpeg4_arg->CbPadVal > 255) || (mpeg4_arg->CrPadVal > 255)) {
LOGE("SsbSipMfcEncInit: No such Pad value is supported.\n");
return MFC_RET_INVALID_PARAM;
}
EncArg.args.enc_init_mpeg4.in_luma_pad_val = mpeg4_arg->LumaPadVal;
//.........这里部分代码省略.........
示例13: onLowMemory
static void onLowMemory(ANativeActivity* activity) {
struct android_app* android_app = (struct android_app*)activity->instance;
LOGV("LowMemory: %p\n", activity);
android_app_write_cmd(android_app, APP_CMD_LOW_MEMORY);
}
示例14: dbopen
/* public native void dbopen(String path, int flags, String locale); */
static void dbopen(JNIEnv* env, jobject object, jstring pathString, jint flags)
{
int err;
sqlite3 * handle = NULL;
sqlite3_stmt * statement = NULL;
char const * path8 = env->GetStringUTFChars(pathString, NULL);
int sqliteFlags;
// register the logging func on sqlite. needs to be done BEFORE any sqlite3 func is called.
registerLoggingFunc(path8);
// convert our flags into the sqlite flags
if (flags & CREATE_IF_NECESSARY) {
sqliteFlags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
} else if (flags & OPEN_READONLY) {
sqliteFlags = SQLITE_OPEN_READONLY;
} else {
sqliteFlags = SQLITE_OPEN_READWRITE;
}
err = sqlite3_open_v2(path8, &handle, sqliteFlags, NULL);
if (err != SQLITE_OK) {
LOGE("sqlite3_open_v2(\"%s\", &handle, %d, NULL) failed\n", path8, sqliteFlags);
throw_sqlite3_exception(env, handle);
goto done;
}
// The soft heap limit prevents the page cache allocations from growing
// beyond the given limit, no matter what the max page cache sizes are
// set to. The limit does not, as of 3.5.0, affect any other allocations.
sqlite3_soft_heap_limit(sSqliteSoftHeapLimit);
// Set the default busy handler to retry for 1000ms and then return SQLITE_BUSY
err = sqlite3_busy_timeout(handle, 1000 /* ms */);
if (err != SQLITE_OK) {
LOGE("sqlite3_busy_timeout(handle, 1000) failed for \"%s\"\n", path8);
throw_sqlite3_exception(env, handle);
goto done;
}
#ifdef DB_INTEGRITY_CHECK
static const char* integritySql = "pragma integrity_check(1);";
err = sqlite3_prepare_v2(handle, integritySql, -1, &statement, NULL);
if (err != SQLITE_OK) {
LOGE("sqlite_prepare_v2(handle, \"%s\") failed for \"%s\"\n", integritySql, path8);
throw_sqlite3_exception(env, handle);
goto done;
}
// first is OK or error message
err = sqlite3_step(statement);
if (err != SQLITE_ROW) {
LOGE("integrity check failed for \"%s\"\n", integritySql, path8);
throw_sqlite3_exception(env, handle);
goto done;
} else {
const char *text = (const char*)sqlite3_column_text(statement, 0);
if (strcmp(text, "ok") != 0) {
LOGE("integrity check failed for \"%s\": %s\n", integritySql, path8, text);
jniThrowException(env, "android/database/sqlite/SQLiteDatabaseCorruptException", text);
goto done;
}
}
#endif
err = register_android_functions(handle, UTF16_STORAGE);
if (err) {
throw_sqlite3_exception(env, handle);
goto done;
}
#ifdef MTK_DIALER_SEARCH_SUPPORT
err = register_dialer_search_custom_functions(handle);
if (err) {
err = register_dialer_search_android_functions(handle);
if (err) {
throw_sqlite3_exception(env, handle);
goto done;
}
}
#endif
LOGV("Opened '%s' - %p\n", path8, handle);
env->SetIntField(object, offset_db_handle, (int) handle);
handle = NULL; // The caller owns the handle now.
done:
// Release allocated resources
if (path8 != NULL) env->ReleaseStringUTFChars(pathString, path8);
if (statement != NULL) sqlite3_finalize(statement);
if (handle != NULL) sqlite3_close(handle);
}
示例15: onWindowFocusChanged
static void onWindowFocusChanged(ANativeActivity* activity, int focused) {
LOGV("WindowFocusChanged: %p -- %d\n", activity, focused);
android_app_write_cmd((struct android_app*)activity->instance,
focused ? APP_CMD_GAINED_FOCUS : APP_CMD_LOST_FOCUS);
}