bug 665716 - build breaks when building SUTAgent with sdk level 11 r=blassey

This commit is contained in:
Brad Lassey 2011-08-09 22:05:17 -04:00
parent d3e424a1a7
commit dafd3ec7f5
2 changed files with 39 additions and 5 deletions

View File

@ -65,15 +65,20 @@ public class ASMozStub extends android.app.Service {
Timer timer = null;
@SuppressWarnings("unchecked")
private static final Class[] mStartForegroundSignature = new Class[] {
private static final Class<?>[] mSetForegroundSignature = new Class[] {
boolean.class};
@SuppressWarnings("unchecked")
private static final Class<?>[] mStartForegroundSignature = new Class[] {
int.class, Notification.class};
@SuppressWarnings("unchecked")
private static final Class[] mStopForegroundSignature = new Class[] {
private static final Class<?>[] mStopForegroundSignature = new Class[] {
boolean.class};
private NotificationManager mNM;
private Method mSetForeground;
private Method mStartForeground;
private Method mStopForeground;
private Object[] mSetForegroundArgs = new Object[1];
private Object[] mStartForegroundArgs = new Object[2];
private Object[] mStopForegroundArgs = new Object[1];
@ -97,6 +102,13 @@ public class ASMozStub extends android.app.Service {
mStartForeground = mStopForeground = null;
}
try {
mSetForeground = getClass().getMethod("setForeground", mSetForegroundSignature);
}
catch (NoSuchMethodException e) {
mSetForeground = null;
}
doToast("Listener Service created...");
}
@ -183,7 +195,18 @@ public class ASMozStub extends android.app.Service {
}
// Fall back on the old API.
setForeground(true);
if (mSetForeground != null) {
try {
mSetForegroundArgs[0] = Boolean.TRUE;
mSetForeground.invoke(this, mSetForegroundArgs);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
mNM.notify(id, notification);
}
@ -210,6 +233,17 @@ public class ASMozStub extends android.app.Service {
// Fall back on the old API. Note to cancel BEFORE changing the
// foreground state, since we could be killed at that point.
mNM.cancel(id);
setForeground(false);
if (mSetForeground != null) {
try {
mSetForegroundArgs[0] = Boolean.FALSE;
mSetForeground.invoke(this, mSetForegroundArgs);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
}

View File

@ -137,7 +137,7 @@ public class DoCommand {
String ffxProvider = "org.mozilla.ffxcp";
String fenProvider = "org.mozilla.fencp";
private final String prgVersion = "SUTAgentAndroid Version 1.01";
private final String prgVersion = "SUTAgentAndroid Version 1.02";
public enum Command
{