[DEV] multiple instance work on android
This commit is contained in:
parent
547c9c4d65
commit
be8264edf9
@ -15,36 +15,21 @@ import android.service.wallpaper.WallpaperService.Engine;
|
||||
import android.util.Log;
|
||||
|
||||
public class Ewol {
|
||||
private static int counterInstance = -1; // Global instance increment at eveny new instance
|
||||
private int instanceID = -1; // local and private instance ID
|
||||
|
||||
/* Default constructor (why not ?)*/
|
||||
public Ewol()
|
||||
public <T extends EwolCallback> Ewol(T activityInstance, int typeApplication)
|
||||
{
|
||||
// TODO : Set an unique intance ID
|
||||
counterInstance ++;
|
||||
instanceID = counterInstance;
|
||||
Log.d("Ewol", "new " + counterInstance + " : " + instanceID);
|
||||
instanceID = -1;
|
||||
instanceID = EWsetJavaVirtualMachineStart(activityInstance, typeApplication);
|
||||
Log.d("Ewol", "new : " + instanceID);
|
||||
}
|
||||
// internal Acces not at the native function ...
|
||||
|
||||
public <T extends Activity & EwolCallback> void setJavaVirtualMachineStart(T activityInstance)
|
||||
{
|
||||
// TODO : Get the instance ID here ...
|
||||
EWsetJavaVirtualMachineStart(activityInstance);
|
||||
}
|
||||
public <T extends WallpaperService & EwolCallback> void setJavaVirtualMachineStartWallpaperEngine(T serviceInstance)
|
||||
{
|
||||
// TODO : Get the instance ID here ...
|
||||
EWsetJavaVirtualMachineStartWallpaperEngine(serviceInstance);
|
||||
}
|
||||
public void setJavaVirtualMachineStop()
|
||||
{
|
||||
EWsetJavaVirtualMachineStop(instanceID);
|
||||
}
|
||||
public void paramSetArchiveDir(int mode, String myString)
|
||||
{
|
||||
Log.d("Ewol", "call : " + instanceID);
|
||||
EWparamSetArchiveDir(instanceID, mode, myString);
|
||||
}
|
||||
|
||||
@ -59,36 +44,30 @@ public class Ewol {
|
||||
// set display properties :
|
||||
public void displayPropertyMetrics(float ratioX, float ratioY)
|
||||
{
|
||||
Log.d("Ewol", "call : " + instanceID);
|
||||
EWdisplayPropertyMetrics(instanceID, ratioX, ratioY);
|
||||
}
|
||||
// IO native function :
|
||||
// Specific for the type of input : TOOL_TYPE_FINGER and TOOL_TYPE_STYLUS (work as the same)
|
||||
public void inputEventMotion(int pointerID, float x, float y)
|
||||
{
|
||||
Log.d("Ewol", "call : " + instanceID);
|
||||
EWinputEventMotion(instanceID, pointerID, x, y);
|
||||
}
|
||||
public void inputEventState(int pointerID, boolean isDown, float x, float y)
|
||||
{
|
||||
Log.d("Ewol", "call : " + instanceID);
|
||||
EWinputEventState(instanceID, pointerID, isDown, x, y);
|
||||
}
|
||||
// Specific for the type of input : TOOL_TYPE_MOUSE
|
||||
public void mouseEventMotion(int pointerID, float x, float y)
|
||||
{
|
||||
Log.d("Ewol", "call : " + instanceID);
|
||||
EWmouseEventMotion(instanceID, pointerID, x, y);
|
||||
}
|
||||
public void mouseEventState(int pointerID, boolean isDown, float x, float y)
|
||||
{
|
||||
Log.d("Ewol", "call : " + instanceID);
|
||||
EWmouseEventState(instanceID, pointerID, isDown, x, y);
|
||||
}
|
||||
// other unknow event ...
|
||||
public void unknowEvent(int eventID)
|
||||
{
|
||||
Log.d("Ewol", "call : " + instanceID);
|
||||
EWunknowEvent(instanceID, eventID);
|
||||
}
|
||||
|
||||
@ -114,23 +93,19 @@ public class Ewol {
|
||||
// renderer Event :
|
||||
public void renderInit()
|
||||
{
|
||||
Log.d("Ewol", "call : " + instanceID);
|
||||
EWrenderInit(instanceID);
|
||||
}
|
||||
public void renderResize(int w, int h)
|
||||
{
|
||||
Log.d("Ewol", "call : " + instanceID);
|
||||
EWrenderResize(instanceID, w, h);
|
||||
}
|
||||
public void renderDraw()
|
||||
{
|
||||
Log.d("Ewol", "call : " + instanceID);
|
||||
EWrenderDraw(instanceID);
|
||||
}
|
||||
|
||||
|
||||
private native <T extends Activity & EwolCallback> void EWsetJavaVirtualMachineStart(T activityInstance);
|
||||
private native <T extends WallpaperService & EwolCallback> void EWsetJavaVirtualMachineStartWallpaperEngine(T serviceInstance);
|
||||
private native <T extends EwolCallback> int EWsetJavaVirtualMachineStart(T activityInstance, int typeApplication);
|
||||
private native void EWsetJavaVirtualMachineStop(int instanceId);
|
||||
private native void EWparamSetArchiveDir(int instanceId, int mode, String myString);
|
||||
|
||||
|
@ -56,9 +56,8 @@ public abstract class EwolActivity extends Activity implements EwolCallback, Ewo
|
||||
}
|
||||
public EwolActivity()
|
||||
{
|
||||
EWOL = new Ewol();
|
||||
// set the java evironement in the C sources :
|
||||
EWOL.setJavaVirtualMachineStart(this);
|
||||
EWOL = new Ewol(this, EWOL_APPL_TYPE_ACTIVITY);
|
||||
}
|
||||
|
||||
protected void initApkPath(String org, String vendor, String project) {
|
||||
@ -218,6 +217,12 @@ public abstract class EwolActivity extends Activity implements EwolCallback, Ewo
|
||||
{
|
||||
setTitle(value);
|
||||
}
|
||||
|
||||
public void stop()
|
||||
{
|
||||
// end application is requested ...
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,64 +22,70 @@ import org.ewol.Ewol;
|
||||
|
||||
public class EwolAudioTask implements Runnable, EwolConstants
|
||||
{
|
||||
public static final int SAMPLE_FREQ_44100 = 44100;
|
||||
private boolean m_stopAudioThreads = false;
|
||||
private AudioTrack m_musicTrack = null;
|
||||
public static final int SAMPLE_FREQ_44100 = 44100;
|
||||
private boolean m_stopAudioThreads = false;
|
||||
private AudioTrack m_musicTrack = null;
|
||||
private Ewol EWOL;
|
||||
|
||||
|
||||
// constructor :
|
||||
public EwolAudioTask(Ewol ewolInstance)
|
||||
{
|
||||
EWOL = ewolInstance;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
if(m_musicTrack != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
if(m_musicTrack != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int sampleFreq = SAMPLE_FREQ_44100; //AudioTrack.getNativeOutputSampleRate(AudioManager.STREAM_MUSIC);
|
||||
int channelConfig = AudioFormat.CHANNEL_CONFIGURATION_STEREO;
|
||||
int audioFormat = AudioFormat.ENCODING_PCM_16BIT;
|
||||
int nbChannels = 2;
|
||||
// we keep the minimum buffer size, otherwite the delay is too big ...
|
||||
int bufferSize = AudioTrack.getMinBufferSize(sampleFreq, channelConfig, audioFormat);
|
||||
// Create a streaming AudioTrack for music playback
|
||||
short[] streamBuffer = new short[bufferSize];
|
||||
m_musicTrack = new AudioTrack(AudioManager.STREAM_MUSIC,
|
||||
SAMPLE_FREQ_44100,
|
||||
AudioFormat.CHANNEL_CONFIGURATION_STEREO,
|
||||
AudioFormat.ENCODING_PCM_16BIT,
|
||||
bufferSize,
|
||||
AudioTrack.MODE_STREAM);
|
||||
m_musicTrack.play();
|
||||
//m_musicTrack.setPositionNotificationPeriod(2048);
|
||||
int sampleFreq = SAMPLE_FREQ_44100; //AudioTrack.getNativeOutputSampleRate(AudioManager.STREAM_MUSIC);
|
||||
int channelConfig = AudioFormat.CHANNEL_CONFIGURATION_STEREO;
|
||||
int audioFormat = AudioFormat.ENCODING_PCM_16BIT;
|
||||
int nbChannels = 2;
|
||||
// we keep the minimum buffer size, otherwite the delay is too big ...
|
||||
int bufferSize = AudioTrack.getMinBufferSize(sampleFreq, channelConfig, audioFormat);
|
||||
// Create a streaming AudioTrack for music playback
|
||||
short[] streamBuffer = new short[bufferSize];
|
||||
m_musicTrack = new AudioTrack(AudioManager.STREAM_MUSIC,
|
||||
SAMPLE_FREQ_44100,
|
||||
AudioFormat.CHANNEL_CONFIGURATION_STEREO,
|
||||
AudioFormat.ENCODING_PCM_16BIT,
|
||||
bufferSize,
|
||||
AudioTrack.MODE_STREAM);
|
||||
m_musicTrack.play();
|
||||
//m_musicTrack.setPositionNotificationPeriod(2048);
|
||||
|
||||
while (!m_stopAudioThreads) {
|
||||
// Fill buffer with PCM data from C++
|
||||
EWOL.audioPlayback(streamBuffer, NATIVE_AUDIO_BUFFER_SIZE, nbChannels);
|
||||
while (!m_stopAudioThreads) {
|
||||
// Fill buffer with PCM data from C++
|
||||
EWOL.audioPlayback(streamBuffer, NATIVE_AUDIO_BUFFER_SIZE, nbChannels);
|
||||
|
||||
// Stream PCM data into the music AudioTrack
|
||||
m_musicTrack.write(streamBuffer, 0, NATIVE_AUDIO_BUFFER_SIZE);
|
||||
}
|
||||
// Stream PCM data into the music AudioTrack
|
||||
m_musicTrack.write(streamBuffer, 0, NATIVE_AUDIO_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
m_musicTrack.flush();
|
||||
m_musicTrack.stop();
|
||||
}
|
||||
public void Pause()
|
||||
{
|
||||
if(m_musicTrack == null) return;
|
||||
m_musicTrack.pause();
|
||||
}
|
||||
public void Resume()
|
||||
{
|
||||
if(m_musicTrack == null) return;
|
||||
m_musicTrack.play();
|
||||
}
|
||||
public void AutoStop()
|
||||
{
|
||||
if(m_musicTrack == null) return;
|
||||
m_stopAudioThreads=true;
|
||||
m_musicTrack.flush();
|
||||
m_musicTrack.stop();
|
||||
}
|
||||
public void Pause()
|
||||
{
|
||||
if(m_musicTrack == null) {
|
||||
return;
|
||||
}
|
||||
m_musicTrack.pause();
|
||||
}
|
||||
public void Resume()
|
||||
{
|
||||
if(m_musicTrack == null) {
|
||||
return;
|
||||
}
|
||||
m_musicTrack.play();
|
||||
}
|
||||
public void AutoStop()
|
||||
{
|
||||
if(m_musicTrack == null) {
|
||||
return;
|
||||
}
|
||||
m_stopAudioThreads=true;
|
||||
}
|
||||
}/* no ; here !!! */
|
||||
|
@ -7,12 +7,13 @@
|
||||
*/
|
||||
|
||||
package org.ewol;
|
||||
import android.util.Log;
|
||||
|
||||
public interface EwolCallback {
|
||||
|
||||
public void keyboardUpdate(boolean show);
|
||||
public void eventNotifier(String[] args);
|
||||
public void orientationUpdate(int screenMode);
|
||||
public void titleSet(String value);
|
||||
|
||||
public interface EwolCallback
|
||||
{
|
||||
public void keyboardUpdate(boolean show);
|
||||
public void eventNotifier(String[] args);
|
||||
public void orientationUpdate(int screenMode);
|
||||
public void titleSet(String value);
|
||||
public void stop();
|
||||
}
|
||||
|
@ -23,4 +23,8 @@ public interface EwolConstants {
|
||||
public static final int EWOL_ORIENTATION_AUTO = 0;
|
||||
public static final int EWOL_ORIENTATION_LANDSCAPE = 1;
|
||||
public static final int EWOL_ORIENTATION_PORTRAIT = 2;
|
||||
|
||||
|
||||
public static final int EWOL_APPL_TYPE_ACTIVITY = 0;
|
||||
public static final int EWOL_APPL_TYPE_WALLPAPER = 1;
|
||||
}
|
||||
|
@ -50,11 +50,10 @@ public abstract class EwolWallpaper extends WallpaperService implements EwolCall
|
||||
EWOL.paramSetArchiveDir(0, apkFilePath);
|
||||
}
|
||||
|
||||
@Override public Engine onCreateEngine() {
|
||||
|
||||
EWOL = new Ewol();
|
||||
@Override public Engine onCreateEngine()
|
||||
{
|
||||
// set the java evironement in the C sources :
|
||||
EWOL.setJavaVirtualMachineStartWallpaperEngine(this);
|
||||
EWOL = new Ewol(this, EWOL_APPL_TYPE_WALLPAPER);
|
||||
|
||||
// Load the application directory
|
||||
EWOL.paramSetArchiveDir(1, getFilesDir().toString());
|
||||
@ -184,21 +183,28 @@ public abstract class EwolWallpaper extends WallpaperService implements EwolCall
|
||||
public void keyboardUpdate(boolean show)
|
||||
{
|
||||
// never display keyboard on wallpaer...
|
||||
Log.d("EwolCallback", "KEABOARD UPDATE is not implemented ...");
|
||||
}
|
||||
|
||||
public void eventNotifier(String[] args)
|
||||
{
|
||||
// just for the test ...
|
||||
Log.d("EwolCallback", "EVENT NOTIFIER is not implemented ...");
|
||||
|
||||
}
|
||||
|
||||
public void orientationUpdate(int screenMode)
|
||||
{
|
||||
|
||||
Log.d("EwolCallback", "SET ORIENTATION is not implemented ...");
|
||||
}
|
||||
|
||||
public void titleSet(String value)
|
||||
{
|
||||
// no title in the wallpaper ...
|
||||
Log.d("EwolCallback", "SET TITLE is not implemented ...");
|
||||
}
|
||||
public void Stop()
|
||||
{
|
||||
Log.d("EwolCallback", "STOP is not implemented ...");
|
||||
};
|
||||
}
|
||||
|
@ -55,7 +55,8 @@ class AndroidContext : public ewol::eContext
|
||||
JNIEnv* m_JavaVirtualMachinePointer; //!< the JVM
|
||||
jclass m_javaClassEwol; //!< main activity class (android ...)
|
||||
jclass m_javaClassEwolCallback;
|
||||
jobject m_javaObjectEwolCallbackAndActivity;
|
||||
jobject m_javaObjectEwolCallback;
|
||||
jmethodID m_javaMethodEwolCallbackStop; //!< Stop function identifier
|
||||
jmethodID m_javaMethodEwolCallbackEventNotifier; //!< basic methode to call ...
|
||||
jmethodID m_javaMethodEwolCallbackKeyboardUpdate; //!< basic methode to call ...
|
||||
jmethodID m_javaMethodEwolCallbackOrientationUpdate;
|
||||
@ -82,7 +83,8 @@ class AndroidContext : public ewol::eContext
|
||||
m_JavaVirtualMachinePointer(NULL),
|
||||
m_javaClassEwol(0),
|
||||
m_javaClassEwolCallback(0),
|
||||
m_javaObjectEwolCallbackAndActivity(0),
|
||||
m_javaObjectEwolCallback(0),
|
||||
m_javaMethodEwolCallbackStop(0),
|
||||
m_javaMethodEwolCallbackEventNotifier(0),
|
||||
m_javaMethodEwolCallbackKeyboardUpdate(0),
|
||||
m_javaMethodEwolCallbackOrientationUpdate(0),
|
||||
@ -126,6 +128,14 @@ class AndroidContext : public ewol::eContext
|
||||
java_check_exception(_env);
|
||||
return;
|
||||
}
|
||||
ret=SafeInitMethodID(m_javaMethodEwolCallbackStop,
|
||||
m_javaClassEwolCallback,
|
||||
"stop",
|
||||
"()V");
|
||||
if (ret==false) {
|
||||
java_check_exception(_env);
|
||||
return;
|
||||
}
|
||||
|
||||
ret=SafeInitMethodID(m_javaMethodEwolCallbackEventNotifier,
|
||||
m_javaClassEwolCallback,
|
||||
@ -154,7 +164,7 @@ class AndroidContext : public ewol::eContext
|
||||
return;
|
||||
}
|
||||
|
||||
m_javaObjectEwolCallbackAndActivity = _env->NewGlobalRef(_objCallback);
|
||||
m_javaObjectEwolCallback = _env->NewGlobalRef(_objCallback);
|
||||
//javaObjectEwolCallbackAndActivity = objCallback;
|
||||
|
||||
m_javaDefaultClassString = m_JavaVirtualMachinePointer->FindClass("java/lang/String" );
|
||||
@ -174,8 +184,8 @@ class AndroidContext : public ewol::eContext
|
||||
|
||||
void UnInit(JNIEnv* _env)
|
||||
{
|
||||
_env->DeleteGlobalRef(m_javaObjectEwolCallbackAndActivity);
|
||||
m_javaObjectEwolCallbackAndActivity = NULL;
|
||||
_env->DeleteGlobalRef(m_javaObjectEwolCallback);
|
||||
m_javaObjectEwolCallback = NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -187,7 +197,16 @@ class AndroidContext : public ewol::eContext
|
||||
|
||||
void Stop(void)
|
||||
{
|
||||
// TODO : send a message to the android system to stop ...
|
||||
EWOL_DEBUG("C->java : send message to the java : STOP REQUESTED");
|
||||
int status;
|
||||
if(!java_attach_current_thread(&status)) {
|
||||
return;
|
||||
}
|
||||
//Call java ...
|
||||
m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectEwolCallback, m_javaMethodEwolCallbackStop);
|
||||
// manage execption :
|
||||
java_check_exception(m_JavaVirtualMachinePointer);
|
||||
java_detach_current_thread(status);
|
||||
}
|
||||
|
||||
void ClipBoardGet(ewol::clipBoard::clipboardListe_te _clipboardID)
|
||||
@ -278,7 +297,7 @@ class AndroidContext : public ewol::eContext
|
||||
}
|
||||
|
||||
//Call java ...
|
||||
m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectEwolCallbackAndActivity, m_javaMethodEwolCallbackKeyboardUpdate, _showIt);
|
||||
m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectEwolCallback, m_javaMethodEwolCallbackKeyboardUpdate, _showIt);
|
||||
// manage execption :
|
||||
java_check_exception(m_JavaVirtualMachinePointer);
|
||||
java_detach_current_thread(status);
|
||||
@ -300,7 +319,7 @@ class AndroidContext : public ewol::eContext
|
||||
jint param = (jint)_orientation;
|
||||
|
||||
//Call java ...
|
||||
m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectEwolCallbackAndActivity, m_javaMethodEwolCallbackOrientationUpdate, param);
|
||||
m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectEwolCallback, m_javaMethodEwolCallbackOrientationUpdate, param);
|
||||
|
||||
// manage execption :
|
||||
java_check_exception(m_JavaVirtualMachinePointer);
|
||||
@ -319,7 +338,7 @@ class AndroidContext : public ewol::eContext
|
||||
etk::Char tmpChar = _title.c_str();
|
||||
//Call java ...
|
||||
jstring title = m_JavaVirtualMachinePointer->NewStringUTF(tmpChar);
|
||||
m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectEwolCallbackAndActivity, m_javaMethodEwolActivitySetTitle, title);
|
||||
m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectEwolCallback, m_javaMethodEwolActivitySetTitle, title);
|
||||
m_JavaVirtualMachinePointer->DeleteLocalRef(title);
|
||||
// manage execption :
|
||||
java_check_exception(m_JavaVirtualMachinePointer);
|
||||
@ -359,7 +378,7 @@ class AndroidContext : public ewol::eContext
|
||||
}
|
||||
EWOL_DEBUG("C->java : 555");
|
||||
//Call java ...
|
||||
m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectEwolCallbackAndActivity, m_javaMethodEwolCallbackEventNotifier, args);
|
||||
m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectEwolCallback, m_javaMethodEwolCallbackEventNotifier, args);
|
||||
|
||||
EWOL_DEBUG("C->java : 666");
|
||||
java_check_exception(m_JavaVirtualMachinePointer);
|
||||
@ -416,7 +435,7 @@ extern "C"
|
||||
}
|
||||
|
||||
/* Call to initialize the graphics state */
|
||||
void Java_org_ewol_Ewol_EWparamSetArchiveDir(JNIEnv* _env, jclass _cls, jint _mode, jstring _myString, jint _id)
|
||||
void Java_org_ewol_Ewol_EWparamSetArchiveDir(JNIEnv* _env, jclass _cls, jint _id, jint _mode, jstring _myString)
|
||||
{
|
||||
if( _id>=s_listInstance.Size()
|
||||
|| _id<0
|
||||
@ -425,6 +444,7 @@ extern "C"
|
||||
// TODO : Generate error in java to stop the current instance
|
||||
return;
|
||||
}
|
||||
//EWOL_CRITICAL(" call with ID : " << _id);
|
||||
// direct setting of the date in the string system ...
|
||||
jboolean isCopy;
|
||||
const char* str = _env->GetStringUTFChars(_myString, &isCopy);
|
||||
@ -436,63 +456,42 @@ extern "C"
|
||||
}
|
||||
}
|
||||
|
||||
// TODO : Return the local ID ...
|
||||
void Java_org_ewol_Ewol_EWsetJavaVirtualMachineStart(JNIEnv* _env, jclass _classBase, jobject _objCallback)
|
||||
jint Java_org_ewol_Ewol_EWsetJavaVirtualMachineStart(JNIEnv* _env, jclass _classBase, jobject _objCallback, int _typeApplication)
|
||||
{
|
||||
EWOL_DEBUG("*******************************************");
|
||||
EWOL_DEBUG("** Creating EWOL context **");
|
||||
EWOL_DEBUG("*******************************************");
|
||||
AndroidContext* tmpContext = new AndroidContext(_env, _classBase, _objCallback, AndroidContext::appl_application);
|
||||
AndroidContext* tmpContext = NULL;
|
||||
if (org_ewol_EwolConstants_EWOL_APPL_TYPE_ACTIVITY == _typeApplication) {
|
||||
tmpContext = new AndroidContext(_env, _classBase, _objCallback, AndroidContext::appl_application);
|
||||
} else if (org_ewol_EwolConstants_EWOL_APPL_TYPE_WALLPAPER == _typeApplication) {
|
||||
tmpContext = new AndroidContext(_env, _classBase, _objCallback, AndroidContext::appl_wallpaper);
|
||||
} else {
|
||||
EWOL_CRITICAL(" try to create an instance with no apply type: " << _typeApplication);
|
||||
return -1;
|
||||
}
|
||||
if (NULL == tmpContext) {
|
||||
EWOL_ERROR("Can not allocate the main context instance _id=" << (s_listInstance.Size()-1));
|
||||
// TODO : return -1;
|
||||
}
|
||||
// TODO : Change this ==> this generate the new ID ...
|
||||
if (s_listInstance.Size()>0) {
|
||||
// note : For now : memory leek and errors ...
|
||||
s_listInstance[0] = tmpContext;
|
||||
} else {
|
||||
// for future case : all time this ...
|
||||
s_listInstance.PushBack(tmpContext);
|
||||
// esize_t newID = s_listInstance.Size()-1;
|
||||
// return newID;
|
||||
return -1;
|
||||
}
|
||||
// for future case : all time this ...
|
||||
s_listInstance.PushBack(tmpContext);
|
||||
int32_t newID = s_listInstance.Size()-1;
|
||||
return newID;
|
||||
}
|
||||
|
||||
// TODO : Return the local ID ...
|
||||
void Java_org_ewol_Ewol_EWsetJavaVirtualMachineStartWallpaperEngine(JNIEnv* _env, jclass _classBase, jobject _objCallback)
|
||||
{
|
||||
EWOL_DEBUG("*******************************************");
|
||||
EWOL_DEBUG("** Creating EWOL context **");
|
||||
EWOL_DEBUG("*******************************************");
|
||||
AndroidContext* tmpContext = new AndroidContext(_env, _classBase, _objCallback, AndroidContext::appl_wallpaper);
|
||||
if (NULL == tmpContext) {
|
||||
EWOL_ERROR("Can not allocate the main context instance _id=" << (s_listInstance.Size()-1));
|
||||
// TODO : return -1;
|
||||
}
|
||||
// TODO : Change this ==> this generate the new ID ...
|
||||
if (s_listInstance.Size()>0) {
|
||||
// note : For now : memory leek and errors ...
|
||||
s_listInstance[0] = tmpContext;
|
||||
} else {
|
||||
// for future case : all time this ...
|
||||
s_listInstance.PushBack(tmpContext);
|
||||
// esize_t newID = s_listInstance.Size()-1;
|
||||
// return newID;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Java_org_ewol_Ewol_EWsetJavaVirtualMachineStop(JNIEnv* _env, jclass _cls, jint _id)
|
||||
{
|
||||
EWOL_DEBUG("*******************************************");
|
||||
EWOL_DEBUG("** Remove JVM Pointer **");
|
||||
EWOL_DEBUG("*******************************************");
|
||||
if( _id>=s_listInstance.Size()
|
||||
|| _id<0
|
||||
|| NULL==s_listInstance[_id] ) {
|
||||
|| _id<0) {
|
||||
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
|
||||
// TODO : Generate error in java to stop the current instance
|
||||
return;
|
||||
}
|
||||
if (NULL==s_listInstance[_id]) {
|
||||
EWOL_ERROR("the requested instance _id=" << (int32_t)_id << " is already removed ...");
|
||||
return;
|
||||
}
|
||||
s_listInstance[_id]->UnInit(_env);
|
||||
|
Loading…
x
Reference in New Issue
Block a user