Removed keep alive receiver, now in library
This commit is contained in:
parent
57148290d1
commit
350fc02997
3 changed files with 0 additions and 98 deletions
|
@ -249,9 +249,6 @@
|
|||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<!-- This one needs to be registered from application -->
|
||||
<receiver android:name=".receivers.KeepAliveReceiver" />
|
||||
|
||||
<receiver android:name=".receivers.HookReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="com.base.module.phone.HOOKEVENT" />
|
||||
|
|
|
@ -119,7 +119,6 @@ import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration.
|
|||
import org.linphone.mediastream.video.capture.hwconf.Hacks;
|
||||
import org.linphone.receivers.BluetoothManager;
|
||||
import org.linphone.receivers.HookReceiver;
|
||||
import org.linphone.receivers.KeepAliveReceiver;
|
||||
import org.linphone.receivers.OutgoingCallReceiver;
|
||||
import org.linphone.settings.LinphonePreferences;
|
||||
import org.linphone.utils.FileUtils;
|
||||
|
@ -174,10 +173,8 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
|||
private boolean mEchoTesterIsRunning;
|
||||
private boolean mCallGsmON;
|
||||
private final ConnectivityManager mConnectivityManager;
|
||||
private BroadcastReceiver mKeepAliveReceiver;
|
||||
private BroadcastReceiver mHookReceiver;
|
||||
private BroadcastReceiver mCallReceiver;
|
||||
private IntentFilter mKeepAliveIntentFilter;
|
||||
private IntentFilter mHookIntentFilter;
|
||||
private IntentFilter mCallIntentFilter;
|
||||
private final Handler mHandler = new Handler();
|
||||
|
@ -676,11 +673,6 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
|||
} catch (Exception e) {
|
||||
Log.e("[Manager] unregister receiver exception: " + e);
|
||||
}
|
||||
try {
|
||||
mServiceContext.unregisterReceiver(mKeepAliveReceiver);
|
||||
} catch (Exception e) {
|
||||
Log.e("[Manager] unregister receiver exception: " + e);
|
||||
}
|
||||
mCore = null;
|
||||
}
|
||||
}
|
||||
|
@ -776,17 +768,6 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
|||
initPushNotificationsService();
|
||||
}
|
||||
|
||||
/*
|
||||
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);
|
||||
|
||||
mCallIntentFilter = new IntentFilter("android.intent.action.ACTION_NEW_OUTGOING_CALL");
|
||||
mCallIntentFilter.setPriority(99999999);
|
||||
mCallReceiver = new OutgoingCallReceiver();
|
||||
|
|
|
@ -1,76 +0,0 @@
|
|||
package org.linphone.receivers;
|
||||
|
||||
/*
|
||||
KeepAliveReceiver.java
|
||||
Copyright (C) 2017 Belledonne Communications, Grenoble, France
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
import android.app.AlarmManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.SystemClock;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.core.Core;
|
||||
import org.linphone.core.tools.Log;
|
||||
|
||||
/*
|
||||
* 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()) {
|
||||
Core lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
if (lc == null) return;
|
||||
|
||||
String action = intent.getAction();
|
||||
if (action == null) {
|
||||
Log.i("[KeepAlive] Refresh registers");
|
||||
lc.refreshRegisters();
|
||||
// make sure iterate will have enough time, device will not sleep until exit from
|
||||
// this method
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
Log.e("Cannot sleep for 2s", e);
|
||||
} finally {
|
||||
// make sure the application will at least wakes up every 10 mn
|
||||
Intent newIntent = new Intent(context, KeepAliveReceiver.class);
|
||||
PendingIntent keepAlivePendingIntent =
|
||||
PendingIntent.getBroadcast(
|
||||
context, 0, newIntent, PendingIntent.FLAG_ONE_SHOT);
|
||||
|
||||
AlarmManager alarmManager =
|
||||
((AlarmManager) context.getSystemService(Context.ALARM_SERVICE));
|
||||
alarmManager.setExact(
|
||||
AlarmManager.ELAPSED_REALTIME_WAKEUP,
|
||||
SystemClock.elapsedRealtime() + 600000,
|
||||
keepAlivePendingIntent);
|
||||
}
|
||||
} else if (action.equalsIgnoreCase(Intent.ACTION_SCREEN_ON)) {
|
||||
Log.i("[KeepAlive] Screen is on, enable");
|
||||
lc.enableKeepAlive(true);
|
||||
} else if (action.equalsIgnoreCase(Intent.ACTION_SCREEN_OFF)) {
|
||||
Log.i("[KeepAlive] Screen is off, disable");
|
||||
lc.enableKeepAlive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue