[DialerIntent] multiples updates to fix crashes
This commit is contained in:
parent
31c5e69d98
commit
8924dca7d5
11 changed files with 117 additions and 38 deletions
|
@ -115,6 +115,10 @@
|
|||
<data android:mimeType="video/*"/>
|
||||
<data android:mimeType="application/*"/>
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="org.linphone.intent.action.CallLaunched" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".LinphoneActivity"
|
||||
|
@ -256,6 +260,12 @@
|
|||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver android:name=".OutgoingCallReceiver"
|
||||
android:permission="android.permission.PROCESS_OUTGOING_CALLS">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<!-- Needed for push notification -->
|
||||
<!--
|
||||
<receiver
|
||||
|
|
|
@ -134,6 +134,7 @@
|
|||
<string name="pref_rfc2833_dtmf_key">pref_rfc2833_dtmf_key</string>
|
||||
<string name="pref_sipinfo_dtmf_key">pref_sipinfo_dtmf_key</string>
|
||||
<string name="pref_voice_mail_key">pref_voice_mail_key</string>
|
||||
<string name="pref_dialer_call_key">pref_dialer_call_key</string>
|
||||
<string name="pref_upnp_enable_key">pref_upnp_enable_key</string>
|
||||
|
||||
<string name="pref_first_time_linphone_chat_storage">pref_first_time_linphone_chat_storage</string>
|
||||
|
|
|
@ -358,6 +358,7 @@
|
|||
<string name="pref_sipinfo_dtmf">Send out-band DTMFs(SIP INFO)</string>
|
||||
<string name="pref_call_timeout_title">Call timeout(in seconds)</string>
|
||||
<string name="pref_voice_mail">Voice mail URI</string>
|
||||
<string name="pref_dialer_call">Use Linphone as default phone app</string>
|
||||
|
||||
<!-- Chat settings -->
|
||||
<string name="pref_chat_title">Chat</string>
|
||||
|
|
|
@ -225,6 +225,12 @@
|
|||
android:key="@string/pref_voice_mail_key"
|
||||
android:persistent="false"/>
|
||||
|
||||
<CheckBoxPreference
|
||||
android:title="@string/pref_dialer_call"
|
||||
android:key="@string/pref_dialer_call_key"
|
||||
android:persistent="false"/>
|
||||
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
|
|
@ -1639,7 +1639,6 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
file = new File(imageUri);
|
||||
contentUri = FileProvider.getUriForFile(getActivity(), "org.linphone.provider", file);
|
||||
} else if (imageUri.startsWith("content://")) {
|
||||
Log.e("===>>> ChatFragment - getView() - imageUri = "+imageUri);
|
||||
contentUri = Uri.parse(imageUri);
|
||||
} else {
|
||||
file = new File(imageUri);
|
||||
|
|
|
@ -17,18 +17,11 @@ You should have received a copy of the GNU General Public License
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.mediastream.Log;
|
||||
import org.linphone.ui.AddressAware;
|
||||
import org.linphone.ui.AddressText;
|
||||
import org.linphone.ui.CallButton;
|
||||
import org.linphone.ui.EraseButton;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
|
@ -36,6 +29,13 @@ import android.view.ViewGroup;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.mediastream.Log;
|
||||
import org.linphone.ui.AddressAware;
|
||||
import org.linphone.ui.AddressText;
|
||||
import org.linphone.ui.CallButton;
|
||||
import org.linphone.ui.EraseButton;
|
||||
|
||||
/**
|
||||
* @author Sylvain Berfini
|
||||
*/
|
||||
|
@ -63,14 +63,14 @@ public class DialerFragment extends Fragment {
|
|||
|
||||
mCall = (CallButton) view.findViewById(R.id.call);
|
||||
mCall.setAddressWidget(mAddress);
|
||||
if (LinphoneActivity.isInstanciated() && LinphoneManager.getLc().getCallsNb() > 0) {
|
||||
if (LinphoneActivity.isInstanciated() && LinphoneManager.getLcIfManagerNotDestroyedOrNull() != null && LinphoneManager.getLcIfManagerNotDestroyedOrNull().getCallsNb() > 0) {
|
||||
if (isCallTransferOngoing) {
|
||||
mCall.setImageResource(R.drawable.call_transfer);
|
||||
} else {
|
||||
mCall.setImageResource(R.drawable.call_add);
|
||||
}
|
||||
} else {
|
||||
if (LinphoneManager.getLc().getVideoAutoInitiatePolicy()) {
|
||||
if (LinphoneManager.getLcIfManagerNotDestroyedOrNull() != null && LinphoneManager.getLcIfManagerNotDestroyedOrNull().getVideoAutoInitiatePolicy()) {
|
||||
mCall.setImageResource(R.drawable.call_video_start);
|
||||
} else {
|
||||
mCall.setImageResource(R.drawable.call_audio_start);
|
||||
|
@ -83,7 +83,7 @@ public class DialerFragment extends Fragment {
|
|||
}
|
||||
|
||||
mAddContact = (ImageView) view.findViewById(R.id.add_contact);
|
||||
mAddContact.setEnabled(!(LinphoneActivity.isInstanciated() && LinphoneManager.getLc().getCallsNb() > 0));
|
||||
mAddContact.setEnabled(!(LinphoneActivity.isInstanciated() && LinphoneManager.getLcIfManagerNotDestroyedOrNull() != null && LinphoneManager.getLc().getCallsNb() > 0));
|
||||
|
||||
addContactListener = new OnClickListener() {
|
||||
@Override
|
||||
|
@ -215,7 +215,7 @@ public class DialerFragment extends Fragment {
|
|||
}
|
||||
|
||||
public void enableDisableAddContact() {
|
||||
mAddContact.setEnabled(LinphoneManager.getLc().getCallsNb() > 0 || !mAddress.getText().toString().equals(""));
|
||||
mAddContact.setEnabled(LinphoneManager.getLcIfManagerNotDestroyedOrNull() != null && LinphoneManager.getLc().getCallsNb() > 0 || !mAddress.getText().toString().equals(""));
|
||||
}
|
||||
|
||||
public void displayTextInAddressBar(String numberOrSipAddress) {
|
||||
|
|
|
@ -1475,7 +1475,6 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
((SettingsFragment) fragment).closePreferenceScreen();
|
||||
}
|
||||
}
|
||||
|
||||
Bundle extras = intent.getExtras();
|
||||
if (extras != null && extras.getBoolean("GoToChat", false)) {
|
||||
LinphoneService.instance().removeMessageNotification();
|
||||
|
@ -1494,6 +1493,15 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
LinphoneCall call = LinphoneManager.getLc().getCalls()[0];
|
||||
startIncallActivity(call);
|
||||
}
|
||||
}else if (extras != null && extras.getBoolean("StartCall", false)) {
|
||||
boolean extraBool = extras.getBoolean("StartCall", false);
|
||||
if (CallActivity.isInstanciated()) {
|
||||
CallActivity.instance().startIncomingCallActivity();
|
||||
} else {
|
||||
mAddressWaitingToBeCalled = extras.getString("NumberToCall");
|
||||
goToDialerFragment();
|
||||
//startActivity(new Intent(this, CallIncomingActivity.class));
|
||||
}
|
||||
} else {
|
||||
DialerFragment dialerFragment = DialerFragment.instance();
|
||||
if (dialerFragment != null) {
|
||||
|
|
|
@ -41,6 +41,8 @@ import static android.content.Intent.ACTION_MAIN;
|
|||
*/
|
||||
public class LinphoneLauncherActivity extends Activity {
|
||||
|
||||
private final String ACTION_CALL_LINPHONE = "org.linphone.intent.action.CallLaunched";
|
||||
|
||||
private Handler mHandler;
|
||||
private ServiceWaitThread mServiceThread;
|
||||
private String addressToCall;
|
||||
|
@ -148,6 +150,13 @@ public class LinphoneLauncherActivity extends Activity {
|
|||
}
|
||||
newIntent.putExtra("fileShared", stringUriFileShared);
|
||||
}
|
||||
}else if( ACTION_CALL_LINPHONE.equals(action) && (intent.getStringExtra("NumberToCall") != null)) {
|
||||
String numberToCall = intent.getStringExtra("NumberToCall");
|
||||
if (CallActivity.isInstanciated()) {
|
||||
CallActivity.instance().startIncomingCallActivity();
|
||||
} else {
|
||||
LinphoneManager.getInstance().newOutgoingCall(numberToCall, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (uriToResolve != null) {
|
||||
|
|
|
@ -154,10 +154,12 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
|||
private BroadcastReceiver mKeepAliveReceiver;
|
||||
private BroadcastReceiver mDozeReceiver;
|
||||
private BroadcastReceiver mHookReceiver;
|
||||
private BroadcastReceiver mCallReceiver;
|
||||
private BroadcastReceiver mNetworkReceiver;
|
||||
private IntentFilter mKeepAliveIntentFilter;
|
||||
private IntentFilter mDozeIntentFilter;
|
||||
private IntentFilter mHookIntentFilter;
|
||||
private IntentFilter mCallIntentFilter;
|
||||
private IntentFilter mNetworkIntentFilter;
|
||||
private Handler mHandler = new Handler();
|
||||
private WakeLock mIncallWakeLock;
|
||||
|
@ -707,6 +709,11 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
|||
} catch (Exception e) {
|
||||
Log.e(e);
|
||||
}
|
||||
try {
|
||||
mServiceContext.unregisterReceiver(mCallReceiver);
|
||||
} catch (Exception e) {
|
||||
Log.e(e);
|
||||
}
|
||||
try {
|
||||
mServiceContext.unregisterReceiver(mKeepAliveReceiver);
|
||||
} catch (Exception e) {
|
||||
|
@ -714,7 +721,9 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
|||
}
|
||||
try {
|
||||
dozeManager(false);
|
||||
} catch (Exception e) {
|
||||
} catch (IllegalArgumentException iae) {
|
||||
Log.e(iae);
|
||||
}catch (Exception e) {
|
||||
Log.e(e);
|
||||
}
|
||||
mLc = null;
|
||||
|
@ -731,9 +740,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
|||
try {
|
||||
copyAssetsFromPackage();
|
||||
//traces alway start with traces enable to not missed first initialization
|
||||
|
||||
mLc = LinphoneCoreFactory.instance().createLinphoneCore(this, mLinphoneConfigFile, mLinphoneFactoryConfigFile, null, c);
|
||||
|
||||
TimerTask lTask = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -750,8 +757,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
|||
/*use schedule instead of scheduleAtFixedRate to avoid iterate from being call in burst after cpu wake up*/
|
||||
mTimer = new Timer("Linphone scheduler");
|
||||
mTimer.schedule(lTask, 0, 20);
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
Log.e(e, "Cannot start linphone");
|
||||
}
|
||||
}
|
||||
|
@ -840,15 +846,21 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
|||
mKeepAliveReceiver = new KeepAliveReceiver();
|
||||
mServiceContext.registerReceiver(mKeepAliveReceiver, mKeepAliveIntentFilter);
|
||||
|
||||
mDozeIntentFilter = new IntentFilter();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
mDozeIntentFilter.addAction(PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED);
|
||||
}
|
||||
mCallIntentFilter = new IntentFilter("android.intent.action.ACTION_NEW_OUTGOING_CALL");
|
||||
mCallIntentFilter.setPriority(99999999);
|
||||
mCallReceiver = new OutgoingCallReceiver();
|
||||
try {
|
||||
mServiceContext.registerReceiver(mCallReceiver, mCallIntentFilter);
|
||||
}catch(IllegalArgumentException e){e.printStackTrace();}
|
||||
mProximityWakelock = mPowerManager.newWakeLock(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK, "manager_proximity_sensor");
|
||||
|
||||
|
||||
mDozeReceiver = new DozeReceiver();
|
||||
|
||||
if (mPrefs.isDozeModeEnabled()) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
mDozeIntentFilter = new IntentFilter();
|
||||
mDozeIntentFilter.addAction(PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED);
|
||||
mDozeReceiver = new DozeReceiver();
|
||||
dozeModeEnabled = ((PowerManager) mServiceContext.getSystemService(Context.POWER_SERVICE)).isDeviceIdleMode();
|
||||
if (dozeModeEnabled)
|
||||
mServiceContext.registerReceiver(mDozeReceiver, mDozeIntentFilter);
|
||||
|
@ -860,8 +872,6 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
|||
mHookReceiver = new HookReceiver();
|
||||
mServiceContext.registerReceiver(mHookReceiver, mHookIntentFilter);
|
||||
|
||||
mProximityWakelock = mPowerManager.newWakeLock(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK, "manager_proximity_sensor");
|
||||
|
||||
// Since Android N we need to register the network manager
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
|
||||
mNetworkReceiver = new NetworkManager();
|
||||
|
@ -1045,8 +1055,15 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
|||
} catch (Exception e) {
|
||||
Log.e(e);
|
||||
}
|
||||
try {
|
||||
mServiceContext.unregisterReceiver(mCallReceiver);
|
||||
} catch (Exception e) {
|
||||
Log.e(e);
|
||||
}
|
||||
try {
|
||||
dozeManager(false);
|
||||
} catch (IllegalArgumentException iae) {
|
||||
Log.e(iae);
|
||||
} catch (Exception e) {
|
||||
Log.e(e);
|
||||
}
|
||||
|
@ -1062,7 +1079,14 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
|||
dozeModeEnabled = true;
|
||||
} else {
|
||||
Log.i("[Doze Mode]: unregister");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
try {
|
||||
mServiceContext.unregisterReceiver(mDozeReceiver);
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
dozeModeEnabled = false;
|
||||
}
|
||||
}
|
||||
|
@ -1274,6 +1298,8 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
|||
Log.e("LinphoneManager"," globalState ON");
|
||||
initLiblinphone(lc);
|
||||
|
||||
}catch(IllegalArgumentException iae){
|
||||
Log.e(iae);
|
||||
} catch (LinphoneCoreException e) {
|
||||
Log.e(e);
|
||||
}
|
||||
|
|
|
@ -19,12 +19,10 @@ along with this program; if not, write to the Free Software
|
|||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
|
||||
import org.linphone.core.LinphoneAddress;
|
||||
import org.linphone.core.LinphoneAddress.TransportType;
|
||||
|
@ -43,10 +41,12 @@ import org.linphone.core.TunnelConfig;
|
|||
import org.linphone.mediastream.Log;
|
||||
import org.linphone.purchase.Purchasable;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @author Sylvain Berfini
|
||||
|
@ -1001,7 +1001,15 @@ public class LinphonePreferences {
|
|||
public void setVoiceMailUri(String uri) {
|
||||
getConfig().setString("app", "voice_mail", uri);
|
||||
}
|
||||
// End of call settings
|
||||
|
||||
public boolean getNativeDialerCall() {
|
||||
return getConfig().getBool("app", "native_dialer_call", false);
|
||||
}
|
||||
|
||||
public void setNativeDialerCall(boolean use) {
|
||||
getConfig().setBool("app", "native_dialer_call", use);
|
||||
}
|
||||
// End of call settings
|
||||
|
||||
// Network settings
|
||||
public void setWifiOnlyEnabled(Boolean enable) {
|
||||
|
|
|
@ -885,6 +885,7 @@ public class SettingsFragment extends PreferencesListFragment {
|
|||
CheckBoxPreference autoAnswer = (CheckBoxPreference) findPreference(getString(R.string.pref_auto_answer_key));
|
||||
CheckBoxPreference rfc2833 = (CheckBoxPreference) findPreference(getString(R.string.pref_rfc2833_dtmf_key));
|
||||
CheckBoxPreference sipInfo = (CheckBoxPreference) findPreference(getString(R.string.pref_sipinfo_dtmf_key));
|
||||
CheckBoxPreference dialerCall = (CheckBoxPreference) findPreference(getString(R.string.pref_dialer_call_key));
|
||||
EditTextPreference incTimeout = (EditTextPreference) findPreference(getString(R.string.pref_incoming_call_timeout_key));
|
||||
EditTextPreference autoAnswerTime = (EditTextPreference) findPreference(getString(R.string.pref_auto_answer_time_key));
|
||||
|
||||
|
@ -904,6 +905,7 @@ public class SettingsFragment extends PreferencesListFragment {
|
|||
}
|
||||
|
||||
setPreferenceDefaultValueAndSummary(R.string.pref_voice_mail_key, mPrefs.getVoiceMailUri());
|
||||
dialerCall.setChecked(mPrefs.getNativeDialerCall());
|
||||
}
|
||||
|
||||
public void enableDeviceRingtone(boolean enabled) {
|
||||
|
@ -997,6 +999,15 @@ public class SettingsFragment extends PreferencesListFragment {
|
|||
}
|
||||
});
|
||||
|
||||
findPreference(getString(R.string.pref_dialer_call_key)).setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
boolean use = (Boolean) newValue;
|
||||
mPrefs.setNativeDialerCall(use);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
findPreference(getString(R.string.pref_incoming_call_timeout_key)).setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
|
|
Loading…
Reference in a new issue