frameworks\base\packages\SystemUI\res\layout\quick_settings_brightness_dialog.xml
进度条控件
<com.android.systemui.settings.brightness.BrightnessSliderView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/brightness_slider"
android:layout_width="match_parent"
android:layout_height="@dimen/brightness_mirror_height"
android:layout_gravity="center"
android:contentDescription="@string/accessibility_brightness"
android:importantForAccessibility="no" >
<com.android.systemui.settings.brightness.ToggleSeekBar
android:id="@+id/slider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:minHeight="48dp"
android:thumb="@null"
android:background="@null"
android:paddingStart="0dp"
android:paddingEnd="0dp"
android:progressDrawable="@drawable/brightness_progress_drawable"
android:splitTrack="false"
/>
</com.android.systemui.settings.brightness.BrightnessSliderView>
frameworks\base\packages\SystemUI\src\com\android\systemui\settings\brightness\BrightnessSliderView.java
// Inflated from quick_settings_brightness_dialog
@Override
protected void onFinishInflate() {
super.onFinishInflate();
setLayerType(LAYER_TYPE_HARDWARE, null);
mSlider = requireViewById(R.id.slider);
mSlider.setAccessibilityLabel(getContentDescription().toString());
// Finds the progress drawable. Assumes brightness_progress_drawable.xml
try {
LayerDrawable progress = (LayerDrawable) mSlider.getProgressDrawable();
DrawableWrapper progressSlider = (DrawableWrapper) progress
.findDrawableByLayerId(android.R.id.progress);
LayerDrawable actualProgressSlider = (LayerDrawable) progressSlider.getDrawable();
mProgressDrawable = actualProgressSlider.findDrawableByLayerId(R.id.slider_foreground);
} catch (Exception e) {
// Nothing to do, mProgressDrawable will be null.
}
}
frameworks\base\packages\SystemUI\src\com\android\systemui\settings\brightness\BrightnessController.java
private volatile boolean mAutomatic; // Brightness adjusted automatically using ambient light.
private volatile boolean mIsVrModeEnabled;
private boolean mListening;
private boolean mExternalChange;
private boolean mControlValueInitialized;
private float mBrightnessMin = PowerManager.BRIGHTNESS_MIN;
private float mBrightnessMax = PowerManager.BRIGHTNESS_MAX;
private void updateSlider(float brightnessValue, boolean inVrMode) {
final float min;
final float max;
if (inVrMode) {
min = mMinimumBacklightForVr;
max = mMaximumBacklightForVr;
} else {
min = mBrightnessMin;
max = mBrightnessMax;
}
// Ensure the slider is in a fixed position first, then check if we should animate.
if (mSliderAnimator != null && mSliderAnimator.isStarted()) {
mSliderAnimator.cancel();
}
// convertGammaToLinearFloat returns 0-1
if (BrightnessSynchronizer.floatEquals(brightnessValue,
convertGammaToLinearFloat(mControl.getValue(), min, max))) {
// If the value in the slider is equal to the value on the current brightness
// then the slider does not need to animate, since the brightness will not change.
return;
}
// Returns GAMMA_SPACE_MIN - GAMMA_SPACE_MAX
final int sliderVal = convertLinearToGammaFloat(brightnessValue, min, max);
animateSliderTo(sliderVal);
}
亮度最小值由PowerManager.BRIGHTNESS_MIN控制
frameworks\base\core\java\android\os\PowerManager.java 修改即可
//Brightness values for new float implementation:
/**
* Brightness value for fully on as float.
* @hide
*/
public static final float BRIGHTNESS_MAX = 1.0f;
/**
* Brightness value for minimum valid brightness as float.
* @hide
*/
public static final float BRIGHTNESS_MIN = 0.5f;
/**
* Brightness value for fully off in float.
* @hide
*/
public static final float BRIGHTNESS_OFF_FLOAT = -1.0f;