void QAndroidOffscreenEditText::setMarqueeRepeatLimit(int marqueeLimit)
{
	if (QJniObject * view = offscreenView())
	{
		view->callVoid("setMarqueeRepeatLimit", jint(marqueeLimit));
	}
}
void QAndroidOffscreenEditText::setMinEms(int minems)
{
	if (QJniObject * view = offscreenView())
	{
		view->callVoid("setMinEms", jint(minems));
	}
}
void QAndroidOffscreenEditText::setTextSize(float size, int unit)
{
	if (QJniObject * view = offscreenView())
	{
		view->callParamVoid("setTextSize", "FI", jfloat(size), jint(unit));
	}
}
void QAndroidOffscreenEditText::setInputType(int type)
{
	if (QJniObject * view = offscreenView())
	{
		view->callVoid("setInputType", jint(type));
	}
}
Ejemplo n.º 5
0
uint32 JavaInputStream::read(void *dataPtr, uint32 dataSize) {
	JNIEnv *env = JNI::getEnv();

	if (_buflen < jint(dataSize)) {
		_buflen = dataSize;

		env->DeleteGlobalRef(_buf);
		_buf = static_cast<jbyteArray>(env->NewGlobalRef(env->NewByteArray(_buflen)));
	}

	jint ret = env->CallIntMethod(_input_stream, MID_read, _buf, 0, dataSize);

	if (env->ExceptionCheck()) {
		warning("Exception during JavaInputStream::read(%p, %d)",
				dataPtr, dataSize);

		env->ExceptionDescribe();
		env->ExceptionClear();

		_err = true;
		ret = -1;
	} else if (ret == -1) {
		_eos = true;
		ret = 0;
	} else {
		env->GetByteArrayRegion(_buf, 0, ret, static_cast<jbyte *>(dataPtr));
		_pos += ret;
	}

	return ret;
}
Ejemplo n.º 6
0
/**
 * Return created Java virtual machine using private JNI_GetCreatedJavaVMs
 * function from the specified library name.
 *
 * @param name library name used for symbol lookups, can be NULL
 * @param log_ctx context used for logging, can be NULL
 * @return the current Java virtual machine in use
 */
static JavaVM *get_java_vm(const char *name, void *log_ctx)
{
    JavaVM *vm = NULL;
    jsize nb_vm = 0;

    void *handle = NULL;
    jint (*get_created_java_vms) (JavaVM ** vmBuf, jsize bufLen, jsize *nVMs) = NULL;

    handle = dlopen(name, RTLD_LOCAL);
    if (!handle) {
        return NULL;
    }

    get_created_java_vms = (jint (*)(JavaVM **, jsize, jsize *)) dlsym(handle, "JNI_GetCreatedJavaVMs");
    if (!get_created_java_vms) {
        av_log(log_ctx, AV_LOG_ERROR, "Could not find JNI_GetCreatedJavaVMs symbol in library '%s'\n", name);
        goto done;
    }

    if (get_created_java_vms(&vm, 1, &nb_vm) != JNI_OK) {
        av_log(log_ctx, AV_LOG_ERROR, "Could not get created Java virtual machines\n");
        goto done;
    }

done:
    if (handle) {
        dlclose(handle);
    }

    return vm;
}
Ejemplo n.º 7
0
	void AndroidSound::play()
	{
		#ifdef __ANDROID__
			jint result = sb::Java::callStaticIntMethod("org/libsdl/app/Sound", "play", "(I)I", m_id);
			SB_WARNING_IF2(result != jint(1), true) << "unable to play android sound " << m_assetPath << std::endl;
		#endif
	}
void SharedPathsMiscInfo::add_path(const char* path, int type) {
  if (TraceClassPaths) {
    tty->print("[type=%s] ", type_name(type));
    trace_class_path("[Add misc shared path ", path);
  }
  write(path, strlen(path) + 1);
  write_jint(jint(type));
}
QString AndroidMultimediaUtils::getDefaultMediaDirectory(MediaType type)
{
    QJNIObjectPrivate path = QJNIObjectPrivate::callStaticObjectMethod("org/qtproject/qt5/android/multimedia/QtMultimediaUtils",
                                                                       "getDefaultMediaDirectory",
                                                                       "(I)Ljava/lang/String;",
                                                                       jint(type));
    return path.toString();
}
void QAndroidOffscreenEditText::setPaintFlags(int flags)
{
	if (QJniObject * view = offscreenView())
	{
		paint_flags_ = flags;
		view->callVoid("setPaintFlags", jint(flags));
	}
}
Ejemplo n.º 11
0
 bool registerListener(AndroidSensorType sensor, AndroidSensorsListenerInterface *listener, int dataRate)
 {
     listenersLocker.lockForWrite();
     bool startService = listenersHash[sensor].empty();
     listenersHash[sensor].push_back(listener);
     listenersLocker.unlock();
     if (startService) {
         AttachedJNIEnv aenv;
         if (!aenv.jniEnv)
             return false;
         int rate = dataRate > 0 ? 1000000/dataRate : SENSOR_DELAY_GAME;
         return aenv.jniEnv->CallStaticBooleanMethod(sensorsClass,
                                                     registerSensorMethodId,
                                                     jint(sensor),
                                                     jint(rate));
     }
     return true;
 }
Ejemplo n.º 12
0
void AndroidCameraPrivate::setPreviewFormat(AndroidCamera::ImageFormat fmt)
{
    QMutexLocker parametersLocker(&m_parametersMutex);

    if (!m_parameters.isValid())
        return;

    m_parameters.callMethod<void>("setPreviewFormat", "(I)V", jint(fmt));
    applyParameters();
}
Ejemplo n.º 13
0
inline jlong
EventLogger::Entry::dump( Stream* s, jlong time ) const {
  time += delta();
  jlong usec = time * 1000 * 1000 / _freq;
  const jlong msec = usec / 1000;
  s->print( "%6d", jint(msec) );
  if( _use_usec ) {
    usec %= 1000;
    s->print(".");
    if( usec < 100 ) {
      s->print("0");
    }
    if( usec < 10 ) {
      s->print("0");
    }
    s->print("%d", usec);
  }
  s->print_cr(" %8d %s %s", jint(time), kind(), name() );
  return time;
}
status_t NativeInputEventSender::receiveFinishedSignals(JNIEnv* env) {
    if (kDebugDispatchCycle) {
        ALOGD("channel '%s' ~ Receiving finished signals.", getInputChannelName());
    }

    ScopedLocalRef<jobject> senderObj(env, NULL);
    bool skipCallbacks = false;
    for (;;) {
        uint32_t publishedSeq;
        bool handled;
        status_t status = mInputPublisher.receiveFinishedSignal(&publishedSeq, &handled);
        if (status) {
            if (status == WOULD_BLOCK) {
                return OK;
            }
            ALOGE("channel '%s' ~ Failed to consume finished signals.  status=%d",
                    getInputChannelName(), status);
            return status;
        }

        ssize_t index = mPublishedSeqMap.indexOfKey(publishedSeq);
        if (index >= 0) {
            uint32_t seq = mPublishedSeqMap.valueAt(index);
            mPublishedSeqMap.removeItemsAt(index);

            if (kDebugDispatchCycle) {
                ALOGD("channel '%s' ~ Received finished signal, seq=%u, handled=%s, "
                        "pendingEvents=%zu.",
                        getInputChannelName(), seq, handled ? "true" : "false",
                        mPublishedSeqMap.size());
            }

            if (!skipCallbacks) {
                if (!senderObj.get()) {
                    senderObj.reset(jniGetReferent(env, mSenderWeakGlobal));
                    if (!senderObj.get()) {
                        ALOGW("channel '%s' ~ Sender object was finalized "
                                "without being disposed.", getInputChannelName());
                        return DEAD_OBJECT;
                    }
                }

                env->CallVoidMethod(senderObj.get(),
                        gInputEventSenderClassInfo.dispatchInputEventFinished,
                        jint(seq), jboolean(handled));
                if (env->ExceptionCheck()) {
                    ALOGE("Exception dispatching finished signal.");
                    skipCallbacks = true;
                }
            }
        }
    }
}
Ejemplo n.º 15
0
void VibroWorker::enqueueVibrationPattern (int count, const int *buffer, int repeat)
{
    if (KITCHENTIMER_USE_VIBRATION) {
	if (jni_env && objVibrator && mVibratePattern) {
	    jlong buf[count];
	    for (int i = 0; i < count; ++i)
		buf[i] = buffer[i];
	    jlongArray pattern = jni_env->NewLongArray (count);
	    jni_env->SetLongArrayRegion (pattern, 0, count, buf);
	    jni_env->CallVoidMethod (objVibrator, mVibratePattern, pattern, jint (repeat));
	}
    }
}
Ejemplo n.º 16
0
	void AndroidSound::load(std::string assetPath)
	{
		#ifdef __ANDROID__
			SB_WARNING() << "The AndroidSound class is deprecated, use the Sound class instead!" << std::endl;

			if (!AndroidAudio::isInit())
				AndroidAudio::init();

			m_assetPath = assetPath;

			m_id = sb::Java::callStaticIntMethod("org/libsdl/app/Sound", "loadAsync", "(Ljava/lang/String;)I", sb::Java::newUtfString(assetPath));
			SB_WARNING_IF2(m_id != jint(1), true) << "unable to load android sound " << assetPath << std::endl;

			jint result = jint(0);
			while (result == jint(0)) {
				result = sb::Java::callStaticIntMethod("org/libsdl/app/Sound", "isLoadComplete", "(I)I", m_id);
				SDL_Delay(1);
			}

			SB_WARNING_IF2(result != jint(1), true) << "unable to complete loading of android sound " << assetPath << std::endl;
		#endif
	}
Ejemplo n.º 17
0
void
watcher(void)
{
	Json *jv, *jtop;
	vlong id;
	char *text, *created_at, *user;
	char *buf;
	int fd, n, i;
	char fname[64];

	buf = malloc(BUFSIZ);
	if(buf == nil)
		sysfatal("malloc: %r");

	for(;;){
		fetch(fname);
		fd = open(fname, OREAD);
		n = readn(fd, buf, BUFSIZ);
		if(n <= 0){
			fprint(2, "read failed.\n");
			sleep(INTERVAL);
			continue;
		}
		/*print("(read %d bytes in %s)\n", n, fname);*/
		buf[n] = 0;

		jtop = parsejson(buf);
		if(jtop == nil){
			fprint(2, "parsejson failed.\n");
			sleep(INTERVAL);
			continue;
		}
		jv = jtop->value[0]; /* FIXME */

		for(i = jv->len - 1; i >= 0; i--){
			id = jint(jlookup(jv->value[i], "id"));
			if(id <= lastid)
				continue;
			text = jstring(jlookup(jv->value[i], "text"));
			created_at = jstring(jlookup(jv->value[i], "created_at"));
			user = jstring(jlookup(jv->value[i], "from_user"));
			print("[%s] %s (%s)\n", user, text, created_at);
			lastid = id;
		}

		jclose(jv);
		close(fd);
		sleep(INTERVAL);
	}
}
Ejemplo n.º 18
0
static jvalue numToJvalue(const T &num)
{
    jvalue value;
    switch (sig) //a good compiler should simplify out the switch
    {
    case 'Z': value.z = jboolean(num); return value;
    case 'C': value.c = jchar(num); return value;
    case 'B': value.b = jbyte(num); return value;
    case 'S': value.s = jshort(num); return value;
    case 'I': value.i = jint(num); return value;
    case 'J': value.j = jlong(num); return value;
    case 'F': value.f = jfloat(num); return value;
    case 'D': value.d = jdouble(num); return value;
    }
    poco_bugcheck_msg(std::string(1, sig).c_str()); throw;
}
Ejemplo n.º 19
0
 QString sensorDescription(AndroidSensorType sensor)
 {
     AttachedJNIEnv aenv;
     if (!aenv.jniEnv)
         return QString();
     jstring jstr = static_cast<jstring>(aenv.jniEnv->CallStaticObjectMethod(sensorsClass,
                                                                             getSensorDescriptionMethodId,
                                                                             jint(sensor)));
     if (!jstr)
         return QString();
     const jchar *pstr = aenv.jniEnv->GetStringChars(jstr, 0);
     QString ret(reinterpret_cast<const QChar *>(pstr), aenv.jniEnv->GetStringLength(jstr));
     aenv.jniEnv->ReleaseStringChars(jstr, pstr);
     aenv.jniEnv->DeleteLocalRef(jstr);
     return ret;
 }
Ejemplo n.º 20
0
void QAndroidDialog::showMessage(
	const QString & title,
	const QString & explanation,
	const QString & positive_button_text,
	const QString & negative_button_text,
	const QString & neutral_button_text,
	bool pause,
	bool lock_rotation)
{
	if (!isInteractiveMode())
	{
		qDebug() << "Dialog was not shown due to non-interactive mode";
		qDebug() << "title: \"" << title << "\"";
		qDebug() << "explanation: " << explanation << "\"";
		return;
	}

	if (dialog_helper_)
	{
		if (pause)
		{
			lock_rotation = true;
		}
		// TODO: We can't read or lock orientation when we don't have an activity.
		// Currently, we check it via customContextSet(), but this might not always be the right way.
		bool in_activity = !QAndroidQPAPluginGap::customContextSet();
		int orientation = (lock_rotation && in_activity)? QAndroidScreenOrientation::getCurrentFixedOrientation(): -1;
		dialog_helper_->callParamVoid("showMessage",
			"Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZIZ",
			QJniLocalRef(title).jObject(),
			QJniLocalRef(explanation).jObject(),
			QJniLocalRef(positive_button_text).jObject(),
			QJniLocalRef(negative_button_text).jObject(),
			QJniLocalRef(neutral_button_text).jObject(),
			jboolean(pause),
			jint(orientation),
			jboolean(in_activity)
		);
	}
	else
	{
		qCritical()<<"Failed to show message because DialogHelper instance not created!";
	}
}
Ejemplo n.º 21
0
char *iguana_inputaddress(struct iguana_info *coin,char *coinaddr,int16_t *spent_hdrsip,uint32_t *unspentindp,cJSON *vinobj)
{
    bits256 txid; int32_t vout,checkind,height;
    *unspentindp = 0;
    *spent_hdrsip = -1;
    if ( jobj(vinobj,"txid") != 0 && jobj(vinobj,"vout") != 0 )
    {
        txid = jbits256(vinobj,"txid");
        vout = jint(vinobj,"vout");
        if ( (checkind= iguana_unspentindfind(coin,coinaddr,0,0,0,&height,txid,vout,coin->bundlescount-1)) > 0 )
        {
            *spent_hdrsip = (height / coin->chain->bundlesize);
            *unspentindp = checkind;
            return(coinaddr);
        }
        else
        {
            char str[65];
            printf("error finding (%s/%d)\n",bits256_str(str,txid),vout);
        }
    }
    return(0);
}
JNIEXPORT jint JNICALL Java_com_opensubdiv_OpenSubdivViewer_OpenSubdiv_CreateCatmarkMesh(
    JNIEnv * env, jclass,
    jint level, jintArray nvertsArray, jintArray vertsArray,
    jint numFloatsPerPoint, jfloatArray pointsArray)
{
    int nvertsSize = env->GetArrayLength(nvertsArray);
    jint *nverts = env->GetIntArrayElements(nvertsArray, 0);

    int vertsSize = env->GetArrayLength(vertsArray);
    jint *verts = env->GetIntArrayElements(vertsArray, 0);

    int pointsSize = env->GetArrayLength(pointsArray);
    int numPoints = pointsSize / numFloatsPerPoint;

    OsdMeshWrapperSharedPtr wrapper = NewWrapper();
    wrapper->CreateCatmarkMesh(level,
                      numPoints, numFloatsPerPoint,
                      nvertsSize, nverts, vertsSize, verts);

    env->ReleaseIntArrayElements(nvertsArray, nverts, 0);
    env->ReleaseIntArrayElements(vertsArray, verts, 0);

    return jint(wrapper->GetMeshHandleId());
}
Ejemplo n.º 23
0
int32_t PLUGNAME(_process_json)(char *forwarder,char *sender,int32_t valid,struct plugin_info *plugin,uint64_t tag,char *retbuf,int32_t maxlen,char *origjsonstr,cJSON *origjson,int32_t initflag,char *tokenstr)
{
    char *resultstr,*retstr = 0,*methodstr,*jsonstr,*destplugin,*submethod; struct destbuf tagstr,endpoint;
    cJSON *retjson,*json,*tokenobj; uint32_t nonce;
    struct applicant_info apply;
    retbuf[0] = 0;
    if ( tokenstr == 0 )
        tokenstr = "";
    if ( is_cJSON_Array(origjson) != 0 && cJSON_GetArraySize(origjson) == 2 )
        json = cJSON_GetArrayItem(origjson,0), jsonstr = cJSON_Print(json), _stripwhite(jsonstr,' ');
    else json = origjson, jsonstr = origjsonstr;
    if ( Debuglevel > 2 )
        printf("<<<<<<<<<<<< INSIDE relays PLUGIN! process %s [(%s).(%s)]\n",plugin->name,jsonstr,tokenstr);
    if ( initflag > 0 )
    {
        // configure settings
        RELAYS.readyflag = 1;
        plugin->allowremote = 1;
        strcpy(retbuf,"{\"result\":\"initflag > 0\"}");
    }
    else
    {
        if ( plugin_result(retbuf,json,tag) > 0 )
            return((int32_t)strlen(retbuf));
        resultstr = cJSON_str(cJSON_GetObjectItem(json,"result"));
        methodstr = cJSON_str(cJSON_GetObjectItem(json,"method"));
        destplugin = cJSON_str(cJSON_GetObjectItem(json,"destplugin"));
        submethod = cJSON_str(cJSON_GetObjectItem(json,"submethod"));
        if ( methodstr == 0 || methodstr[0] == 0 )
        {
            printf("(%s) has not method\n",jsonstr);
            return(0);
        }
        //fprintf(stderr,"RELAYS methodstr.(%s) (%s)\n",methodstr,jsonstr);
        if ( resultstr != 0 && strcmp(resultstr,"registered") == 0 )
        {
            plugin->registered = 1;
            strcpy(retbuf,"{\"result\":\"activated\"}");
        }
#ifdef INSIDE_MGW
        else if ( strcmp(methodstr,"msigaddr") == 0 )
        {
            char *devMGW_command(char *jsonstr,cJSON *json);
            if ( SUPERNET.gatewayid >= 0 )
                retstr = devMGW_command(jsonstr,json);
        }
#endif
        else
        {
            strcpy(retbuf,"{\"result\":\"relay command under construction\"}");
            if ( strcmp(methodstr,"list") == 0 )
                retstr = relays_jsonstr(jsonstr,json);
            else if ( strcmp(methodstr,"telepathy") == 0 )
            {
                sprintf(retbuf,"%s",jsonstr);
            }
            else if ( strcmp(methodstr,"busdata") == 0 )
            {
                retstr = busdata_sync(&nonce,jsonstr,cJSON_str(cJSON_GetObjectItem(json,"broadcast")),0);
                // {"plugin":"relay","method":"busdata","destplugin":"relay","submethod":"join","broadcast":"join","endpoint":""}
            }
            else if ( strcmp(methodstr,"allservices") == 0 )
            {
                if ( (retjson= serviceprovider_json()) != 0 )
                {
                    retstr = cJSON_Print(retjson), _stripwhite(retstr,' ');
                    free_json(retjson);
                    //printf("got.(%s)\n",retstr);
                } else printf("null serviceprovider_json()\n");
            }
            else if ( strcmp(methodstr,"protocol") == 0 || strcmp(methodstr,"allprotocols") == 0 )
            {
                if ( strcmp(methodstr,"protocol") == 0 && valid > 0 )
                    protocols_register(sender,jstr(json,"protocol"),jstr(json,"endpoint"),jint(json,"disconnect"));
                if ( (retjson= protocols_json(jstr(json,"protocol"))) != 0 )
                {
                    retstr = cJSON_Print(retjson), _stripwhite(retstr,' ');
                    free_json(retjson);
                } else printf("null protocols_json()\n");
            }
            else if ( strcmp(methodstr,"join") == 0 )
            {
                if ( SUPERNET.noncing == 0 )
                {
                    copy_cJSON(&tagstr,cJSON_GetObjectItem(json,"tag"));
                    copy_cJSON(&endpoint,cJSON_GetObjectItem(json,"endpoint"));
                    SUPERNET.noncing = 1;
                    if ( SUPERNET.iamrelay != 0 )
                    {
                        portable_thread_create((void *)calc_nonces,clonestr(endpoint.buf));
                        sprintf(retbuf,"{\"result\":\"noncing\",\"endpoint\":\"%s\"}",endpoint.buf);
                    }
                    //fprintf(stderr,"join or nonce.(%s)\n",retbuf);
                }
            }
            else if ( strcmp(methodstr,"nonce") == 0 )
            {
                struct destbuf endpoint,sender,destpoint,relaypoint,globalpoint,noncestr;
                memset(&apply,0,sizeof(apply));
                copy_cJSON(&destpoint,cJSON_GetObjectItem(json,"destpoint"));
                copy_cJSON(&endpoint,cJSON_GetObjectItem(json,"lbendpoint"));
                copy_cJSON(&relaypoint,cJSON_GetObjectItem(json,"relaypoint"));
                copy_cJSON(&globalpoint,cJSON_GetObjectItem(json,"globalpoint"));
                copy_cJSON(&sender,cJSON_GetObjectItem(json,"NXT"));
                if ( SUPERNET.noncing != 0 && strcmp(SUPERNET.lbendpoint,destpoint.buf) == 0 )
                {
                    if ( endpoint.buf[0] != 0 && tokenstr[0] != 0 && (tokenobj= cJSON_Parse(tokenstr)) != 0 )
                    {
                        strcpy(apply.lbendpoint,endpoint.buf);
                        strcpy(apply.relayendpoint,relaypoint.buf);
                        strcpy(apply.globalendpoint,globalpoint.buf);
                        apply.senderbits = calc_nxt64bits(sender.buf);
                        copy_cJSON(&noncestr,cJSON_GetObjectItem(tokenobj,"nonce"));
                        if ( noncestr.buf[0] != 0 )
                            apply.nonce = (uint32_t)calc_nxt64bits(noncestr.buf);
                        //printf("tokenobj.(%s) -> nonce.%u\n",tokenstr,apply.nonce);
                        free_json(tokenobj);
                        recv_nonces(&apply);
                    }
                }
            }
        }
    }
    return(plugin_copyretstr(retbuf,maxlen,retstr));
}
Ejemplo n.º 24
0
/**
* Connect to the given device. Return error code if fails
**/
JNIEXPORT jint JNICALL Java_eu_tevs_openbm_GatewayNative_connect(JNIEnv* env, jobject obj, jstring _device, jint _cts)
{
    int loglevel = 0;
 
    // set log level and file
    if (loglevel < 0) loglevel = 0;
    if (loglevel > 4) loglevel = 4;
    Logger::instance()->setLevel((Logger::Level)loglevel);
    Logger::instance()->setCallback(logCallback);
    
    LOG_DEBUG("Connect to IBus...");
    
    // get arguments
    std::string device = env->GetStringUTFChars(_device, 0);
    int cts = static_cast<int>(_cts);
 
 #if 1 
     int fd, serial;
    fd = open("/dev/ttyS2", O_RDWR | O_NONBLOCK | O_NOCTTY);
  termios ios;
  errno = 0;
  tcgetattr(fd, &ios);
    ios.c_iflag &= ~(IGNBRK | BRKINT | PARMRK
        | ISTRIP | INLCR | IGNCR | ICRNL | IXON);
    ios.c_oflag &= ~OPOST;
    ios.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
    ios.c_cflag &= ~(CSIZE | PARENB);
    ios.c_cflag |= CS8;
    ios.c_iflag |= IGNPAR;
    ios.c_cflag |= CREAD | CLOCAL;
    errno = 0;
    tcsetattr(fd, TCSANOW, &ios);
    
    ioctl(fd, TIOCMGET, &serial);
    if (serial & TIOCM_CTS)
        logCallback("TIOCM_CTS is not set");
    else
        logCallback("TIOCM_CTS is set");
    close(fd);      
#endif
    
    // try to connect 
    try
    {
        if (Application::g_app)
        {
            Application::g_app->disconnectIBus();
            delete Application::g_app;
            Application::g_app = NULL;
        }
        
        Application::g_app = new Application(openbm::Address, openbm::Port, 0, openbm::ClientAliveTimeout);
        
        IBus::CTSType ccc = IBus::NO;
        if (cts < 0) ccc = IBus::NO;
        if (cts == 0) ccc = IBus::HARDWARE;
        if (cts > 0) ccc = IBus::GPIO;
        
        if (!Application::g_app->connectIBus(device, ccc)) return jint(-1);
        
    }catch(...)
    {
        return jint(-1);    
    }
    
    Application::g_app->setUseWebserver(false);
 
    LOG_DEBUG("Connected...");
    
    return jint(0);
}
Ejemplo n.º 25
0
inline jint low (jlong value)                    { return jint(value); }
Ejemplo n.º 26
0
static void testProxy0ReturnInt(CuTest* tc) {
    handler = testProxy0ReturnInt_handler;
    jint (*f)(jint) = (jint (*)(jint)) _proxy0;
    jint result = f(0xdeadbeef);
    CuAssertIntEquals(tc, 0xffdeadbe, result);
}
void DdmConnection::start(const char* name) {
    JavaVM* vm;
    JNIEnv* env;

    // start a VM
    JavaVMInitArgs args;
    JavaVMOption opt;

    opt.optionString =
        "-agentlib:jdwp=transport=dt_android_adb,suspend=n,server=y";

    args.version = JNI_VERSION_1_4;
    args.options = &opt;
    args.nOptions = 1;
    args.ignoreUnrecognized = JNI_FALSE;


    // TODO: Should this just link against libnativehelper and use its
    // JNI_CreateJavaVM wrapper that essential does this dlopen/dlsym
    // work based on the current system default runtime?
    void* libart_dso = dlopen("libart.so", RTLD_NOW);
    ALOGE_IF(!libart_dso, "DdmConnection: %s", dlerror());

    void* libandroid_runtime_dso = dlopen("libandroid_runtime.so", RTLD_NOW);
    ALOGE_IF(!libandroid_runtime_dso, "DdmConnection: %s", dlerror());

    if (!libart_dso || !libandroid_runtime_dso) {
        goto error;
    }

    jint (*JNI_CreateJavaVM)(JavaVM** p_vm, JNIEnv** p_env, void* vm_args);
    JNI_CreateJavaVM = reinterpret_cast<decltype(JNI_CreateJavaVM)>(
            dlsym(libart_dso, "JNI_CreateJavaVM"));
    ALOGE_IF(!JNI_CreateJavaVM, "DdmConnection: %s", dlerror());

    jint (*registerNatives)(JNIEnv* env, jclass clazz);
    registerNatives = reinterpret_cast<decltype(registerNatives)>(
            dlsym(libandroid_runtime_dso,
                  "Java_com_android_internal_util_WithFramework_registerNatives"));
    ALOGE_IF(!registerNatives, "DdmConnection: %s", dlerror());

    if (!JNI_CreateJavaVM || !registerNatives) {
        goto error;
    }

    if (JNI_CreateJavaVM(&vm, &env, &args) == 0) {
        jclass startClass;
        jmethodID startMeth;

        // register native code
        if (registerNatives(env, 0) == 0) {
            // set our name by calling DdmHandleAppName.setAppName()
            startClass = env->FindClass("android/ddm/DdmHandleAppName");
            if (startClass) {
                startMeth = env->GetStaticMethodID(startClass,
                        "setAppName", "(Ljava/lang/String;I)V");
                if (startMeth) {
                    jstring str = env->NewStringUTF(name);
                    env->CallStaticVoidMethod(startClass, startMeth, str, getuid());
                    env->DeleteLocalRef(str);
                }
            }

            // initialize DDMS communication by calling
            // DdmRegister.registerHandlers()
            startClass = env->FindClass("android/ddm/DdmRegister");
            if (startClass) {
                startMeth = env->GetStaticMethodID(startClass,
                        "registerHandlers", "()V");
                if (startMeth) {
                    env->CallStaticVoidMethod(startClass, startMeth);
                }
            }
        }
    }
    return;

error:
    if (libandroid_runtime_dso) {
        dlclose(libandroid_runtime_dso);
    }
    if (libart_dso) {
        dlclose(libart_dso);
    }
}
Ejemplo n.º 28
0
 static jobject NewAdvertisingObject(int t, int p, const string &did, const StringVec &td) {
   if (!jni->advertising_class) jni->advertising_class = CheckNotNull
     (jclass(jni->env->NewGlobalRef(jni->env->FindClass("com/lucidfusionlabs/ads/Advertising"))));
   static jmethodID mid = CheckNotNull
     (jni->env->GetStaticMethodID(jni->advertising_class, "createStaticInstance",
                                  "(Lcom/lucidfusionlabs/core/LifecycleActivity;IILjava/lang/String;Ljava/util/List;)Lcom/lucidfusionlabs/ads/Advertising;"));
   LocalJNIString di(jni->env, JNI::ToJString(jni->env, did));
   LocalJNIObject l(jni->env, JNI::ToJStringArrayList(jni->env, td));
   return jni->env->CallStaticObjectMethod(jni->advertising_class, mid, jni->activity, jint(t), jint(p), di.v, l.v);
 }
Ejemplo n.º 29
0
static jint android_view_MotionEvent_nativeGetHistorySize(JNIEnv* env, jclass clazz,
        jint nativePtr) {
    MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
    return jint(event->getHistorySize());
}
Ejemplo n.º 30
0
static jint android_view_MotionEvent_nativeFindPointerIndex(JNIEnv* env, jclass clazz,
        jint nativePtr, jint pointerId) {
    MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
    return jint(event->findPointerIndex(pointerId));
}