summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/keyguard/CarrierTextManager.java37
-rw-r--r--packages/SystemUI/src/com/android/systemui/shade/carrier/ShadeCarrierGroupController.java36
-rw-r--r--packages/SystemUI/src/com/android/systemui/shade/carrier/ShadeCarrierGroupControllerLogger.kt9
-rw-r--r--packages/SystemUI/tests/src/com/android/keyguard/CarrierTextManagerTest.java42
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/shade/carrier/ShadeCarrierGroupControllerTest.java71
5 files changed, 155 insertions, 40 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/CarrierTextManager.java b/packages/SystemUI/src/com/android/keyguard/CarrierTextManager.java
index 3bf3fb3a1ebd..b116e297ccbf 100644
--- a/packages/SystemUI/src/com/android/keyguard/CarrierTextManager.java
+++ b/packages/SystemUI/src/com/android/keyguard/CarrierTextManager.java
@@ -308,7 +308,13 @@ public class CarrierTextManager {
} else {
// Don't listen and clear out the text when the device isn't a phone.
mMainExecutor.execute(() -> callback.updateCarrierInfo(
- new CarrierTextCallbackInfo("", null, false, null)
+ new CarrierTextCallbackInfo(
+ /* carrierText= */ "",
+ /* listOfCarriers= */ null,
+ /* anySimReady= */ false,
+ /* isInSatelliteMode= */ false,
+ /* subscriptionIds= */ null,
+ /* airplaneMode= */ false)
));
}
} else {
@@ -448,10 +454,12 @@ public class CarrierTextManager {
displayText = currentSatelliteText;
}
+ boolean isInSatelliteMode = mSatelliteCarrierText != null;
final CarrierTextCallbackInfo info = new CarrierTextCallbackInfo(
displayText,
carrierNames,
!allSimsMissing,
+ isInSatelliteMode,
subsIds,
airplaneMode);
mLogger.logCallbackSentFromUpdate(info);
@@ -757,21 +765,35 @@ public class CarrierTextManager {
public final CharSequence carrierText;
public final CharSequence[] listOfCarriers;
public final boolean anySimReady;
+ public final boolean isInSatelliteMode;
public final int[] subscriptionIds;
public boolean airplaneMode;
@VisibleForTesting
- public CarrierTextCallbackInfo(CharSequence carrierText, CharSequence[] listOfCarriers,
- boolean anySimReady, int[] subscriptionIds) {
- this(carrierText, listOfCarriers, anySimReady, subscriptionIds, false);
+ public CarrierTextCallbackInfo(
+ CharSequence carrierText,
+ CharSequence[] listOfCarriers,
+ boolean anySimReady,
+ int[] subscriptionIds) {
+ this(carrierText,
+ listOfCarriers,
+ anySimReady,
+ /* isInSatelliteMode= */ false,
+ subscriptionIds,
+ /* airplaneMode= */ false);
}
- @VisibleForTesting
- public CarrierTextCallbackInfo(CharSequence carrierText, CharSequence[] listOfCarriers,
- boolean anySimReady, int[] subscriptionIds, boolean airplaneMode) {
+ public CarrierTextCallbackInfo(
+ CharSequence carrierText,
+ CharSequence[] listOfCarriers,
+ boolean anySimReady,
+ boolean isInSatelliteMode,
+ int[] subscriptionIds,
+ boolean airplaneMode) {
this.carrierText = carrierText;
this.listOfCarriers = listOfCarriers;
this.anySimReady = anySimReady;
+ this.isInSatelliteMode = isInSatelliteMode;
this.subscriptionIds = subscriptionIds;
this.airplaneMode = airplaneMode;
}
@@ -782,6 +804,7 @@ public class CarrierTextManager {
+ "carrierText=" + carrierText
+ ", listOfCarriers=" + Arrays.toString(listOfCarriers)
+ ", anySimReady=" + anySimReady
+ + ", isInSatelliteMode=" + isInSatelliteMode
+ ", subscriptionIds=" + Arrays.toString(subscriptionIds)
+ ", airplaneMode=" + airplaneMode
+ '}';
diff --git a/packages/SystemUI/src/com/android/systemui/shade/carrier/ShadeCarrierGroupController.java b/packages/SystemUI/src/com/android/systemui/shade/carrier/ShadeCarrierGroupController.java
index 5e4b1732bd42..a171d33ddb47 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/carrier/ShadeCarrierGroupController.java
+++ b/packages/SystemUI/src/com/android/systemui/shade/carrier/ShadeCarrierGroupController.java
@@ -381,7 +381,10 @@ public class ShadeCarrierGroupController {
mLogger.logHandleUpdateCarrierInfo(info);
mNoSimTextView.setVisibility(View.GONE);
- if (!info.airplaneMode && info.anySimReady) {
+ if (info.isInSatelliteMode) {
+ mLogger.logUsingSatelliteText(info.carrierText);
+ showSingleText(info.carrierText);
+ } else if (!info.airplaneMode && info.anySimReady) {
boolean[] slotSeen = new boolean[SIM_SLOTS];
if (info.listOfCarriers.length == info.subscriptionIds.length) {
mLogger.logUsingSimViews();
@@ -416,22 +419,31 @@ public class ShadeCarrierGroupController {
info.listOfCarriers.length, info.subscriptionIds.length);
}
} else {
+ // No sims or airplane mode (but not WFC), so just show the main carrier text.
mLogger.logUsingNoSimView(info.carrierText);
- // No sims or airplane mode (but not WFC). Do not show ShadeCarrierGroup,
- // instead just show info.carrierText in a different view.
- for (int i = 0; i < SIM_SLOTS; i++) {
- mInfos[i] = mInfos[i].changeVisibility(false);
- mCarrierGroups[i].setCarrierText("");
- mCarrierGroups[i].setVisibility(View.GONE);
- }
- mNoSimTextView.setText(info.carrierText);
- if (!TextUtils.isEmpty(info.carrierText)) {
- mNoSimTextView.setVisibility(View.VISIBLE);
- }
+ showSingleText(info.carrierText);
}
handleUpdateState(); // handleUpdateCarrierInfo is always called from main thread.
}
+ /**
+ * Shows only the given text in a single TextView and hides ShadeCarrierGroup (which would show
+ * individual SIM details).
+ */
+ private void showSingleText(CharSequence text) {
+ for (int i = 0; i < SIM_SLOTS; i++) {
+ mInfos[i] = mInfos[i].changeVisibility(false);
+ mCarrierGroups[i].setCarrierText("");
+ mCarrierGroups[i].setVisibility(View.GONE);
+ }
+ // TODO(b/341841138): Re-name this view now that it's being used for more than just the
+ // no-SIM case.
+ mNoSimTextView.setText(text);
+ if (!TextUtils.isEmpty(text)) {
+ mNoSimTextView.setVisibility(View.VISIBLE);
+ }
+ }
+
private static class H extends Handler {
private Consumer<CarrierTextManager.CarrierTextCallbackInfo> mUpdateCarrierInfo;
private Runnable mUpdateState;
diff --git a/packages/SystemUI/src/com/android/systemui/shade/carrier/ShadeCarrierGroupControllerLogger.kt b/packages/SystemUI/src/com/android/systemui/shade/carrier/ShadeCarrierGroupControllerLogger.kt
index af06a356002b..b563cd9f0301 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/carrier/ShadeCarrierGroupControllerLogger.kt
+++ b/packages/SystemUI/src/com/android/systemui/shade/carrier/ShadeCarrierGroupControllerLogger.kt
@@ -65,6 +65,15 @@ constructor(@ShadeCarrierGroupControllerLog val buffer: LogBuffer) {
)
}
+ fun logUsingSatelliteText(text: CharSequence) {
+ buffer.log(
+ TAG,
+ LogLevel.VERBOSE,
+ { str1 = "$text" },
+ { "┗ updating No SIM view with satellite text=$str1" },
+ )
+ }
+
fun logUsingSimViews() {
buffer.log(TAG, LogLevel.VERBOSE, {}, { "┗ updating SIM views" })
}
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/CarrierTextManagerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/CarrierTextManagerTest.java
index 8c4179d385ba..0a3225eecbe4 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/CarrierTextManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/keyguard/CarrierTextManagerTest.java
@@ -161,8 +161,11 @@ public class CarrierTextManagerTest extends SysuiTestCase {
doAnswer(this::checkMainThread).when(mKeyguardUpdateMonitor)
.removeCallback(any(KeyguardUpdateMonitorCallback.class));
- mCarrierTextCallbackInfo = new CarrierTextManager.CarrierTextCallbackInfo("",
- new CharSequence[]{}, false, new int[]{});
+ mCarrierTextCallbackInfo = new CarrierTextManager.CarrierTextCallbackInfo(
+ /* carrierText= */ "",
+ /* listOfCarriers= */ new CharSequence[]{},
+ /* anySimReady= */ false,
+ /* subscriptionIds= */ new int[]{});
when(mTelephonyManager.getSupportedModemCount()).thenReturn(3);
when(mTelephonyManager.getActiveModemCount()).thenReturn(3);
@@ -473,7 +476,7 @@ public class CarrierTextManagerTest extends SysuiTestCase {
}
@Test
- public void carrierText_satelliteTextNull_notUsed() {
+ public void carrierText_satelliteTextNull_isSatelliteFalse_textNotUsed() {
reset(mCarrierTextCallback);
List<SubscriptionInfo> list = new ArrayList<>();
list.add(TEST_SUBSCRIPTION);
@@ -491,12 +494,38 @@ public class CarrierTextManagerTest extends SysuiTestCase {
CarrierTextManager.CarrierTextCallbackInfo.class);
FakeExecutor.exhaustExecutors(mMainExecutor, mBgExecutor);
- // THEN the default subscription carrier text is used
+ // THEN satellite mode is false and the default subscription carrier text is used
verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
+ assertThat(captor.getValue().isInSatelliteMode).isFalse();
assertThat(captor.getValue().carrierText).isEqualTo(TEST_CARRIER);
}
@Test
+ public void carrierText_hasSatelliteText_isSatelliteTrue_textUsed() {
+ reset(mCarrierTextCallback);
+ List<SubscriptionInfo> list = new ArrayList<>();
+ list.add(TEST_SUBSCRIPTION);
+ when(mKeyguardUpdateMonitor.getSimState(anyInt())).thenReturn(
+ TelephonyManager.SIM_STATE_READY);
+ when(mKeyguardUpdateMonitor.getFilteredSubscriptionInfo()).thenReturn(list);
+ mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
+
+ // WHEN the satellite text is non-null
+ mSatelliteViewModel.getCarrierText().setValue("Satellite Test Text");
+ mTestScope.getTestScheduler().runCurrent();
+
+ ArgumentCaptor<CarrierTextManager.CarrierTextCallbackInfo> captor =
+ ArgumentCaptor.forClass(
+ CarrierTextManager.CarrierTextCallbackInfo.class);
+ FakeExecutor.exhaustExecutors(mMainExecutor, mBgExecutor);
+
+ // THEN satellite mode is true and the satellite text is used
+ verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
+ assertThat(captor.getValue().isInSatelliteMode).isTrue();
+ assertThat(captor.getValue().carrierText).isEqualTo("Satellite Test Text");
+ }
+
+ @Test
public void carrierText_satelliteTextUpdates_autoTriggersCallback() {
reset(mCarrierTextCallback);
List<SubscriptionInfo> list = new ArrayList<>();
@@ -517,6 +546,7 @@ public class CarrierTextManagerTest extends SysuiTestCase {
FakeExecutor.exhaustExecutors(mMainExecutor, mBgExecutor);
verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
// AND use the satellite text as the carrier text
+ assertThat(captor.getValue().isInSatelliteMode).isTrue();
assertThat(captor.getValue().carrierText).isEqualTo("Test satellite text");
// WHEN the satellite text is reset to null
@@ -528,6 +558,7 @@ public class CarrierTextManagerTest extends SysuiTestCase {
// that doesn't include the satellite info
FakeExecutor.exhaustExecutors(mMainExecutor, mBgExecutor);
verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
+ assertThat(captor.getValue().isInSatelliteMode).isFalse();
assertThat(captor.getValue().carrierText).isEqualTo(TEST_CARRIER);
}
@@ -566,10 +597,11 @@ public class CarrierTextManagerTest extends SysuiTestCase {
mCarrierTextManager.setListening(mCarrierTextCallback);
// THEN we should automatically re-trigger #updateCarrierText and get callback info
- // that includes the new satellite text
+ // that includes the new satellite state and text
mTestScope.getTestScheduler().runCurrent();
FakeExecutor.exhaustExecutors(mMainExecutor, mBgExecutor);
verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
+ assertThat(captor.getValue().isInSatelliteMode).isTrue();
assertThat(captor.getValue().carrierText).isEqualTo("New satellite text");
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/carrier/ShadeCarrierGroupControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/shade/carrier/ShadeCarrierGroupControllerTest.java
index 5363c57c1bad..308b3708e407 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/shade/carrier/ShadeCarrierGroupControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/shade/carrier/ShadeCarrierGroupControllerTest.java
@@ -312,9 +312,10 @@ public class ShadeCarrierGroupControllerTest extends LeakCheckedTest {
info = new CarrierTextManager.CarrierTextCallbackInfo(
"",
new CharSequence[]{""},
- true,
+ /* anySimReady= */ true,
+ /* isInSatelliteMode= */ false,
new int[]{0},
- true /* airplaneMode */);
+ /* airplaneMode= */ true);
mCallback.updateCarrierInfo(info);
mTestableLooper.processAllMessages();
assertEquals(View.GONE, mShadeCarrierGroup.getNoSimTextView().getVisibility());
@@ -326,15 +327,59 @@ public class ShadeCarrierGroupControllerTest extends LeakCheckedTest {
info = new CarrierTextManager.CarrierTextCallbackInfo(
"",
new CharSequence[]{FIRST_CARRIER_NAME, ""},
- true,
+ /* anySimReady= */ true,
+ /* isInSatelliteMode= */ false,
new int[]{0, 1},
- false /* airplaneMode */);
+ /* airplaneMode= */ false);
mCallback.updateCarrierInfo(info);
mTestableLooper.processAllMessages();
assertEquals(View.VISIBLE, mShadeCarrierGroupController.getShadeCarrierVisibility(0));
}
@Test
+ public void isInSatelliteMode_true_noSimViewShownWithText() {
+ CarrierTextManager.CarrierTextCallbackInfo
+ info = new CarrierTextManager.CarrierTextCallbackInfo(
+ "Satellite Mode Test",
+ new CharSequence[]{FIRST_CARRIER_NAME},
+ /* anySimReady= */ true,
+ /* isInSatelliteMode= */ true,
+ new int[]{1},
+ /* airplaneMode= */ false);
+
+ mCallback.updateCarrierInfo(info);
+ mTestableLooper.processAllMessages();
+
+ assertThat(mShadeCarrierGroup.getNoSimTextView().getVisibility()).isEqualTo(View.VISIBLE);
+ assertThat(mShadeCarrierGroup.getNoSimTextView().getText()).isEqualTo(
+ "Satellite Mode Test");
+
+ verify(mShadeCarrier1).setVisibility(View.GONE);
+ verify(mShadeCarrier2).setVisibility(View.GONE);
+ verify(mShadeCarrier3).setVisibility(View.GONE);
+ }
+
+ @Test
+ public void isInSatelliteMode_false_normalSimViewsShown() {
+ CarrierTextManager.CarrierTextCallbackInfo
+ info = new CarrierTextManager.CarrierTextCallbackInfo(
+ "Satellite Mode Test",
+ new CharSequence[]{FIRST_CARRIER_NAME, SECOND_CARRIER_NAME},
+ /* anySimReady= */ true,
+ /* isInSatelliteMode= */ false,
+ new int[]{0, 1},
+ /* airplaneMode= */ false);
+
+ mCallback.updateCarrierInfo(info);
+ mTestableLooper.processAllMessages();
+
+ assertThat(mShadeCarrierGroup.getNoSimTextView().getVisibility()).isEqualTo(View.GONE);
+
+ verify(mShadeCarrier1).setVisibility(View.VISIBLE);
+ verify(mShadeCarrier2).setVisibility(View.VISIBLE);
+ }
+
+ @Test
public void testListenerNotCalledOnRegistreation() {
mShadeCarrierGroupController
.setOnSingleCarrierChangedListener(mOnSingleCarrierChangedListener);
@@ -350,8 +395,7 @@ public class ShadeCarrierGroupControllerTest extends LeakCheckedTest {
SINGLE_CARRIER_TEXT,
new CharSequence[]{SINGLE_CARRIER_TEXT},
true,
- new int[]{0},
- false /* airplaneMode */);
+ new int[]{0});
mCallback.updateCarrierInfo(info);
mTestableLooper.processAllMessages();
@@ -369,8 +413,7 @@ public class ShadeCarrierGroupControllerTest extends LeakCheckedTest {
MULTI_CARRIER_TEXT,
new CharSequence[]{FIRST_CARRIER_NAME, SECOND_CARRIER_NAME},
true,
- new int[]{0, 1},
- false /* airplaneMode */);
+ new int[]{0, 1});
mCallback.updateCarrierInfo(info);
mTestableLooper.processAllMessages();
@@ -387,16 +430,14 @@ public class ShadeCarrierGroupControllerTest extends LeakCheckedTest {
SINGLE_CARRIER_TEXT,
new CharSequence[]{FIRST_CARRIER_NAME},
true,
- new int[]{0},
- false /* airplaneMode */);
+ new int[]{0});
CarrierTextManager.CarrierTextCallbackInfo
multiCarrierInfo = new CarrierTextManager.CarrierTextCallbackInfo(
MULTI_CARRIER_TEXT,
new CharSequence[]{FIRST_CARRIER_NAME, SECOND_CARRIER_NAME},
true,
- new int[]{0, 1},
- false /* airplaneMode */);
+ new int[]{0, 1});
mCallback.updateCarrierInfo(singleCarrierInfo);
mTestableLooper.processAllMessages();
@@ -421,8 +462,7 @@ public class ShadeCarrierGroupControllerTest extends LeakCheckedTest {
SINGLE_CARRIER_TEXT,
new CharSequence[]{FIRST_CARRIER_NAME},
true,
- new int[]{0},
- false /* airplaneMode */);
+ new int[]{0});
mCallback.updateCarrierInfo(singleCarrierInfo);
mTestableLooper.processAllMessages();
@@ -443,8 +483,7 @@ public class ShadeCarrierGroupControllerTest extends LeakCheckedTest {
MULTI_CARRIER_TEXT,
new CharSequence[]{FIRST_CARRIER_NAME, SECOND_CARRIER_NAME},
true,
- new int[]{0, 1},
- false /* airplaneMode */);
+ new int[]{0, 1});
mCallback.updateCarrierInfo(multiCarrierInfo);
mTestableLooper.processAllMessages();