diff options
author | 2017-01-11 09:41:05 -0500 | |
---|---|---|
committer | 2017-01-11 09:41:05 -0500 | |
commit | 861e09ade26afbeef3bee746ce1d53e0ec82a50e (patch) | |
tree | 65cc035d8f3f7e4f16f14072fa935fdf8fd84bb1 | |
parent | fabf8e8187367a1ff9f2cbcc0a986b1e4b5242dc (diff) |
Fixes for FlashlightTile lifecycle
Change-Id: I690440465ef5312d77a279e73eaa22ccbdfbcd53
Fixes: 33861261
Test: runtest systemui
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/qs/tiles/FlashlightTile.java | 7 | ||||
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/policy/FlashlightControllerImpl.java | 2 |
2 files changed, 7 insertions, 2 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/FlashlightTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/FlashlightTile.java index d86aebfd0255..416c7cef8e5d 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/FlashlightTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/FlashlightTile.java @@ -47,13 +47,11 @@ public class FlashlightTile extends QSTile<QSTile.BooleanState> implements public FlashlightTile(Host host) { super(host); mFlashlightController = host.getFlashlightController(); - mFlashlightController.addCallback(this); } @Override protected void handleDestroy() { super.handleDestroy(); - mFlashlightController.removeCallback(this); } @Override @@ -63,6 +61,11 @@ public class FlashlightTile extends QSTile<QSTile.BooleanState> implements @Override public void setListening(boolean listening) { + if (listening) { + mFlashlightController.addCallback(this); + } else { + mFlashlightController.removeCallback(this); + } } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/FlashlightControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/FlashlightControllerImpl.java index 008d837da51c..f0cfa2c40931 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/FlashlightControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/FlashlightControllerImpl.java @@ -121,6 +121,8 @@ public class FlashlightControllerImpl implements FlashlightController { } cleanUpListenersLocked(l); mListeners.add(new WeakReference<>(l)); + l.onFlashlightAvailabilityChanged(mTorchAvailable); + l.onFlashlightChanged(mFlashlightEnabled); } } |