1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/browser/battery_status/battery_status_manager_android.h"
9 #include "base/android/jni_android.h"
10 #include "jni/BatteryStatusManager_jni.h"
12 using base::android::AttachCurrentThread
;
16 BatteryStatusManagerAndroid::BatteryStatusManagerAndroid() {
18 Java_BatteryStatusManager_getInstance(
19 AttachCurrentThread(), base::android::GetApplicationContext()));
22 BatteryStatusManagerAndroid::~BatteryStatusManagerAndroid() {
23 StopListeningBatteryChange();
26 bool BatteryStatusManagerAndroid::Register(JNIEnv
* env
) {
27 return RegisterNativesImpl(env
);
30 void BatteryStatusManagerAndroid::GotBatteryStatus(JNIEnv
*, jobject
,
31 jboolean charging
, jdouble chargingTime
, jdouble dischargingTime
,
36 bool BatteryStatusManagerAndroid::StartListeningBatteryChange() {
37 return Java_BatteryStatusManager_start(
38 AttachCurrentThread(), j_manager_
.obj(),
39 reinterpret_cast<intptr_t>(this));
42 void BatteryStatusManagerAndroid::StopListeningBatteryChange() {
43 Java_BatteryStatusManager_stop(
44 AttachCurrentThread(), j_manager_
.obj());
47 } // namespace content