//SystemUI中的获取状态项
frameworks\base\packages\SystemUI\src\com\android\systemui\statusbar\policy\ BatteryController.java
/// M: Support "battery percentage". @{
private boolean mShouldShowBatteryPercentage = true;//the default value false
public BatteryController(Context context) {
mContext = context;
/// M: Support "battery percentage".
//modify support battery percentage lhw start
//mShouldShowBatteryPercentage = (Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.BATTERY_PERCENTAGE, 0) != 0);
private void refreshBatteryPercentage() {
if (mLabelViews.size() > 0) {
TextView v = mLabelViews.get(0);
if (v != null) {
//modify show BatteryPercentage lhw start
if (mShouldShowBatteryPercentage) {
v.setVisibility(View.GONE);
} else {
v.setText(mBatteryPercentage);
v.setVisibility(View.VISIBLE);
}
/* if (mShouldShowBatteryPercentage) {
v.setText(mBatteryPercentage);
v.setVisibility(View.VISIBLE);
} else {a
v.setVisibility(View.GONE);
}*/
//modify show BatteryPercentage lhw end
}
}
}
//Settiing 中的电池开关控制项
package\apps\Settings …..PowerUsageExts.java
public boolean onPowerUsageExtItemsClick(PreferenceScreen preferenceScreen, Preference preference) {
} else if (KEY_BATTERY_PERCENTAGE.equals(preference.getKey())) {
int state = pref.isChecked() ? 1 : 0;
Xlog.d(TAG, "battery percentage state: " + state);
Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.BATTERY_PERCENTAGE, state);
// Post the intent
Intent intent = new Intent(ACTION_BATTERY_PERCENTAGE_SWITCH);
intent.putExtra("state", state);
// { @: ALPS01292477
if (mBatterrPercentPrf != null) {
mBatterrPercentPrf.setChecked(pref.isChecked());
} // @ }
// @ CR: ALPS00462531 for multi user
mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
} else if (KEY_BACKGROUND_POWER_SAVING.equals(preference.getKey())) {