安卓11双屏双背光修改方法

安卓11上调双屏异显功能,系统驱动默认支持双背光功能,老一点的系统不支持双背光驱动,所以老版本的双屏异显都是同时控制2个屏的背光,客户也没做特别要求,新版本客户有这个需求了,所以就想办法去实现;底层已经出现了2个背光节点,但是上层就没有做这个功能,硬件上2个背光也是分开的,默认双屏点亮后系统只能调默认原生的那个背光,自己修改节点的背光要想办法去实现,不说了,直接上货:

1.从系统状态栏滑竿调整背光的代码开始追起,

  frameworks/base/packages/SystemUI/src/com/android/systemui/settings/BrightnessController.java
  public void onChanged(ToggleSlider toggleSlider, boolean tracking, boolean automatic,
            int value, boolean stopTracking) ->
          final float valFloat = convertGammaToLinearFloat(value,
                minBacklight, maxBacklight);
        if (stopTracking) {
            // TODO(brightnessfloat): change to use float value instead.
            MetricsLogger.action(mContext, metric,
                    BrightnessSynchronizer.brightnessFloatToInt(mContext, valFloat));

        }
       setBrightness(valFloat);
    private void setBrightness(float brightness) {
        mDisplayManager.setTemporaryBrightness(brightness);
    }
->
frameworks/base/core/java/android/hardware/display/DisplayManager.java
    public void setTemporaryBrightness(float brightness) {
        mGlobal.setTemporaryBrightness(brightness);
    }
->   
frameworks/base/core/java/android/hardware/display/DisplayManagerGlobal.java
    public void setTemporaryBrightness(float brightness) {
        try {
            mDm.setTemporaryBrightness(brightness);
        } catch (RemoteException ex) {
            throw ex.rethrowFromSystemServer();
        }
    }

2.中间代码有兴趣的自己追,我不追了,最终会调用到hal层里面,修改补丁如下:

Index: hardware/rockchip/light_aidl/Android.bp
===================================================================
--- hardware/rockchip/light_aidl/Android.bp	(revision 844)
+++ hardware/rockchip/light_aidl/Android.bp	(working copy)
@@ -7,6 +7,7 @@
     shared_libs: [
         "libbase",
         "liblog",
+        "libcutils",   //加这个是为了在cpp文件调用property接口
         "libbinder_ndk",
         "android.hardware.light-ndk_platform",
     ],
Index: hardware/rockchip/light_aidl/Lights.cpp
===================================================================
--- hardware/rockchip/light_aidl/Lights.cpp	(revision 844)
+++ hardware/rockchip/light_aidl/Lights.cpp	(working copy)
@@ -23,6 +23,7 @@
 
 #include <aidl/android/hardware/light/LightType.h>
 #include <aidl/android/hardware/light/FlashMode.h>
+#include <cutils/properties.h>
 
 using namespace std;
 
@@ -54,9 +55,19 @@
 }
 
 const char* getDriverPath(LightType type) {
+
+
     switch (type) {
         case LightType::BACKLIGHT:
-            return "/sys/class/backlight/backlight/brightness";
+			char value[PROPERTY_VALUE_MAX];
+			property_get("persist.sys.backlight", value, "");
+
+			if(!strcmp(value,"1")){
+		          return "/sys/class/backlight/backlight1/brightness";
+			}
+			else{
+				  return "/sys/class/backlight/backlight/brightness";
+			}
         case LightType::BUTTONS:
             return "/sys/class/leds/button-backlight/brightness";
         case LightType::BATTERY:
相关推荐
li_liuliu10 分钟前
Android4.4 在系统中添加自己的System Service
android
C4rpeDime2 小时前
自建MD5解密平台-续
android
鲤籽鲲4 小时前
C# Random 随机数 全面解析
android·java·c#
m0_548514778 小时前
2024.12.10——攻防世界Web_php_include
android·前端·php
凤邪摩羯8 小时前
Android-性能优化-03-启动优化-启动耗时
android
凤邪摩羯8 小时前
Android-性能优化-02-内存优化-LeakCanary原理解析
android
喀什酱豆腐9 小时前
Handle
android
m0_7482329210 小时前
Android Https和WebView
android·网络协议·https
m0_7482517210 小时前
Android webview 打开本地H5项目(Cocos游戏以及Unity游戏)
android·游戏·unity
m0_7482546612 小时前
go官方日志库带色彩格式化
android·开发语言·golang