No more warnings that can't be removed

This commit is contained in:
Sylvain Berfini 2012-08-02 14:39:47 +02:00
parent 7959949ab9
commit 528907057a
7 changed files with 127 additions and 17 deletions

View file

@ -941,12 +941,6 @@ public final class LinphoneManager implements LinphoneCoreListener {
if (state == IncomingReceived || (state == State.CallIncomingEarlyMedia && mR.getBoolean(R.bool.allow_ringing_while_early_media))) {
// Brighten screen for at least 10 seconds
WakeLock wl = mPowerManager.newWakeLock(
PowerManager.ACQUIRE_CAUSES_WAKEUP
|PowerManager.ON_AFTER_RELEASE,
"incoming_call");
wl.acquire(10000);
if (mLc.getCallsNb() == 1) {
ringingCall = call;
startRinging();

View file

@ -22,7 +22,6 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;
import org.linphone.LinphoneManager.NewOutgoingCallUiListener;
import org.linphone.LinphoneSimpleListener.LinphoneServiceListener;
@ -88,7 +87,6 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
private boolean mTestDelayElapsed = true; // no timer
private WifiManager mWifiManager ;
private WifiLock mWifiLock ;
private List<Notification> messagesNotifications;
public static boolean isReady() {
return instance!=null && instance.mTestDelayElapsed;
}
@ -161,7 +159,8 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
Intent notifIntent = new Intent(this, incomingReceivedActivity);
notifIntent.putExtra("Notification", true);
mNotifContentIntent = PendingIntent.getActivity(this, 0, notifIntent, PendingIntent.FLAG_CANCEL_CURRENT);
mNotif.setLatestEventInfo(this, mNotificationTitle,"", mNotifContentIntent);
Compatibility.setNotificationLatestEventInfo(mNotif, this, mNotificationTitle, "", mNotifContentIntent);
LinphoneManager.createAndStart(this, this);
LinphoneManager.getLc().setPresenceInfo(0, null, OnlineStatus.Online);
@ -287,8 +286,7 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
mCustomNotif.defaults |= Notification.DEFAULT_SOUND;
mCustomNotif.defaults |= Notification.DEFAULT_LIGHTS;
mCustomNotif.setLatestEventInfo(this, title, message, notifContentIntent);
Compatibility.setNotificationLatestEventInfo(mCustomNotif, this, title, message, notifContentIntent);
notifyWrapper(CUSTOM_NOTIF_ID, mCustomNotif);
}
@ -435,7 +433,7 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
text = String.format(text, id);
}
mNotif.setLatestEventInfo(this, mNotificationTitle, text, mNotifContentIntent);
Compatibility.setNotificationLatestEventInfo(mNotif, this, mNotificationTitle, text, mNotifContentIntent);
notifyWrapper(NOTIF_ID, mNotif);
}
@ -528,7 +526,7 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
Intent notifIntent = new Intent(this, incomingReceivedActivity);
mNotifContentIntent = PendingIntent.getActivity(this, 0, notifIntent, 0);
mNotif.setLatestEventInfo(this, mNotificationTitle,"", mNotifContentIntent);
Compatibility.setNotificationLatestEventInfo(mNotif, this, mNotificationTitle, "", mNotifContentIntent);
}
protected void onIncomingReceived() {

View file

@ -40,7 +40,8 @@ public class NetworkManager extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
NetworkInfo lNetworkInfo = (NetworkInfo) intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo lNetworkInfo = cm.getActiveNetworkInfo();
Log.i("Network info [",lNetworkInfo,"]");
Boolean lNoConnectivity = intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY,false);
@ -65,9 +66,7 @@ public class NetworkManager extends BroadcastReceiver {
// Other unhandled events
}
NetworkInfo eventInfo = (NetworkInfo) intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
LinphoneManager.getInstance().connectivityChanged(eventInfo, cm);
LinphoneManager.getInstance().connectivityChanged(lNetworkInfo, cm);
}
}

View file

@ -0,0 +1,82 @@
package org.linphone.compatibility;
import org.linphone.R;
import android.annotation.TargetApi;
import android.app.Notification;
import android.app.PendingIntent;
import android.content.Context;
import android.graphics.Bitmap;
/*
ApiElevenPlus.java
Copyright (C) 2012 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
* @author Sylvain Berfini
*/
@TargetApi(11)
public class ApiElevenPlus {
@SuppressWarnings("deprecation")
public static Notification createMessageNotification(Context context,
int msgCount, String msgSender, String msg, Bitmap contactIcon,
PendingIntent intent) {
String title;
if (msgCount == 1) {
title = "Unread message from %s".replace("%s", msgSender);
} else {
title = "%i unread messages"
.replace("%i", String.valueOf(msgCount));
}
Notification notif = new Notification.Builder(context)
.setContentTitle(title)
.setContentText(msg)
.setSmallIcon(R.drawable.chat_icon_over)
.setAutoCancel(true)
.setDefaults(
Notification.DEFAULT_LIGHTS
| Notification.DEFAULT_SOUND
| Notification.DEFAULT_VIBRATE)
.setWhen(System.currentTimeMillis())
.setLargeIcon(contactIcon).getNotification();
notif.contentIntent = intent;
return notif;
}
@SuppressWarnings("deprecation")
public static Notification createInCallNotification(Context context,
String title, String msg, int iconID, Bitmap contactIcon,
String contactName, PendingIntent intent) {
Notification notif = new Notification.Builder(context).setContentTitle(contactName)
.setContentText(msg).setSmallIcon(iconID)
.setAutoCancel(false)
.setWhen(System.currentTimeMillis())
.setLargeIcon(contactIcon).getNotification();
notif.contentIntent = intent;
return notif;
}
public static void setNotificationLatestEventInfo(Notification notif,
Context context, String title, String content, PendingIntent intent) {
notif.contentIntent = intent;
}
}

View file

@ -316,4 +316,9 @@ public class ApiFivePlus {
return notif;
}
@SuppressWarnings("deprecation")
public static void setNotificationLatestEventInfo(Notification notif, Context context, String title, String content, PendingIntent intent) {
notif.setLatestEventInfo(context, title, content, intent);
}
}

View file

@ -7,7 +7,27 @@ import android.app.Notification;
import android.app.PendingIntent;
import android.content.Context;
import android.graphics.Bitmap;
/*
ApiSixteenPlus.java
Copyright (C) 2012 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
* @author Sylvain Berfini
*/
@TargetApi(16)
public class ApiSixteenPlus {

View file

@ -118,6 +118,8 @@ public class Compatibility {
if (Version.sdkAboveOrEqual(16)) {
notif = ApiSixteenPlus.createMessageNotification(context, msgCount, msgSender, msg, contactIcon, intent);
} else if (Version.sdkAboveOrEqual(11)) {
notif = ApiElevenPlus.createMessageNotification(context, msgCount, msgSender, msg, contactIcon, intent);
} else {
notif = ApiFivePlus.createMessageNotification(context, title, msg, intent);
}
@ -129,6 +131,8 @@ public class Compatibility {
if (Version.sdkAboveOrEqual(16)) {
notif = ApiSixteenPlus.createInCallNotification(context, title, msg, iconID, contactIcon, contactName, intent);
} else if (Version.sdkAboveOrEqual(11)) {
notif = ApiElevenPlus.createInCallNotification(context, title, msg, iconID, contactIcon, contactName, intent);
} else {
notif = ApiFivePlus.createInCallNotification(context, title, msg, iconID, intent);
}
@ -149,4 +153,12 @@ public class Compatibility {
return ApiEightPlus.getRotation(display);
}
}
public static void setNotificationLatestEventInfo(Notification notif, Context context, String title, String content, PendingIntent intent) {
if (Version.sdkAboveOrEqual(11)) {
ApiElevenPlus.setNotificationLatestEventInfo(notif, context, title, content, intent);
} else {
ApiFivePlus.setNotificationLatestEventInfo(notif, context, title, content, intent);
}
}
}