Beispiel #1
0
static void awtUnlock(JNIEnv *env, XlibBlitter *blt) {
  jmethodID mid;
  jclass cls;
  if ( jawt == 1 ) {
    cls = (jclass)(*env)->FindClass(env, "com/sun/media/DrawingSurfaceJAWT");
    if ( cls == NULL ) {
	printf("in awtUnlock cls is null\n");
	return;
    }
    
    mid = (*env)->GetStaticMethodID(env, cls, "unlockAWT", "(I)V");
    if ( mid == NULL ) {
	printf("in awtUnlock mid is null\n");
	return;
    }

    (*env)->CallStaticVoidMethod(env, cls, mid, blt->drawingSurface);
    if((*env)->ExceptionOccurred(env)) {
	(*env)->ExceptionDescribe(env);
	(*env)->ExceptionClear(env);
    }

    return;
  } else {
    CallVoidMethod(env, blt->surface, "unlock", "()V", NULL);
    }
}
void SyncerListener::JavaProxy::finished() {
    auto jniEnv = ::djinni::jniGetThreadEnv();
    ::djinni::JniLocalScope jscope(jniEnv, 10);
    const auto& data = ::djinni::JniClass<::JNI::Kullo::Api::SyncerListener>::get();
    jniEnv->CallVoidMethod(Handle::get().get(), data.method_finished);
    ::djinni::jniExceptionCheck(jniEnv);
}
Beispiel #3
0
void JniFirebase::UnAuth() {
    auto env = getEnv();
    if (!GetMethod(env, s_firebaseClass, "unauth", "()V",
                   &s_unAuth)) {
        return;
    }
    env->CallVoidMethod(m_firebase, s_unAuth);
}
void SyncerListener::JavaProxy::progressed(const ::Kullo::Api::SyncProgress & c_progress) {
    auto jniEnv = ::djinni::jniGetThreadEnv();
    ::djinni::JniLocalScope jscope(jniEnv, 10);
    const auto& data = ::djinni::JniClass<::JNI::Kullo::Api::SyncerListener>::get();
    jniEnv->CallVoidMethod(Handle::get().get(), data.method_progressed,
                           ::djinni::get(::JNI::Kullo::Api::SyncProgress::fromCpp(jniEnv, c_progress)));
    ::djinni::jniExceptionCheck(jniEnv);
}
void NativeAnalyticsListener::JavaProxy::SetPropertyId(const std::string & c_property_id) {
    auto jniEnv = ::djinni::jniGetThreadEnv();
    ::djinni::JniLocalScope jscope(jniEnv, 10);
    const auto& data = ::djinni::JniClass<::djinni_generated::NativeAnalyticsListener>::get();
    jniEnv->CallVoidMethod(Handle::get().get(), data.method_setPropertyId,
                           ::djinni::get(::djinni::String::fromCpp(jniEnv, c_property_id)));
    ::djinni::jniExceptionCheck(jniEnv);
}
void NativeAnalyticsListener::JavaProxy::TrackScreenView(const std::string & c_screen_name) {
    auto jniEnv = ::djinni::jniGetThreadEnv();
    ::djinni::JniLocalScope jscope(jniEnv, 10);
    const auto& data = ::djinni::JniClass<::djinni_generated::NativeAnalyticsListener>::get();
    jniEnv->CallVoidMethod(Handle::get().get(), data.method_trackScreenView,
                           ::djinni::get(::djinni::String::fromCpp(jniEnv, c_screen_name)));
    ::djinni::jniExceptionCheck(jniEnv);
}
void SessionAccountInfoListener::JavaProxy::finished(const ::Kullo::Api::AccountInfo & c_accountInfo) {
    auto jniEnv = ::djinni::jniGetThreadEnv();
    ::djinni::JniLocalScope jscope(jniEnv, 10);
    const auto& data = ::djinni::JniClass<::JNI::Kullo::Api::SessionAccountInfoListener>::get();
    jniEnv->CallVoidMethod(Handle::get().get(), data.method_finished,
                           ::djinni::get(::JNI::Kullo::Api::AccountInfo::fromCpp(jniEnv, c_accountInfo)));
    ::djinni::jniExceptionCheck(jniEnv);
}
void SyncerListener::JavaProxy::error(::Kullo::Api::NetworkError c_error) {
    auto jniEnv = ::djinni::jniGetThreadEnv();
    ::djinni::JniLocalScope jscope(jniEnv, 10);
    const auto& data = ::djinni::JniClass<::JNI::Kullo::Api::SyncerListener>::get();
    jniEnv->CallVoidMethod(Handle::get().get(), data.method_error,
                           ::djinni::get(::JNI::Kullo::Api::NetworkError::fromCpp(jniEnv, c_error)));
    ::djinni::jniExceptionCheck(jniEnv);
}
void NativeILifecyleViewModelDelegate::JavaProxy::onAccountStatusChanged(::core_gen::EAccountStatus c_status) {
    auto jniEnv = ::djinni::jniGetThreadEnv();
    ::djinni::JniLocalScope jscope(jniEnv, 10);
    const auto& data = ::djinni::JniClass<::djinni_generated::NativeILifecyleViewModelDelegate>::get();
    jniEnv->CallVoidMethod(Handle::get().get(), data.method_onAccountStatusChanged,
                           ::djinni::get(::djinni_generated::NativeEAccountStatus::fromCpp(jniEnv, c_status)));
    ::djinni::jniExceptionCheck(jniEnv);
}
Beispiel #10
0
static int
formatMpeg(JNIEnv *env, jobject jxil, InstanceState *inst, jobject jStream)
{
    CallVoidMethod(env, jStream, "setMpegFormat", "(IIIII)V",
			inst->inWidth, inst->inHeight,
			inst->outWidth, inst->outHeight,
			inst->quality);
    return 1;
}
Beispiel #11
0
    ActivityState* ActivityState::create(ANativeActivity* activity)
    {
        JOP_ASSERT(ns_instance == nullptr, "There must only be one ActivityState!");

        ns_instance.reset(new ActivityState);
        ns_instance->nativeActivity = activity;

        ANativeActivity_setWindowFlags(activity, AWINDOW_FLAG_KEEP_SCREEN_ON, AWINDOW_FLAG_KEEP_SCREEN_ON);

        Thread::attachJavaThread(activity->vm, activity->env);

        // Get the screen size
        {
            auto env = Thread::getCurrentJavaEnv();

            if (!env)
            {
                JOP_DEBUG_ERROR("No current java environment, function \"" << __func__ << "\"");
                return get();
            }

            jclass activityClass = env->GetObjectClass(activity->clazz);

            jclass displayMetricsClass = env->FindClass("android/util/DisplayMetrics");
            jmethodID displayMetricsInit = env->GetMethodID(displayMetricsClass, "<init>", "()V");
            jobject displayMetricsObject = env->NewObject(displayMetricsClass, displayMetricsInit);

            jmethodID getWindowManagerMethod = env->GetMethodID(activityClass, "getWindowManager", "()Landroid/view/WindowManager;");
            jobject windowManagerObject = env->CallObjectMethod(activity->clazz, getWindowManagerMethod);

            jclass windowManagerClass = env->FindClass("android/view/WindowManager");
            jmethodID getDefaultDisplayMethod = env->GetMethodID(windowManagerClass, "getDefaultDisplay", "()Landroid/view/Display;");
            jobject displayObject = env->CallObjectMethod(windowManagerObject, getDefaultDisplayMethod);

            jclass displayClass = env->FindClass("android/view/Display");
            jmethodID getMetricsMethod = env->GetMethodID(displayClass, "getMetrics", "(Landroid/util/DisplayMetrics;)V");
            env->CallVoidMethod(displayObject, getMetricsMethod, displayMetricsObject);

            jfieldID pixelsWidth = env->GetFieldID(displayMetricsClass, "widthPixels", "I");
            jfieldID pixelsHeight = env->GetFieldID(displayMetricsClass, "heightPixels", "I");

            ns_instance->screenSize.x = env->GetIntField(displayMetricsObject, pixelsWidth);
            ns_instance->screenSize.y = env->GetIntField(displayMetricsObject, pixelsHeight);

            //jmethodID getRefreshRateMethod = env->GetMethodID(displayClass, "getRefreshRate", "(Landroid/view/Display;)F");
            ns_instance->screenRefreshRate = 60;//env->CallFloatMethod(displayObject, getRefreshRateMethod);

            env->DeleteLocalRef(activityClass);
            env->DeleteLocalRef(displayMetricsObject);
            env->DeleteLocalRef(windowManagerObject);
            env->DeleteLocalRef(windowManagerClass);
            env->DeleteLocalRef(displayObject);
            env->DeleteLocalRef(displayClass);
        }

        return get();
    }
void ClientAddressExistsListener::JavaProxy::error(const std::shared_ptr<::Kullo::Api::Address> & c_address, ::Kullo::Api::NetworkError c_error) {
    auto jniEnv = ::djinni::jniGetThreadEnv();
    ::djinni::JniLocalScope jscope(jniEnv, 10);
    const auto& data = ::djinni::JniClass<::JNI::Kullo::Api::ClientAddressExistsListener>::get();
    jniEnv->CallVoidMethod(Handle::get().get(), data.method_error,
                           ::djinni::get(::JNI::Kullo::Api::Address::fromCpp(jniEnv, c_address)),
                           ::djinni::get(::JNI::Kullo::Api::NetworkError::fromCpp(jniEnv, c_error)));
    ::djinni::jniExceptionCheck(jniEnv);
}
void NativeAnalyticsListener::JavaProxy::SetCustomDimension(int32_t c_index, const std::string & c_value, ::demicapps::CustomDimensionScope c_scope) {
    auto jniEnv = ::djinni::jniGetThreadEnv();
    ::djinni::JniLocalScope jscope(jniEnv, 10);
    const auto& data = ::djinni::JniClass<::djinni_generated::NativeAnalyticsListener>::get();
    jniEnv->CallVoidMethod(Handle::get().get(), data.method_setCustomDimension,
                           ::djinni::get(::djinni::I32::fromCpp(jniEnv, c_index)),
                           ::djinni::get(::djinni::String::fromCpp(jniEnv, c_value)),
                           ::djinni::get(::djinni_generated::NativeCustomDimensionScope::fromCpp(jniEnv, c_scope)));
    ::djinni::jniExceptionCheck(jniEnv);
}
void NativeCoreApi::JavaProxy::Post(const std::string & c_url, const std::string & c_data, const std::shared_ptr<::demicapps::HttpCallback> & c_callback) {
    auto jniEnv = ::djinni::jniGetThreadEnv();
    ::djinni::JniLocalScope jscope(jniEnv, 10);
    const auto& data = ::djinni::JniClass<::djinni_generated::NativeCoreApi>::get();
    jniEnv->CallVoidMethod(Handle::get().get(), data.method_post,
                           ::djinni::get(::djinni::String::fromCpp(jniEnv, c_url)),
                           ::djinni::get(::djinni::String::fromCpp(jniEnv, c_data)),
                           ::djinni::get(::djinni_generated::NativeHttpCallback::fromCpp(jniEnv, c_callback)));
    ::djinni::jniExceptionCheck(jniEnv);
}
JniChildEventStub::~JniChildEventStub() {
    auto env = getEnv();
    if (env != NULL && m_stub != NULL) {
        if (s_stubRelease != NULL) {
            env->CallVoidMethod(m_stub, s_stubRelease);
        }
        env->DeleteGlobalRef((jobject)m_stub);
    }
    m_stub = NULL;
}
void NativeAnalyticsListener::JavaProxy::TrackEvent(const std::string & c_event_category, const std::string & c_event_action, const std::string & c_event_label, int32_t c_event_value) {
    auto jniEnv = ::djinni::jniGetThreadEnv();
    ::djinni::JniLocalScope jscope(jniEnv, 10);
    const auto& data = ::djinni::JniClass<::djinni_generated::NativeAnalyticsListener>::get();
    jniEnv->CallVoidMethod(Handle::get().get(), data.method_trackEvent,
                           ::djinni::get(::djinni::String::fromCpp(jniEnv, c_event_category)),
                           ::djinni::get(::djinni::String::fromCpp(jniEnv, c_event_action)),
                           ::djinni::get(::djinni::String::fromCpp(jniEnv, c_event_label)),
                           ::djinni::get(::djinni::I32::fromCpp(jniEnv, c_event_value)));
    ::djinni::jniExceptionCheck(jniEnv);
}
Beispiel #17
0
	void _copyString(const std::string &value) {
		auto env = spjni::getJniEnv();
		auto clipboard = spjni::getService(spjni::Service::Clipboard, env);
		auto clipboardClass = env->GetObjectClass(clipboard);
		auto method = spjni::getMethodID(env, clipboardClass, "copyStringToClipboard", "(Ljava/lang/String;)V");
		if (method) {
			auto str = env->NewStringUTF(value.c_str());
			env->CallVoidMethod(clipboard, method, str);
			env->DeleteLocalRef(str);
		}
	}
Beispiel #18
0
void JniFirebase::SetString(const char *value) {
    if (!m_firebase) {
        return;
    }
    auto env = getEnv();
    
    if (!GetMethod(env, s_firebaseClass, s_firebaseSetValueName, s_firebaseSetValueSig, &s_firebaseSetValue)) {
        return;
    }
    env->CallVoidMethod(m_firebase, s_firebaseSetValue, (jstring)JSTRING(env, env->NewStringUTF(value)));
}
void SyncerListener::JavaProxy::draftPartTooBig(int64_t c_convId, ::Kullo::Api::DraftPart c_part, int64_t c_currentSize, int64_t c_maxSize) {
    auto jniEnv = ::djinni::jniGetThreadEnv();
    ::djinni::JniLocalScope jscope(jniEnv, 10);
    const auto& data = ::djinni::JniClass<::JNI::Kullo::Api::SyncerListener>::get();
    jniEnv->CallVoidMethod(Handle::get().get(), data.method_draftPartTooBig,
                           ::djinni::get(::djinni::I64::fromCpp(jniEnv, c_convId)),
                           ::djinni::get(::JNI::Kullo::Api::DraftPart::fromCpp(jniEnv, c_part)),
                           ::djinni::get(::djinni::I64::fromCpp(jniEnv, c_currentSize)),
                           ::djinni::get(::djinni::I64::fromCpp(jniEnv, c_maxSize)));
    ::djinni::jniExceptionCheck(jniEnv);
}
Beispiel #20
0
static int
formatRaw(JNIEnv *env, jobject jxil, InstanceState *inst, jobject jStream)
{
    int stride = inst->inStrideX;

    if (stride <= 0)
	stride = formatUnspec;
    CallVoidMethod(env, jStream, "setRGBFormat", "(IIIII)V",
			inst->inWidth, inst->inHeight,
			inst->outWidth, inst->outHeight,
			stride);
    return 1;
}
Beispiel #21
0
void JniFirebase::SetFloat(float value) {
    if (!m_firebase) {
        return;
    }
    auto env = getEnv();
    
    if (!GetMethod(env, s_firebaseClass, s_firebaseSetValueName, s_firebaseSetValueSig, &s_firebaseSetValue)) {
        return;
    }
    JniFloat* jniFloat = new JniFloat(env, value);
    env->CallVoidMethod(m_firebase, s_firebaseSetValue, (jobject) (*jniFloat));
    delete jniFloat;
}
void platformSetOrientation(int orientation)
{
	auto env = gApp->activity->env;
	auto vm = gApp->activity->vm;
	auto obj = gApp->activity->clazz;

	vm->AttachCurrentThread( &env, NULL );

	auto clazz = env->GetObjectClass(obj);
	jmethodID orientationID = env->GetMethodID(clazz, "setOrientation", "(I)V");

	env->CallVoidMethod(obj, orientationID, orientation);
	vm->DetachCurrentThread();
}
Beispiel #23
0
void JniFirebase::SetJson(const char *value) {
    auto env = getEnv();
    
    if (s_objectMapperInstance == NULL) {
        lock<std::mutex> lock(s_objectMapperLock);
        if (s_objectMapperInstance == NULL) {
            if (!GetClass(env, "java/util/HashMap", &s_objectClass)) {
                return;
            }

            if (!GetClass(env, s_objectMapperClassName, &s_objectMapperClass)) {
                return;
            }

            jmethodID ctor = NULL;
            if (!GetMethod(env, s_objectMapperClass, "<init>", "()V", &ctor))
            {
                return;
            }

            if (!GetMethod(env, s_objectMapperClass, s_objectMapperReadValueName, s_objectMapperReadValueSig, &s_objectMapperReadValue)) {
                return;
            }

            JOBJECT localRef = JOBJECT(env, env->NewObject(s_objectMapperClass, ctor));
            s_objectMapperInstance = env->NewGlobalRef(localRef);
        }
    }
    
    JOBJECT localValue = JOBJECT(env,
                                env->CallObjectMethod(s_objectMapperInstance, s_objectMapperReadValue,
                                                      (jstring)JSTRING(env, env->NewStringUTF(value)), s_objectClass));

    if (env->ExceptionCheck() == JNI_TRUE) {
        SetString(GetJNIExceptionDescription(env, env->ExceptionOccurred()));
        return;
    }
    
    if (!GetMethod(env, s_firebaseClass, s_firebaseSetValueName, s_firebaseSetValueSig, &s_firebaseSetValue)) {
        return;
    }
    
    env->CallVoidMethod(m_firebase, s_firebaseSetValue, (jobject)localValue);
}
Beispiel #24
0
void JOutputStream::write(JArray<jbyte>& buffer) {
	CallVoidMethod("write", "([B)V", buffer.GetJObject());
}
Beispiel #25
0
void JOutputStream::write(JArray<jbyte>& buffer, int offset, int count) {
	CallVoidMethod("write", "([BII)V", buffer.GetJObject(), offset, count);
}
Beispiel #26
0
void JOutputStream::write(jint oneByte) {
	CallVoidMethod("write", "(I)V", oneByte);
}
Beispiel #27
0
void JOutputStream::close() {
	CallVoidMethod("close", "()V");
}