Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 12066c72 authored by SongFerngWang's avatar SongFerngWang
Browse files

Update OpenNetworkSelect UI at main thread

Bug: 270652395
Test: local test and atest AutoSelectPreferenceControllerTest
Change-Id: Idfc7a07106d552c35a94414bb14eac0fbdc3974f
parent 813f654a
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -211,6 +211,7 @@ public class AutoSelectPreferenceController extends TelephonyTogglePreferenceCon
                            mSwitchPreference.setChecked(isChecked());
                        }
                        mRecursiveUpdate.decrementAndGet();
                        updateListenerValue();
                        dismissProgressBar();
                    });
                });
@@ -245,13 +246,13 @@ public class AutoSelectPreferenceController extends TelephonyTogglePreferenceCon

        ThreadUtils.postOnBackgroundThread(() -> {
            queryNetworkSelectionMode(INTERNAL_LOG_TAG_INIT);

            //Update UI in UI thread
            mUiHandler.post(() -> {
                if (mSwitchPreference != null) {
                    mRecursiveUpdate.getAndIncrement();
                    mSwitchPreference.setChecked(isChecked());
                    mRecursiveUpdate.decrementAndGet();
                    updateListenerValue();
                }
            });
        });
@@ -267,7 +268,6 @@ public class AutoSelectPreferenceController extends TelephonyTogglePreferenceCon
    private void queryNetworkSelectionMode(String tag) {
        mCacheOfModeStatus = mTelephonyManager.getNetworkSelectionMode();
        Log.d(LOG_TAG, tag + ": query commend done. mCacheOfModeStatus: " + mCacheOfModeStatus);
        updateListenerValue();
    }

    @VisibleForTesting
@@ -284,12 +284,11 @@ public class AutoSelectPreferenceController extends TelephonyTogglePreferenceCon
            }
            mCacheOfModeStatus = networkSelectionMode;
            Log.d(LOG_TAG, "updateUiAutoSelectValue: mCacheOfModeStatus: " + mCacheOfModeStatus);
            updateListenerValue();

            mRecursiveUpdate.getAndIncrement();
            updateState(mSwitchPreference);
            mRecursiveUpdate.decrementAndGet();

            updateListenerValue();
        }
    }