summaryrefslogtreecommitdiff
path: root/core/java/android/os/BatteryManager.java
Commit message (Collapse)AuthorAgeFilesLines
* Don't change public APILuca Stefani2023-01-311-0/+3
| | | | | | * This is fine on master, but not on REL branches Change-Id: I4baa4e26df8f39a9e46d1d68129a1f7039244882 Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
* frameworks: Reset battery stats [1/2]Jorge Ruesga2022-12-301-0/+8
| | | | | | | | | BenzoEdit: Added permission to priv-app whitelist for Settings rdEdit: utilize battery stats reset interface from 10473c47221968bbeffff5b18c31f3868e6b0877 Change-Id: I1a1c0831d55c2da01c02da29e78a2c5da441b9a6 Signed-off-by: minaripenguin <minaripenguin@users.noreply.github.com>
* BatteryService: Add support for battery Moto ModsVachounet2022-10-211-1/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Squash of: Author: Vachounet <vachounet@live.fr> Date: Thu May 8 14:16:54 2019 +0200 BatteryService: Add support for battery Moto Mods * This relies on the prebuilt Moto Health service being included device side. Reference: I48803eeb72499fe8459805f6ef80ef5f868f431e Change-Id: I41a4d5fdeb5e1f2ad7838851ad0815cef7d72980 Author: LuK1337 <priv.luk@gmail.com> Date: Tue Mar 2 12:47:51 2021 +0100 BatteryManager: Mark battery moto mods constants as hidden Change-Id: I095a646d78c718df14cd8cd4fcde848ae3ba01df Author: Ali B <abittin@gmail.com> Date: Tues Mar 2 17:40:53 2021 +0300 BatteryService: Mod: Check against all conditions * Change logical operators from `||` to ~&&` to achieve this. * Additionally, change to using supplementalOrEmergencyModOnline() to avoid duplicating logic. * This fixes battery power saver mode on some devices that were effected by the initial Battery mod commit. Change-Id: I9b2bfa26ab0c204f7a42ba6010f1f569fa7b0fd8 Change-Id: Ic4017dd7946ffcf4ab874131240136c07f3f063b (cherry picked from commit 619042ec7eda1d8c8392246b91398b790c8b1b56)
* BatteryService: Add support for oem fast charger detectionAlexander Martinz2022-10-211-0/+7
| | | | | | | | | | | | | | | | | | | Based on AOSPA fw/base 0af31949c69f7c306b49ecf2c25579300973fdc9 - https://github.com/AOSPA/android_frameworks_base/commit/0af31949c69f7c306b49ecf2c25579300973fdc9 Allows to indicate, whether a device is charged using a proprietary oem fast charge solution, which write their status to sysfs. The oem fast charge detection tries to be as generic as possible and is configured via overlays. Paths to sysfs to read status - core/res/res/values/aicp_config.xml - config_oemFastChargerStatusPaths Change-Id: Ia91a9c3bb20967c5aac18c24ac7c2be10a0b8bf1 Signed-off-by: Alexander Martinz <alex@amartinz.at>
* BatteryService: add Turbo power charging supportjhenrique092022-10-211-0/+7
| | | | | | | | | | | Inspired by oneplus dash charging commit https://github.com/AOSPA/android_frameworks_base/commit/0af31949c69f7c306b49ecf2c25579300973fdc9 Charlie-117: Port to R Signed-off-by: Charlie-117 <gmoto1179@gmail.com> Change-Id: I12784d37062753a306af9fd9c9d5cbba0cc578ea
* BatteryService: Add VOOC charging supportkarthick1112022-10-211-0/+7
| | | | | | | | | | | * Based on: https://github.com/ForkLineageOS/android_frameworks_base/commit/81e2ed461f5d3a206570bd748e353932d7cf4bc9 Stallix: Port to R Eyosen: Ported to S Co-authored-by: Joey Huab <joey@evolution-x.org> Change-Id: I3823d67bb256ac6a44a5f93e584a2302e10c9997
* BatteryService: Add Warp charging supportAnushek Prasal2022-10-211-0/+7
| | | | | | | | | Stallix: Port to R Eyosen: Port to S Not really needed but feels good to have it. Based on https://github.com/Havoc-OS/android_frameworks_base/commit/9fcb3663e315d2c2884a66d951b1dd30a9c034bb Change-Id: I6bdc72a0654bed75bfcf595049378e61736d28d8
* BatteryService: add dash charging supportthecrazyskull2022-10-211-0/+7
| | | | Change-Id: I5e79f057b80276401beaa55018eb240fb454be18
* BatteryManager support dock charging 2/2Wesley Wang2022-01-261-1/+4
| | | | | | Bug: 194012532 Test: manually, local test with kernel patch Change-Id: I1ce467844bb7657c1412b8958fe4d4b0961576e8
* Add maxTargetSdk restriction to unused APIs.Mathew Inwood2020-10-291-3/+3
| | | | | | | | | | | | | | | | | | | These are APIs that have @UnsupportedAppUsage but for which we don't have any evidence of them currently being used, so should be safe to remove from the unsupported list. This is a resubmit of ag/12929664 with some APIs excluded that caused test failures; see bugs 171886397, 171888296, 171864568. APIs excluded: Landroid/bluetooth/le/ScanRecord;->parseFromBytes([B)Landroid/bluetooth/le/ScanRecord; Landroid/os/Process;->myPpid()I Landroid/os/SharedMemory;->getFd()I Landroid/hardware/input/InputManager;->INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH:I Bug: 170729553 Test: Treehugger Change-Id: I8285daa8530260251ecad6f3f38f98e263629ca7
* Revert "Add maxTargetSdk restriction to unused APIs."Hongwei Wang2020-10-281-3/+3
| | | | | | | | | This reverts commit 72f07d6a8a32db4a0dedd7682a0b3385be2b9cd6. Reason for revert: Droidcop-triggered revert due to breakage https://android-build.googleplex.com/builds/quarterdeck?testMethod=testAppZygotePreload&testClass=android.app.cts.ServiceTest&atpConfigName=suite%2Ftest-mapping-presubmit-retry_cloud-tf&testModule=CtsAppTestCases&fkbb=6936597&lkbb=6936969&lkgb=6936551&testResults=true&branch=git_master&target=cf_x86_phone-userdebug>, bug b/171886397 Bug: 171886397 Change-Id: Ibe0f0430a3451477c1ee8ef56a596e91ea1e7672
* Add maxTargetSdk restriction to unused APIs.Mathew Inwood2020-10-271-3/+3
| | | | | | | | | | These are APIs that have @UnsupportedAppUsage but for which we don't have any evidence of them currently being used, so should be safe to remove from the unsupported list. Bug: 170729553 Test: Treehugger Change-Id: I4c8fd0006f950de9955242e93968fb0996ceb372
* Remove @TestApi from @SystemApi symbolsAnton Hansson2020-10-201-2/+0
| | | | | | | | | | | | | I ran these commands: cd frameworks/base grep -rl '@TestApi' --include '*.java' | xargs perl -i -p0e \ 's/\@SystemApi[\s\n]+(\@\w+[\s\n]+)?\@TestApi/\@SystemApi\1/gs' grep -rl '@TestApi' --include '*.java' | xargs perl -i -p0e \ 's/\@TestApi[\s\n]+(\@\w+[\s\n]+)?\@SystemApi/\1\@SystemApi/gs' Bug: 171179806 Test: m checkapi Change-Id: I772790b783b0a8730b8bf680c9e569a886b8d789
* Use new UnsupportedAppUsage annotation.Artur Satayev2019-12-181-1/+1
| | | | | | | | Existing annotations in libcore/ and frameworks/ will deleted after the migration. This also means that any java library that compiles @UnsupportedAppUsage requires a direct dependency on "unsupportedappusage" java_library. Bug: 145132366 Test: m && diff unsupportedappusage_index.csv Change-Id: I534e3fd1305e2f4af076986770033478448a665c
* Add @UnsupportedAppUsage annotationsAndrei Onea2019-03-151-0/+5
| | | | | | | | | | | | | | | | For packages: android.os This is an automatically generated CL. See go/UnsupportedAppUsage for more details. Exempted-From-Owner-Approval: Mechanical changes to the codebase which have been approved by Android API council and announced on android-eng@ Bug: 110868826 Test: m Change-Id: I4ece0a3f37f88fc2508cb965092aed7cabc61819
* Fix boost charging, also expose test APIMakoto Onuki2019-02-191-0/+2
| | | | | | | Bug: 124437856 Bug: 111360323 Test: atest CtsBatterySavingTestCases Change-Id: I7cf25e9dca669ae1bb5d9bb62ada35a59ca26f6f
* Add api to change charging state update delayNg Zhi An2019-01-251-0/+24
| | | | | | | | | | | | | | | | | | This adds a field Settings.Global.BATTERY_CHARGING_STATE_UPDATE_DELAY that overrides the value of battery_charged_delay_ms in Settings.GLOBAL.BATTERY_STATS_CONSTANTS. This new field can then be set for experimentation, and easily reset to default by deleting, or setting it to a negative value. Expose a method in BatteryManager to set a value for this new setting. Bug: 111360323 Test: adb shell settings put global battery_charging_state_update_delay 999 adb shell dumpsys batterystats --settings # should see battery_charged_delay_ms=999 adb shell settings put global battery_charging_state_update_delay -1 adb shell dumpsys batterystats --settings # should see battery_charged_delay_ms=90000 Change-Id: Ic308af938836a1f9c235cec341808b6c6c28d22d
* Add API to compute charge time remaining.Michael Wright2018-04-111-0/+16
| | | | | | | | | This is so unbundled applications (e.g. dreams) can present a charge time indicator that is in sync with the rest of the system. Bug: 77919650 Test: manual Change-Id: I7d62dea4fd49eb173b4f052a0fc36f4e7ce5b6bb
* Added ACTION_BATTERY_LEVEL_CHANGEDFyodor Kupolov2018-03-081-0/+18
| | | | | | | | | | | | | | Sent when the current battery level changes. It has EXTRA_EVENTS that carries a list of Bundle instances representing individual battery level changes with associated extras from ACTION_BATTERY_CHANGED Each event has EXTRA_EVENT_TIMESTAMP representing time when it occured. Test: manual Bug: 74020080 Change-Id: I993005950299c5298c9111ca51cc7717e1f029de
* Wireless charging on aod and lockscreenBeverly2018-02-081-0/+12
| | | | | | | | | | - wireless charging animation plays on aod + lockscreen - timing changes on animation based on design spec - charging feedback only given if phone is not just booted Test: manual Bug: 67598445 Change-Id: I009ff6016141bcdfe9f0392bb9a1c220ea88dfe5
* Statsd and frameworks reference proto enumsBookatz2018-01-251-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | For frameworks constants that don't have intrinsic meaning (i.e. their actual value and order don't matter), so that it is unlikely that their values will be changed: This cl introduces proto enums representing some constants found in the Android codebase, and connects the two. By using the Proto enum as the source-of-truth, it means that Java and proto can be kept in sync. Otherwise, when the Java frameworks code changes, it silently breaks the protos from working properly, since the enums are wrong. By having the Java code reference the proto enums, it ensures that everything is in sync. The values of the constants are unchanged. But future changes to these constants will need to be done in the proto file, which the Java file merely references. The protos are necessary for incidentd and statsd and, in the future, possibly dumpsys. In this way, the logging mechanism is much less likely to get broken when new constants are added, and we can be ensured that the logging accurately reflects the underlying codebase. Bug: 69478930 Test: cts-tradefed run cts-dev -m CtsStatsdHostTestCases Test: cts-tradefed run cts-dev -m CtsIncidentHostTestCases Change-Id: If79032c34b2799db1e3e70cb47b1312fd72092b9
* Fix issue #67019445: Detect BATTERY_LOW/OKAYDianne Hackborn2017-11-211-0/+9
| | | | | | | Add a new extra that indicates the battery is low. Test: BatteryConstraintTest updated Change-Id: I9ff92e15974ea092283a840cd01c860d6586c9b5
* Fix BatteryManager.getIntProperty returns 0 as invalid value.Yifan Hong2017-11-031-15/+27
| | | | | | | | Long.MIN_VALUE cast to Integer.MIN_VALUE always returns 0. Change-Id: Ief7a1fd12a356c83a4ef3f28139c330034507dfa Fixes: 37090343 Test: BatteryManagerTest
* Annotate @SystemApi with required permissions.Jeff Sharkey2017-06-051-0/+3
| | | | | | | | | | | | | | | | | Most @SystemApi methods should be protected with system (or higher) permissions, so annotate common methods with @RequiresPermission to make automatic verification easier. Verification is really only relevant when calling into system services (where permissions checking can happen on the other side of a Binder call), so annotate managers with the new @SystemService annotation, which is now automatically documented. This is purely a docs change; no logic changes are being made. Test: make -j32 update-api && make -j32 offline-sdk-docs Bug: 62263906 Change-Id: I2554227202d84465676aa4ab0dd336b5c45fc651
* Merge "BatteryManager: rename BATTERY_PROPERTY_BATTERY_STATUS"TreeHugger Robot2017-02-281-1/+1
|\
| * BatteryManager: rename BATTERY_PROPERTY_BATTERY_STATUSJin Qian2017-02-281-1/+1
| | | | | | | | | | | | | | | | To BATTERY_PROPERTY_STATUS Test: build Bug: 35813122 Change-Id: Ia8308def79b79706dbdc3e47f93afa56661a47aa
* | Add new job scheduler constraints for "battery not low".Dianne Hackborn2017-02-271-0/+7
|/ | | | | | | | | | | | | | | | | | | | Clean up the implementation of boolean constraints so that they are in a single flags value that gets propagated all of the way from JobInfo.Builder in to the JobStatus. Much simpler and easier to add new constraints! Also introduce some shell commands to make it easier to write tests against the job scheduler (and other things tied to power). One of the big things here is that there is a new sequence number that propagates with battery updates, which we can look for in the job scheduler to determine when a change the test has made to battery state has actually gotten applied, to allow it to safely and minimally wait until executing the condition being tested. Test: New BatteryConstraintTest suite added. Change-Id: I11076d90b80ec25ee604c29b6a6dc2337fd867ce
* BatteryManager: Add battery status to getPropertyJin Qian2017-02-071-0/+5
| | | | | Bug: 34198239 Change-Id: I65cef6864b1074445342e18f49c7cecd0706b938
* health: import android.hardware.health@1.0 constants into BatteryManagerSandeep Patil2016-11-101-12/+13
| | | | | | | | Test: make Bug: b/32724915 Change-Id: I7ca7507b7be54442dc3250b02db3e4f7e95f0685 Signed-off-by: Sandeep Patil <sspatil@google.com>
* Avoid caching services with missing binders.Jeff Sharkey2016-08-111-5/+7
| | | | | | | | | | | | | | | | When fetching system services early during boot, if the underlying binder interface hasn't been published yet, we end up caching a manager class that is broken for the remainder of the process lifetime, and innocent downstream callers end up using the broken cached manager. Fix this by using an explicit exception to quickly abort manager creation when the underlying binder is missing. The exception is only used to skip the remainder of the manager creation, and it doesn't actually crash the process. Bug: 28634953 Change-Id: I0cb62261e6d6833660704b93a11185aa11a2ac97
* batteryService: Add Charge Counter.Ruchi Kandoi2016-04-081-0/+7
| | | | | | Bug: 27174034 Change-Id: Ib8bc8f617288c0ad543c67e0fa609c5a0c87b5fd Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
* When system server goes down, crash apps more.Jeff Sharkey2016-03-011-2/+2
| | | | | | | | | | | | | Apps making calls into the system server may end up persisting internal state or making security decisions based on the perceived success or failure of a call, or the default values returned. The reality is that if the system process just died, init will be along shortly to kill all running apps, so we should have no problem rethrowing the RemoteException as a RuntimeException. Bug: 27364859 Change-Id: Ife0bcb079636c88d54c44d17eb580409fd79028b
* BatteryService: Add Max charging voltageBadhri Jagan Sridharan2015-10-271-0/+7
| | | | | Bug: 25229483 Change-Id: Ibeba97eb145c3d59a763bd8632ab7fcc43118e4b
* Show charging speed on KeyguardAdrian Roos2015-07-141-0/+7
| | | | | Bug: 8099739 Change-Id: I2e5c21dd7ec028ce47fb03ab71e74f7fccaa9e36
* More work on device idle mode and other power stuff.Dianne Hackborn2015-04-091-0/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add idle mode support to the alarm manager. Introduce a new concept of flags associated with alarms to tell the alarm manager how to treat the alarm -- they allow everything from the alarm that will bring us out of idle mode, to alarms that are allowed when idle or should also bring us out of idle. The standalone boolean is now also a flag. (Note there is currently no protection from user space setting the flags however it wants; I will be working on that in a follow-up change.) When in idle mode, the alarm manager pushes all alarms that shouldn't execute during that time over to a separate list that is not executed until out of idle. To help with this, I reworked a bit how Alarm objects are managed, so that when rebatching or moving between lists we don't have to allocated new objects but can just use the same existing instance. Also tweaked the sync manager to deal with idle mode, which currently just means doing the same thing as when low on storage -- turning off sync. Add new ACTION_CHARGING and ACTION_DISCHARGING broadcasts that apps can listen for to know when the device is actively charging and discharging. These are better than the old POWER_CONNECTED and POWER_DISCONNECTED ones because we only report charging when we actually see that there is enough power being provided to charge the battery (and will report discharging if there is not enough power). The job controller uses these new actions for scheduling jobs that want to run while plugged in. Removed the "stable charging" stuff while doing so, since the new charging state serves as an even better signal for that. Introduced two new process states: FOREGROUND_SERVICE and TOP_SLEEPING. This will allow us to treat foreground services specially (such as still allowing network access to them for background music playback) while not mixing them together with whatever happens to be the top activity while the device is asleep. Also some other small cleanup here and there. Change-Id: I7a9808b578bad6f50deb8e1baf919298512a0d3a
* Add Context.getSystemService(Class<?>).Jeff Brown2015-02-251-7/+10
| | | | | | | | | | | | Added an overload of getSystemService() that takes a class instead of a service name to eliminate the extra cast and provide more type safety. Cleaned up docs. Removed the default constructor of BatteryManager which should not have existed. Change-Id: I9da46b20641fc83ecd3342560e5b94cb721f289c
* BatteryManager: battery property query API updateTodd Poynor2014-06-051-11/+79
| | | | | | | | | Move battery property value accessors to BatteryManager. Hide BatteryProperty class. Bug: 15191190 Change-Id: Ic021e6e28a8bc30c145ccc31b3a3446ba82d2004
* BatteryManager: Add property ENERGY_COUNTER and long data type propertiesTodd Poynor2014-05-161-2/+2
| | | | Change-Id: Ie7f9b19c5cd47a48bb33af03d51acddaa14b0243
* BatteryManager: Add API and service for battery property retrievalTodd Poynor2014-04-151-1/+33
| | | | | | | | | Add service "batterymanager" and method getProperty to retrieve battery properties. This is a public API. Make BatteryProperty public. Cleanups for public-facing API. Change-Id: I3637d131aabe4811dff40661728d5353eaf854c4
* Fix some synchronization issues in BatteryService.Jeff Brown2012-10-021-0/+4
| | | | | | | | Some of the BatteryService state was being locked sometimes and it wasn't at all consistent. Bug: 7158734 Change-Id: I46e75f66fde92c5a577a80a6bd99c9573066f3c1
* add wireless charger supportBrian Muramatsu2012-08-201-0/+2
| | | | | | | | | bug: 6879638 - add new enum value BATTERY_PLUGGED_WIRELESS - check for sys online file with contents "Wireless" Change-Id: I22dc3c40f50573c98643e7b5cbcb237d0216530d
* Implement reminder power dialog and invalid charger dialog.Joe Onorato2010-10-271-1/+1
| | | | | | Bug: 2510318 Bug: 2974431 Change-Id: I92eb419eeffb657e5572a35a490735a96b303d6b
* am 89fbcd72: resolved conflicts for merge of c2894474 to gingerbread-plus-aospJean-Baptiste Queru2010-10-111-0/+1
|\ | | | | | | | | | | | | Merge commit '89fbcd72fbe6ef26ea2703f8e338fd198c958ecc' * commit '89fbcd72fbe6ef26ea2703f8e338fd198c958ecc': Support showing "Cold" battery health.
| * Support showing "Cold" battery health.Imre Sunyi2010-10-101-0/+1
| | | | | | | | | | | | | | | | The Linux kernel supports reporting "cold" battery health to sysfs. Android framework has not implemented this and it defaults to "unknown" This adds handling the cold battery health. Change-Id: Idcc156aae6aabce73391081143f79d052edf332e
* | Add extra to ACTION_BATTERY_CHANGED to indicate an invalid charger is attached.Mike Lockwood2010-09-041-1/+9
|/ | | | | Change-Id: I24a24a49d2e3ddee8fbce590ef75ea323b3be97b Signed-off-by: Mike Lockwood <lockwood@android.com>
* Add better APIs for the battery status, and other cleanup.Dianne Hackborn2009-09-191-2/+65
| | | | | | | Also add new configs for keeping screen on while docked, which will be used elsewhere. Change-Id: Ifaa1118f14fd850ac809895f9a5c9e8c413259b8
* auto import from //depot/cupcake/@135843The Android Open Source Project2009-03-031-0/+46
|
* auto import from //depot/cupcake/@135843The Android Open Source Project2009-03-031-46/+0
|
* Code drop from //branches/cupcake/...@124589The Android Open Source Project2008-12-171-2/+4
|
* Initial ContributionThe Android Open Source Project2008-10-211-0/+44