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