Revert part of previous commit as ScreenOn/Off broadcastreceiver must be registered by application
This commit is contained in:
parent
6f51902be9
commit
ad0702277b
3 changed files with 29 additions and 10 deletions
|
@ -207,14 +207,8 @@
|
||||||
<intent-filter><action android:name="android.intent.action.PHONE_STATE" /></intent-filter>
|
<intent-filter><action android:name="android.intent.action.PHONE_STATE" /></intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
<receiver android:name="KeepAliveReceiver">
|
<!-- This one needs to be registered from application -->
|
||||||
<intent-filter>
|
<receiver android:name="KeepAliveReceiver"/>
|
||||||
<action android:name="android.intent.action.SCREEN_ON"></action>
|
|
||||||
</intent-filter>
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.SCREEN_OFF"></action>
|
|
||||||
</intent-filter>
|
|
||||||
</receiver>
|
|
||||||
|
|
||||||
<!-- Needed for push notification -->
|
<!-- Needed for push notification -->
|
||||||
<receiver android:name="org.linphone.gcm.GCMReceiver" android:permission="com.google.android.c2dm.permission.SEND" >
|
<receiver android:name="org.linphone.gcm.GCMReceiver" android:permission="com.google.android.c2dm.permission.SEND" >
|
||||||
|
|
|
@ -80,8 +80,11 @@ import android.annotation.TargetApi;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.hardware.Sensor;
|
import android.hardware.Sensor;
|
||||||
|
@ -140,6 +143,8 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
||||||
private boolean mAudioFocused;
|
private boolean mAudioFocused;
|
||||||
private int mLastNetworkType=-1;
|
private int mLastNetworkType=-1;
|
||||||
private ConnectivityManager mConnectivityManager;
|
private ConnectivityManager mConnectivityManager;
|
||||||
|
private BroadcastReceiver mKeepAliveReceiver;
|
||||||
|
private IntentFilter mKeepAliveIntentFilter;
|
||||||
private Handler mHandler = new Handler();
|
private Handler mHandler = new Handler();
|
||||||
private WakeLock mIncallWakeLock;
|
private WakeLock mIncallWakeLock;
|
||||||
private static List<LinphoneChatMessage> mPendingChatFileMessage;
|
private static List<LinphoneChatMessage> mPendingChatFileMessage;
|
||||||
|
@ -633,6 +638,11 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
||||||
Log.e(e);
|
Log.e(e);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
try {
|
||||||
|
mServiceContext.unregisterReceiver(mKeepAliveReceiver);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(e);
|
||||||
|
}
|
||||||
mLc = null;
|
mLc = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -640,7 +650,12 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
||||||
public void restartLinphoneCore() {
|
public void restartLinphoneCore() {
|
||||||
destroyLinphoneCore();
|
destroyLinphoneCore();
|
||||||
startLibLinphone(mServiceContext);
|
startLibLinphone(mServiceContext);
|
||||||
|
/*
|
||||||
|
You cannot receive this through components declared in manifests, only
|
||||||
|
by explicitly registering for it with Context.registerReceiver(). This is a protected intent that can only
|
||||||
|
be sent by the system.
|
||||||
|
*/
|
||||||
|
mServiceContext.registerReceiver(mKeepAliveReceiver, mKeepAliveIntentFilter);
|
||||||
sExited = false;
|
sExited = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -730,6 +745,16 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
||||||
Compatibility.initPushNotificationService(mServiceContext);
|
Compatibility.initPushNotificationService(mServiceContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
You cannot receive this through components declared in manifests, only
|
||||||
|
by explicitly registering for it with Context.registerReceiver(). This is a protected intent that can only
|
||||||
|
be sent by the system.
|
||||||
|
*/
|
||||||
|
mKeepAliveIntentFilter = new IntentFilter(Intent.ACTION_SCREEN_ON);
|
||||||
|
mKeepAliveIntentFilter.addAction(Intent.ACTION_SCREEN_OFF);
|
||||||
|
mKeepAliveReceiver = new KeepAliveReceiver();
|
||||||
|
mServiceContext.registerReceiver(mKeepAliveReceiver, mKeepAliveIntentFilter);
|
||||||
|
|
||||||
updateNetworkReachability();
|
updateNetworkReachability();
|
||||||
|
|
||||||
if (Version.sdkAboveOrEqual(Version.API11_HONEYCOMB_30)) {
|
if (Version.sdkAboveOrEqual(Version.API11_HONEYCOMB_30)) {
|
||||||
|
@ -845,6 +870,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
||||||
Log.e(e);
|
Log.e(e);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
mServiceContext.unregisterReceiver(mKeepAliveReceiver);
|
||||||
mLc = null;
|
mLc = null;
|
||||||
instance = null;
|
instance = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ package org.linphone;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Calendar;
|
|
||||||
|
|
||||||
import org.linphone.compatibility.Compatibility;
|
import org.linphone.compatibility.Compatibility;
|
||||||
import org.linphone.core.LinphoneAddress;
|
import org.linphone.core.LinphoneAddress;
|
||||||
|
|
Loading…
Reference in a new issue