Protect against weak pointer crash.

Because assuming GC won't run within any period of time is not a
valid testing strategy.

Test: runtest systemui
Change-Id: Id29ab777a70ca27b6ca33bd2a44cfb4c38f0fd09
Fixes: 64581449
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothControllerImpl.java
index fc74952..5b24f9c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothControllerImpl.java
@@ -296,10 +296,13 @@
 
         @Override
         public void run() {
-            mBondState = mDevice.get().getBondState();
-            mMaxConnectionState = mDevice.get().getMaxConnectionState();
-            mUiHandler.removeMessages(H.MSG_PAIRED_DEVICES_CHANGED);
-            mUiHandler.sendEmptyMessage(H.MSG_PAIRED_DEVICES_CHANGED);
+            CachedBluetoothDevice device = mDevice.get();
+            if (device != null) {
+                mBondState = device.getBondState();
+                mMaxConnectionState = device.getMaxConnectionState();
+                mUiHandler.removeMessages(H.MSG_PAIRED_DEVICES_CHANGED);
+                mUiHandler.sendEmptyMessage(H.MSG_PAIRED_DEVICES_CHANGED);
+            }
         }
     }