Handle null intent in WifiCallingPreferenceController
When intent is null, we will hide wifi calling preference however its listener might still triggered with null intent. This CL update controller so it can handle this event inside listener callback. Fixes: 135095929 Test: RunSettingsRoboTests Change-Id: I4c5aba03871f11a2d9f9b4da329c2c2655ff9adb
This commit is contained in:
@@ -114,6 +114,10 @@ public class WifiCallingPreferenceController extends TelephonyBasePreferenceCont
|
|||||||
if (mSimCallManager != null) {
|
if (mSimCallManager != null) {
|
||||||
Intent intent = MobileNetworkUtils.buildPhoneAccountConfigureIntent(mContext,
|
Intent intent = MobileNetworkUtils.buildPhoneAccountConfigureIntent(mContext,
|
||||||
mSimCallManager);
|
mSimCallManager);
|
||||||
|
if (intent == null) {
|
||||||
|
// Do nothing in this case since preference is invisible
|
||||||
|
return;
|
||||||
|
}
|
||||||
final PackageManager pm = mContext.getPackageManager();
|
final PackageManager pm = mContext.getPackageManager();
|
||||||
List<ResolveInfo> resolutions = pm.queryIntentActivities(intent, 0);
|
List<ResolveInfo> resolutions = pm.queryIntentActivities(intent, 0);
|
||||||
preference.setTitle(resolutions.get(0).loadLabel(pm));
|
preference.setTitle(resolutions.get(0).loadLabel(pm));
|
||||||
|
@@ -27,6 +27,7 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.PersistableBundle;
|
import android.os.PersistableBundle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
import android.telecom.PhoneAccountHandle;
|
||||||
import android.telephony.CarrierConfigManager;
|
import android.telephony.CarrierConfigManager;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
@@ -117,6 +118,14 @@ public class WifiCallingPreferenceControllerTest {
|
|||||||
assertThat(mPreference.isEnabled()).isFalse();
|
assertThat(mPreference.isEnabled()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateState_invalidPhoneAccountHandle_shouldNotCrash() {
|
||||||
|
mController.mSimCallManager = new PhoneAccountHandle(null /* invalid */, "");
|
||||||
|
|
||||||
|
//Should not crash
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateState_wfcNonRoaming() {
|
public void updateState_wfcNonRoaming() {
|
||||||
assertNull(mController.mSimCallManager);
|
assertNull(mController.mSimCallManager);
|
||||||
|
Reference in New Issue
Block a user