300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > android电量百分比 Android MTK 修改默认显示电池百分比

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

时间:2020-10-26 00:10:03

相关推荐

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

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。