diff --git a/src/org/linphone/LinphoneManager.java b/src/org/linphone/LinphoneManager.java index 1e925cbf7..d0553a497 100644 --- a/src/org/linphone/LinphoneManager.java +++ b/src/org/linphone/LinphoneManager.java @@ -145,7 +145,6 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag private LinphoneCore mLc; private OpenH264DownloadHelper mCodecDownloader; private OpenH264DownloadHelperListener mCodecListener; - private OpenH264DownloadHelperAction mCodecAction; private String lastLcStatusMessage; private String basePath; private static boolean sExited; @@ -193,7 +192,6 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag mConnectivityManager = (ConnectivityManager) c.getSystemService(Context.CONNECTIVITY_SERVICE); mR = c.getResources(); mPendingChatFileMessage = new ArrayList(); - initOpenH264Helper(); } private static final int LINPHONE_VOLUME_STREAM = STREAM_VOICE_CALL; @@ -225,7 +223,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag } public void initOpenH264Helper() { - mCodecDownloader = new OpenH264DownloadHelper(); + mCodecDownloader = LinphoneCoreFactory.instance().createOpenH264DownloadHelper(); mCodecListener = new OpenH264DownloadHelperListener() { ProgressDialog progress; int box = 1; @@ -250,7 +248,6 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag } else { progress.dismiss(); progress = null; - LinphoneCoreFactoryImpl.loadOptionalLibraryWithPath(((Context)ohcodec.getUserData(ctxt)).getFilesDir() + "/" + mCodecDownloader.getNameLib()); LinphoneManager.getLc().reloadMsPlugins(null); if (ohcodec.getUserDataSize() > box && ohcodec.getUserData(box) != null) @@ -276,45 +273,13 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag }); } }; - mCodecAction = new OpenH264DownloadHelperAction() { - @Override - public void startDownload() { - askPopUp(); - } - - public void askPopUp() { - AlertDialog.Builder builder = new AlertDialog.Builder(LinphoneManager.getInstance().getContext()); - builder.setCancelable(false); - AlertDialog.Builder show = builder.setMessage("Do you agree to download " - + mCodecDownloader.getLicenseMessage()).setPositiveButton("Yes", new DialogInterface.OnClickListener(){ - @Override - public void onClick(DialogInterface dialog, int which) { - if (which == DialogInterface.BUTTON_POSITIVE) - mCodecDownloader.downloadCodec(); - } - }); - builder.setNegativeButton("No", new DialogInterface.OnClickListener(){ - @Override - public void onClick(DialogInterface dialog, int which) { - if (which == DialogInterface.BUTTON_NEGATIVE){ - // Disable H264 - } - } - }).show(); - } - }; mCodecDownloader.setOpenH264HelperListener(mCodecListener); - mCodecDownloader.setOpenH264HelperAction(mCodecAction); } public OpenH264DownloadHelperListener getOpenH264HelperListener() { return mCodecListener; } - public OpenH264DownloadHelperAction getOpenH264HelperAction() { - return mCodecAction; - } - public OpenH264DownloadHelper getOpenH264DownloadHelper(){ return mCodecDownloader; } @@ -1005,6 +970,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag if (state == GlobalState.GlobalOn){ try { initLiblinphone(lc); + initOpenH264Helper(); } catch (LinphoneCoreException e) { Log.e(e); } diff --git a/src/org/linphone/SettingsFragment.java b/src/org/linphone/SettingsFragment.java index cb3aca8cc..73b0064c2 100644 --- a/src/org/linphone/SettingsFragment.java +++ b/src/org/linphone/SettingsFragment.java @@ -37,6 +37,8 @@ import org.linphone.tools.OpenH264DownloadHelper; import org.linphone.ui.LedPreference; import org.linphone.ui.PreferencesListFragment; +import android.app.AlertDialog; +import android.content.DialogInterface; import android.os.Bundle; import android.os.Handler; import android.preference.CheckBoxPreference; @@ -571,7 +573,6 @@ public class SettingsFragment extends PreferencesListFragment { } } } - mCodecDownloader.setFileDirection(LinphoneManager.getInstance().getContext().getFilesDir().toString()); if (pt.getMime().equals("H264") && mCodecDownloader.isCodecFound()) codec.setSummary(mCodecDownloader.getLicenseMessage()); codec.setChecked(lc.isPayloadTypeEnabled(pt)); @@ -584,10 +585,27 @@ public class SettingsFragment extends PreferencesListFragment { if (enable && Version.getCpuAbis().contains("armeabi-v7a") && !Version.getCpuAbis().contains("x86") && pt.getMime().equals("H264") && !mCodecDownloader.isCodecFound()) { LinphoneManager.getInstance().getOpenH264DownloadHelper().setOpenH264HelperListener(LinphoneManager.getInstance().getOpenH264HelperListener()); - LinphoneManager.getInstance().getOpenH264DownloadHelper().setOpenH264HelperAction(LinphoneManager.getInstance().getOpenH264DownloadHelper().getOpenH264DownloadHelperAction()); LinphoneManager.getInstance().getOpenH264DownloadHelper().setUserData(0,LinphoneManager.getInstance().getContext()); LinphoneManager.getInstance().getOpenH264DownloadHelper().setUserData(1,codec); - LinphoneManager.getInstance().getOpenH264DownloadHelper().getOpenH264DownloadHelperAction().startDownload(); + + AlertDialog.Builder builder = new AlertDialog.Builder(LinphoneManager.getInstance().getContext()); + builder.setCancelable(false); + AlertDialog.Builder show = builder.setMessage("Do you agree to download " + + mCodecDownloader.getLicenseMessage()).setPositiveButton("Yes", new DialogInterface.OnClickListener(){ + @Override + public void onClick(DialogInterface dialog, int which) { + if (which == DialogInterface.BUTTON_POSITIVE) + mCodecDownloader.downloadCodec(); + } + }); + builder.setNegativeButton("No", new DialogInterface.OnClickListener(){ + @Override + public void onClick(DialogInterface dialog, int which) { + if (which == DialogInterface.BUTTON_NEGATIVE){ + // Disable H264 + } + } + }).show(); } LinphoneManager.getLcIfManagerNotDestroyedOrNull().enablePayloadType(pt, enable); } catch (LinphoneCoreException e) { diff --git a/src/org/linphone/assistant/AssistantActivity.java b/src/org/linphone/assistant/AssistantActivity.java index 82b7f79e5..8992418c9 100644 --- a/src/org/linphone/assistant/AssistantActivity.java +++ b/src/org/linphone/assistant/AssistantActivity.java @@ -113,7 +113,8 @@ private static AssistantActivity instance; if (state == RegistrationState.RegistrationOk) { if (progress != null) progress.dismiss(); if (LinphoneManager.getLc().getDefaultProxyConfig() != null) { - launchEchoCancellerCalibration(true); + if (!launchEchoCancellerCalibration(true)) + launchDownloadCodec(); } } else if (state == RegistrationState.RegistrationFailed) { if (progress != null) progress.dismiss(); @@ -242,15 +243,11 @@ private static AssistantActivity instance; if (requestCode == PERMISSIONS_REQUEST_RECORD_AUDIO) { if (getPackageManager().checkPermission(Manifest.permission.RECORD_AUDIO, getPackageName()) == PackageManager.PERMISSION_GRANTED) { launchEchoCancellerCalibration(true); - } else { - launchDownloadCodec(); } - } else { - launchDownloadCodec(); } } - private void launchEchoCancellerCalibration(boolean sendEcCalibrationResult) { + private boolean launchEchoCancellerCalibration(boolean sendEcCalibrationResult) { if (getPackageManager().checkPermission(Manifest.permission.RECORD_AUDIO, getPackageName()) == PackageManager.PERMISSION_GRANTED) { boolean needsEchoCalibration = LinphoneManager.getLc().needsEchoCalibration(); if (needsEchoCalibration && mPrefs.isFirstLaunch()) { @@ -260,12 +257,12 @@ private static AssistantActivity instance; currentFragment = AssistantFragmentsEnum.ECHO_CANCELLER_CALIBRATION; back.setVisibility(View.VISIBLE); cancel.setEnabled(false); - } else { - launchDownloadCodec(); + return true; } } else { checkAndRequestAudioPermission(); } + return false; } private void logIn(String username, String password, String displayName, String domain, TransportType transport, boolean sendEcCalibrationResult) { @@ -355,8 +352,7 @@ private static AssistantActivity instance; } private void launchDownloadCodec() { - OpenH264DownloadHelper downloadHelper = new OpenH264DownloadHelper(); - downloadHelper.setFileDirection(LinphoneManager.getInstance().getContext().getFilesDir().toString()); + OpenH264DownloadHelper downloadHelper = LinphoneCoreFactory.instance().createOpenH264DownloadHelper(); if (Version.getCpuAbis().contains("armeabi-v7a") && !Version.getCpuAbis().contains("x86") && !downloadHelper.isCodecFound()) { CodecDownloaderFragment codecFragment = new CodecDownloaderFragment(); changeFragment(codecFragment); @@ -498,7 +494,8 @@ private static AssistantActivity instance; public void isAccountVerified(String username) { Toast.makeText(this, getString(R.string.assistant_account_validated), Toast.LENGTH_LONG).show(); - launchEchoCancellerCalibration(true); + if(!launchEchoCancellerCalibration(true)) + launchDownloadCodec(); // Echo canceller cancel } public void isEchoCalibrationFinished() { diff --git a/src/org/linphone/assistant/CodecDownloaderFragment.java b/src/org/linphone/assistant/CodecDownloaderFragment.java index 8597f650d..a14dfde53 100644 --- a/src/org/linphone/assistant/CodecDownloaderFragment.java +++ b/src/org/linphone/assistant/CodecDownloaderFragment.java @@ -31,9 +31,9 @@ import android.widget.TextView; import org.linphone.LinphoneManager; import org.linphone.R; +import org.linphone.core.LinphoneCoreFactory; import org.linphone.core.OpenH264DownloadHelperListener; import org.linphone.core.LinphoneCoreException; -import org.linphone.core.LinphoneCoreFactoryImpl; import org.linphone.core.PayloadType; import org.linphone.tools.OpenH264DownloadHelper; @@ -57,8 +57,7 @@ public class CodecDownloaderFragment extends Fragment { final ProgressBar bar = (ProgressBar) view.findViewById(R.id.progressBar); final TextView downloadingInfo = (TextView) view.findViewById(R.id.downloadingInfo); - final OpenH264DownloadHelper codecDownloader = new OpenH264DownloadHelper(); - codecDownloader.setFileDirection(LinphoneManager.getInstance().getContext().getFilesDir().toString()); + final OpenH264DownloadHelper codecDownloader = LinphoneCoreFactory.instance().createOpenH264DownloadHelper(); final OpenH264DownloadHelperListener codecListener = new OpenH264DownloadHelperListener() { @Override @@ -75,7 +74,6 @@ public class CodecDownloaderFragment extends Fragment { } else { downloadingInfo.setVisibility(View.INVISIBLE); bar.setVisibility(View.INVISIBLE); - LinphoneCoreFactoryImpl.loadOptionalLibraryWithPath(LinphoneManager.getInstance().getContext().getFilesDir() + "/" + codecDownloader.getNameLib()); LinphoneManager.getLc().reloadMsPlugins(null); downloading.setVisibility(View.INVISIBLE); downloaded.setVisibility(View.VISIBLE); diff --git a/submodules/linphone b/submodules/linphone index 7ab235c55..1bfb20e56 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 7ab235c55a337f68e404097d6e76baf6edc11b4f +Subproject commit 1bfb20e56f99ae77578d90850750c740a065c7fe