android电量百分比,Android MTK 修改默认显示电池百分比

//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())) {

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值