summaryrefslogtreecommitdiff
path: root/firmware/target/hosted/android/powermgmt-android.c
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2011-07-18 21:02:47 +0000
committerThomas Martitz <kugel@rockbox.org>2011-07-18 21:02:47 +0000
commit33de9cdaefd8684e3411486612e68c0c2bd6be3d (patch)
treef1219711bfc0c1333ad8ec611a45f7ab0c416216 /firmware/target/hosted/android/powermgmt-android.c
parent788e246c996c9ac6e8efae87d13b14af001fd354 (diff)
downloadrockbox-33de9cdaefd8684e3411486612e68c0c2bd6be3d.tar.gz
rockbox-33de9cdaefd8684e3411486612e68c0c2bd6be3d.zip
Android: Refactor some of the glue code.
* Cleanup RockboxService.java by moving the battery and headphone monitors to separate classes and detaching their instances * Move those monitors and RockboxTelephony.java into a new monitors subdirectory * Call those monitors all the same from native code by creating the objects there git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30160 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/hosted/android/powermgmt-android.c')
-rw-r--r--firmware/target/hosted/android/powermgmt-android.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/firmware/target/hosted/android/powermgmt-android.c b/firmware/target/hosted/android/powermgmt-android.c
index d23fece39a..dcbd7a6214 100644
--- a/firmware/target/hosted/android/powermgmt-android.c
+++ b/firmware/target/hosted/android/powermgmt-android.c
@@ -29,28 +29,28 @@ extern jclass RockboxService_class;
29extern jobject RockboxService_instance; 29extern jobject RockboxService_instance;
30 30
31static jfieldID _battery_level; 31static jfieldID _battery_level;
32static jobject BatteryMonitor_instance;
32 33
33void powermgmt_init_target(void) 34void powermgmt_init_target(void)
34{ 35{
35 jmethodID initBatteryMonitor = (*env_ptr)->GetMethodID(env_ptr, 36 JNIEnv e = *env_ptr;
36 RockboxService_class, 37 jclass class = e->FindClass(env_ptr, "org/rockbox/monitors/BatteryMonitor");
37 "initBatteryMonitor", 38 jmethodID constructor = e->GetMethodID(env_ptr, class,
38 "()V"); 39 "<init>",
39 /* start the monitor */ 40 "(Landroid/content/Context;)V");
40 (*env_ptr)->CallVoidMethod(env_ptr, 41 BatteryMonitor_instance = e->NewObject(env_ptr, class,
41 RockboxService_instance, 42 constructor,
42 initBatteryMonitor); 43 RockboxService_instance);
43 44
44 /* cache the battery level field id */ 45 /* cache the battery level field id */
45 _battery_level = (*env_ptr)->GetFieldID(env_ptr, 46 _battery_level = (*env_ptr)->GetFieldID(env_ptr,
46 RockboxService_class, 47 class,
47 "battery_level", 48 "mBattLevel", "I");
48 "I");
49} 49}
50 50
51int battery_level(void) 51int battery_level(void)
52{ 52{
53 return (*env_ptr)->GetIntField(env_ptr, RockboxService_instance, _battery_level); 53 return (*env_ptr)->GetIntField(env_ptr, BatteryMonitor_instance, _battery_level);
54} 54}
55 55
56int battery_time(void) 56int battery_time(void)