From 0868eb9839bb433e89cf70e22a6f4e97eed7f166 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Wed, 30 May 2018 15:55:58 +0200 Subject: [PATCH] fix cpim tester crashes --- .../src/org/linphone/tester/LogsActivity.java | 2 +- .../src/org/linphone/tester/TestUnit.java | 34 +++---------------- 2 files changed, 6 insertions(+), 30 deletions(-) diff --git a/liblinphone_tester/src/org/linphone/tester/LogsActivity.java b/liblinphone_tester/src/org/linphone/tester/LogsActivity.java index 40c7062cf..b4021760b 100644 --- a/liblinphone_tester/src/org/linphone/tester/LogsActivity.java +++ b/liblinphone_tester/src/org/linphone/tester/LogsActivity.java @@ -23,7 +23,7 @@ public class LogsActivity extends Activity { @Override public void run() { - String res_path = mLogsActivity.getFilesDir().getAbsolutePath()+"/config_files"; + String res_path = mLogsActivity.getFilesDir().getAbsolutePath(); String write_path = mLogsActivity.getCacheDir().getPath(); tester = new TesterLogger(mLogsActivity); List list = new LinkedList(Arrays.asList(new String[]{"tester", "--verbose", "--resource-dir", res_path, "--writable-dir", write_path})); diff --git a/liblinphone_tester/src/org/linphone/tester/TestUnit.java b/liblinphone_tester/src/org/linphone/tester/TestUnit.java index da92a72e4..eefe4f675 100644 --- a/liblinphone_tester/src/org/linphone/tester/TestUnit.java +++ b/liblinphone_tester/src/org/linphone/tester/TestUnit.java @@ -32,37 +32,13 @@ public class TestUnit extends AndroidTestCase { } static public void copyAssetsFromPackage(Context ctx) throws IOException { - copyAssetsFromPackage(ctx,"config_files"); + //copy sdk assets + org.linphone.core.tools.AndroidPlatformHelper.copyAssetsFromPackage(ctx,"org.linphone.core","."); + //copy tester assets + org.linphone.core.tools.AndroidPlatformHelper.copyAssetsFromPackage(ctx,"config_files","."); } - public static void copyAssetsFromPackage(Context ctx,String fromPath) throws IOException { - new File(ctx.getFilesDir().getPath()+"/"+fromPath).mkdir(); - - for (String f :ctx.getAssets().list(fromPath)) { - String current_name=fromPath+"/"+f; - InputStream lInputStream; - try { - lInputStream = ctx.getAssets().open(current_name); - } catch (IOException e) { - //probably a dir - new File(ctx.getFilesDir().getPath()+"/"+current_name).mkdir(); - copyAssetsFromPackage(ctx,current_name); - continue; - } - FileOutputStream lOutputStream = new FileOutputStream(new File(ctx.getFilesDir().getPath()+"/"+current_name));//ctx.openFileOutput (fromPath+"/"+f, 0); - - - int readByte; - byte[] buff = new byte[8048]; - while (( readByte = lInputStream.read(buff)) != -1) { - lOutputStream.write(buff,0, readByte); - } - lOutputStream.flush(); - lOutputStream.close(); - lInputStream.close(); - } - } @Override protected void setUp() throws Exception { super.setUp(); @@ -80,7 +56,7 @@ public class TestUnit extends AndroidTestCase { @Override protected void runTest() { - String res_path = getContext().getFilesDir().getPath()+"/config_files"; + String res_path = getContext().getFilesDir().getPath(); String write_path = getContext().getCacheDir().getPath(); Tester tester = new Tester();