From 226bdbae183f9108e9747e5ea0ecad572af63948 Mon Sep 17 00:00:00 2001 From: Margaux Clerc Date: Wed, 18 Feb 2015 15:24:33 +0100 Subject: [PATCH] Remove wifi lock --- src/org/linphone/LinphoneService.java | 30 ++------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/src/org/linphone/LinphoneService.java b/src/org/linphone/LinphoneService.java index 77faafc09..034867c38 100644 --- a/src/org/linphone/LinphoneService.java +++ b/src/org/linphone/LinphoneService.java @@ -35,7 +35,6 @@ import org.linphone.core.LinphoneProxyConfig; import org.linphone.mediastream.Log; import org.linphone.mediastream.Version; -import android.annotation.TargetApi; import android.app.Activity; import android.app.AlarmManager; import android.app.Notification; @@ -49,8 +48,6 @@ import android.content.pm.PackageManager.NameNotFoundException; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.net.Uri; -import android.net.wifi.WifiManager; -import android.net.wifi.WifiManager.WifiLock; import android.os.Build; import android.os.Handler; import android.os.IBinder; @@ -105,8 +102,6 @@ public final class LinphoneService extends Service { // private boolean mTestDelayElapsed; // add a timer for testing private boolean mTestDelayElapsed = true; // no timer - private WifiManager mWifiManager; - private WifiLock mWifiLock; private NotificationManager mNM; private Notification mNotif; @@ -159,11 +154,7 @@ public final class LinphoneService extends Service { mNotif = Compatibility.createNotification(this, mNotificationTitle, "", R.drawable.status_level, IC_LEVEL_OFFLINE, bm, mNotifContentIntent, true); LinphoneManager.createAndStart(LinphoneService.this); - - mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); - if (Version.sdkAboveOrEqual(Version.API12_HONEYCOMB_MR1_31X)) { - startWifiLock(); - } + instance = this; // instance is ready once linphone manager has been created LinphoneManager.getLc().addListener(mListener = new LinphoneCoreListenerBase(){ @@ -196,18 +187,10 @@ public final class LinphoneService extends Service { // Workaround bug current call seems to be updated after state changed to streams running if (getResources().getBoolean(R.bool.enable_call_notification)) refreshIncallIcon(call); - if (Version.sdkAboveOrEqual(Version.API12_HONEYCOMB_MR1_31X)) { - mWifiLock.acquire(); - } } else { if (getResources().getBoolean(R.bool.enable_call_notification)) refreshIncallIcon(LinphoneManager.getLc().getCurrentCall()); } - if ((state == State.CallEnd || state == State.Error) && LinphoneManager.getLc().getCallsNb() < 1) { - if (Version.sdkAboveOrEqual(Version.API12_HONEYCOMB_MR1_31X)) { - mWifiLock.release(); - } - } } @Override @@ -275,12 +258,6 @@ public final class LinphoneService extends Service { , 600000 , mkeepAlivePendingIntent); } - - @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1) - private void startWifiLock() { - mWifiLock = mWifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, this.getPackageName()+"-wifi-call-lock"); - mWifiLock.setReferenceCounted(false); - } private enum IncallIconState {INCALL, PAUSE, VIDEO, IDLE} private IncallIconState mCurrentIncallIconState = IncallIconState.IDLE; @@ -569,10 +546,7 @@ public final class LinphoneService extends Service { stopForegroundCompat(NOTIF_ID); mNM.cancel(INCALL_NOTIF_ID); mNM.cancel(MESSAGE_NOTIF_ID); - - if (Version.sdkAboveOrEqual(Version.API12_HONEYCOMB_MR1_31X)) { - mWifiLock.release(); - } + ((AlarmManager) this.getSystemService(Context.ALARM_SERVICE)).cancel(mkeepAlivePendingIntent); super.onDestroy(); }