Hide emergency call text if not support it.

Show "emergency call only" text in carrier string
only if phone supports emergency calls.

bug:5570742
Change-Id: Ie826583fd55073e57c5fe4fe6e585781127caa6a
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java b/policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java
index ee54de1..76d3df0 100644
--- a/policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java
+++ b/policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java
@@ -475,8 +475,9 @@
                 break;
 
             case NetworkLocked:
-                carrierText = makeCarierString(mPlmn,
-                        getContext().getText(R.string.lockscreen_network_locked_message));
+                carrierText = makeCarrierStringOnEmergencyCapable(
+                        getContext().getText(R.string.lockscreen_network_locked_message),
+                        mPlmn);
                 carrierHelpTextId = R.string.lockscreen_instructions_when_pattern_disabled;
                 break;
 
@@ -485,10 +486,9 @@
                 // This depends on mPlmn containing the text "Emergency calls only" when the radio
                 // has some connectivity. Otherwise, it should be null or empty and just show
                 // "No SIM card"
-                carrierText = getContext().getText(R.string.lockscreen_missing_sim_message_short);
-                if (mLockPatternUtils.isEmergencyCallCapable()) {
-                    carrierText = makeCarierString(carrierText, mPlmn);
-                }
+                carrierText =  makeCarrierStringOnEmergencyCapable(
+                        getContext().getText(R.string.lockscreen_missing_sim_message_short),
+                        mPlmn);
                 carrierHelpTextId = R.string.lockscreen_missing_sim_instructions_long;
                 break;
 
@@ -499,21 +499,24 @@
                 break;
 
             case SimMissingLocked:
-                carrierText = makeCarierString(mPlmn,
-                        getContext().getText(R.string.lockscreen_missing_sim_message_short));
+                carrierText =  makeCarrierStringOnEmergencyCapable(
+                        getContext().getText(R.string.lockscreen_missing_sim_message_short),
+                        mPlmn);
                 carrierHelpTextId = R.string.lockscreen_missing_sim_instructions;
                 mEmergencyButtonEnabledBecauseSimLocked = true;
                 break;
 
             case SimLocked:
-                carrierText = makeCarierString(mPlmn,
-                        getContext().getText(R.string.lockscreen_sim_locked_message));
+                carrierText = makeCarrierStringOnEmergencyCapable(
+                        getContext().getText(R.string.lockscreen_sim_locked_message),
+                        mPlmn);
                 mEmergencyButtonEnabledBecauseSimLocked = true;
                 break;
 
             case SimPukLocked:
-                carrierText = makeCarierString(mPlmn,
-                        getContext().getText(R.string.lockscreen_sim_puk_locked_message));
+                carrierText = makeCarrierStringOnEmergencyCapable(
+                        getContext().getText(R.string.lockscreen_sim_puk_locked_message),
+                        mPlmn);
                 if (!mLockPatternUtils.isPukUnlockScreenEnable()) {
                     // This means we're showing the PUK unlock screen
                     mEmergencyButtonEnabledBecauseSimLocked = true;
@@ -526,6 +529,18 @@
         updateEmergencyCallButtonState(mPhoneState);
     }
 
+
+    /*
+     * Add emergencyCallMessage to carrier string only if phone supports emergency calls.
+     */
+    private CharSequence makeCarrierStringOnEmergencyCapable(
+            CharSequence simMessage, CharSequence emergencyCallMessage) {
+        if (mLockPatternUtils.isEmergencyCallCapable()) {
+            return makeCarierString(simMessage, emergencyCallMessage);
+        }
+        return simMessage;
+    }
+
     private View findViewById(int id) {
         return mContainer.findViewById(id);
     }