Remove BluetoothEventManager#setReceiverHandler

Make BluetoothEventManager fields final and remove the method to
unregister receivers unnecessarily (introduced in b/35415158).

Bug: 113122466
Test: runtest systemui && make RunSettingsLibRoboTests
Change-Id: I8f34ab1a809638959ab4096a829c72b3d1ac3a23
diff --git a/packages/SystemUI/src/com/android/systemui/Dependency.java b/packages/SystemUI/src/com/android/systemui/Dependency.java
index 2dd54aa..b2cf305 100644
--- a/packages/SystemUI/src/com/android/systemui/Dependency.java
+++ b/packages/SystemUI/src/com/android/systemui/Dependency.java
@@ -133,6 +133,10 @@
      */
     public static final DependencyKey<Looper> BG_LOOPER = new DependencyKey<>("background_looper");
     /**
+     * Key for getting a background Handler for background work.
+     */
+    public static final DependencyKey<Handler> BG_HANDLER = new DependencyKey<>("background_handler");
+    /**
      * Key for getting a Handler for receiving time tick broadcasts on.
      */
     public static final DependencyKey<Handler> TIME_TICK_HANDLER =
@@ -166,6 +170,7 @@
             thread.start();
             return thread.getLooper();
         });
+        mProviders.put(BG_HANDLER, () -> new Handler(getDependency(BG_LOOPER)));
         mProviders.put(MAIN_HANDLER, () -> new Handler(Looper.getMainLooper()));
         mProviders.put(ActivityStarter.class, () -> new ActivityStarterDelegate());
         mProviders.put(ActivityStarterDelegate.class, () ->
@@ -288,7 +293,7 @@
                 new PluginDependencyProvider(get(PluginManager.class)));
 
         mProviders.put(LocalBluetoothManager.class, () ->
-                LocalBluetoothManager.getInstance(mContext, null));
+                LocalBluetoothManager.create(mContext, getDependency(BG_HANDLER)));
 
         mProviders.put(VolumeDialogController.class, () ->
                 new VolumeDialogControllerImpl(mContext));
diff --git a/packages/SystemUI/src/com/android/systemui/keyboard/KeyboardUI.java b/packages/SystemUI/src/com/android/systemui/keyboard/KeyboardUI.java
index 76a1acc..e0657c9 100644
--- a/packages/SystemUI/src/com/android/systemui/keyboard/KeyboardUI.java
+++ b/packages/SystemUI/src/com/android/systemui/keyboard/KeyboardUI.java
@@ -49,6 +49,7 @@
 import com.android.settingslib.bluetooth.LocalBluetoothManager;
 import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
 import com.android.settingslib.bluetooth.BluetoothUtils;
+import com.android.systemui.Dependency;
 import com.android.systemui.R;
 import com.android.systemui.SystemUI;
 
@@ -171,7 +172,7 @@
             return;
         }
 
-        LocalBluetoothManager bluetoothManager = LocalBluetoothManager.getInstance(context, null);
+        LocalBluetoothManager bluetoothManager = Dependency.get(LocalBluetoothManager.class);
         if (bluetoothManager == null)  {
             if (DEBUG) {
                 Slog.e(TAG, "Failed to retrieve LocalBluetoothManager instance");
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 1085b06..6f64a563 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothControllerImpl.java
@@ -65,7 +65,6 @@
         mLocalBluetoothManager = Dependency.get(LocalBluetoothManager.class);
         mBgHandler = new Handler(bgLooper);
         if (mLocalBluetoothManager != null) {
-            mLocalBluetoothManager.getEventManager().setReceiverHandler(mBgHandler);
             mLocalBluetoothManager.getEventManager().registerCallback(this);
             mLocalBluetoothManager.getProfileManager().addServiceListener(this);
             onBluetoothStateChanged(