handle negative temperature
When the battery temperature drops to below zero, BatteryLevelInit() fails to show negative temperature. Because the type is unsigned and the size of bit field is 10 bits. So to handle negative temperature, change the type of battery temperature from "char" to "short". And extend the size of temperature bit field from 10 to 11 bits, which first bit is used for the sign bit. Before: 31 24 14 0 +---------------+---------------------+-----------------+ | Battery Level | Battery temperature | Battery Voltage | +---------------+---------------------+-----------------+ After: 31 25 14 0 +-------------+-----------------------+-----------------+ |Battery Level| Battery temperature | Battery Voltage | +-------------+-----------------------+-----------------+ Bits 31..25: battery level percentage (7 bits unsigned) Bits 24..14: battery temperature (11 bits signed) First bit is used for the sign and others for the temperature Bits 13..0: battery voltage in 0.001 volt units (14 bits unsigned) Becuase of changing the format, let the BatteryStatsImpl.VERSION field increment. Bug: 8009514 Change-Id: Iaa12f4d3f14e6cf4d73bc1a23d81c60f9677a499
Loading
Please register or sign in to comment