Merge "[Settings] Use background thread to get VoNr state." into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
1fd77775cb
@@ -17,6 +17,8 @@
|
|||||||
package com.android.settings.network.telephony;
|
package com.android.settings.network.telephony;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
import android.os.PersistableBundle;
|
import android.os.PersistableBundle;
|
||||||
import android.telephony.CarrierConfigManager;
|
import android.telephony.CarrierConfigManager;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
@@ -33,9 +35,10 @@ import com.android.internal.telephony.util.ArrayUtils;
|
|||||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnStart;
|
import com.android.settingslib.core.lifecycle.events.OnStart;
|
||||||
import com.android.settingslib.core.lifecycle.events.OnStop;
|
import com.android.settingslib.core.lifecycle.events.OnStop;
|
||||||
|
import com.android.settingslib.utils.ThreadUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Preference controller for "Enhanced 4G LTE"
|
* Preference controller for "Voice over NR".
|
||||||
*/
|
*/
|
||||||
public class NrAdvancedCallingPreferenceController extends TelephonyTogglePreferenceController
|
public class NrAdvancedCallingPreferenceController extends TelephonyTogglePreferenceController
|
||||||
implements LifecycleObserver, OnStart, OnStop {
|
implements LifecycleObserver, OnStart, OnStop {
|
||||||
@@ -50,8 +53,11 @@ public class NrAdvancedCallingPreferenceController extends TelephonyTogglePrefer
|
|||||||
private boolean mIsVonrVisibleFromCarrierConfig = false;
|
private boolean mIsVonrVisibleFromCarrierConfig = false;
|
||||||
private boolean mIsNrEnableFromCarrierConfig = false;
|
private boolean mIsNrEnableFromCarrierConfig = false;
|
||||||
private boolean mHas5gCapability = false;
|
private boolean mHas5gCapability = false;
|
||||||
|
private boolean mIsVoNrEnabled = false;
|
||||||
private Integer mCallState;
|
private Integer mCallState;
|
||||||
|
|
||||||
|
private Handler mHandler = new Handler(Looper.getMainLooper());
|
||||||
|
|
||||||
public NrAdvancedCallingPreferenceController(Context context, String key) {
|
public NrAdvancedCallingPreferenceController(Context context, String key) {
|
||||||
super(context, key);
|
super(context, key);
|
||||||
mTelephonyManager = context.getSystemService(TelephonyManager.class);
|
mTelephonyManager = context.getSystemService(TelephonyManager.class);
|
||||||
@@ -94,6 +100,8 @@ public class NrAdvancedCallingPreferenceController extends TelephonyTogglePrefer
|
|||||||
CarrierConfigManager.KEY_CARRIER_NR_AVAILABILITIES_INT_ARRAY);
|
CarrierConfigManager.KEY_CARRIER_NR_AVAILABILITIES_INT_ARRAY);
|
||||||
mIsNrEnableFromCarrierConfig = !ArrayUtils.isEmpty(nrAvailabilities);
|
mIsNrEnableFromCarrierConfig = !ArrayUtils.isEmpty(nrAvailabilities);
|
||||||
|
|
||||||
|
updateVoNrState();
|
||||||
|
|
||||||
Log.d(TAG, "mHas5gCapability: " + mHas5gCapability
|
Log.d(TAG, "mHas5gCapability: " + mHas5gCapability
|
||||||
+ ",mIsNrEnabledFromCarrierConfig: " + mIsNrEnableFromCarrierConfig
|
+ ",mIsNrEnabledFromCarrierConfig: " + mIsNrEnableFromCarrierConfig
|
||||||
+ ",mIsVonrEnabledFromCarrierConfig: " + mIsVonrEnabledFromCarrierConfig
|
+ ",mIsVonrEnabledFromCarrierConfig: " + mIsVonrEnabledFromCarrierConfig
|
||||||
@@ -162,7 +170,7 @@ public class NrAdvancedCallingPreferenceController extends TelephonyTogglePrefer
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isChecked() {
|
public boolean isChecked() {
|
||||||
return mTelephonyManager.isVoNrEnabled();
|
return mIsVoNrEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -174,6 +182,19 @@ public class NrAdvancedCallingPreferenceController extends TelephonyTogglePrefer
|
|||||||
return isCallStateIdle();
|
return isCallStateIdle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateVoNrState() {
|
||||||
|
ThreadUtils.postOnBackgroundThread(() -> {
|
||||||
|
boolean result = mTelephonyManager.isVoNrEnabled();
|
||||||
|
if (result != mIsVoNrEnabled) {
|
||||||
|
Log.i(TAG, "VoNr state : " + result);
|
||||||
|
mIsVoNrEnabled = result;
|
||||||
|
mHandler.post(() -> {
|
||||||
|
updateState(mPreference);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private class PhoneCallStateTelephonyCallback extends TelephonyCallback implements
|
private class PhoneCallStateTelephonyCallback extends TelephonyCallback implements
|
||||||
TelephonyCallback.CallStateListener {
|
TelephonyCallback.CallStateListener {
|
||||||
|
|
||||||
|
@@ -186,6 +186,7 @@ public class NrAdvancedCallingPreferenceControllerTest {
|
|||||||
doReturn(true).when(mTelephonyManager).isVoNrEnabled();
|
doReturn(true).when(mTelephonyManager).isVoNrEnabled();
|
||||||
mPreference.setChecked(false);
|
mPreference.setChecked(false);
|
||||||
|
|
||||||
|
mController.init(SUB_ID);
|
||||||
mController.updateState(mPreference);
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
assertThat(mPreference.isChecked()).isTrue();
|
assertThat(mPreference.isChecked()).isTrue();
|
||||||
|
Reference in New Issue
Block a user