| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 package org.chromium.device.battery; | 5 package org.chromium.device.battery; |
| 6 | 6 |
| 7 import android.annotation.TargetApi; | 7 import android.annotation.TargetApi; |
| 8 import android.content.BroadcastReceiver; | 8 import android.content.BroadcastReceiver; |
| 9 import android.content.Context; | 9 import android.content.Context; |
| 10 import android.content.Intent; | 10 import android.content.Intent; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 BatteryStatusManager.this.onReceive(intent); | 41 BatteryStatusManager.this.onReceive(intent); |
| 42 } | 42 } |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 // This is to workaround a Galaxy Nexus bug, see the comment in the construc
tor. | 45 // This is to workaround a Galaxy Nexus bug, see the comment in the construc
tor. |
| 46 private final boolean mIgnoreBatteryPresentState; | 46 private final boolean mIgnoreBatteryPresentState; |
| 47 | 47 |
| 48 // Only used in L (API level 21) and higher. | 48 // Only used in L (API level 21) and higher. |
| 49 private AndroidBatteryManagerWrapper mAndroidBatteryManager; | 49 private AndroidBatteryManagerWrapper mAndroidBatteryManager; |
| 50 | 50 |
| 51 private boolean mEnabled = false; | 51 private boolean mEnabled; |
| 52 | 52 |
| 53 @VisibleForTesting | 53 @VisibleForTesting |
| 54 static class AndroidBatteryManagerWrapper { | 54 static class AndroidBatteryManagerWrapper { |
| 55 private final BatteryManager mBatteryManager; | 55 private final BatteryManager mBatteryManager; |
| 56 | 56 |
| 57 protected AndroidBatteryManagerWrapper(BatteryManager batteryManager) { | 57 protected AndroidBatteryManagerWrapper(BatteryManager batteryManager) { |
| 58 mBatteryManager = batteryManager; | 58 mBatteryManager = batteryManager; |
| 59 } | 59 } |
| 60 | 60 |
| 61 public int getIntProperty(int id) { | 61 public int getIntProperty(int id) { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 } | 183 } |
| 184 } else { | 184 } else { |
| 185 if (averageCurrentMicroA < 0) { | 185 if (averageCurrentMicroA < 0) { |
| 186 double dischargeFromFullHours = batteryCapacityMicroAh / -averag
eCurrentMicroA; | 186 double dischargeFromFullHours = batteryCapacityMicroAh / -averag
eCurrentMicroA; |
| 187 batteryStatus.dischargingTime = | 187 batteryStatus.dischargingTime = |
| 188 Math.floor(remainingCapacityRatio * dischargeFromFullHou
rs * 3600.0); | 188 Math.floor(remainingCapacityRatio * dischargeFromFullHou
rs * 3600.0); |
| 189 } | 189 } |
| 190 } | 190 } |
| 191 } | 191 } |
| 192 } | 192 } |
| OLD | NEW |