3737import com .android .systemui .statusbar .policy .RotationLockController ;
3838import com .android .systemui .statusbar .policy .HotspotController ;
3939import com .android .systemui .statusbar .policy .ZenModeController ;
40- import com .android .systemui .volume .VolumeComponent ;
4140
42- import java .util .List ;
41+ import java .util .Collection ;
4342import java .util .Objects ;
4443
4544/**
@@ -134,6 +133,14 @@ public void fireScanStateChanged(boolean state) {
134133 mHandler .obtainMessage (H .SCAN_STATE_CHANGED , state ? 1 : 0 , 0 ).sendToTarget ();
135134 }
136135
136+ public void destroy () {
137+ mHandler .sendEmptyMessage (H .DESTROY );
138+ }
139+
140+ public TState getState () {
141+ return mState ;
142+ }
143+
137144 // call only on tile worker looper
138145
139146 private void handleSetCallback (Callback callback ) {
@@ -181,6 +188,11 @@ protected void handleUserSwitch(int newUserId) {
181188 handleRefreshState (null );
182189 }
183190
191+ protected void handleDestroy () {
192+ setListening (false );
193+ mCallback = null ;
194+ }
195+
184196 protected final class H extends Handler {
185197 private static final int SET_CALLBACK = 1 ;
186198 private static final int CLICK = 2 ;
@@ -190,6 +202,7 @@ protected final class H extends Handler {
190202 private static final int USER_SWITCH = 6 ;
191203 private static final int TOGGLE_STATE_CHANGED = 7 ;
192204 private static final int SCAN_STATE_CHANGED = 8 ;
205+ private static final int DESTROY = 9 ;
193206
194207 private H (Looper looper ) {
195208 super (looper );
@@ -223,6 +236,11 @@ public void handleMessage(Message msg) {
223236 } else if (msg .what == SCAN_STATE_CHANGED ) {
224237 name = "handleScanStateChanged" ;
225238 handleScanStateChanged (msg .arg1 != 0 );
239+ } else if (msg .what == DESTROY ) {
240+ name = "handleDestroy" ;
241+ handleDestroy ();
242+ } else {
243+ throw new IllegalArgumentException ("Unknown msg: " + msg .what );
226244 }
227245 } catch (Throwable t ) {
228246 final String error = "Error in " + name ;
@@ -245,7 +263,8 @@ public interface Host {
245263 void collapsePanels ();
246264 Looper getLooper ();
247265 Context getContext ();
248- List <QSTile <?>> getTiles ();
266+ Collection <QSTile <?>> getTiles ();
267+ void setCallback (Callback callback );
249268 BluetoothController getBluetoothController ();
250269 LocationController getLocationController ();
251270 RotationLockController getRotationLockController ();
@@ -255,6 +274,10 @@ public interface Host {
255274 CastController getCastController ();
256275 FlashlightController getFlashlightController ();
257276 KeyguardMonitor getKeyguardMonitor ();
277+
278+ public interface Callback {
279+ void onTilesChanged ();
280+ }
258281 }
259282
260283 public static class State {
0 commit comments