diff --git a/res/values/strings.xml b/res/values/strings.xml
index 6b30ab108c6..92819794fd1 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -10503,6 +10503,9 @@
Preferred network type
Carrier
+
+ Settings version
Calling
diff --git a/res/xml/mobile_network_settings_v2.xml b/res/xml/mobile_network_settings_v2.xml
index f269fade5c9..c3bb656bbfa 100644
--- a/res/xml/mobile_network_settings_v2.xml
+++ b/res/xml/mobile_network_settings_v2.xml
@@ -98,6 +98,12 @@
android:title="@string/carrier_settings_euicc"
settings:controller="com.android.settings.network.telephony.EuiccPreferenceController" />
+
+
diff --git a/src/com/android/settings/network/telephony/CarrierSettingsVersionPreferenceController.java b/src/com/android/settings/network/telephony/CarrierSettingsVersionPreferenceController.java
new file mode 100644
index 00000000000..a6db773d709
--- /dev/null
+++ b/src/com/android/settings/network/telephony/CarrierSettingsVersionPreferenceController.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.network.telephony;
+
+import android.content.Context;
+import android.os.PersistableBundle;
+import android.telephony.CarrierConfigManager;
+import android.telephony.SubscriptionManager;
+
+import com.android.settings.core.BasePreferenceController;
+
+public class CarrierSettingsVersionPreferenceController extends BasePreferenceController {
+
+ private int mSubscriptionId;
+ private CarrierConfigManager mManager;
+
+ public CarrierSettingsVersionPreferenceController(Context context, String preferenceKey) {
+ super(context, preferenceKey);
+ mManager = context.getSystemService(CarrierConfigManager.class);
+ mSubscriptionId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
+ }
+
+ public void init(int subscriptionId) {
+ mSubscriptionId = subscriptionId;
+ }
+
+ @Override
+ public CharSequence getSummary() {
+ final PersistableBundle config = mManager.getConfigForSubId(mSubscriptionId);
+ if (config == null) {
+ return null;
+ }
+ return config.getString(CarrierConfigManager.KEY_CARRIER_CONFIG_VERSION_STRING);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+}
diff --git a/src/com/android/settings/network/telephony/MobileNetworkSettings.java b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
index e05f185716a..b3f085f2cd8 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkSettings.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
@@ -133,6 +133,7 @@ public class MobileNetworkSettings extends RestrictedDashboardFragment {
use(CallsDefaultSubscriptionController.class).init(getLifecycle());
use(SmsDefaultSubscriptionController.class).init(getLifecycle());
use(MobileNetworkSwitchController.class).init(getLifecycle(), mSubId);
+ use(CarrierSettingsVersionPreferenceController.class).init(mSubId);
}
use(MobileDataPreferenceController.class).init(getFragmentManager(), mSubId);
use(RoamingPreferenceController.class).init(getFragmentManager(), mSubId);
diff --git a/tests/robotests/src/com/android/settings/network/telephony/CarrierSettingsVersionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/CarrierSettingsVersionPreferenceControllerTest.java
new file mode 100644
index 00000000000..268c5819e03
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/network/telephony/CarrierSettingsVersionPreferenceControllerTest.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.network.telephony;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.os.PersistableBundle;
+import android.telephony.CarrierConfigManager;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Shadows;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowCarrierConfigManager;
+
+@RunWith(RobolectricTestRunner.class)
+@Config(shadows = ShadowCarrierConfigManager.class)
+public class CarrierSettingsVersionPreferenceControllerTest {
+
+ private ShadowCarrierConfigManager mCarrierConfigManager;
+ private CarrierSettingsVersionPreferenceController mController;
+ private int mSubscriptionId = 1234;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ final Context context = RuntimeEnvironment.application;
+ mController = new CarrierSettingsVersionPreferenceController(context, "dummy_key");
+ mController.init(mSubscriptionId);
+ mCarrierConfigManager = Shadows.shadowOf(
+ context.getSystemService(CarrierConfigManager.class));
+ }
+
+ @Test
+ public void getSummary_nullConfig_noCrash() {
+ mCarrierConfigManager.setConfigForSubId(mSubscriptionId, null);
+ assertThat(mController.getSummary()).isNull();
+ }
+
+ @Test
+ public void getSummary_nullVersionString_noCrash() {
+ mCarrierConfigManager.setConfigForSubId(mSubscriptionId, new PersistableBundle());
+ assertThat(mController.getSummary()).isNull();
+ }
+
+ @Test
+ public void getSummary_hasVersionString_correctSummary() {
+ final PersistableBundle bundle = new PersistableBundle();
+ bundle.putString(CarrierConfigManager.KEY_CARRIER_CONFIG_VERSION_STRING,
+ "test_version_123");
+ mCarrierConfigManager.setConfigForSubId(mSubscriptionId, bundle);
+ assertThat(mController.getSummary()).isEqualTo("test_version_123");
+ }
+}