Merge "[Settings] Fix crash when user enter bluetooth page quickly." into udc-dev am: 3e374cc7a7 am: 9b68c3c9c1

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/23601556

Change-Id: Ie63476cbbc3efc7d3d00a7b9bcc0c1772d33e327
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
TreeHugger Robot
2023-06-07 13:44:52 +00:00
committed by Automerger Merge Worker
2 changed files with 28 additions and 7 deletions

View File

@@ -113,15 +113,27 @@ public class BlockingPrefWithSliceController extends BasePreferenceController im
@Override
public void onStart() {
if (mLiveData != null) {
if (mLiveData == null) {
return;
}
try {
mLiveData.observeForever(this);
} catch (SecurityException e) {
Log.w(TAG, "observeForever - no permission");
}
}
@Override
public void onStop() {
if (mLiveData != null) {
if (mLiveData == null) {
return;
}
try {
mLiveData.removeObserver(this);
} catch (SecurityException e) {
Log.w(TAG, "removeObserver - no permission");
}
}