[Provider Model] Fix Internet preference crash
- Post on main thread for UI update - Add NPE checking Bug: 178670562 Test: manual test - atest InternetPreferenceControllerTest Change-Id: I6c37f7dc19f9f9bbc75b36415a47aa1366dc5f5e
This commit is contained in:
@@ -36,6 +36,7 @@ import android.net.NetworkScoreManager;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.telephony.SubscriptionManager;
|
||||
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.preference.Preference;
|
||||
@@ -123,4 +124,13 @@ public class InternetPreferenceControllerTest {
|
||||
|
||||
assertThat(mPreference.getSummary()).isEqualTo(TEST_SUMMARY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateCellularSummary_getNullSubscriptionInfo_shouldNotCrash() {
|
||||
final SubscriptionManager subscriptionManager = mock(SubscriptionManager.class);
|
||||
when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(subscriptionManager);
|
||||
when(subscriptionManager.getDefaultDataSubscriptionInfo()).thenReturn(null);
|
||||
|
||||
mController.updateCellularSummary();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user