OLD | NEW |
---|---|
1 // Copyright (c) 2011 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/system_monitor/system_monitor.h" | 5 #include "base/power_monitor/power_monitor.h" |
6 #include "jni/SystemMonitor_jni.h" | 6 #include "jni/SystemMonitor_jni.h" |
vandebo (ex-Chrome)
2013/03/19 23:36:04
SysMon->PowMon
Hongbo Min
2013/03/20 13:01:50
Done.
| |
7 | 7 |
8 namespace base { | 8 namespace base { |
9 | 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 | |
10 namespace android { | 16 namespace android { |
11 | 17 |
12 // Native implementation of SystemMonitor.java. | 18 // Native implementation of SystemMonitor.java. |
13 void OnBatteryChargingChanged(JNIEnv* env, jclass clazz) { | 19 void OnBatteryChargingChanged(JNIEnv* env, jclass clazz) { |
14 SystemMonitor::Get()->ProcessPowerMessage(SystemMonitor::POWER_STATE_EVENT); | 20 ProcessPowerEventHelper(PowerMonitor::POWER_STATE_EVENT); |
15 } | 21 } |
16 | 22 |
17 void OnMainActivityResumed(JNIEnv* env, jclass clazz) { | 23 void OnMainActivityResumed(JNIEnv* env, jclass clazz) { |
18 SystemMonitor::Get()->ProcessPowerMessage(SystemMonitor::RESUME_EVENT); | 24 ProcessPowerEventHelper(PowerMonitor::RESUME_EVENT); |
19 } | 25 } |
20 | 26 |
21 void OnMainActivitySuspended(JNIEnv* env, jclass clazz) { | 27 void OnMainActivitySuspended(JNIEnv* env, jclass clazz) { |
22 SystemMonitor::Get()->ProcessPowerMessage(SystemMonitor::SUSPEND_EVENT); | 28 ProcessPowerEventHelper(PowerMonitor::SUSPEND_EVENT); |
23 } | 29 } |
24 | 30 |
25 } // namespace android | 31 } // namespace android |
26 | 32 |
27 bool SystemMonitor::IsBatteryPower() { | 33 bool PowerMonitor::IsBatteryPower() { |
28 JNIEnv* env = base::android::AttachCurrentThread(); | 34 JNIEnv* env = base::android::AttachCurrentThread(); |
29 return base::android::Java_SystemMonitor_isBatteryPower(env); | 35 return base::android::Java_SystemMonitor_isBatteryPower(env); |
30 } | 36 } |
31 | 37 |
38 // TODO(hmin): Rename it to RegisterPowerMonitor. | |
vandebo (ex-Chrome)
2013/03/19 23:36:04
Do this in this CL.
Hongbo Min
2013/03/20 13:01:50
Done.
| |
32 bool RegisterSystemMonitor(JNIEnv* env) { | 39 bool RegisterSystemMonitor(JNIEnv* env) { |
33 return base::android::RegisterNativesImpl(env); | 40 return base::android::RegisterNativesImpl(env); |
34 } | 41 } |
35 | 42 |
36 } // namespace base | 43 } // namespace base |
OLD | NEW |