Hi All,
Our project is a customized Android tablet, developed based on i.MX6 Sololite EVK with IMX6_JB43_110_ANDROID_SOURCE_BSP, the battery gauge is STC3115 and the driver porting is successful, working w/o problem. When the power cord plugging into the micro-USB port, we can see the battery icon became charging icon with a "flash" sign, however, the battery level won't change until we unplug the power cord, or plug the power cord again then we can see the updated battery level.
Have studying and understand we might need to implement a program like:
private final BroadcastReceiver mBatteryInfoReceiver = new BroadcastReceiver(){
@Override
public void onReceive(Context arg0, Intent intent) {
int rawLevel = intent.getIntExtra("level", -1);
int scale = intent.getIntExtra("scale", -1);
int status = intent.getIntExtra("status", -1);
// Do something
}
};
public void onCreate() {
registerReceiver(this.mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
}
public void onDestroy() {
unregisterReceiver(this.mBatteryInfoReceiver);
}
But we think there should be an existing mechanism in the BSP since this is a general requirement for the Android tablets. We have reviewed BatterManager.java, BatteryService.java and BatteryController.java in BSP, and developer.Android.com (Monitoring the Battery Level and Charging State | Android Developers) but still got no clear idea on how to make the Android battery icon in the status bar always reflecting the correct battery capacity level, either in charging and not-charging status. We understand it's might impact the battery life if we regularly checked the battery status but we just hope the battery icon can be updated per 5 or 10 mins.
Please advise if you have the solution, any suggestion/comment are also more than welcome!
-tftu
Please take a look at the following thread, it might help you: