summaryrefslogtreecommitdiffstats
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;
extern jobject RockboxService_instance;
static jfieldID _battery_level;
+static jobject BatteryMonitor_instance;
void powermgmt_init_target(void)
{
- jmethodID initBatteryMonitor = (*env_ptr)->GetMethodID(env_ptr,
- RockboxService_class,
- "initBatteryMonitor",
- "()V");
- /* start the monitor */
- (*env_ptr)->CallVoidMethod(env_ptr,
- RockboxService_instance,
- initBatteryMonitor);
+ JNIEnv e = *env_ptr;
+ jclass class = e->FindClass(env_ptr, "org/rockbox/monitors/BatteryMonitor");
+ jmethodID constructor = e->GetMethodID(env_ptr, class,
+ "<init>",
+ "(Landroid/content/Context;)V");
+ BatteryMonitor_instance = e->NewObject(env_ptr, class,
+ constructor,
+ RockboxService_instance);
/* cache the battery level field id */
_battery_level = (*env_ptr)->GetFieldID(env_ptr,
- RockboxService_class,
- "battery_level",
- "I");
+ class,
+ "mBattLevel", "I");
}
int battery_level(void)
{
- return (*env_ptr)->GetIntField(env_ptr, RockboxService_instance, _battery_level);
+ return (*env_ptr)->GetIntField(env_ptr, BatteryMonitor_instance, _battery_level);
}
int battery_time(void)