#14917: example JNI functions with callback
#14650: change android configdir
#14741: function to get env variable
#14399: add debug in SIP
#14881: Playback fully implemented, fixed buffer size, add dump to disk
#14881: Fix audio thread for OpenSL
#14881: Add index increment
Merge branch 'master' of git+ssh://git.sflphone.org/var/repos/sflphone/git/sflphone into android
Merge branch 'master' of git+ssh://git.sflphone.org/var/repos/sflphone/git/sflphone into android
#14881: Put buffers in OpenSL playback queue only if filled
Merge branch 'master' of git+ssh://git.sflphone.org/var/repos/sflphone/git/sflphone into android
Merge branch 'master' of git+ssh://git.sflphone.org/var/repos/sflphone/git/sflphone into android
Merge branch 'master' of git+ssh://git.sflphone.org/var/repos/sflphone/git/sflphone into android
Merge branch 'master' of git+ssh://git.sflphone.org/var/repos/sflphone/git/sflphone into android
#14371: Update settings for playback buffers
#14371: Remove update OpenSL mixer settings
Merge branch 'master' of git+ssh://git.sflphone.org/var/repos/sflphone/git/sflphone into android
diff --git a/jni/sflphone b/jni/sflphone
index 74fd123..68ff480 160000
--- a/jni/sflphone
+++ b/jni/sflphone
@@ -1 +1 @@
-Subproject commit 74fd123135921fb6b2727c7a3cb064a73783dde5
+Subproject commit 68ff480db511284bfd33e55071b2d7f78590a1f2
diff --git a/res/layout/test_layout.xml b/res/layout/test_layout.xml
index 96a7328..6df0a81 100644
--- a/res/layout/test_layout.xml
+++ b/res/layout/test_layout.xml
@@ -61,4 +61,51 @@
         android:onClick="onClick"
         android:text="test1" />
 
+    <TextView
+        android:id="@+id/callVoid_text"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_below="@+id/buttonTest1"
+        android:text="callVoidText" />
+    
+    <Button
+        android:id="@+id/buttonCallVoid"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_below="@+id/callVoid_text"
+        android:onClick="onClick"
+        android:text="CallVoid" />
+
+    <TextView
+        android:id="@+id/NewData_text"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_below="@+id/buttonCallVoid"
+        android:layout_centerHorizontal="true"
+        android:text="getNewDataText" />
+    
+    <Button
+        android:id="@+id/buttonGetNewData"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_below="@+id/NewData_text"
+        android:onClick="onClick"
+        android:text="GetNewData" />
+
+    <TextView
+        android:id="@+id/DataString_text"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_below="@+id/buttonGetNewData"
+        android:layout_centerHorizontal="true"
+        android:text="callbackString" />
+  
+    <Button
+        android:id="@+id/buttonGetDataString"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_below="@+id/DataString_text"
+        android:onClick="onClick"
+        android:text="GetDataString" />
+
 </RelativeLayout>
\ No newline at end of file
diff --git a/src/com/savoirfairelinux/sflphone/client/ButtonSectionFragment.java b/src/com/savoirfairelinux/sflphone/client/ButtonSectionFragment.java
new file mode 100644
index 0000000..faa03cd
--- /dev/null
+++ b/src/com/savoirfairelinux/sflphone/client/ButtonSectionFragment.java
@@ -0,0 +1,85 @@
+package com.savoirfairelinux.sflphone.client;
+
+import android.app.Fragment;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+import android.view.InflateException;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.TextView;
+
+import com.savoirfairelinux.sflphone.R;
+
+public class ButtonSectionFragment extends Fragment
+{
+		//private SFLPhoneHome myButtonSectionFragment;
+		static final String TAG = "ButtonSectionFragment";
+		public TextView callVoidText, NewDataText, DataStringText;
+		Button buttonCallVoid, buttonGetNewData, buttonGetDataString;
+		Handler callbackHandler;
+		ManagerImpl managerImpl;
+
+		public ButtonSectionFragment()
+		{
+			setRetainInstance(true);
+		}
+		
+		public TextView getcallVoidText() {
+			return callVoidText;
+		}
+		
+		public TextView getNewDataText() {
+			return NewDataText;
+		}
+		
+		public TextView getDataStringText() {
+			return DataStringText;
+		}
+		
+//		public ButtonSectionFragment(SFLPhoneHome sflPhoneHome)
+//		{
+//			myButtonSectionFragment = sflPhoneHome;
+//			setRetainInstance(true);
+//		}
+
+		public static final String ARG_SECTION_NUMBER = "section_number";
+
+		@Override
+		public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState)
+		{
+			View view;
+			
+			Log.i(TAG, "onCreateView" );
+			view = inflater.inflate(R.layout.test_layout, parent, false);
+
+			callVoidText = (TextView) view.findViewById(R.id.callVoid_text);
+			if (callVoidText == null)
+				Log.e(TAG, "callVoidText is " + callVoidText);
+			callbackHandler = new Handler() {
+				public void handlerMessage(Message msg) {
+					Bundle b = msg.getData();
+					callVoidText.setText(b.getString("callback_string"));
+					Log.i(TAG, "handlerMessage: " + b.getString("callback_string"));
+				}
+			};
+			managerImpl = new ManagerImpl(callbackHandler);
+			
+		    NewDataText = (TextView) view.findViewById(R.id.NewData_text);  
+		    buttonGetNewData = (Button) view.findViewById(R.id.buttonGetNewData);
+
+		    DataStringText = (TextView) view.findViewById(R.id.DataString_text);
+		    buttonGetDataString = (Button) view.findViewById(R.id.buttonGetDataString);
+			
+		    try {
+				inflater.inflate(R.layout.test_layout, parent, false);
+			} catch (InflateException e) {
+				Log.e(TAG, "Error inflating test_layout ", e);
+				return null;
+			}
+			return view;
+		}
+}
\ No newline at end of file
diff --git a/src/com/savoirfairelinux/sflphone/client/Data.java b/src/com/savoirfairelinux/sflphone/client/Data.java
new file mode 100644
index 0000000..27e5654
--- /dev/null
+++ b/src/com/savoirfairelinux/sflphone/client/Data.java
@@ -0,0 +1,13 @@
+package com.savoirfairelinux.sflphone.client;
+
+public class Data {
+	public int i;
+	public String s;
+	
+	public Data() {}
+	
+	public Data(int i, String s) {
+		this.i = i;
+		this.s = s;
+	}
+}
diff --git a/src/com/savoirfairelinux/sflphone/client/ManagerImpl.java b/src/com/savoirfairelinux/sflphone/client/ManagerImpl.java
index fe9f178..901fe97 100644
--- a/src/com/savoirfairelinux/sflphone/client/ManagerImpl.java
+++ b/src/com/savoirfairelinux/sflphone/client/ManagerImpl.java
@@ -1,54 +1,48 @@
 package com.savoirfairelinux.sflphone.client;
 
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
+import android.os.Handler;
+import android.os.Bundle;
+import android.os.Message;
 import android.util.Log;
 
 public class ManagerImpl {
 	
 	private static final String TAG = "ManagerImpl";
 	private static String sipLogLevel;
+	static Handler h; 
+	
+	public ManagerImpl () {}
+	
+	public ManagerImpl(Handler h) {
+		this.h = h;
+	}
+	
+	public static void callBack(String s) {
+		Bundle b = new Bundle();
+		Log.i(TAG, "callBack: " + s);
+		b.putString("callback_string", s);
+		Message m = Message.obtain();
+		m.setData(b);
+		m.setTarget(h);
+		m.sendToTarget();
+	}
 
 	public static boolean outgoingCallJ(String account_id) {
 		Log.i(TAG, "account_id:" + account_id);
 		return true;
 	}
-	
-	/* native implementation */
-	static {
-		System.setProperty("SIPLOGLEVEL", "4");
-		sipLogLevel = System.getProperty("SIPLOGLEVEL");
-		Log.i(TAG, "SIPLOGLEVEL: " + sipLogLevel);
-
-		// FIXME
-		System.loadLibrary("gnustl_shared");
-		System.loadLibrary("expat");
-		System.loadLibrary("yaml");
-		System.loadLibrary("ccgnu2");
-		System.loadLibrary("crypto");
-		System.loadLibrary("ssl");
-		System.loadLibrary("ccrtp1");
-		System.loadLibrary("dbus");
-		System.loadLibrary("dbus-c++-1");
-		System.loadLibrary("samplerate");
-		System.loadLibrary("codec_ulaw");
-		System.loadLibrary("codec_alaw");
-		System.loadLibrary("speexresampler");
-		System.loadLibrary("sflphone");
-	}
 
 	public String getSipLogLevel() {
 		return sipLogLevel;
 	}
 
-	//public static native JNI_OnLoad(JavaVM* vm, void* reserved);
-
+	public static native void callVoid();
+	public static native Data getNewData(int i, String s);
+	public static native String getDataString(Data d);
+	public static native String getDataString2();
+	
 	public static native void setSipLogLevel(String level);
-
     public static native String getJniString();
-	
 	public static native boolean outgoingCallN(String account_id);
-	
 	public static native void initN(String config_file);
 }
diff --git a/src/com/savoirfairelinux/sflphone/client/SFLPhoneHome.java b/src/com/savoirfairelinux/sflphone/client/SFLPhoneHome.java
index 7fa5ec9..bcb04da 100644
--- a/src/com/savoirfairelinux/sflphone/client/SFLPhoneHome.java
+++ b/src/com/savoirfairelinux/sflphone/client/SFLPhoneHome.java
@@ -35,29 +35,27 @@
 import android.app.Fragment;
 import android.app.FragmentManager;
 import android.app.FragmentTransaction;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
 import android.os.Bundle;
 import android.support.v13.app.FragmentStatePagerAdapter;
 import android.support.v4.view.ViewPager;
 import android.util.Log;
 import android.view.Gravity;
-import android.view.InflateException;
 import android.view.LayoutInflater;
 import android.view.Menu;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.view.ViewGroup;
-import android.widget.Button;
 import android.widget.TextView;
+import com.savoirfairelinux.sflphone.client.Data;
+import com.savoirfairelinux.sflphone.client.ManagerImpl;
 
 import com.savoirfairelinux.sflphone.R;
 
-public class SFLPhoneHome extends Activity implements ActionBar.TabListener
+public class SFLPhoneHome extends Activity implements ActionBar.TabListener, OnClickListener
 {
 	SectionsPagerAdapter mSectionsPagerAdapter;
-	private static final String TAG = "SFLPhoneHome";
+	static final String TAG = "SFLPhoneHome";
+	ButtonSectionFragment buttonFragment;
 
 	/**
 	 * The {@link ViewPager} that will host the section contents.
@@ -102,6 +100,24 @@
 		}
 	}
 
+	// FIXME
+	static {
+		System.loadLibrary("gnustl_shared");
+		System.loadLibrary("expat");
+		System.loadLibrary("yaml");
+		System.loadLibrary("ccgnu2");
+		System.loadLibrary("crypto");
+		System.loadLibrary("ssl");
+		System.loadLibrary("ccrtp1");
+		System.loadLibrary("dbus");
+		System.loadLibrary("dbus-c++-1");
+		System.loadLibrary("samplerate");
+		System.loadLibrary("codec_ulaw");
+		System.loadLibrary("codec_alaw");
+		System.loadLibrary("speexresampler");
+		System.loadLibrary("sflphone");
+	}
+	
 	@Override
 	public boolean onCreateOptionsMenu(Menu menu)
 	{
@@ -144,6 +160,7 @@
 		public Fragment getItem(int i)
 		{
 			Fragment fragment;
+			
 			switch (i) {
 			case 0:
 				fragment = new CallElementList();
@@ -152,7 +169,9 @@
 				fragment = new DummySectionFragment();
 				break;
 			case 2:
-				fragment = new ButtonSectionFragment();
+				buttonFragment = new ButtonSectionFragment();
+				Log.i(TAG, "getItem: fragment is " + buttonFragment);
+				fragment = buttonFragment;
 				break;
 			default:
 				Log.e(TAG, "getItem: unknown tab position " + i);
@@ -212,100 +231,56 @@
 			textView.setText("java sucks");
 			return textView;
 		}
-
 	}
 
-	public static class ButtonSectionFragment extends Fragment implements OnClickListener
-	{ 
-		public ButtonSectionFragment()
-		{
-			setRetainInstance(true);
-		}
+	public static String getAppPath() {
+		return "/data/data/com.savoirfairelinux.sflphone";
+//		PackageManager m = getPackageManager();
+//		String s = getPackageName();
+//		Log.d(TAG, "Application path: " + s);
+//		try {
+//			PackageInfo p = m.getPackageInfo(s, 0);
+//			s = p.applicationInfo.dataDir;
+//		} catch (NameNotFoundException e) {
+//			Log.w(TAG, "Error Package name not found ", e);
+//		}
+//		return s;
+	}
 
-		public static final String ARG_SECTION_NUMBER = "section_number";
-		public static final OnClickListener myListener = new OnClickListener() {
-			@Override
-		    public void onClick(View view)
-		    {
-		    	switch (view.getId()) {
-		    	case R.id.buttonCall:
-		        	ManagerImpl.outgoingCallJ("");
-		        	break;
-		    	case R.id.buttonInit:
-		    		ManagerImpl.initN("");
-		    		break;
-		    	case R.id.buttonTest1:
-		    		Log.i(TAG, "buttonTest1");
-		    		break;
-		        default:
-		    		Log.w(TAG, "unknown button " + view.getId());
-		        	break;
-		    	}
-	    	}
-		};
-
-		@Override
-		public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState)
-		{
-			View view;
-			Button buttonInit, buttonCall, buttonTest1;
-			
-			Log.i(TAG, "onCreateView" );
-			view = inflater.inflate(R.layout.test_layout, parent, false);
-			
-			buttonInit = (Button) view.findViewById(R.id.buttonInit);
-			if (buttonInit == null)
-	        	Log.e(TAG, "buttonInit is " + buttonInit);
-			buttonInit.setOnClickListener(myListener);
-			
-	        buttonCall = (Button) view.findViewById(R.id.buttonCall);
-			if (buttonCall == null)
-	        	Log.e(TAG, "buttonCall is " + buttonCall);
-			buttonCall.setOnClickListener(myListener);
-
-			buttonTest1 = (Button) view.findViewById(R.id.buttonTest1);
-			if (buttonTest1 == null)
-	        	Log.e(TAG, "buttonTest1 is " + buttonTest1);
-			buttonTest1.setOnClickListener(myListener);
-			
-//			buttonInit.setGravity(Gravity.CENTER);
-//			buttonInit.setText("init");
-//			buttonInit.setOnClickListener(this);
-			//TextView textView = new TextView(getActivity());
-			//textView.setGravity(Gravity.CENTER);
-			//Bundle args = getArguments();
-			//textView.setText(Integer.toString(args.getInt(ARG_SECTION_NUMBER)));
-			//textView.setText("java sucks");
-			if (parent == null)
-				Log.e(TAG, "parent is " + parent);
-			if (R.layout.test_layout == 0)
-				Log.e(TAG, "buttonInit = " + R.layout.test_layout);
-			try {
-				inflater.inflate(R.layout.test_layout, parent, false);
-			} catch (InflateException e) {
-				Log.e(TAG, "Error inflating test_layout ", e);
-				return null;
-			}
-			return view;
-		}
-		
-		@Override
-	    public void onClick(View view)
-	    {
-    		Log.d(TAG, "onClick ");
+	@Override
+    public void onClick(View view)
+    {
+    	switch (view.getId()) {
+    	case R.id.buttonCall:
+    		ManagerImpl.outgoingCallJ("");
+        	break;
+    	case R.id.buttonInit:
+    		ManagerImpl.initN("");
+    		break;
+    	case R.id.buttonTest1:
+    		Log.i(TAG, "buttonTest1");
+    		break;
+    	case R.id.buttonCallVoid:
+    		ManagerImpl.callVoid();
+        	break;
+    	case R.id.buttonGetNewData:
+    		Data d = ManagerImpl.getNewData(42, "foo");
+    		if (d != null)
+    			buttonFragment.getNewDataText().setText("getNewData(42, \"foo\") == Data(" + d.i + ", \"" + d.s + "\")");
+    		break;
+    	case R.id.buttonGetDataString:
+//    		Data daita = new Data(43, "bar");
+//    		String s = ManagerImpl.getDataString(daita);
+    		String s = ManagerImpl.getDataString2();
+			Log.i(TAG, "buttonGetDataString: getDataString2 is " + s);
+    		if (s != "") {
+//    			getDataStringText.setText("getDataString(Data(43, \"bar\")) == \"" + s + "\"");
+    			buttonFragment.getDataStringText().setText("getDataString: " + s);
+    		}
+        	break;
+        default:
+    		Log.w(TAG, "unknown button " + view.getId());
+        	break;
     	}
-    }
-
-	public String getAppPath() {
-		PackageManager m = getPackageManager();
-		String s = getPackageName();
-		Log.d(TAG, "Application path: " + s);
-		try {
-			PackageInfo p = m.getPackageInfo(s, 0);
-			s = p.applicationInfo.dataDir;
-		} catch (NameNotFoundException e) {
-			Log.w(TAG, "Error Package name not found ", e);
-		}
-		return s;
 	}
 }