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: Ie47f1d1d909d7f753619ff91041e24d58ae934fb Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -113,15 +113,27 @@ public class BlockingPrefWithSliceController extends BasePreferenceController im
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
if (mLiveData != null) {
|
if (mLiveData == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
mLiveData.observeForever(this);
|
mLiveData.observeForever(this);
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
Log.w(TAG, "observeForever - no permission");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStop() {
|
public void onStop() {
|
||||||
if (mLiveData != null) {
|
if (mLiveData == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
mLiveData.removeObserver(this);
|
mLiveData.removeObserver(this);
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
Log.w(TAG, "removeObserver - no permission");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -44,7 +44,6 @@ public class SlicePreferenceController extends BasePreferenceController implemen
|
|||||||
LiveData<Slice> mLiveData;
|
LiveData<Slice> mLiveData;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
SlicePreference mSlicePreference;
|
SlicePreference mSlicePreference;
|
||||||
private boolean mIsObservering = false;
|
|
||||||
private Uri mUri;
|
private Uri mUri;
|
||||||
|
|
||||||
public SlicePreferenceController(Context context, String preferenceKey) {
|
public SlicePreferenceController(Context context, String preferenceKey) {
|
||||||
@@ -74,9 +73,14 @@ public class SlicePreferenceController extends BasePreferenceController implemen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
if (mLiveData != null && !mIsObservering) {
|
if (mLiveData == null) {
|
||||||
mIsObservering = true;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
mLiveData.observeForever(this);
|
mLiveData.observeForever(this);
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
Log.w(TAG, "observeForever - no permission");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,9 +95,14 @@ public class SlicePreferenceController extends BasePreferenceController implemen
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void removeLiveDataObserver() {
|
private void removeLiveDataObserver() {
|
||||||
if (mLiveData != null && mIsObservering && mLiveData.hasActiveObservers()) {
|
if (mLiveData == null) {
|
||||||
mIsObservering = false;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
mLiveData.removeObserver(this);
|
mLiveData.removeObserver(this);
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
Log.w(TAG, "removeLiveDataObserver - no permission");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user