近期任务点:修改Android4.4.4系统在低电量时候弹出的提醒框。
找了一番,发现在SystemUI里面。发现SystemUI涵盖的内容还是很多了,这个之后有时间得仔细看看。
OK,我们接着说今天的主题,过程不必赘述。定位到方法体,文件在framework/base/packages/SystemUI/syc/com/android/systemui/power/PowerUI.java 类。
方法体的位置在191行showLowBatteryWarning()。注意这里说的是Android4.4.4的源码位置,其他的不一定在这个位置,但是基本上是在SystemUI这个project下面。
void showLowBatteryWarning() {
Slog.i(TAG,
((mBatteryLevelTextView == null) ? "showing" : "updating")
+ " low battery warning: level=" + mBatteryLevel
+ " [" + findBatteryLevelBucket(mBatteryLevel) + "]");
CharSequence levelText = mContext.getString(
R.string.battery_low_percent_format, mBatteryLevel);
if (mBatteryLevelTextView != null) {
mBatteryLevelTextView.setText(levelText);
} else {
View v = View.inflate(mContext, R.layout.battery_low, null);
mBatteryLevelTextView = (TextView)v.findViewById(R.id.level_percent);
mBatteryLevelTextView.setText(levelText);
AlertDialog.Builder b = new AlertDialog.Builder(mContext);
b.setCancelable(true);
b.setTitle(R.string.battery_low_title);
b.setView(v);
b.setIconAttribute(android.R.attr.alertDialogIcon);
b.setPositiveButton(android.R.string.ok, null);
final Intent intent = new Intent(Intent.ACTION_POWER_USAGE_SUMMARY);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_MULTIPLE_TASK
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
| Intent.FLAG_ACTIVITY_NO_HISTORY);
if (intent.resolveActivity(mContext.getPackageManager()) != null) {
b.setNegativeButton(R.string.battery_low_why,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mContext.startActivityAsUser(intent, UserHandle.CURRENT);
dismissLowBatteryWarning();
}
});
}
AlertDialog d = b.create();
d.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
mLowBatteryDialog = null;
mBatteryLevelTextView = null;
}
});
d.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
d.getWindow().getAttributes().privateFlags |=
WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS;
d.show();
mLowBatteryDialog = d;
}
}
修改不必说了,改动一下样式,背景,文字颜色也就OK了。