Merge "Fix crash when showing the device not found dialog." into main
diff --git a/src/com/android/settings/connecteddevice/fastpair/FastPairDeviceGroupController.java b/src/com/android/settings/connecteddevice/fastpair/FastPairDeviceGroupController.java
index 8918f01..52ad91c 100644
--- a/src/com/android/settings/connecteddevice/fastpair/FastPairDeviceGroupController.java
+++ b/src/com/android/settings/connecteddevice/fastpair/FastPairDeviceGroupController.java
@@ -82,6 +82,7 @@
     @Override
     public void onStart(@NonNull LifecycleOwner owner) {
         if (mFastPairDeviceUpdater != null) {
+            mFastPairDeviceUpdater.setPreferenceContext(mContext);
             mFastPairDeviceUpdater.registerCallback();
         } else {
             if (DEBUG) {
@@ -94,6 +95,7 @@
     @Override
     public void onStop(@NonNull LifecycleOwner owner) {
         if (mFastPairDeviceUpdater != null) {
+            mFastPairDeviceUpdater.setPreferenceContext(null);
             mFastPairDeviceUpdater.unregisterCallback();
         } else {
             if (DEBUG) {
diff --git a/src/com/android/settings/connecteddevice/fastpair/FastPairDevicePreferenceController.java b/src/com/android/settings/connecteddevice/fastpair/FastPairDevicePreferenceController.java
index 76c9d00..a1c6d18 100644
--- a/src/com/android/settings/connecteddevice/fastpair/FastPairDevicePreferenceController.java
+++ b/src/com/android/settings/connecteddevice/fastpair/FastPairDevicePreferenceController.java
@@ -91,6 +91,7 @@
     @Override
     public void onStart(@NonNull LifecycleOwner owner) {
         if (mFastPairDeviceUpdater != null) {
+            mFastPairDeviceUpdater.setPreferenceContext(mContext);
             mFastPairDeviceUpdater.registerCallback();
         } else {
             if (DEBUG) {
@@ -103,6 +104,7 @@
     @Override
     public void onStop(@NonNull LifecycleOwner owner) {
         if (mFastPairDeviceUpdater != null) {
+            mFastPairDeviceUpdater.setPreferenceContext(null);
             mFastPairDeviceUpdater.unregisterCallback();
         } else {
             if (DEBUG) {
@@ -118,7 +120,6 @@
         mPreferenceGroup = screen.findPreference(getPreferenceKey());
         mSeeAllPreference = mPreferenceGroup.findPreference(KEY_SEE_ALL);
         updatePreferenceVisibility();
-
         if (isAvailable()) {
             final Context context = screen.getContext();
             mFastPairDeviceUpdater.setPreferenceContext(context);
diff --git a/src/com/android/settings/connecteddevice/fastpair/FastPairDeviceUpdater.java b/src/com/android/settings/connecteddevice/fastpair/FastPairDeviceUpdater.java
index b975b9e..d1407ae 100644
--- a/src/com/android/settings/connecteddevice/fastpair/FastPairDeviceUpdater.java
+++ b/src/com/android/settings/connecteddevice/fastpair/FastPairDeviceUpdater.java
@@ -16,37 +16,24 @@
 
 package com.android.settings.connecteddevice.fastpair;
 
-import android.annotation.NonNull;
+import android.annotation.Nullable;
 import android.content.Context;
 
 /**
- * Updates the Fast Pair devices. It notifies the upper level whether to add/remove the
- * preference through {@link DevicePreferenceCallback}
+ * Updates the Fast Pair devices. It notifies the upper level whether to add/remove the preference
+ * through {@link DevicePreferenceCallback}
  */
 public interface FastPairDeviceUpdater {
 
-    /**
-     * Registers the Fast Pair event callback and update the list
-     */
-    default void registerCallback() {
-    }
+    /** Registers the Fast Pair event callback and update the list */
+    default void registerCallback() {}
 
-    /**
-     * Unregisters the Fast Pair event callback
-     */
-    default void unregisterCallback() {
-    }
+    /** Unregisters the Fast Pair event callback */
+    default void unregisterCallback() {}
 
-    /**
-     * Forces to update the list of Fast Pair devices
-     */
-    default void forceUpdate() {
-    }
+    /** Forces to update the list of Fast Pair devices */
+    default void forceUpdate() {}
 
-    /**
-     * Sets the context to generate the {@link Preference}, so it could get the correct theme.
-     */
-    default void setPreferenceContext(@NonNull Context preferenceContext) {
-    }
+    /** Sets the context to generate the {@link Preference}, so it could get the correct theme. */
+    default void setPreferenceContext(@Nullable Context preferenceContext) {}
 }
-