diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 4a5a991cd..545b7b63b 100755 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -2,8 +2,8 @@ + android:versionCode="3311" + android:versionName="3.3.1"> + android:versionCode="3311" + android:versionName="3.3.1"> =3.7)_. * On 64 bits linux systems you'll need the _ia32-libs_ package. * With the latest Debian (multiarch), you need this: * `dpkg --add-architecture i386` diff --git a/src/android/org/linphone/LinphoneManager.java b/src/android/org/linphone/LinphoneManager.java index 3ae37f00b..1ad4f8569 100644 --- a/src/android/org/linphone/LinphoneManager.java +++ b/src/android/org/linphone/LinphoneManager.java @@ -293,10 +293,12 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou } else { progress.dismiss(); progress = null; - LinphoneManager.getLc().reloadMsPlugins(LinphoneManager.this.getContext().getApplicationInfo().nativeLibraryDir); - if (ohcodec.getUserDataSize() > box && ohcodec.getUserData(box) != null) { - ((CheckBoxPreference) ohcodec.getUserData(box)).setSummary(mCodecDownloader.getLicenseMessage()); - ((CheckBoxPreference) ohcodec.getUserData(box)).setTitle("OpenH264"); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { + LinphoneManager.getLc().reloadMsPlugins(AssistantActivity.instance().getApplicationInfo().nativeLibraryDir); + AssistantActivity.instance().endDownloadCodec(); + } else { + // We need to restart due to bad android linker + AssistantActivity.instance().restartApplication(); } } } @@ -348,9 +350,6 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou // H264 codec Management - set to auto mode -> MediaCodec >= android 5.0 >= OpenH264 H264Helper.setH264Mode(H264Helper.MODE_AUTO, getLc()); - TelephonyManager tm = (TelephonyManager) c.getSystemService(Context.TELEPHONY_SERVICE); - boolean gsmIdle = tm.getCallState() == TelephonyManager.CALL_STATE_IDLE; - setGsmIdle(gsmIdle); return instance; } @@ -1135,33 +1134,6 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou } } - private int savedMaxCallWhileGsmIncall; - private synchronized void preventSIPCalls() { - if (savedMaxCallWhileGsmIncall != 0) { - Log.w("SIP calls are already blocked due to GSM call running"); - return; - } - savedMaxCallWhileGsmIncall = mLc.getMaxCalls(); - mLc.setMaxCalls(0); - } - private synchronized void allowSIPCalls() { - if (savedMaxCallWhileGsmIncall == 0) { - Log.w("SIP calls are already allowed as no GSM call known to be running"); - return; - } - mLc.setMaxCalls(savedMaxCallWhileGsmIncall); - savedMaxCallWhileGsmIncall = 0; - } - public static void setGsmIdle(boolean gsmIdle) { - LinphoneManager mThis = instance; - if (mThis == null) return; - if (gsmIdle) { - mThis.allowSIPCalls(); - } else { - mThis.preventSIPCalls(); - } - } - public Context getContext() { try { if (LinphoneActivity.isInstanciated()) diff --git a/src/android/org/linphone/LinphonePreferences.java b/src/android/org/linphone/LinphonePreferences.java index 5ffa7b7f9..120fd458f 100644 --- a/src/android/org/linphone/LinphonePreferences.java +++ b/src/android/org/linphone/LinphonePreferences.java @@ -532,8 +532,8 @@ public class LinphonePreferences { String domain = getAccountDomain(n); String userid = null; String realm = null; - if(user != null && domain != null) { - if (LinphoneManager.getLc().getAuthInfoList().length >= n && LinphoneManager.getLc().getAuthInfoList()[n] != null) { + if (user != null && domain != null) { + if (LinphoneManager.getLc().getAuthInfoList().length > n && LinphoneManager.getLc().getAuthInfoList()[n] != null) { userid = getAccountUserId(n); realm = getAccountRealm(n); LinphoneManager.getLc().removeAuthInfo(LinphoneManager.getLc().getAuthInfoList()[n]); diff --git a/src/android/org/linphone/call/CallActivity.java b/src/android/org/linphone/call/CallActivity.java index da55a2033..8ef94c900 100644 --- a/src/android/org/linphone/call/CallActivity.java +++ b/src/android/org/linphone/call/CallActivity.java @@ -24,7 +24,10 @@ import android.app.Activity; import android.app.Dialog; import android.app.Fragment; import android.app.FragmentTransaction; +import android.content.BroadcastReceiver; +import android.content.Context; import android.content.Intent; +import android.content.IntentFilter; import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.content.res.Resources; @@ -119,6 +122,7 @@ public class CallActivity extends LinphoneGenericActivity implements OnClickList private boolean isVideoCallPaused = false; private Dialog dialog = null; private static long TimeRemind = 0; + private HeadsetReceiver headsetReceiver; private LinearLayout callsList, conferenceList; private LayoutInflater inflater; @@ -133,6 +137,8 @@ public class CallActivity extends LinphoneGenericActivity implements OnClickList private HashMap mEncoderTexts; private HashMap mDecoderTexts; + private boolean oldIsSpeakerEnabled = false; + public static CallActivity instance() { return instance; } @@ -153,6 +159,12 @@ public class CallActivity extends LinphoneGenericActivity implements OnClickList getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); setContentView(R.layout.call); + //Earset Connectivity Broadcast Processing + IntentFilter intentFilter = new IntentFilter(); + intentFilter.addAction("android.intent.action.HEADSET_PLUG"); + headsetReceiver = new HeadsetReceiver(); + registerReceiver(headsetReceiver, intentFilter); + isTransferAllowed = getApplicationContext().getResources().getBoolean(R.bool.allow_transfers); cameraNumber = AndroidCameraConfiguration.retrieveCameras().length; @@ -1247,6 +1259,8 @@ public class CallActivity extends LinphoneGenericActivity implements OnClickList LinphoneManager.getInstance().changeStatusToOnline(); LinphoneManager.getInstance().enableProximitySensing(false); + unregisterReceiver(headsetReceiver); + if (mControlsHandler != null && mControls != null) { mControlsHandler.removeCallbacks(mControls); } @@ -1749,4 +1763,31 @@ public class CallActivity extends LinphoneGenericActivity implements OnClickList }; mTimer.scheduleAtFixedRate(mTask, 0, 1000); } + + ////Earset Connectivity Broadcast innerClass + public class HeadsetReceiver extends BroadcastReceiver { + @Override + public void onReceive(Context context, Intent intent) { + if (!BluetoothManager.getInstance().isBluetoothHeadsetAvailable()) { + if (intent.hasExtra("state")) { + switch (intent.getIntExtra("state", 0)) { + case 0: + if (oldIsSpeakerEnabled) { + LinphoneManager.getInstance().routeAudioToSpeaker(); + isSpeakerEnabled = true; + speaker.setEnabled(true); + } + break; + case 1: + LinphoneManager.getInstance().routeAudioToReceiver(); + oldIsSpeakerEnabled = isSpeakerEnabled; + isSpeakerEnabled = false; + speaker.setEnabled(false); + break; + } + refreshInCallActions(); + } + } + } + } } diff --git a/src/android/org/linphone/fragments/SettingsFragment.java b/src/android/org/linphone/fragments/SettingsFragment.java index 701240d54..2219bbc5e 100644 --- a/src/android/org/linphone/fragments/SettingsFragment.java +++ b/src/android/org/linphone/fragments/SettingsFragment.java @@ -680,6 +680,31 @@ public class SettingsFragment extends PreferencesListFragment { echoCancellerCalibration.setSummary(R.string.failed); } + private void initOpenH264AlertDialog(final OpenH264DownloadHelper mCodecDownloader, final CheckBoxPreference codec) { + mCodecDownloader.setOpenH264HelperListener(LinphoneManager.getInstance().getOpenH264HelperListener()); + mCodecDownloader.setUserData(0, LinphoneManager.getInstance().getContext()); + mCodecDownloader.setUserData(1, codec); + + AlertDialog.Builder builder = new AlertDialog.Builder(LinphoneManager.getInstance().getContext()); + builder.setCancelable(false); + 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 + codec.setChecked(false); + } + } + }).show(); + } + private void initVideoSettings() { initializePreferredVideoSizePreferences((ListPreference) findPreference(getString(R.string.pref_preferred_video_size_key))); initializePreferredVideoFpsPreferences((ListPreference) findPreference(getString(R.string.pref_preferred_video_fps_key))); @@ -699,6 +724,7 @@ public class SettingsFragment extends PreferencesListFragment { final OpenH264DownloadHelper mCodecDownloader = LinphoneManager.getInstance().getOpenH264DownloadHelper(); + boolean h264IsHere = false; for (final PayloadType pt : lc.getVideoPayloadTypes()) { final CheckBoxPreference codec = new CheckBoxPreference(getActivity()); codec.setTitle(pt.getMimeType()); @@ -707,20 +733,20 @@ public class SettingsFragment extends PreferencesListFragment { if (getResources().getBoolean(R.bool.disable_all_patented_codecs_for_markets)) { continue; } else { - if (!Version.hasFastCpuWithAsmOptim() && pt.getMimeType().equals("H264")) - { + if (!Version.hasFastCpuWithAsmOptim() && pt.getMimeType().equals("H264")) { // Android without neon doesn't support H264 Log.w("CPU does not have asm optimisations available, disabling H264"); continue; } } - } - if (OpenH264DownloadHelper.isOpenH264DownloadEnabled()) { - if (pt.getMimeType().equals("H264") && mCodecDownloader.isCodecFound()) { + } else if (pt.getMimeType().equals("H264")) { + h264IsHere = true; + if (OpenH264DownloadHelper.isOpenH264DownloadEnabled() && mCodecDownloader.isCodecFound()) { codec.setSummary(mCodecDownloader.getLicenseMessage()); codec.setTitle("OpenH264"); } } + codec.setDefaultValue(pt.enabled()); codec.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @@ -760,6 +786,27 @@ public class SettingsFragment extends PreferencesListFragment { codecs.addPreference(codec); } + // Adding OpenH264 button on device < 5.1 + if (mCodecDownloader.isOpenH264DownloadEnabled() && !h264IsHere) { + final CheckBoxPreference codec = new CheckBoxPreference(getActivity()); + codec.setTitle("OpenH264"); + codec.setSummary(mCodecDownloader.getLicenseMessage()); + //codec.setEnabled(false); + codec.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + boolean enable = (Boolean) newValue; + if (mCodecDownloader.isOpenH264DownloadEnabled()) { + if (enable && Version.getCpuAbis().contains("armeabi-v7a") && !Version.getCpuAbis().contains("x86") + && !mCodecDownloader.isCodecFound()) { + initOpenH264AlertDialog(mCodecDownloader, codec); + } + } + return true; + } + }); + codecs.addPreference(codec); + } ((CheckBoxPreference) findPreference(getString(R.string.pref_video_enable_key))).setChecked(mPrefs.isVideoEnabled()); ((CheckBoxPreference) findPreference(getString(R.string.pref_video_use_front_camera_key))).setChecked(mPrefs.useFrontCam()); ((CheckBoxPreference) findPreference(getString(R.string.pref_video_initiate_call_with_video_key))).setChecked(mPrefs.shouldInitiateVideoCall()); diff --git a/submodules/msopenh264 b/submodules/msopenh264 index 18b41c256..e77223326 160000 --- a/submodules/msopenh264 +++ b/submodules/msopenh264 @@ -1 +1 @@ -Subproject commit 18b41c2569ea76b8eb1df9f85a32f16b3d001cc0 +Subproject commit e7722332645b324dfc6aba3e94ab71750a3c0fd7 diff --git a/submodules/msx264 b/submodules/msx264 index 3a22b8d31..1df2129d3 160000 --- a/submodules/msx264 +++ b/submodules/msx264 @@ -1 +1 @@ -Subproject commit 3a22b8d31c43a3a4e1e4985b5a6bbec7b03972bf +Subproject commit 1df2129d373c4752929f2d0ae834dbdeb4855170