RK Android7.1 电池电量 Android5.1 电池图标

一.adb查询电池信息

adb shell dumpsys battery

  

 二.状态栏 电池图标

2.1.布局

frameworks\base\packages\SystemUI\res\layout\system_icons.xml

2.2.SystemUI

diff --git a/frameworks/base/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java b/frameworks/base/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java
index 5047b78..c06abca 100755
--- a/frameworks/base/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java
+++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java
@@ -54,7 +54,7 @@ public class BatteryMeterView extends ImageView implements
 
         mSlotBattery = context.getString(
                 com.android.internal.R.string.status_bar_battery);
-        //setImageDrawable(mDrawable);  
+        setImageDrawable(mDrawable); 
     }

2.3.healthd 电池电量强制100

diff --git a/system/core/healthd/BatteryMonitor.cpp b/system/core/healthd/BatteryMonitor.cpp
index 2ad37c1..10f81c5 100755
--- a/system/core/healthd/BatteryMonitor.cpp
+++ b/system/core/healthd/BatteryMonitor.cpp
@@ -240,9 +240,11 @@ bool BatteryMonitor::update(void) {
     else
         props.batteryPresent = mBatteryDevicePresent;
 
-    props.batteryLevel = mBatteryFixedCapacity ?
-        mBatteryFixedCapacity :
-        getIntField(mHealthdConfig->batteryCapacityPath);
+    //props.batteryLevel = mBatteryFixedCapacity ?
+        //mBatteryFixedCapacity :
+        //getIntField(mHealthdConfig->batteryCapacityPath);
+		props.batteryLevel = 100;
+		
     props.batteryVoltage = getIntField(mHealthdConfig->batteryVoltagePath) / 1000;
 
     if (!mHealthdConfig->batteryCurrentNowPath.isEmpty())

 

Android5.1 电池图标  

1.修改SystemUI目录下的 隐藏下拉的电池图标
frameworks\base\packages\SystemUI\src\com\android\systemui\statusbar\phone\PhoneStatusBarTransitions.java
    public void init() {
        mLeftSide = mView.findViewById(R.id.notification_icon_area);
        mStatusIcons = mView.findViewById(R.id.statusIcons);
        mSignalCluster = mView.findViewById(R.id.signal_cluster);
        
        mBattery = mView.findViewById(R.id.battery);
        if (SystemProperties.get("persist.sys.batteryhide").equals("true")) 
        {               
                mBattery.setVisibility(View.GONE);
        }        
        mClock = mView.findViewById(R.id.clock);
        applyModeBackground(-1, getMode(), false /*animate*/);
        applyMode(getMode(), false /*animate*/);
    }

2.隐藏下拉的电池百分比的显示

frameworks\base\packages\SystemUI\src\com\android\systemui\statusbar\phone\StatusBarHeaderView.java

    private void updateVisibilities() {
        if ( PhoneStatusBar.getSimSwitch() ) {
            int show = 0;
            if(mExpanded) {
                if(mAlarmShowing) {
                    show = 2;
                } else {
                    show = 1;
                }
            }
            mDateExpanded.setVisibility(show==1?View.VISIBLE:View.INVISIBLE);
            mDateCollapsed.setVisibility(show==2?View.VISIBLE:View.INVISIBLE);
            mAlarmStatus.setVisibility(show==2?View.VISIBLE:View.INVISIBLE);
            mSettingsButton.setVisibility(View.INVISIBLE);
            mQsDetailHeader.setVisibility(View.INVISIBLE);
            mSystemIcons.setVisibility(View.INVISIBLE);
            mEmergencyCallsOnly.setVisibility(View.GONE);
            mBatteryLevel.setVisibility(View.GONE);
            mMultiUserSwitch.setVisibility(View.INVISIBLE);
        } else {
            mDateCollapsed.setVisibility(mExpanded && mAlarmShowing ? View.VISIBLE : View.INVISIBLE);
            mDateExpanded.setVisibility(mExpanded && mAlarmShowing ? View.INVISIBLE : View.VISIBLE);
            mAlarmStatus.setVisibility(mExpanded && mAlarmShowing ? View.VISIBLE : View.INVISIBLE);
            mSettingsButton.setVisibility(mExpanded ? View.VISIBLE : View.INVISIBLE);
            mQsDetailHeader.setVisibility(mExpanded && mShowingDetail? View.VISIBLE : View.INVISIBLE);
            mSystemIcons.setVisibility(View.VISIBLE);
            if (mSignalCluster != null) {
                updateSignalClusterDetachment();
            }
            mEmergencyCallsOnly.setVisibility(mExpanded && mShowEmergencyCallsOnly ? VISIBLE : GONE);
            //mBatteryLevel.setVisibility(mExpanded ? View.VISIBLE : View.GONE); 隐藏电池百分比
           if(SystemProperties.get("persist.sys.batteryhide").equals("true")){    
               mBatteryLevel.setVisibility(View.GONE);
           }else{
               mBatteryLevel.setVisibility(View.VISIBLE);
               }          
            mMultiUserSwitch.setVisibility(View.VISIBLE);
        }
    }

  

  

  

posted @ 2021-04-25 10:39  CrushGirl  阅读(609)  评论(0编辑  收藏  举报