mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-26 07:38:09 +00:00
Started to bind log collection methods in JNI layer
This commit is contained in:
parent
88e2ba7625
commit
4e5e409dc2
9 changed files with 207 additions and 9 deletions
|
|
@ -30,6 +30,7 @@ import org.linphone.core.LinphoneContent;
|
|||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
|
||||
import org.linphone.core.LinphoneCore.GlobalState;
|
||||
import org.linphone.core.LinphoneCore.LogCollectionUploadState;
|
||||
import org.linphone.core.LinphoneCore.RegistrationState;
|
||||
import org.linphone.core.LinphoneCore.RemoteProvisioningState;
|
||||
import org.linphone.core.LinphoneCoreException;
|
||||
|
|
@ -322,4 +323,17 @@ public class TutorialBuddyStatus implements LinphoneListener {
|
|||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadProgressIndication(LinphoneCore lc, int offset, int total) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadStateChanged(LinphoneCore lc,
|
||||
LogCollectionUploadState state, String info) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import org.linphone.core.LinphoneContent;
|
|||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
|
||||
import org.linphone.core.LinphoneCore.GlobalState;
|
||||
import org.linphone.core.LinphoneCore.LogCollectionUploadState;
|
||||
import org.linphone.core.LinphoneCore.RegistrationState;
|
||||
import org.linphone.core.LinphoneCore.RemoteProvisioningState;
|
||||
import org.linphone.core.LinphoneCoreException;
|
||||
|
|
@ -241,5 +242,18 @@ public class TutorialChatRoom implements LinphoneListener, LinphoneChatMessage.S
|
|||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadProgressIndication(LinphoneCore lc, int offset, int total) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadStateChanged(LinphoneCore lc,
|
||||
LogCollectionUploadState state, String info) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import org.linphone.core.LinphoneContent;
|
|||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
|
||||
import org.linphone.core.LinphoneCore.GlobalState;
|
||||
import org.linphone.core.LinphoneCore.LogCollectionUploadState;
|
||||
import org.linphone.core.LinphoneCore.RegistrationState;
|
||||
import org.linphone.core.LinphoneCore.RemoteProvisioningState;
|
||||
import org.linphone.core.LinphoneCoreException;
|
||||
|
|
@ -243,5 +244,18 @@ public class TutorialHelloWorld implements LinphoneListener {
|
|||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadProgressIndication(LinphoneCore lc, int offset, int total) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadStateChanged(LinphoneCore lc,
|
||||
LogCollectionUploadState state, String info) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import org.linphone.core.LinphoneContent;
|
|||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
|
||||
import org.linphone.core.LinphoneCore.GlobalState;
|
||||
import org.linphone.core.LinphoneCore.LogCollectionUploadState;
|
||||
import org.linphone.core.LinphoneCore.RegistrationState;
|
||||
import org.linphone.core.LinphoneCore.RemoteProvisioningState;
|
||||
import org.linphone.core.LinphoneCoreException;
|
||||
|
|
@ -274,6 +275,16 @@ public class TutorialRegistration implements LinphoneListener {
|
|||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadProgressIndication(LinphoneCore lc, int offset, int total) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void uploadStateChanged(LinphoneCore lc,
|
||||
LogCollectionUploadState state, String info) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -420,6 +420,19 @@ public:
|
|||
if (fileTransferRecvId) {
|
||||
vTable->file_transfer_recv = fileTransferRecv;
|
||||
}
|
||||
|
||||
logCollectionUploadStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$LogCollectionUploadState"));
|
||||
logCollectionUploadStateFromIntId = env->GetStaticMethodID(logCollectionUploadStateClass, "fromInt", "(I)Lorg/linphone/core/LinphoneCore$LogCollectionUploadState;");
|
||||
logCollectionUploadProgressId = env->GetMethodID(listenerClass, "uploadProgressIndication", "(Lorg/linphone/core/LinphoneCore;I;I)V");
|
||||
env->ExceptionClear();
|
||||
if (logCollectionUploadProgressId) {
|
||||
vTable->log_collection_upload_progress_indication = logCollectionUploadProgressIndication;
|
||||
}
|
||||
logCollectionUploadStateId = env->GetMethodID(listenerClass, "uploadStateChanged", "(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$LogCollectionUploadState;Ljava/lang/String;)V");
|
||||
env->ExceptionClear();
|
||||
if (logCollectionUploadStateId) {
|
||||
vTable->log_collection_upload_state_changed = logCollectionUploadStateChange;
|
||||
}
|
||||
|
||||
chatMessageStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatMessage$State"));
|
||||
chatMessageStateFromIntId = env->GetStaticMethodID(chatMessageStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneChatMessage$State;");
|
||||
|
|
@ -479,6 +492,7 @@ public:
|
|||
env->DeleteGlobalRef(linphoneEventClass);
|
||||
env->DeleteGlobalRef(subscriptionStateClass);
|
||||
env->DeleteGlobalRef(subscriptionDirClass);
|
||||
env->DeleteGlobalRef(logCollectionUploadStateClass);
|
||||
}
|
||||
jobject core;
|
||||
jobject listener;
|
||||
|
|
@ -566,6 +580,11 @@ public:
|
|||
jmethodID fileTransferSendId;
|
||||
jmethodID fileTransferRecvId;
|
||||
|
||||
jclass logCollectionUploadStateClass;
|
||||
jmethodID logCollectionUploadStateId;
|
||||
jmethodID logCollectionUploadStateFromIntId;
|
||||
jmethodID logCollectionUploadProgressId;
|
||||
|
||||
LinphoneCoreVTable vTable;
|
||||
|
||||
static void displayStatusCb(LinphoneCore *lc, const char *message) {
|
||||
|
|
@ -1001,6 +1020,40 @@ public:
|
|||
jbytes,
|
||||
size);
|
||||
}
|
||||
static void logCollectionUploadProgressIndication(LinphoneCore *lc, size_t offset, size_t total) {
|
||||
JNIEnv *env = 0;
|
||||
jint result = jvm->AttachCurrentThread(&env,NULL);
|
||||
if (result != 0) {
|
||||
ms_error("cannot attach VM");
|
||||
return;
|
||||
}
|
||||
LinphoneCoreVTable *table = linphone_core_get_current_vtable(lc);
|
||||
LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_v_table_get_user_data(table);
|
||||
env->CallVoidMethod(lcData->listener
|
||||
,lcData->logCollectionUploadProgressId
|
||||
,lcData->core
|
||||
,(jlong)offset
|
||||
,(jlong)total);
|
||||
}
|
||||
static void logCollectionUploadStateChange(LinphoneCore *lc, LinphoneCoreLogCollectionUploadState state, const char *info) {
|
||||
JNIEnv *env = 0;
|
||||
jint result = jvm->AttachCurrentThread(&env,NULL);
|
||||
if (result != 0) {
|
||||
ms_error("cannot attach VM");
|
||||
return;
|
||||
}
|
||||
LinphoneCoreVTable *table = linphone_core_get_current_vtable(lc);
|
||||
LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_v_table_get_user_data(table);
|
||||
jstring msg = info ? env->NewStringUTF(info) : NULL;
|
||||
env->CallVoidMethod(lcData->listener
|
||||
,lcData->logCollectionUploadStateId
|
||||
,lcData->core
|
||||
,env->CallStaticObjectMethod(lcData->logCollectionUploadStateClass,lcData->logCollectionUploadStateFromIntId,(jint)state),
|
||||
msg);
|
||||
if (msg) {
|
||||
env->DeleteLocalRef(msg);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_newLinphoneCore(JNIEnv* env
|
||||
|
|
@ -1082,6 +1135,22 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeListener(JNIEnv* e
|
|||
env->DeleteGlobalRef(listener);
|
||||
}
|
||||
|
||||
|
||||
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_uploadLogCollection(JNIEnv* env, jobject thiz, jlong lc) {
|
||||
LinphoneCore *core = (LinphoneCore*)lc;
|
||||
linphone_core_upload_log_collection(core);
|
||||
}
|
||||
|
||||
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableLogCollection(JNIEnv* env, jclass cls, jboolean enable) {
|
||||
linphone_core_enable_log_collection(enable ? LinphoneLogCollectionEnabledWithoutPreviousLogHandler : LinphoneLogCollectionDisabled);
|
||||
}
|
||||
|
||||
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setLogCollectionPath(JNIEnv* env, jclass cls, jstring jpath) {
|
||||
const char* path = env->GetStringUTFChars(jpath, NULL);
|
||||
linphone_core_set_log_collection_path(path);
|
||||
env->ReleaseStringUTFChars(jpath, path);
|
||||
}
|
||||
|
||||
extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_migrateToMultiTransport(JNIEnv* env
|
||||
,jobject thiz
|
||||
,jlong lc) {
|
||||
|
|
|
|||
|
|
@ -430,6 +430,45 @@ public interface LinphoneCore {
|
|||
return mStringValue;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* linphone log collection upload states
|
||||
*/
|
||||
static public class LogCollectionUploadState {
|
||||
|
||||
static private Vector<LogCollectionUploadState> values = new Vector<LogCollectionUploadState>();
|
||||
/**
|
||||
* Delivery in progress
|
||||
*/
|
||||
static public LogCollectionUploadState LogCollectionUploadStateInProgress = new LogCollectionUploadState(0,"LinphoneCoreLogCollectionUploadStateInProgress");
|
||||
/**
|
||||
* Log collection upload successfully delivered and acknowledged by remote end point
|
||||
*/
|
||||
static public LogCollectionUploadState LogCollectionUploadStateDelivered = new LogCollectionUploadState(1,"LinphoneCoreLogCollectionUploadStateDelivered");
|
||||
/**
|
||||
* Log collection upload was not delivered
|
||||
*/
|
||||
static public LogCollectionUploadState LogCollectionUploadStateNotDelivered = new LogCollectionUploadState(2,"LinphoneCoreLogCollectionUploadStateNotDelivered");
|
||||
|
||||
private final int mValue;
|
||||
private final String mStringValue;
|
||||
|
||||
private LogCollectionUploadState(int value, String stringValue) {
|
||||
mValue = value;
|
||||
values.addElement(this);
|
||||
mStringValue=stringValue;
|
||||
}
|
||||
public static LogCollectionUploadState fromInt(int value) {
|
||||
|
||||
for (int i=0; i<values.size();i++) {
|
||||
LogCollectionUploadState state = (LogCollectionUploadState) values.elementAt(i);
|
||||
if (state.mValue == value) return state;
|
||||
}
|
||||
throw new RuntimeException("state not found ["+value+"]");
|
||||
}
|
||||
public String toString() {
|
||||
return mStringValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the context of creation of the LinphoneCore.
|
||||
|
|
@ -1808,9 +1847,17 @@ public interface LinphoneCore {
|
|||
public void setRemoteRingbackTone(String file);
|
||||
|
||||
/**
|
||||
* Return the ringback tone file used when doing early media. It may be null.
|
||||
* Return the ringback tone file used when doing early media. It may be
|
||||
|
||||
jclass logCollectionUploadStateClass;
|
||||
jmethodID logCollectionUploadStateId;
|
||||
jmethodID logCollectionUploadStateFromIntId; null.
|
||||
* @return the ringback tone file path.
|
||||
*/
|
||||
String getRemoteRingbackTone();
|
||||
|
||||
/**
|
||||
* Upload the log collection to the configured server url.
|
||||
*/
|
||||
public void uploadLogCollection();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ package org.linphone.core;
|
|||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.linphone.core.LinphoneCore.RemoteProvisioningState;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -31,7 +30,7 @@ public interface LinphoneCoreListener {
|
|||
public interface LinphoneListener extends LinphoneCoreListener,
|
||||
LinphoneRemoteProvisioningListener, LinphoneMessageListener, LinphoneCallStateListener,
|
||||
LinphoneCallEncryptionStateListener, LinphoneNotifyListener, LinphoneComposingListener,
|
||||
LinphoneGlobalStateListener, LinphoneRegistrationStateListener {
|
||||
LinphoneGlobalStateListener, LinphoneRegistrationStateListener, LinphoneLogCollectionUploadListener {
|
||||
/**< Ask the application some authentication information
|
||||
* @return */
|
||||
void authInfoRequested(LinphoneCore lc, String realm, String username, String Domain);
|
||||
|
|
@ -185,7 +184,7 @@ public interface LinphoneCoreListener {
|
|||
* @param state the RemoteProvisioningState
|
||||
* @param message the error message if state == Failed
|
||||
*/
|
||||
void configuringStatus(LinphoneCore lc, RemoteProvisioningState state, String message);
|
||||
void configuringStatus(LinphoneCore lc, LinphoneCore.RemoteProvisioningState state, String message);
|
||||
}
|
||||
|
||||
public interface LinphoneMessageListener extends LinphoneCoreListener {
|
||||
|
|
@ -243,7 +242,22 @@ public interface LinphoneCoreListener {
|
|||
* @param delay_ms echo delay
|
||||
* @param data
|
||||
*/
|
||||
void ecCalibrationStatus(LinphoneCore lc,LinphoneCore.EcCalibratorStatus status, int delay_ms, Object data);
|
||||
void ecCalibrationStatus(LinphoneCore lc, LinphoneCore.EcCalibratorStatus status, int delay_ms, Object data);
|
||||
}
|
||||
|
||||
public interface LinphoneLogCollectionUploadListener extends LinphoneCoreListener {
|
||||
/**
|
||||
* Callback prototype for reporting log collection upload progress indication.
|
||||
*/
|
||||
void uploadProgressIndication(LinphoneCore lc, int offset, int total);
|
||||
|
||||
/**
|
||||
* Callback prototype for reporting log collection upload state change.
|
||||
* @param lc LinphoneCore object
|
||||
* @param state The state of the log collection upload
|
||||
* @param info Additional information: error message in case of error state, URL of uploaded file in case of success.
|
||||
*/
|
||||
void uploadStateChanged(LinphoneCore lc, LinphoneCore.LogCollectionUploadState state, String info);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -173,5 +173,4 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory {
|
|||
public PresenceModel createPresenceModel(PresenceActivityType type, String description, String note, String lang) {
|
||||
return new PresenceModelImpl(type, description, note, lang);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,8 +32,7 @@ import org.linphone.mediastream.video.capture.hwconf.Hacks;
|
|||
import android.content.Context;
|
||||
import android.media.AudioManager;
|
||||
|
||||
|
||||
class LinphoneCoreImpl implements LinphoneCore {
|
||||
public class LinphoneCoreImpl implements LinphoneCore {
|
||||
|
||||
private final LinphoneCoreListener mListener; //to make sure to keep a reference on this object
|
||||
protected long nativePtr = 0;
|
||||
|
|
@ -1314,4 +1313,21 @@ class LinphoneCoreImpl implements LinphoneCore {
|
|||
public String getRemoteRingbackTone() {
|
||||
return getRemoteRingbackTone(nativePtr);
|
||||
}
|
||||
|
||||
private native void uploadLogCollection(long nativePtr);
|
||||
@Override
|
||||
public void uploadLogCollection() {
|
||||
uploadLogCollection(nativePtr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable the linphone core log collection to upload logs on a server.
|
||||
*/
|
||||
public native static void enableLogCollection(boolean enable);
|
||||
|
||||
/**
|
||||
* Set the path where the log files will be written for log collection.
|
||||
* @param path The path where the log files will be written.
|
||||
*/
|
||||
public native static void setLogCollectionPath(String path);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue