鸿蒙传说
/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryControllerImpl.java在Intent.ACTION_BATTERY_CHANGED broadcast处理中调用fireBatteryLevelChanged()方法fireBatteryLevelChanged中会回掉BatteryStateChangeCallbackframeworks/base/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java中实现了BatteryStateChangeCallback, 并向BatteryControllerImpl注册了,mBatteryController.addCallback(this); public void onAttachedToWindow() {
super.onAttachedToWindow();
mBatteryController = Dependency.get(BatteryController.class);
mBatteryController.addCallback(this);
mUser = ActivityManager.getCurrentUser();
getContext().getContentResolver().registerContentObserver(
Settings.System.getUriFor(SHOW_BATTERY_PERCENT), false, mSettingObserver, mUser);
updateShowPercent();
Dependency.get(TunerService.class).addTunable(this, StatusBarIconController.ICON_BLACKLIST);
Dependency.get(ConfigurationController.class).addCallback(this);
mUserTracker.startTracking();
}看下BatteryMeterView中的BatteryStateChangeCallback实现就知道了