| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 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. | |
| 4 | |
| 5 #include "base/power_monitor/power_monitor.h" | |
| 6 #include "jni/PowerMonitor_jni.h" | |
| 7 | |
| 8 namespace base { | |
| 9 | |
| 10 // A helper function which is a friend of PowerMonitor. | |
| 11 void ProcessPowerEventHelper(PowerMonitor::PowerEvent event) { | |
| 12 if (base::PowerMonitor::Get()) | |
| 13 base::PowerMonitor::Get()->ProcessPowerEvent(event); | |
| 14 } | |
| 15 | |
| 16 namespace android { | |
| 17 | |
| 18 // Native implementation of PowerMonitor.java. | |
| 19 void OnBatteryChargingChanged(JNIEnv* env, jclass clazz) { | |
| 20 ProcessPowerEventHelper(PowerMonitor::POWER_STATE_EVENT); | |
| 21 } | |
| 22 | |
| 23 void OnMainActivityResumed(JNIEnv* env, jclass clazz) { | |
| 24 ProcessPowerEventHelper(PowerMonitor::RESUME_EVENT); | |
| 25 } | |
| 26 | |
| 27 void OnMainActivitySuspended(JNIEnv* env, jclass clazz) { | |
| 28 ProcessPowerEventHelper(PowerMonitor::SUSPEND_EVENT); | |
| 29 } | |
| 30 | |
| 31 } // namespace android | |
| 32 | |
| 33 bool PowerMonitor::IsBatteryPower() { | |
| 34 JNIEnv* env = base::android::AttachCurrentThread(); | |
| 35 return base::android::Java_PowerMonitor_isBatteryPower(env); | |
| 36 } | |
| 37 | |
| 38 bool RegisterPowerMonitor(JNIEnv* env) { | |
| 39 return base::android::RegisterNativesImpl(env); | |
| 40 } | |
| 41 | |
| 42 } // namespace base | |
| OLD | NEW |