Fix overlay crash on rotation + go back to call activity when clicking on overlay

This commit is contained in:
Sylvain Berfini 2016-07-12 14:27:22 +02:00
parent dbdb72c465
commit d53ee51346
4 changed files with 13 additions and 14 deletions

View file

@ -18,6 +18,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
import org.linphone.core.LinphoneCoreFactory;
import org.linphone.mediastream.Log;
import android.content.BroadcastReceiver;
@ -25,10 +26,13 @@ import android.content.Context;
import android.content.Intent;
public class KeepAliveHandler extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
//Log.i("Keep alive handler invoked"); //TODO FIXME Crash since the log rework
boolean isDebugEnabled = LinphonePreferences.instance().isDebugEnabled();
LinphoneCoreFactory.instance().enableLogCollection(isDebugEnabled);
LinphoneCoreFactory.instance().setDebugMode(isDebugEnabled, context.getString(R.string.app_name));
Log.i("Keep alive handler invoked");
if (LinphoneManager.getLcIfManagerNotDestroyedOrNull() != null) {
//first refresh registers
LinphoneManager.getLc().refreshRegisters();
@ -38,9 +42,6 @@ public class KeepAliveHandler extends BroadcastReceiver {
} catch (InterruptedException e) {
//Log.e("Cannot sleep for 2s", e); //TODO FIXME Crash since the log rework
}
}
}
}

View file

@ -29,10 +29,8 @@ import android.content.Intent;
* Purpose of this receiver is to disable keep alives when screen is off
* */
public class KeepAliveReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (!LinphoneService.isReady()) {
Log.i("Keep alive broadcast received while Linphone service not ready");
return;
@ -43,7 +41,5 @@ public class KeepAliveReceiver extends BroadcastReceiver {
LinphoneManager.getLc().enableKeepAlive(false);
}
}
}
}

View file

@ -49,7 +49,6 @@ import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.PixelFormat;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
@ -57,7 +56,6 @@ import android.os.IBinder;
import android.os.SystemClock;
import android.provider.ContactsContract;
import android.provider.MediaStore;
import android.view.Gravity;
import android.view.WindowManager;
/**
@ -314,7 +312,7 @@ public final class LinphoneService extends Service {
public void destroyOverlay() {
if (mOverlay != null) {
mWindowManager.removeView(mOverlay);
mWindowManager.removeViewImmediate(mOverlay);
mOverlay.destroy();
}
mOverlay = null;

View file

@ -1,11 +1,14 @@
package org.linphone.ui;
import org.linphone.LinphoneActivity;
import org.linphone.LinphoneManager;
import org.linphone.LinphoneService;
import org.linphone.core.LinphoneCall;
import org.linphone.core.LinphoneCallParams;
import org.linphone.mediastream.video.AndroidVideoWindowImpl;
import android.content.Context;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
@ -48,7 +51,6 @@ public class LinphoneOverlay extends org.linphone.mediastream.video.display.GL2J
}
public void onVideoPreviewSurfaceReady(AndroidVideoWindowImpl vw, SurfaceView surface) {
LinphoneManager.getLc().setPreviewWindow(null);
}
public void onVideoPreviewSurfaceDestroyed(AndroidVideoWindowImpl vw) {
@ -64,7 +66,9 @@ public class LinphoneOverlay extends org.linphone.mediastream.video.display.GL2J
setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Context context = LinphoneService.instance();
Intent intent = new Intent(context, LinphoneActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
});
}