Fix force close for updating UI after activity destroyed.

If activity is finishing or destroyed, getting activity context will return null results in settings app force close.

Directly return if network select activity is finishing or destroyed when handling network scan callback.

Bug: 372123288
Change-Id: Ia8c89569761b66da58cafd0140ceda29ac7d678c
This commit is contained in:
hoffc
2024-10-08 17:29:32 +08:00
parent 28f83ffab0
commit 2545f06558

View File

@@ -368,6 +368,11 @@ public class NetworkSelectSettings extends DashboardFragment {
@VisibleForTesting
protected void scanResultHandler(NetworkScanRepository.NetworkScanResult results) {
if (isFinishingOrDestroyed()) {
Log.d(TAG, "scanResultHandler: activity isFinishingOrDestroyed, directly return");
return;
}
mCellInfoList = filterOutSatellitePlmn(results.getCellInfos());
Log.d(TAG, "CellInfoList: " + CellInfoUtil.cellInfoListToString(mCellInfoList));
updateAllPreferenceCategory();