summaryrefslogtreecommitdiffstats
path: root/android
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-08-07 21:30:22 +0000
committerThomas Martitz <kugel@rockbox.org>2010-08-07 21:30:22 +0000
commitca4439ff65bdc93fc44f4cc1be52aab50217ce78 (patch)
tree06578c5243a9c7b0c4c5dcb322ffb9a4609b5e7a /android
parentf1184f963aea4cb16a5886c71cc662a0503e1cd5 (diff)
downloadrockbox-ca4439ff65bdc93fc44f4cc1be52aab50217ce78.tar.gz
rockbox-ca4439ff65bdc93fc44f4cc1be52aab50217ce78.tar.bz2
rockbox-ca4439ff65bdc93fc44f4cc1be52aab50217ce78.zip
Android port: handle incoming calls.
Stop explicitely if a call comes in, and resume playback (if it was playing before the call) upon hang up. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27746 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'android')
-rw-r--r--android/src/org/rockbox/RockboxTimer.java28
1 files changed, 25 insertions, 3 deletions
diff --git a/android/src/org/rockbox/RockboxTimer.java b/android/src/org/rockbox/RockboxTimer.java
index 6491e4ffe9..68a0e866fb 100644
--- a/android/src/org/rockbox/RockboxTimer.java
+++ b/android/src/org/rockbox/RockboxTimer.java
@@ -24,6 +24,8 @@ package org.rockbox;
import java.util.Timer;
import java.util.TimerTask;
+import android.content.Context;
+import android.telephony.TelephonyManager;
import android.util.Log;
public class RockboxTimer extends Timer
@@ -33,24 +35,42 @@ public class RockboxTimer extends Timer
private class RockboxTimerTask extends TimerTask {
private RockboxTimer t;
- public RockboxTimerTask(RockboxTimer parent) {
+ private TelephonyManager tm;
+ private int last_state;
+ public RockboxTimerTask(RockboxService s, RockboxTimer parent) {
super();
t = parent;
+ tm = (TelephonyManager)s.getSystemService(Context.TELEPHONY_SERVICE);
+ last_state = tm.getCallState();
}
@Override
public void run() {
timerTask();
+ int state = tm.getCallState();
+ if (state != last_state)
+ {
+ switch (state) {
+ case TelephonyManager.CALL_STATE_IDLE:
+ postCallHungUp();
+ break;
+ case TelephonyManager.CALL_STATE_RINGING:
+ postCallIncoming();
+ default:
+ break;
+ }
+ last_state = state;
+ }
synchronized(t) {
t.notify();
}
}
}
- public RockboxTimer(long period_inverval_in_ms)
+ public RockboxTimer(RockboxService instance, long period_inverval_in_ms)
{
super("tick timer", false);
- task = new RockboxTimerTask(this);
+ task = new RockboxTimerTask(instance, this);
schedule(task, 0, period_inverval_in_ms);
interval = period_inverval_in_ms;
}
@@ -75,4 +95,6 @@ public class RockboxTimer extends Timer
}
}
public native void timerTask();
+ private native void postCallIncoming();
+ private native void postCallHungUp();
}