diff options
author | 2017-01-11 16:02:51 +0000 | |
---|---|---|
committer | 2017-01-11 16:02:54 +0000 | |
commit | 2d75264011f384d960a0a08d79fabb50bb84d9cd (patch) | |
tree | f5310daa5b4c2977455e6c4603caf257a2285e91 | |
parent | 5becc4872f507a5399d2ccfdd174e97eab6bd699 (diff) | |
parent | 861e09ade26afbeef3bee746ce1d53e0ec82a50e (diff) |
Merge "Fixes for FlashlightTile lifecycle"
-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); } } |