From d65785b28f57bf7eb53f90ef263beae3ee8a9cdc Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 13 Dec 2012 12:44:02 +0100 Subject: [PATCH] Perform echo canceller calibration for every option of the wizard. Also perform the calibration only on first start of the application, not when the wizard is run manually. --- .../EchoCancellerCalibrationFragment.java | 11 ++++- src/org/linphone/setup/SetupActivity.java | 43 ++++++++++--------- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/src/org/linphone/setup/EchoCancellerCalibrationFragment.java b/src/org/linphone/setup/EchoCancellerCalibrationFragment.java index f3e8120aa..a86ed9f7c 100644 --- a/src/org/linphone/setup/EchoCancellerCalibrationFragment.java +++ b/src/org/linphone/setup/EchoCancellerCalibrationFragment.java @@ -48,6 +48,7 @@ import android.view.ViewGroup; */ public class EchoCancellerCalibrationFragment extends Fragment implements EcCalibrationListener { private Handler mHandler = new Handler(); + private boolean mSendEcCalibrationResult = false; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, @@ -73,7 +74,15 @@ public class EchoCancellerCalibrationFragment extends Fragment implements EcCali editor.putBoolean(getString(R.string.pref_echo_cancellation_key), true); } editor.commit(); - sendEcCalibrationResult(status, delayMs); + if (mSendEcCalibrationResult) { + sendEcCalibrationResult(status, delayMs); + } else { + SetupActivity.instance().isEchoCalibrationFinished(); + } + } + + public void enableEcCalibrationResultSending(boolean enabled) { + mSendEcCalibrationResult = enabled; } private void sendEcCalibrationResult(EcCalibratorStatus status, int delayMs) { diff --git a/src/org/linphone/setup/SetupActivity.java b/src/org/linphone/setup/SetupActivity.java index e3652c4c9..c6a83d4b5 100644 --- a/src/org/linphone/setup/SetupActivity.java +++ b/src/org/linphone/setup/SetupActivity.java @@ -138,7 +138,22 @@ public class SetupActivity extends FragmentActivity implements OnClickListener { } } - public void logIn(String username, String password, String domain) { + private void launchEchoCancellerCalibration(boolean sendEcCalibrationResult) { + if (!Hacks.hasBuiltInEchoCanceller() && !mPref.getBoolean(getString(R.string.first_launch_suceeded_once_key), false)) { + EchoCancellerCalibrationFragment fragment = new EchoCancellerCalibrationFragment(); + fragment.enableEcCalibrationResultSending(sendEcCalibrationResult); + changeFragment(fragment); + currentFragment = SetupFragments.ECHO_CANCELLER_CALIBRATION; + back.setVisibility(View.VISIBLE); + next.setVisibility(View.GONE); + next.setEnabled(false); + cancel.setEnabled(false); + } else { + success(); + } + } + + private void logIn(String username, String password, String domain, boolean sendEcCalibrationResult) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); if (imm != null && getCurrentFocus() != null) { imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0); @@ -153,30 +168,18 @@ public class SetupActivity extends FragmentActivity implements OnClickListener { Log.e(e, "Error while initializing from config in first login activity"); Toast.makeText(this, getString(R.string.error), Toast.LENGTH_LONG).show(); } + + if (LinphoneManager.getLc().getDefaultProxyConfig() != null) { + launchEchoCancellerCalibration(sendEcCalibrationResult); + } } public void linphoneLogIn(String username, String password) { - logIn(username, password, getString(R.string.default_domain)); - if (LinphoneManager.getLc().getDefaultProxyConfig() != null) { - if (!Hacks.hasBuiltInEchoCanceller()) { - EchoCancellerCalibrationFragment fragment = new EchoCancellerCalibrationFragment(); - changeFragment(fragment); - currentFragment = SetupFragments.ECHO_CANCELLER_CALIBRATION; - back.setVisibility(View.VISIBLE); - next.setVisibility(View.GONE); - next.setEnabled(false); - cancel.setEnabled(false); - } else { - success(); - } - } + logIn(username, password, getString(R.string.default_domain), true); } public void genericLogIn(String username, String password, String domain) { - logIn(username, password, domain); - if (LinphoneManager.getLc().getDefaultProxyConfig() != null) { - success(); - } + logIn(username, password, domain, false); } private void writePreference(int key, String value) { @@ -269,7 +272,7 @@ public class SetupActivity extends FragmentActivity implements OnClickListener { Toast.makeText(this, getString(R.string.error), Toast.LENGTH_LONG).show(); } - success(); + launchEchoCancellerCalibration(true); } public void isEchoCalibrationFinished() {