2025년 3월 27일부터 AOSP를 빌드하고 기여하려면 aosp-main
대신 android-latest-release
를 사용하는 것이 좋습니다. 자세한 내용은 AOSP 변경사항을 참고하세요.
무배터리 기기 지원
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
이 페이지에서는 Android에서 분리형 배터리가 있거나 내장 배터리가 없는 제품을 어떻게 취급하는지를 설명합니다. 내장 배터리가 없는 기기는 대신 AC 전원 콘센트나 다른 기기의 USB 포트와 같은 외부 전원에 연결됩니다.
배터리가 있나요?
다음 코드는 애플리케이션에서 기기에 배터리가 있는지 감지하는 데 사용될 수 있습니다.
```
final Intent batteryInfo = registerReceiver(null, new
IntentFilter(Intent.ACTION_BATTERY_CHANGED));
return batteryInfo.getBooleanExtra(BatteryManager.EXTRA_PRESENT, true);
```
무배터리 기기 동작
Android가 제품의 배터리 기기를 감지하지 못하는 경우에는 다음과 같은 배터리 관련 기본값이 사용됩니다. Android 9 버전에서는 기본값이 변경되었습니다. 아래 표에 차이점이 나와 있습니다.
배터리 상태 |
Android 9 이상 |
Android 8.1 이하 |
있음
|
거짓 |
응 |
상태
|
알 수 없음 |
충전 중 |
잔여 용량
|
0 |
100% |
상태
|
알 수 없음 |
네 |
AC 충전기 온라인 상태
|
변경되지 않음 |
true로 강제됨 |
제조업체는 커널 power_supply 드라이버 또는 Health HAL을 사용하여 기본 설정을 변경할 수 있습니다.
Android 9 이상
Android 9에서는 기본적으로 배터리가 있다고 가장했거나 100%에서 충전되고 있었거나 서미스터 온도가 정상으로 판독되는 정상 상태였던 무배터리와 관련된 이전 코드 중 일부가 제거되었습니다.
이러한 정보를 취급하는 대부분의 프레임워크 API는 계속해서 일반적인 상황을 이전과 같은 방식으로 처리합니다. 즉, 시스템이 충전 중 (배터리 전력으로 구동되지 않음)으로 간주되며 배터리 낮음으로 간주되지 않습니다. 사용자 인터페이스에서 배터리 아이콘을 생성하면, 이 아이콘이 느낌표와 함께 표시되고 배터리 비율이 0%로 표시됩니다.
하지만 배터리 낮음으로 인해 기기가 종료되지는 않으며, 충전 또는 양호한 배터리가 필요한 작업이 예약됩니다.
Android 8.1 이하
배터리 상태를 알 수 없으므로 Android 프레임워크 API는 시스템을 충전 중 (또는 배터리 전력으로 구동되지 않음)으로 간주하며, 배터리 낮음으로 간주하지 않습니다. 사용자 인터페이스에서 배터리 아이콘을 생성하면, 이 아이콘이 느낌표와 함께 표시되고 배터리 비율이 0%로 표시됩니다. 하지만 배터리 낮음으로 인해 기기가 종료되지는 않으며, 충전 또는 양호한 배터리가 필요한 작업이 예약됩니다.
구현
Android 9의 기본 코드는 기기에서 제대로 작동할 수 있지만 이전에 설명한 대로 제품의 전원 및 배터리 상태를 정확하게 반영할 수 있도록 커널 또는 HAL을 변경하는 것이 좋습니다. Android 9 이상에서 Linux 전원 공급 장치 클래스 충전기 기기를 감지하지 않으면 기본적으로 모든 충전기 유형 (AC, USB, 무선)이 오프라인 상태가 됩니다. 모든 충전기가 오프라인 상태이지만 감지된 배터리 기기는 없는 경우 시스템은 이전에 설명한 것처럼 배터리 전력이 아닌 외부에서 구동된다는 측면에서 계속해서 충전되고 있는 것으로 간주될 수 있습니다.
제품에 배터리가 없고 항상 전원에 연결되어 있는 경우 온라인 sysfs
속성을 true
로 설정하는 AC나 USB 전원용 Linux 커널 power_supply 클래스 충전기 드라이버를 구현하는 것이 가장 좋습니다. 아니면 기기의 Health HAL에서 AC 충전기 온라인 속성을 구성할 수도 있습니다. Health HAL에서 AC 충전기 온라인 속성을 구성하려면 Health AIDL HAL을 참고하세요.
이 맞춤 Health HAL은 BatteryProperties.chargerAcOnline = true
값을 수정하는 Health::getHealthInfo()
의 맞춤 버전을 구현합니다.
시작하려면 hardware/interfaces/health/aidl/default/Health.cpp
파일을 자체 Health HAL 구현에 복사하고 Health AIDL HAL에 따라 수정하세요.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-07-27(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-27(UTC)"],[],[],null,["# Support batteryless devices\n\nThis page describes how Android handles products that have either removable\nbatteries or no internal batteries. The latter devices are instead connected to\nan external power source, such as an AC power outlet or USB port on another\ndevice.\n\nIs a battery present?\n---------------------\n\nThe following code may be used by applications to detect whether the device has\na battery present: \n\n ```\n final Intent batteryInfo = registerReceiver(null, new\n IntentFilter(Intent.ACTION_BATTERY_CHANGED));\n\n return batteryInfo.getBooleanExtra(BatteryManager.EXTRA_PRESENT, true);\n ```\n\nBatteryless device behavior\n---------------------------\n\nIf Android does not detect a battery device for your product, then the following\nbattery-related default values are used. Note the defaults have changed in the\nAndroid 9 release. This table shows the differences.\n\n| Battery state | Android 9 and higher | Android 8.1 and lower |\n|----------------------------|----------------------|-----------------------|\n| *Present* | false | true |\n| *Status* | unknown | charging |\n| *Remaining capacity* | 0 | 100% |\n| *Health* | unknown | good |\n| *AC charger online status* | not modified | forced to true |\n\nManufacturers may alter the default settings using a kernel\n[power_supply](https://www.kernel.org/doc/Documentation/power/power_supply_class.txt)\ndriver or [Health HAL](/docs/core/perf/health).\n\n### Android 9 and higher\n\nAndroid 9 removes some previous code for batteryless\ndevices that by default pretended a battery was present, was being charged at\n100%, and was in good health with a normal temperature reading on its\nthermistor.\n\nMost framework APIs that deal with this information continue to handle common\nsituations the same as previously: the system is considered to be\n*charging* (that is, not running on battery power), and won't be considered\nto have a low battery. If the user interface draws the battery icon, it will\nappear with an exclamation point, and battery percentage is shown as 0%.\nBut the device won't shut down due to low battery, and jobs that require\ncharging or good battery are scheduled.\n\n### Android 8.1 and lower\n\nBecause the battery status is unknown, the Android framework APIs will consider\nthe system to be *charging* (or, not running on battery power) and won't be\nconsidered to have a low battery. If the user interface renders the battery\nicon, it will appear with an exclamation point, and battery percentage is\nshown as 0%. But the device won't shut down due to low battery, and jobs that\nrequire charging or good battery are scheduled.\n\nImplementation\n--------------\n\nThe Android 9 default code may work properly for your\ndevice, but it's recommended to make either a kernel or a HAL change to\naccurately reflect the power and battery state for your product, as described\npreviously. If Android 9 and higher doesn't detect a [Linux power supply\nclass](https://www.kernel.org/doc/Documentation/power/power_supply_class.txt)\ncharger device, then by default all charger types (AC, USB, Wireless) will have\nstatus *offline*. If all chargers are offline but there is no battery device\ndetected, the system will still be considered to be charging in the sense that\nit is running on external, not battery power, as described previously.\n\nIf your product doesn't have a battery and is always connected to a power\nsource, it's best to implement a Linux kernel power_supply class *charger*\ndriver for the AC or USB power source that sets its *online* `sysfs` attribute\nto `true`. Or you can configure the AC charger online property in a Health HAL\nfor your device. To configure the AC charger online property in a Health HAL,\nrefer to [Health AIDL HAL](https://android.googlesource.com/platform/hardware/interfaces/+/main/health/aidl/README.md).\n\nThis custom Health HAL implements a custom version of `Health::getHealthInfo()`\nthat modifies the value of `BatteryProperties.chargerAcOnline = true`.\n\nTo get started, copy file\n[`hardware/interfaces/health/aidl/default/Health.cpp`](https://android.googlesource.com/platform/hardware/interfaces/+/main/health/aidl/default/Health.cpp)\nto your own Health HAL implementation and modify it according to the\n[Health AIDL HAL](https://android.googlesource.com/platform/hardware/interfaces/+/main/health/aidl/README.md)."]]