安卓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:
相关推荐
找藉口是失败者的习惯4 小时前
Jetpack Compose 如何布局解析
android·xml·ui
Estar.Lee9 小时前
查手机号归属地免费API接口教程
android·网络·后端·网络协议·tcp/ip·oneapi
温辉_xh9 小时前
uiautomator案例
android
工业甲酰苯胺10 小时前
MySQL 主从复制之多线程复制
android·mysql·adb
少说多做34310 小时前
Android 不同情况下使用 runOnUiThread
android·java
Estar.Lee12 小时前
时间操作[计算时间差]免费API接口教程
android·网络·后端·网络协议·tcp/ip
找藉口是失败者的习惯12 小时前
从传统到未来:Android XML布局 与 Jetpack Compose的全面对比
android·xml
Jinkey13 小时前
FlutterBasic - GetBuilder、Obx、GetX<Controller>、GetxController 有啥区别
android·flutter·ios
大白要努力!15 小时前
Android opencv使用Core.hconcat 进行图像拼接
android·opencv
天空中的野鸟16 小时前
Android音频采集
android·音视频