summaryrefslogtreecommitdiff
path: root/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java
diff options
context:
space:
mode:
authorSteven Laver <lavers@google.com>2019-05-08 06:18:42 -0700
committerSteven Laver <lavers@google.com>2019-05-08 06:18:42 -0700
commit4a30c150e58ec67edb92a7bec5ea48cebd6b90d4 (patch)
tree6d902794d7e59acd54f54ef235feb75becfb01e3 /packages/SystemUI/src/com/android/keyguard/CarrierTextController.java
parenta6c7c402af360214e509d15980957e74fc673f42 (diff)
parente4f4eabc31685c001c2b46d8fa87b443f4af5b21 (diff)
Merge QP1A.190501.001
Change-Id: I0f9f887d6a33702a6988709d8296731cfdb8f73d
Diffstat (limited to 'packages/SystemUI/src/com/android/keyguard/CarrierTextController.java')
-rw-r--r--packages/SystemUI/src/com/android/keyguard/CarrierTextController.java67
1 files changed, 54 insertions, 13 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java b/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java
index 806ffb6f2d1e..0228f2f8fe49 100644
--- a/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java
+++ b/packages/SystemUI/src/com/android/keyguard/CarrierTextController.java
@@ -27,6 +27,7 @@ import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.wifi.WifiManager;
import android.os.Handler;
+import android.os.SystemProperties;
import android.telephony.CarrierConfigManager;
import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
@@ -40,6 +41,7 @@ import androidx.annotation.VisibleForTesting;
import com.android.internal.telephony.IccCardConstants;
import com.android.internal.telephony.TelephonyIntents;
+import com.android.internal.telephony.TelephonyProperties;
import com.android.settingslib.WirelessUtils;
import com.android.systemui.Dependency;
import com.android.systemui.keyguard.WakefulnessLifecycle;
@@ -72,6 +74,8 @@ public class CarrierTextController {
private Context mContext;
private CharSequence mSeparator;
private WakefulnessLifecycle mWakefulnessLifecycle;
+ @VisibleForTesting
+ protected boolean mDisplayOpportunisticSubscriptionCarrierText;
private FiveGServiceClient mFiveGServiceClient;
private final WakefulnessLifecycle.Observer mWakefulnessObserver =
new WakefulnessLifecycle.Observer() {
@@ -250,7 +254,6 @@ public class CarrierTextController {
}
/**
- * STOPSHIP(b/130246708) remove when no longer needed for testing purpose.
* @param subscriptions
*/
private void filterMobileSubscriptionInSameGroup(List<SubscriptionInfo> subscriptions) {
@@ -277,6 +280,35 @@ public class CarrierTextController {
}
}
+ /**
+ * updates if opportunistic sub carrier text should be displayed or not
+ *
+ */
+ @VisibleForTesting
+ public void updateDisplayOpportunisticSubscriptionCarrierText() {
+ mDisplayOpportunisticSubscriptionCarrierText = SystemProperties
+ .getBoolean(TelephonyProperties
+ .DISPLAY_OPPORTUNISTIC_SUBSCRIPTION_CARRIER_TEXT_PROPERTY_NAME, false);
+ }
+
+ protected List<SubscriptionInfo> getSubscriptionInfo() {
+ List<SubscriptionInfo> subs;
+ if (mDisplayOpportunisticSubscriptionCarrierText) {
+ SubscriptionManager subscriptionManager = ((SubscriptionManager) mContext
+ .getSystemService(
+ Context.TELEPHONY_SUBSCRIPTION_SERVICE));
+ subs = subscriptionManager.getActiveSubscriptionInfoList(false);
+ if (subs == null) {
+ subs = new ArrayList<>();
+ } else {
+ filterMobileSubscriptionInSameGroup(subs);
+ }
+ } else {
+ subs = mKeyguardUpdateMonitor.getSubscriptionInfo(false);
+ }
+ return subs;
+ }
+
protected void updateCarrierText() {
boolean allSimsMissing = true;
boolean anySimReadyAndInService = false;
@@ -284,17 +316,7 @@ public class CarrierTextController {
boolean showCustomizeName = getContext().getResources().getBoolean(
com.android.systemui.R.bool.config_show_customize_carrier_name);
CharSequence displayText = null;
-
- // STOPSHIP(b/130246708) revert to mKeyguardUpdateMonitor.getSubscriptionInfo(false).
- SubscriptionManager subscriptionManager = ((SubscriptionManager) mContext.getSystemService(
- Context.TELEPHONY_SUBSCRIPTION_SERVICE));
- List<SubscriptionInfo> subs = subscriptionManager.getActiveSubscriptionInfoList(false);
-
- if (subs == null) {
- subs = new ArrayList<>();
- } else {
- filterMobileSubscriptionInSameGroup(subs);
- }
+ List<SubscriptionInfo> subs = getSubscriptionInfo();
final int numSubs = subs.size();
final int[] subsIds = new int[numSubs];
@@ -393,7 +415,7 @@ public class CarrierTextController {
}
if (TextUtils.isEmpty(displayText) && !airplaneMode) {
- displayText = TextUtils.join(mSeparator, carrierNames);
+ displayText = joinNotEmpty(mSeparator, carrierNames);
}
final CarrierTextCallbackInfo info = new CarrierTextCallbackInfo(
displayText,
@@ -556,6 +578,25 @@ public class CarrierTextController {
}
}
+ /**
+ * Joins the strings in a sequence using a separator. Empty strings are discarded with no extra
+ * separator added so there are no extra separators that are not needed.
+ */
+ private static CharSequence joinNotEmpty(CharSequence separator, CharSequence[] sequences) {
+ int length = sequences.length;
+ if (length == 0) return "";
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < length; i++) {
+ if (!TextUtils.isEmpty(sequences[i])) {
+ if (!TextUtils.isEmpty(sb)) {
+ sb.append(separator);
+ }
+ sb.append(sequences[i]);
+ }
+ }
+ return sb.toString();
+ }
+
private static List<CharSequence> append(List<CharSequence> list, CharSequence string) {
if (!TextUtils.isEmpty(string)) {
list.add(string);