After a crash, finish some autostarting activities.
- auto restart of activities when service crash spotted on Samsung devices; - only some activities supported: incall, conference, linphoneactivity.
This commit is contained in:
parent
f2e13e6a5b
commit
ff81ad9a30
6 changed files with 32 additions and 4 deletions
|
@ -28,6 +28,7 @@ import org.linphone.LinphoneSimpleListener.LinphoneOnCallStateChangedListener;
|
|||
import org.linphone.core.LinphoneAddress;
|
||||
import org.linphone.core.LinphoneCall;
|
||||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.Log;
|
||||
import org.linphone.core.LinphoneCall.State;
|
||||
|
||||
import android.app.ListActivity;
|
||||
|
@ -82,6 +83,15 @@ public abstract class AbstractCalleesActivity extends ListActivity implements Li
|
|||
|
||||
protected abstract CalleeListAdapter createCalleeListAdapter();
|
||||
|
||||
protected final boolean finishIfAutoRestartAfterACrash() {
|
||||
if (!LinphoneManager.isInstanciated() || LinphoneManager.getLc().getCallsNb() == 0) {
|
||||
Log.e("No service running: avoid crash by finishing ", this.getClass().getName());
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
mSpecificCalls = updateSpecificCallsList();
|
||||
|
|
|
@ -87,12 +87,13 @@ public class CallManager {
|
|||
|
||||
// Check if video possible regarding bandwidth limitations
|
||||
bm().updateWithProfileSettings(lc, params);
|
||||
|
||||
// Abort if not enough bandwidth...
|
||||
if (!params.getVideoEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Not yet in video call: try to re-invite with video
|
||||
params.setVideoEnabled(true);
|
||||
lc.updateCall(lCall, params);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ public class ConferenceDetailsActivity extends AbstractCalleesActivity {
|
|||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
if (finishIfAutoRestartAfterACrash()) return;
|
||||
setContentView(R.layout.conference_details_layout);
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
|
|
@ -89,6 +89,7 @@ public class IncallActivity extends AbstractCalleesActivity implements
|
|||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
if (finishIfAutoRestartAfterACrash()) return;
|
||||
setContentView(R.layout.incall_layout);
|
||||
|
||||
mAllowTransfers = getResources().getBoolean(R.bool.allow_transfers);
|
||||
|
|
|
@ -95,6 +95,11 @@ public class LinphoneActivity extends TabActivity implements
|
|||
}
|
||||
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
if (!LinphoneManager.isInstanciated()) {
|
||||
Log.e("No service running: avoid crash by finishing ", this.getClass().getName());
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
instance = this;
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.main);
|
||||
|
@ -424,15 +429,20 @@ public class LinphoneActivity extends TabActivity implements
|
|||
// Do not call if video activity already launched as it would cause a pause() of the launched one
|
||||
// and a race condition with capture surfaceview leading to a crash
|
||||
public void startVideoActivity(final LinphoneCall call, int delay) {
|
||||
if (VideoCallActivity.launched || call == null) return;
|
||||
if (VideoCallActivity.launched || call == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
mHandler.postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
LinphoneManager.getInstance().enableCamera(call, true);
|
||||
if (VideoCallActivity.launched) return;
|
||||
LinphoneManager.getInstance().enableCamera(call, true);
|
||||
startActivityForResult(new Intent().setClass(
|
||||
LinphoneActivity.this,
|
||||
VideoCallActivity.class),
|
||||
video_activity);
|
||||
// Avoid two consecutive runs to enter the previous block
|
||||
VideoCallActivity.launched = true;
|
||||
}
|
||||
}, delay);
|
||||
LinphoneManager.getInstance().routeAudioToSpeaker();
|
||||
|
|
|
@ -60,6 +60,11 @@ public class VideoCallActivity extends Activity implements LinphoneOnCallStateCh
|
|||
private Runnable mCallQualityUpdater;
|
||||
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
if (!LinphoneManager.isInstanciated() || LinphoneManager.getLc().getCallsNb() == 0) {
|
||||
Log.e("No service running: avoid crash by finishing ", this.getClass().getName());
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
Log.d("onCreate VideoCallActivity");
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.videocall);
|
||||
|
|
Loading…
Reference in a new issue