Android: Change headphone detection to call into native.

Making a JNI call from tick tasks is not permitted as the underlying thread
is not attached to the Java VM. This is an error and crashes in the emulator
(which has stricter JNI checks enabled by default).

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30173 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Thomas Martitz 2011-07-19 23:44:56 +00:00
parent b8bfa84d1b
commit b2f52477df
3 changed files with 29 additions and 18 deletions

View file

@ -29,7 +29,6 @@ import android.content.IntentFilter;
public class HeadphoneMonitor extends BroadcastReceiver
{
@SuppressWarnings("unused")
private int mHpState; /* read by native code */
public HeadphoneMonitor(Context c)
{
@ -45,7 +44,7 @@ public class HeadphoneMonitor extends BroadcastReceiver
public void onReceive(Context arg0, Intent intent)
{
int state = intent.getIntExtra("state", -1);
mHpState = state;
postHpStateChanged(state);
}
/* audio becoming noise acts as headphones extracted */
@ -54,7 +53,9 @@ public class HeadphoneMonitor extends BroadcastReceiver
@Override
public void onReceive(Context arg0, Intent arg1)
{
mHpState = 0;
postHpStateChanged(0);
}
}
private synchronized native void postHpStateChanged(int state);
}