Fix crash when don't keep activity flag enabled
This commit is contained in:
parent
6ea2f360ce
commit
4672742b49
2 changed files with 30 additions and 2 deletions
|
@ -46,12 +46,22 @@ import android.widget.Toast;
|
||||||
*/
|
*/
|
||||||
public class IncomingCallActivity extends Activity implements LinphoneOnCallStateChangedListener, LinphoneSliderTriggered {
|
public class IncomingCallActivity extends Activity implements LinphoneOnCallStateChangedListener, LinphoneSliderTriggered {
|
||||||
|
|
||||||
|
private static IncomingCallActivity instance;
|
||||||
|
|
||||||
private TextView mNameView;
|
private TextView mNameView;
|
||||||
private TextView mNumberView;
|
private TextView mNumberView;
|
||||||
private AvatarWithShadow mPictureView;
|
private AvatarWithShadow mPictureView;
|
||||||
private LinphoneCall mCall;
|
private LinphoneCall mCall;
|
||||||
private LinphoneSliders mIncomingCallWidget;
|
private LinphoneSliders mIncomingCallWidget;
|
||||||
|
|
||||||
|
public static IncomingCallActivity instance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isInstanciated() {
|
||||||
|
return instance != null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
|
@ -70,11 +80,13 @@ public class IncomingCallActivity extends Activity implements LinphoneOnCallStat
|
||||||
mIncomingCallWidget.setOnTriggerListener(this);
|
mIncomingCallWidget.setOnTriggerListener(this);
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
instance = this;
|
||||||
LinphoneManager.addListener(this);
|
LinphoneManager.addListener(this);
|
||||||
// Only one call ringing at a time is allowed
|
// Only one call ringing at a time is allowed
|
||||||
List<LinphoneCall> calls = LinphoneUtils.getLinphoneCalls(LinphoneManager.getLc());
|
List<LinphoneCall> calls = LinphoneUtils.getLinphoneCalls(LinphoneManager.getLc());
|
||||||
|
@ -109,6 +121,12 @@ public class IncomingCallActivity extends Activity implements LinphoneOnCallStat
|
||||||
LinphoneManager.removeListener(this);
|
LinphoneManager.removeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
instance = null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||||
if (LinphoneManager.isInstanciated() && (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_HOME)) {
|
if (LinphoneManager.isInstanciated() && (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_HOME)) {
|
||||||
|
|
|
@ -1030,6 +1030,16 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
mThis.preventSIPCalls();
|
mThis.preventSIPCalls();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Context getActivity() {
|
||||||
|
if (LinphoneActivity.isInstanciated())
|
||||||
|
return LinphoneActivity.instance();
|
||||||
|
else if (InCallActivity.isInstanciated())
|
||||||
|
return InCallActivity.instance();
|
||||||
|
else if (IncomingCallActivity.isInstanciated())
|
||||||
|
return IncomingCallActivity.instance();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressLint("Wakelock")
|
@SuppressLint("Wakelock")
|
||||||
public void callState(final LinphoneCore lc,final LinphoneCall call, final State state, final String message) {
|
public void callState(final LinphoneCore lc,final LinphoneCall call, final State state, final String message) {
|
||||||
|
@ -1055,7 +1065,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state == CallEnd || state == Error) {
|
if (state == CallEnd || state == Error) {
|
||||||
TelephonyManager tm = (TelephonyManager) LinphoneActivity.instance().getSystemService(Context.TELEPHONY_SERVICE);
|
TelephonyManager tm = (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
if (tm.getCallState() == TelephonyManager.CALL_STATE_IDLE) {
|
if (tm.getCallState() == TelephonyManager.CALL_STATE_IDLE) {
|
||||||
mAudioManager.setMode(MODE_NORMAL);
|
mAudioManager.setMode(MODE_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -1432,7 +1442,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
boolean sendCamera = mLc.getConferenceSize() == 0;
|
boolean sendCamera = mLc.getConferenceSize() == 0;
|
||||||
enableCamera(call, sendCamera);
|
enableCamera(call, sendCamera);
|
||||||
}
|
}
|
||||||
TelephonyManager tm = (TelephonyManager) LinphoneActivity.instance().getSystemService(Context.TELEPHONY_SERVICE);
|
TelephonyManager tm = (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
if (state == State.CallEnd && mLc.getCallsNb() == 0 && tm.getCallState() == TelephonyManager.CALL_STATE_IDLE) {
|
if (state == State.CallEnd && mLc.getCallsNb() == 0 && tm.getCallState() == TelephonyManager.CALL_STATE_IDLE) {
|
||||||
routeAudioToReceiver();
|
routeAudioToReceiver();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue