Revert 268405 "Make sure that ScratchBuffer::Allocate() always r..."
[chromium-blink-merge.git] / content / browser / battery_status / battery_status_manager_android.cc
blobe7769ca2baa940011d64d3e256246f8d68889d62
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"
7 #include <string.h>
9 #include "base/android/jni_android.h"
10 #include "jni/BatteryStatusManager_jni.h"
12 using base::android::AttachCurrentThread;
14 namespace content {
16 BatteryStatusManagerAndroid::BatteryStatusManagerAndroid() {
17 j_manager_.Reset(
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,
32 jdouble level) {
33 NOTIMPLEMENTED();
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