Android 9.0 系统默认显示电量百分比

Android 9.0 系统默认显示电量百分比

近来收到项目需求需要设备默认显示电量百分比,具体修改参照如下:

/frameworks/base/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java

    private void updateShowPercent() {
        final boolean showing = mBatteryPercentView != null;
        final boolean systemSetting = 0 != Settings.System
                .getIntForUser(getContext().getContentResolver(),
-                SHOW_BATTERY_PERCENT, 0, mUser);
+                SHOW_BATTERY_PERCENT, 1, mUser);

/frameworks/base/packages/SystemUI/src/com/android/systemui/tuner/BatteryPreference.java

    public void onAttached() {
        super.onAttached();
        mHasPercentage = Settings.System.getInt(getContext().getContentResolver(),
-                SHOW_BATTERY_PERCENT, 0) != 0;
+                SHOW_BATTERY_PERCENT, 1) != 0;

/packages/apps/Settings/src/com/android/settings/display/BatteryPercentagePreferenceController.java
 

    public void updateState(Preference preference) {
        int setting = Settings.System.getInt(mContext.getContentResolver(),
-                SHOW_BATTERY_PERCENT, 0);
+                SHOW_BATTERY_PERCENT, 1);

重新编译验证,修改生效,设备已默认显示电量百分比

你可能感兴趣的:(Android,framework,android)