Fix crash when receiving push notification without service
This commit is contained in:
parent
7c48345625
commit
5a40d15e1b
1 changed files with 16 additions and 0 deletions
|
@ -25,6 +25,7 @@ import org.linphone.LinphonePreferences;
|
||||||
import org.linphone.LinphoneService;
|
import org.linphone.LinphoneService;
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.UIThreadDispatcher;
|
import org.linphone.UIThreadDispatcher;
|
||||||
|
import org.linphone.core.LinphoneCoreFactory;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
@ -44,12 +45,19 @@ public class GCMService extends GCMBaseIntentService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onError(Context context, String errorId) {
|
protected void onError(Context context, String errorId) {
|
||||||
|
boolean isDebugEnabled = LinphonePreferences.instance().isDebugEnabled();
|
||||||
|
LinphoneCoreFactory.instance().enableLogCollection(isDebugEnabled);
|
||||||
|
LinphoneCoreFactory.instance().setDebugMode(isDebugEnabled, context.getString(R.string.app_name));
|
||||||
Log.e("Error while registering push notification : " + errorId);
|
Log.e("Error while registering push notification : " + errorId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onMessage(Context context, Intent intent) {
|
protected void onMessage(Context context, Intent intent) {
|
||||||
|
boolean isDebugEnabled = LinphonePreferences.instance().isDebugEnabled();
|
||||||
|
LinphoneCoreFactory.instance().enableLogCollection(isDebugEnabled);
|
||||||
|
LinphoneCoreFactory.instance().setDebugMode(isDebugEnabled, context.getString(R.string.app_name));
|
||||||
Log.d("Push notification received");
|
Log.d("Push notification received");
|
||||||
|
|
||||||
if (!LinphoneService.isReady()) {
|
if (!LinphoneService.isReady()) {
|
||||||
startService(new Intent(ACTION_MAIN).setClass(this, LinphoneService.class));
|
startService(new Intent(ACTION_MAIN).setClass(this, LinphoneService.class));
|
||||||
} else if (LinphoneManager.isInstanciated() && LinphoneManager.getLc().getCallsNb() == 0) {
|
} else if (LinphoneManager.isInstanciated() && LinphoneManager.getLc().getCallsNb() == 0) {
|
||||||
|
@ -68,13 +76,21 @@ public class GCMService extends GCMBaseIntentService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onRegistered(Context context, String regId) {
|
protected void onRegistered(Context context, String regId) {
|
||||||
|
boolean isDebugEnabled = LinphonePreferences.instance().isDebugEnabled();
|
||||||
|
LinphoneCoreFactory.instance().enableLogCollection(isDebugEnabled);
|
||||||
|
LinphoneCoreFactory.instance().setDebugMode(isDebugEnabled, context.getString(R.string.app_name));
|
||||||
Log.d("Registered push notification : " + regId);
|
Log.d("Registered push notification : " + regId);
|
||||||
|
|
||||||
LinphonePreferences.instance().setPushNotificationRegistrationID(regId);
|
LinphonePreferences.instance().setPushNotificationRegistrationID(regId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onUnregistered(Context context, String regId) {
|
protected void onUnregistered(Context context, String regId) {
|
||||||
|
boolean isDebugEnabled = LinphonePreferences.instance().isDebugEnabled();
|
||||||
|
LinphoneCoreFactory.instance().enableLogCollection(isDebugEnabled);
|
||||||
|
LinphoneCoreFactory.instance().setDebugMode(isDebugEnabled, context.getString(R.string.app_name));
|
||||||
Log.w("Unregistered push notification : " + regId);
|
Log.w("Unregistered push notification : " + regId);
|
||||||
|
|
||||||
LinphonePreferences.instance().setPushNotificationRegistrationID(null);
|
LinphonePreferences.instance().setPushNotificationRegistrationID(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue