| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/power_monitor/power_monitor_device_source_android.h" | 5 #include "base/power_monitor/power_monitor_device_source_android.h" |
| 6 | 6 |
| 7 #include "base/power_monitor/power_monitor.h" | 7 #include "base/power_monitor/power_monitor.h" |
| 8 #include "base/power_monitor/power_monitor_device_source.h" | 8 #include "base/power_monitor/power_monitor_device_source.h" |
| 9 #include "base/power_monitor/power_monitor_source.h" | 9 #include "base/power_monitor/power_monitor_source.h" |
| 10 #include "jni/PowerMonitor_jni.h" | 10 #include "jni/PowerMonitor_jni.h" |
| 11 | 11 |
| 12 namespace base { | 12 namespace base { |
| 13 | 13 |
| 14 // A helper function which is a friend of PowerMonitorSource. | 14 // A helper function which is a friend of PowerMonitorSource. |
| 15 void ProcessPowerEventHelper(PowerMonitorSource::PowerEvent event) { | 15 void ProcessPowerEventHelper(PowerMonitorSource::PowerEvent event) { |
| 16 PowerMonitorSource::ProcessPowerEvent(event); | 16 PowerMonitorSource::ProcessPowerEvent(event); |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace android { | 19 namespace android { |
| 20 | 20 |
| 21 // Native implementation of PowerMonitor.java. | 21 // Native implementation of PowerMonitor.java. |
| 22 void OnBatteryChargingChanged(JNIEnv* env, jclass clazz) { | 22 void OnBatteryChargingChanged(JNIEnv* env, const JavaParamRef<jclass>& clazz) { |
| 23 ProcessPowerEventHelper(PowerMonitorSource::POWER_STATE_EVENT); | 23 ProcessPowerEventHelper(PowerMonitorSource::POWER_STATE_EVENT); |
| 24 } | 24 } |
| 25 | 25 |
| 26 void OnMainActivityResumed(JNIEnv* env, jclass clazz) { | 26 void OnMainActivityResumed(JNIEnv* env, const JavaParamRef<jclass>& clazz) { |
| 27 ProcessPowerEventHelper(PowerMonitorSource::RESUME_EVENT); | 27 ProcessPowerEventHelper(PowerMonitorSource::RESUME_EVENT); |
| 28 } | 28 } |
| 29 | 29 |
| 30 void OnMainActivitySuspended(JNIEnv* env, jclass clazz) { | 30 void OnMainActivitySuspended(JNIEnv* env, const JavaParamRef<jclass>& clazz) { |
| 31 ProcessPowerEventHelper(PowerMonitorSource::SUSPEND_EVENT); | 31 ProcessPowerEventHelper(PowerMonitorSource::SUSPEND_EVENT); |
| 32 } | 32 } |
| 33 | 33 |
| 34 } // namespace android | 34 } // namespace android |
| 35 | 35 |
| 36 bool PowerMonitorDeviceSource::IsOnBatteryPowerImpl() { | 36 bool PowerMonitorDeviceSource::IsOnBatteryPowerImpl() { |
| 37 JNIEnv* env = base::android::AttachCurrentThread(); | 37 JNIEnv* env = base::android::AttachCurrentThread(); |
| 38 return base::android::Java_PowerMonitor_isBatteryPower(env); | 38 return base::android::Java_PowerMonitor_isBatteryPower(env); |
| 39 } | 39 } |
| 40 | 40 |
| 41 bool RegisterPowerMonitor(JNIEnv* env) { | 41 bool RegisterPowerMonitor(JNIEnv* env) { |
| 42 return base::android::RegisterNativesImpl(env); | 42 return base::android::RegisterNativesImpl(env); |
| 43 } | 43 } |
| 44 | 44 |
| 45 } // namespace base | 45 } // namespace base |
| OLD | NEW |