ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
โปรไฟล์พลังงานสำหรับ Android
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ข้อมูลการใช้งานแบตเตอรี่มาจากสถิติการใช้งานแบตเตอรี่และค่าโปรไฟล์พลังงาน
สถิติการใช้งานแบตเตอรี่
เฟรมเวิร์กจะระบุสถิติการใช้แบตเตอรี่โดยอัตโนมัติด้วยการติดตามระยะเวลาที่คอมโพเนนต์ของอุปกรณ์อยู่ในสถานะต่างๆ เมื่อคอมโพเนนต์ (ชิปเซ็ต Wi-Fi, วิทยุมือถือ, บลูทูธ, GPS, จอแสดงผล, CPU) เปลี่ยนสถานะ (ปิด/เปิด ไม่ทำงาน/ทำงานเต็มกำลัง ความสว่างต่ำ/สูง ฯลฯ) บริการที่ควบคุมจะรายงานไปยังบริการ BatteryStats ของเฟรมเวิร์ก BatteryStats จะรวบรวมข้อมูลเมื่อเวลาผ่านไปและจัดเก็บไว้เพื่อใช้ในระบบที่รีบูต บริการนี้ไม่ได้ติดตามปริมาณการดึงกระแสไฟฟ้าของแบตเตอรี่โดยตรง แต่รวบรวมข้อมูลการจับเวลาซึ่งสามารถใช้เพื่อประมาณปริมาณการใช้แบตเตอรี่ของคอมโพเนนต์ต่างๆ
เฟรมเวิร์กจะรวบรวมสถิติโดยใช้วิธีการต่อไปนี้
- ดัน บริการที่ทราบการเปลี่ยนแปลงของคอมโพเนนต์จะพุชการเปลี่ยนแปลงสถานะไปยังบริการ BatteryStats
- ดึง สำหรับคอมโพเนนต์ต่างๆ เช่น การใช้งาน CPU ของแอป เฟรมเวิร์กจะดึงข้อมูล ณ จุดเปลี่ยน (เช่น การเริ่มหรือหยุดกิจกรรม) โดยอัตโนมัติเพื่อจับภาพ
ปริมาณการใช้ทรัพยากรจะเชื่อมโยงกับแอปพลิเคชันที่ใช้ทรัพยากร เมื่อแอปพลิเคชันหลายแอปใช้ทรัพยากรพร้อมกัน (เช่น Wakelock ที่ป้องกันไม่ให้ระบบหยุดทำงานชั่วคราว) เฟรมเวิร์กจะกระจายการบริโภคไปยังแอปพลิเคชันเหล่านั้น แม้ว่าจะไม่เท่ากัน
เพื่อไม่ให้สูญเสียสถิติการใช้งานสำหรับเหตุการณ์การปิดเครื่อง ซึ่งอาจบ่งบอกถึงปัญหาการสิ้นเปลืองพลังงานแบตเตอรี่ (เช่น การปิดเครื่องเกิดขึ้นเนื่องจากแบตเตอรี่เหลือพลังงานไม่เพียงพอ) เฟรมเวิร์กจะแสดงสถิติเป็นประกายทุกๆ 30 นาทีโดยประมาณ
เฟรมเวิร์กจะจัดการสถิติการใช้งานแบตเตอรี่ทั้งหมดโดยไม่จำเป็นต้องมีการแก้ไขจาก OEM
ค่าโปรไฟล์พลังงาน
ข้อควรระวัง: ผู้ผลิตอุปกรณ์ต้องระบุโปรไฟล์พลังงานของชิ้นส่วนประกอบซึ่งกำหนดค่าการใช้พลังงานปัจจุบันของชิ้นส่วนประกอบและการสิ้นเปลืองแบตเตอรี่โดยประมาณที่เกิดจากชิ้นส่วนประกอบเมื่อเวลาผ่านไป โปรไฟล์นี้กำหนดไว้ใน
platform/frameworks/base/core/res/res/xml/power_profile.xml
ดูคําแนะนําเกี่ยวกับการตั้งค่าเหล่านี้ได้ที่ค่ากำลัง
ภายในโปรไฟล์พลังงาน ปริมาณการใช้พลังงานจะระบุเป็นมิลลิแอมป์ (mA) ของกระแสที่ดึงดูดที่แรงดันไฟฟ้าที่ระบุ และอาจเป็นค่าเศษที่ระบุเป็นไมโครแอมป์ (uA) ค่าควรเป็น mA ที่บริโภคที่แบตเตอรี่ ไม่ใช่ค่าที่ใช้กับรางไฟที่ไม่สอดคล้องกับกระแสที่บริโภคจากแบตเตอรี่
เช่น โปรไฟล์พลังงานของจอแสดงผลจะระบุ mA ของกระแสไฟฟ้าที่จําเป็นต่อการเปิดจอแสดงผลไว้ที่ความสว่างขั้นต่ำและสูงสุด หากต้องการระบุต้นทุนพลังงาน (เช่น แบตเตอรี่ที่หมดลงจากคอมโพเนนต์จอแสดงผล) ของการเปิดจอแสดงผลไว้ เฟรมเวิร์กจะติดตามเวลาที่ใช้ในการแสดงผลในระดับความสว่างแต่ละระดับ จากนั้นจะคูณช่วงเวลาเหล่านั้นด้วยต้นทุนความสว่างของจอแสดงผลที่ประมาณ
เฟรมเวิร์กยังคูณเวลา CPU สําหรับแต่ละแอปพลิเคชันด้วย mA ที่จําเป็นในการใช้งาน CPU ที่ความเร็วหนึ่งๆ ด้วย การคํานวณนี้จะสร้างการจัดอันดับแบบเปรียบเทียบปริมาณแบตเตอรี่ที่แอปพลิเคชันใช้โดยเรียกใช้โค้ด CPU (ระบบจะรายงานเวลาที่แอปอยู่เบื้องหน้าและเวลาทั้งหมดรวมถึงกิจกรรมเบื้องหลังแยกกัน)
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ 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,["# Power profiles for Android\n\nBattery use information is derived from battery use statistics and power profile values.\n\nBattery use statistics\n----------------------\n\nThe framework automatically determines battery use statistics by tracking how long device\ncomponents spend in different states. As components (Wi-Fi chipset, cellular radio, Bluetooth, GPS,\ndisplay, CPU) change states (OFF/ON, idle/full power, low/high brightness, etc.), the controlling\nservice reports to the framework BatteryStats service. BatteryStats collects information over time\nand stores it for use across reboots. The service doesn't track battery current draw directly,\nbut instead collects timing information that can be used to approximate battery\nconsumption by different components.\n\nThe framework gathers statistics using the following methods:\n\n- **Push**. Services aware of component changes push state changes to the BatteryStats service.\n- **Pull**. For components such as the CPU use by apps, the framework automatically pulls the data at transition points (such as starting or stopping an activity) to take a snapshot.\n\nResource consumption is associated with the application using the resource. When multiple\napplications simultaneously use a resource (such as wakelocks that prevent the system from\nsuspending), the framework spreads consumption across those applications, although not necessarily\nequally.\n\nTo avoid losing use statistics for a shutdown event, which may indicate battery power\nconsumption problems (i.e. shutdown occurs because the battery reached zero remaining capacity),\nthe framework flashes statistics approximately every 30 minutes.\n\nBattery use statistics are handled entirely by the framework and do not require OEM\nmodifications.\n\nPower profile values\n--------------------\n\n**Caution:** Device manufacturers must provide a component power\nprofile that defines the current consumption value for the component and the approximate battery\ndrain caused by the component over time. This profile is defined in\n[platform/frameworks/base/core/res/res/xml/power_profile.xml](https://android.googlesource.com/platform/frameworks/base/+/android16-release/core/res/res/xml/power_profile.xml).\nFor guidance on these settings, see [Power Values](/docs/core/power/values).\n\nWithin a power profile, power consumption is specified in milliamps (mA) of current draw at a\nnominal voltage and can be a fractional value specified in microamps (uA). The value should be the\nmA consumed at the battery and not a value applicable to a power rail that does not correspond to\ncurrent consumed from the battery.\n\nFor example, a display power profile specifies the mA of current required to keep the display on\nat minimum brightness and at maximum brightness. To determine the power cost (i.e the battery\ndrained by the display component) of keeping the display on, the framework tracks the time spent at\neach brightness level, then multiplies those time intervals by an interpolated display brightness\ncost.\n\nThe framework also multiplies the CPU time for each application by the mA required to run the\nCPU at a specific speed. This calculation establishes a comparative ranking of how much battery an\napplication consumes by executing CPU code (time as the foreground app and total time including\nbackground activity are reported separately)."]]