diff options
author | Thomas Martitz <kugel@rockbox.org> | 2010-11-12 21:04:13 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2010-11-12 21:04:13 +0000 |
commit | 0cf2cc1607a0844e906042173815451cd9c2ff58 (patch) | |
tree | 77c555919d5c08f9a54f2b28cababe1d2d207f7e /firmware/target/hosted | |
parent | bb56bc4ba08bf6c6458a289ef4918dfaea30b238 (diff) | |
download | rockbox-0cf2cc1607a0844e906042173815451cd9c2ff58.tar.gz rockbox-0cf2cc1607a0844e906042173815451cd9c2ff58.zip |
Android: Change how detecting call state (introduced in r27746) works, from polling to event based.
* For some reason, the polling methid is much more inefficient than I thought. According to htop it caused up to 15% CPU load on some phones (e.g. Galaxy S).
The event based causes no CPU load.
Rockbox' idle CPU load is now back to 0%, while it was previously dominated by polling the call state.
* Also stop on outgoing calls (no need to explicitely pause for making a call anymore).
* Factor out the detection mechanism to separate files.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28564 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/hosted')
-rw-r--r-- | firmware/target/hosted/android/kernel-android.c | 18 | ||||
-rw-r--r-- | firmware/target/hosted/android/system-android.c | 22 | ||||
-rw-r--r-- | firmware/target/hosted/android/telephony-android.c | 54 |
3 files changed, 70 insertions, 24 deletions
diff --git a/firmware/target/hosted/android/kernel-android.c b/firmware/target/hosted/android/kernel-android.c index 636c849c24..c0d927d026 100644 --- a/firmware/target/hosted/android/kernel-android.c +++ b/firmware/target/hosted/android/kernel-android.c | |||
@@ -52,22 +52,6 @@ Java_org_rockbox_RockboxTimer_timerTask(JNIEnv *env, jobject this) | |||
52 | call_tick_tasks(); | 52 | call_tick_tasks(); |
53 | } | 53 | } |
54 | 54 | ||
55 | JNIEXPORT void JNICALL | ||
56 | Java_org_rockbox_RockboxTimer_postCallIncoming(JNIEnv *env, jobject this) | ||
57 | { | ||
58 | (void)env; | ||
59 | (void)this; | ||
60 | queue_broadcast(SYS_CALL_INCOMING, 0); | ||
61 | } | ||
62 | |||
63 | JNIEXPORT void JNICALL | ||
64 | Java_org_rockbox_RockboxTimer_postCallHungUp(JNIEnv *env, jobject this) | ||
65 | { | ||
66 | (void)env; | ||
67 | (void)this; | ||
68 | queue_broadcast(SYS_CALL_HUNG_UP, 0); | ||
69 | } | ||
70 | |||
71 | void tick_start(unsigned int interval_in_ms) | 55 | void tick_start(unsigned int interval_in_ms) |
72 | { | 56 | { |
73 | JNIEnv e = *env_ptr; | 57 | JNIEnv e = *env_ptr; |
@@ -76,7 +60,7 @@ void tick_start(unsigned int interval_in_ms) | |||
76 | jmethodID constructor = e->GetMethodID(env_ptr, | 60 | jmethodID constructor = e->GetMethodID(env_ptr, |
77 | RockboxTimer_class, | 61 | RockboxTimer_class, |
78 | "<init>", | 62 | "<init>", |
79 | "(Lorg/rockbox/RockboxService;J)V"); | 63 | "(Landroid/content/Context;J)V"); |
80 | /* the constructor will do the tick_start */ | 64 | /* the constructor will do the tick_start */ |
81 | RockboxTimer_instance = e->NewObject(env_ptr, | 65 | RockboxTimer_instance = e->NewObject(env_ptr, |
82 | RockboxTimer_class, | 66 | RockboxTimer_class, |
diff --git a/firmware/target/hosted/android/system-android.c b/firmware/target/hosted/android/system-android.c index 7d1fe9d458..009630eeaa 100644 --- a/firmware/target/hosted/android/system-android.c +++ b/firmware/target/hosted/android/system-android.c | |||
@@ -24,10 +24,6 @@ | |||
24 | #include "config.h" | 24 | #include "config.h" |
25 | #include "system.h" | 25 | #include "system.h" |
26 | 26 | ||
27 | void system_exception_wait(void) { } | ||
28 | void system_reboot(void) { } | ||
29 | void power_off(void) { } | ||
30 | void system_init(void) { } | ||
31 | 27 | ||
32 | 28 | ||
33 | /* global fields for use with various JNI calls */ | 29 | /* global fields for use with various JNI calls */ |
@@ -40,6 +36,21 @@ uintptr_t *stackend; | |||
40 | 36 | ||
41 | extern int main(void); | 37 | extern int main(void); |
42 | extern void powermgmt_init_target(void); | 38 | extern void powermgmt_init_target(void); |
39 | extern void telephony_init_device(void); | ||
40 | |||
41 | void system_exception_wait(void) { } | ||
42 | void system_reboot(void) { } | ||
43 | void power_off(void) { } | ||
44 | |||
45 | void system_init(void) | ||
46 | { | ||
47 | /* no better place yet, most of powermgmt.c is #ifdef'd out for non-native | ||
48 | * builds */ | ||
49 | powermgmt_init_target(); | ||
50 | /* also no better place yet */ | ||
51 | telephony_init_device(); | ||
52 | } | ||
53 | |||
43 | /* this is the entry point of the android app initially called by jni */ | 54 | /* this is the entry point of the android app initially called by jni */ |
44 | JNIEXPORT void JNICALL | 55 | JNIEXPORT void JNICALL |
45 | Java_org_rockbox_RockboxService_main(JNIEnv *env, jobject this) | 56 | Java_org_rockbox_RockboxService_main(JNIEnv *env, jobject this) |
@@ -57,8 +68,5 @@ Java_org_rockbox_RockboxService_main(JNIEnv *env, jobject this) | |||
57 | RockboxService_instance = this; | 68 | RockboxService_instance = this; |
58 | RockboxService_class = (*env)->GetObjectClass(env, this); | 69 | RockboxService_class = (*env)->GetObjectClass(env, this); |
59 | 70 | ||
60 | /* no better place yet, most of powermgmt.c is #ifdef'd out for non-native | ||
61 | * builds */ | ||
62 | powermgmt_init_target(); | ||
63 | main(); | 71 | main(); |
64 | } | 72 | } |
diff --git a/firmware/target/hosted/android/telephony-android.c b/firmware/target/hosted/android/telephony-android.c new file mode 100644 index 0000000000..771b7a973a --- /dev/null +++ b/firmware/target/hosted/android/telephony-android.c | |||
@@ -0,0 +1,54 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2010 by Thomas Martitz | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | |||
23 | #include <jni.h> | ||
24 | #include "kernel.h" | ||
25 | |||
26 | extern JNIEnv *env_ptr; | ||
27 | extern RockboxService_instance; | ||
28 | |||
29 | |||
30 | void telephony_init_device(void) | ||
31 | { | ||
32 | JNIEnv e = *env_ptr; | ||
33 | jclass class = e->FindClass(env_ptr, "org/rockbox/RockboxTelephony"); | ||
34 | jmethodID constructor = e->GetMethodID(env_ptr, class, "<init>", "(Landroid/content/Context;)V"); | ||
35 | |||
36 | e->NewObject(env_ptr, class, constructor, RockboxService_instance); | ||
37 | } | ||
38 | |||
39 | |||
40 | JNIEXPORT void JNICALL | ||
41 | Java_org_rockbox_RockboxTelephony_postCallIncoming(JNIEnv *env, jobject this) | ||
42 | { | ||
43 | (void)env; | ||
44 | (void)this; | ||
45 | queue_broadcast(SYS_CALL_INCOMING, 0); | ||
46 | } | ||
47 | |||
48 | JNIEXPORT void JNICALL | ||
49 | Java_org_rockbox_RockboxTelephony_postCallHungUp(JNIEnv *env, jobject this) | ||
50 | { | ||
51 | (void)env; | ||
52 | (void)this; | ||
53 | queue_broadcast(SYS_CALL_HUNG_UP, 0); | ||
54 | } | ||