一.现象
Android7.1 进Camera2 背光亮度会增加到 brightness 229 ,退出之后Camera2 亮度会回到默认值,不正常退出Camera2 (不完成生命周期)则会保存到 brightness 229
adb shell settings get system screen_brightness
二.RK OS
ZK_RXXX_RK3399_ANDROID7.1packagesappsCamera2srccomandroidcameraCameraActivity.java
setScreenBrightAdjust 设置背光值
mScreenBrightAdjust
restoreScreenBright
private void setMaxScreenBright() { Window win = getWindow(); WindowManager.LayoutParams winParams = win.getAttributes(); Log.i(TAG, "screenBrightness = " + winParams.screenBrightness); winParams.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_FULL; win.setAttributes(winParams); } private int mOrignalScreenBrightMode = -1; private int mOrignalScreenBrightness = -1; private void setScreenBrightAdjust() { mOrignalScreenBrightMode = getScreenMode(); mOrignalScreenBrightness = getScreenBrightness(); Log.i(TAG, "mOrignalScreenBrightMode = " + mOrignalScreenBrightMode + ",mOrignalScreenBrightness = " + mOrignalScreenBrightness); if (mOrignalScreenBrightMode == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) setScreenMode(Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL); if (mOrignalScreenBrightness < ((int) (255 * 0.9f))) saveScreenBrightness((int) (255 * 0.9f)); } private Runnable mScreenBrightAdjust = new Runnable() { @Override public void run() { // TODO Auto-generated method stub setScreenBrightAdjust(); } }; private void restoreScreenBright() { mMainHandler.removeCallbacks(mScreenBrightAdjust); setScreenMode(mOrignalScreenBrightMode); saveScreenBrightness(mOrignalScreenBrightness); } /** * getCurrentScreenBrightMode * SCREEN_BRIGHTNESS_MODE_AUTOMATIC=1 auto * SCREEN_BRIGHTNESS_MODE_MANUAL=0 manual */ private int getScreenMode() { int screenMode=0; try { screenMode = Settings.System.getInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE); } catch (Exception localException){ Log.e(TAG, "getScreenMode error:" + localException); } return screenMode; } /** * getScreenBrightness 0--255 */ private int getScreenBrightness() { int screenBrightness = 255; try { screenBrightness = Settings.System.getInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS); } catch (Exception localException){ Log.e(TAG, "getScreenBrightness error:" + localException); } return screenBrightness; } /** * setScreenMode * SCREEN_BRIGHTNESS_MODE_AUTOMATIC=1 auto * SCREEN_BRIGHTNESS_MODE_MANUAL=0 manual */ private void setScreenMode(int paramInt){ if (paramInt < 0) return; try{ Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE, paramInt); }catch (Exception localException){ Log.e(TAG, "setScreenMode error:" + localException); } } /** * saveScreenBrightness 0--255 */ private void saveScreenBrightness(int paramInt){ if (paramInt < 0) return; try{ Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, paramInt); } catch (Exception localException) { Log.e(TAG, "saveScreenBrightness error:" + localException); } }
把setScreenBrightAdjust 干掉就差不多了………