欢迎来到天天文库
浏览记录
ID:27488435
大小:106.50 KB
页数:23页
时间:2018-12-04
《android的lcd和键盘+背光亮度设置的实现》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Android的LCD和键盘背光亮度设置亮度设置应用设计1.1设置进度条范围背光设置是在:设置->声音和显示->亮度,通过进度条来设置的。文件:packages/apps/Settings/src/com/android/settings/BrightnessPreference.javaprivatestaticfinalintMINIMUM_BACKLIGHT=android.os.Power.BRIGHTNESS_DIM+10;privatestaticfinalintMAXIMUM_BACKLIGHT=android.os.Power.BRIG
2、HTNESS_ON;mSeekBar.setMax(MAXIMUM_BACKLIGHT-MINIMUM_BACKLIGHT);设置进度条的范围,BRIGHTNESS_DIM=20BRIGHTNESS_ON=255,它们的定义在:frameworks/base/core/java/android/os/Power.java1.2设置亮度文件:packages/apps/Settings/src/com/android/settings/BrightnessPreference.javapublicvoidonCheckedChanged(Compound
3、ButtonbuttonView,booleanisChecked){setMode(isChecked?Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC:Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);if(!isChecked){setBrightness(mSeekBar.getProgress()+MINIMUM_BACKLIGHT);}}privatevoidsetBrightness(intbrightness){try{IPowerManager
4、power=IPowerManager.Stub.asInterface(ServiceManager.getService("power"));if(power!=null){power.setBacklightBrightness(brightness);}}catch(RemoteExceptiondoe){}}由以上代码可知,brightness的范围是:20~255;代码通过服务管理器(ServiceManager)获得power服务,然后通过power服务设置亮度。power.setBacklightBrightness的定义在:ramew
5、orks/base/core/java/android/os/IPowerManager.aidl.javaframeworks/base/core/java/android/os/PowerManager.java2,Power服务文件:frameworks/base/core/java/android/os/Power.java/***Brightnessvaluefordimbacklight*/publicstaticfinalintBRIGHTNESS_DIM=20;/***Brightnessvalueforfullyon*/publics
6、taticfinalintBRIGHTNESS_ON=255;文件:frameworks/base/core/java/android/os/PowerManager.java/***setsthebrightnessofthebacklights(screen,keyboard,button).**@parambrightnessvaluefrom0to255**{@hide}*/publicvoidsetBacklightBrightness(intbrightness){try{mService.setBacklightBrightness(br
7、ightness);}catch(RemoteExceptione){}}电源管理器(powermager)将brightness转给电源服务,该服务位置如下:文件:frameworks/base/services/java/com/android/server/PowerManagerService.javapublicvoidsetBacklightBrightness(intbrightness){mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_
8、POWER,null);//Don'tletapplicationsturnthescreen
此文档下载收益归作者所有