Merge "Fix crash when showing the device not found dialog." into main
This commit is contained in:
@@ -82,6 +82,7 @@ public class FastPairDeviceGroupController extends BasePreferenceController
|
|||||||
@Override
|
@Override
|
||||||
public void onStart(@NonNull LifecycleOwner owner) {
|
public void onStart(@NonNull LifecycleOwner owner) {
|
||||||
if (mFastPairDeviceUpdater != null) {
|
if (mFastPairDeviceUpdater != null) {
|
||||||
|
mFastPairDeviceUpdater.setPreferenceContext(mContext);
|
||||||
mFastPairDeviceUpdater.registerCallback();
|
mFastPairDeviceUpdater.registerCallback();
|
||||||
} else {
|
} else {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
@@ -94,6 +95,7 @@ public class FastPairDeviceGroupController extends BasePreferenceController
|
|||||||
@Override
|
@Override
|
||||||
public void onStop(@NonNull LifecycleOwner owner) {
|
public void onStop(@NonNull LifecycleOwner owner) {
|
||||||
if (mFastPairDeviceUpdater != null) {
|
if (mFastPairDeviceUpdater != null) {
|
||||||
|
mFastPairDeviceUpdater.setPreferenceContext(null);
|
||||||
mFastPairDeviceUpdater.unregisterCallback();
|
mFastPairDeviceUpdater.unregisterCallback();
|
||||||
} else {
|
} else {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
|
@@ -91,6 +91,7 @@ public class FastPairDevicePreferenceController extends BasePreferenceController
|
|||||||
@Override
|
@Override
|
||||||
public void onStart(@NonNull LifecycleOwner owner) {
|
public void onStart(@NonNull LifecycleOwner owner) {
|
||||||
if (mFastPairDeviceUpdater != null) {
|
if (mFastPairDeviceUpdater != null) {
|
||||||
|
mFastPairDeviceUpdater.setPreferenceContext(mContext);
|
||||||
mFastPairDeviceUpdater.registerCallback();
|
mFastPairDeviceUpdater.registerCallback();
|
||||||
} else {
|
} else {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
@@ -103,6 +104,7 @@ public class FastPairDevicePreferenceController extends BasePreferenceController
|
|||||||
@Override
|
@Override
|
||||||
public void onStop(@NonNull LifecycleOwner owner) {
|
public void onStop(@NonNull LifecycleOwner owner) {
|
||||||
if (mFastPairDeviceUpdater != null) {
|
if (mFastPairDeviceUpdater != null) {
|
||||||
|
mFastPairDeviceUpdater.setPreferenceContext(null);
|
||||||
mFastPairDeviceUpdater.unregisterCallback();
|
mFastPairDeviceUpdater.unregisterCallback();
|
||||||
} else {
|
} else {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
@@ -118,7 +120,6 @@ public class FastPairDevicePreferenceController extends BasePreferenceController
|
|||||||
mPreferenceGroup = screen.findPreference(getPreferenceKey());
|
mPreferenceGroup = screen.findPreference(getPreferenceKey());
|
||||||
mSeeAllPreference = mPreferenceGroup.findPreference(KEY_SEE_ALL);
|
mSeeAllPreference = mPreferenceGroup.findPreference(KEY_SEE_ALL);
|
||||||
updatePreferenceVisibility();
|
updatePreferenceVisibility();
|
||||||
|
|
||||||
if (isAvailable()) {
|
if (isAvailable()) {
|
||||||
final Context context = screen.getContext();
|
final Context context = screen.getContext();
|
||||||
mFastPairDeviceUpdater.setPreferenceContext(context);
|
mFastPairDeviceUpdater.setPreferenceContext(context);
|
||||||
|
@@ -16,37 +16,24 @@
|
|||||||
|
|
||||||
package com.android.settings.connecteddevice.fastpair;
|
package com.android.settings.connecteddevice.fastpair;
|
||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.Nullable;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the Fast Pair devices. It notifies the upper level whether to add/remove the
|
* Updates the Fast Pair devices. It notifies the upper level whether to add/remove the preference
|
||||||
* preference through {@link DevicePreferenceCallback}
|
* through {@link DevicePreferenceCallback}
|
||||||
*/
|
*/
|
||||||
public interface FastPairDeviceUpdater {
|
public interface FastPairDeviceUpdater {
|
||||||
|
|
||||||
/**
|
/** Registers the Fast Pair event callback and update the list */
|
||||||
* Registers the Fast Pair event callback and update the list
|
default void registerCallback() {}
|
||||||
*/
|
|
||||||
default void registerCallback() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/** Unregisters the Fast Pair event callback */
|
||||||
* Unregisters the Fast Pair event callback
|
default void unregisterCallback() {}
|
||||||
*/
|
|
||||||
default void unregisterCallback() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/** Forces to update the list of Fast Pair devices */
|
||||||
* Forces to update the list of Fast Pair devices
|
default void forceUpdate() {}
|
||||||
*/
|
|
||||||
default void forceUpdate() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/** Sets the context to generate the {@link Preference}, so it could get the correct theme. */
|
||||||
* Sets the context to generate the {@link Preference}, so it could get the correct theme.
|
default void setPreferenceContext(@Nullable Context preferenceContext) {}
|
||||||
*/
|
|
||||||
default void setPreferenceContext(@NonNull Context preferenceContext) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user