summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src/com/android/systemui/settings
diff options
context:
space:
mode:
authorAdrian Roos <roosa@google.com>2014-08-15 20:11:38 +0200
committerAdrian Roos <roosa@google.com>2014-08-15 19:09:09 +0000
commitb7ebbded5f1512c5747acc0f06a42399d7710728 (patch)
treec6b4226a89996ea75abcb4a4aa981417581e59af /packages/SystemUI/src/com/android/systemui/settings
parent4482e4bb8d1f5fe586b641bc3d6298dc7b8fee80 (diff)
downloadframeworks_base-b7ebbded5f1512c5747acc0f06a42399d7710728.zip
frameworks_base-b7ebbded5f1512c5747acc0f06a42399d7710728.tar.gz
frameworks_base-b7ebbded5f1512c5747acc0f06a42399d7710728.tar.bz2
Fix errors that could lead to brightness flickering
Ensures that changing the brightness doesn't lead to another write to settings from SystemUI. Also makes sure that a BrightnessDialog from a background user is never showing. While we're in there, fix the obsolete window flags as well and ensure BrightnessDialog only ever allocates one BrightnessController. Bug: 16297345 Change-Id: Id95b598b0fa99680072bc160afb00d2cd49f05ca
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/settings')
-rw-r--r--packages/SystemUI/src/com/android/systemui/settings/BrightnessController.java34
-rw-r--r--packages/SystemUI/src/com/android/systemui/settings/BrightnessDialog.java16
2 files changed, 25 insertions, 25 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/settings/BrightnessController.java b/packages/SystemUI/src/com/android/systemui/settings/BrightnessController.java
index 2113c68..9fbcd7f 100644
--- a/packages/SystemUI/src/com/android/systemui/settings/BrightnessController.java
+++ b/packages/SystemUI/src/com/android/systemui/settings/BrightnessController.java
@@ -59,6 +59,7 @@ public class BrightnessController implements ToggleSlider.Listener {
private boolean mAutomatic;
private boolean mListening;
+ private boolean mExternalChange;
public interface BrightnessStateChangeCallback {
public void onBrightnessLevelChanged();
@@ -86,19 +87,24 @@ public class BrightnessController implements ToggleSlider.Listener {
@Override
public void onChange(boolean selfChange, Uri uri) {
if (selfChange) return;
- if (BRIGHTNESS_MODE_URI.equals(uri)) {
- updateMode();
- updateSlider();
- } else if (BRIGHTNESS_URI.equals(uri) && !mAutomatic) {
- updateSlider();
- } else if (BRIGHTNESS_ADJ_URI.equals(uri) && mAutomatic) {
- updateSlider();
- } else {
- updateMode();
- updateSlider();
- }
- for (BrightnessStateChangeCallback cb : mChangeCallbacks) {
- cb.onBrightnessLevelChanged();
+ try {
+ mExternalChange = true;
+ if (BRIGHTNESS_MODE_URI.equals(uri)) {
+ updateMode();
+ updateSlider();
+ } else if (BRIGHTNESS_URI.equals(uri) && !mAutomatic) {
+ updateSlider();
+ } else if (BRIGHTNESS_ADJ_URI.equals(uri) && mAutomatic) {
+ updateSlider();
+ } else {
+ updateMode();
+ updateSlider();
+ }
+ for (BrightnessStateChangeCallback cb : mChangeCallbacks) {
+ cb.onBrightnessLevelChanged();
+ }
+ } finally {
+ mExternalChange = false;
}
}
@@ -191,6 +197,8 @@ public class BrightnessController implements ToggleSlider.Listener {
@Override
public void onChanged(ToggleSlider view, boolean tracking, boolean automatic, int value) {
updateIcon(mAutomatic);
+ if (mExternalChange) return;
+
if (!mAutomatic) {
final int val = value + mMinimumBacklight;
setBrightness(val);
diff --git a/packages/SystemUI/src/com/android/systemui/settings/BrightnessDialog.java b/packages/SystemUI/src/com/android/systemui/settings/BrightnessDialog.java
index d113139..a1704ff 100644
--- a/packages/SystemUI/src/com/android/systemui/settings/BrightnessDialog.java
+++ b/packages/SystemUI/src/com/android/systemui/settings/BrightnessDialog.java
@@ -40,35 +40,27 @@ public class BrightnessDialog extends Activity {
super.onCreate(savedInstanceState);
final Window window = getWindow();
- final WindowManager.LayoutParams lp = window.getAttributes();
- // Offset from the top
- lp.y = getResources().getDimensionPixelOffset(R.dimen.volume_panel_top);
- lp.type = WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY;
- lp.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS;
-
- window.setAttributes(lp);
window.setGravity(Gravity.TOP);
window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
window.requestFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.quick_settings_brightness_dialog);
+
+ final ImageView icon = (ImageView) findViewById(R.id.brightness_icon);
+ final ToggleSlider slider = (ToggleSlider) findViewById(R.id.brightness_slider);
+ mBrightnessController = new BrightnessController(this, icon, slider);
}
@Override
protected void onStart() {
super.onStart();
-
- final ImageView icon = (ImageView) findViewById(R.id.brightness_icon);
- final ToggleSlider slider = (ToggleSlider) findViewById(R.id.brightness_slider);
- mBrightnessController = new BrightnessController(this, icon, slider);
mBrightnessController.registerCallbacks();
}
@Override
protected void onStop() {
super.onStop();
-
mBrightnessController.unregisterCallbacks();
}