OSDN Git Service

DO NOT MERGE - Fixed an issue where the emergency affordance would show
authorSelim Cinek <cinek@google.com>
Tue, 11 Oct 2016 19:49:48 +0000 (12:49 -0700)
committerSelim Cinek <cinek@google.com>
Wed, 12 Oct 2016 23:21:44 +0000 (23:21 +0000)
If a device isn't voice capable, it shouldn't show the emergency
option.

Test: use tablet which isn't voice capable, insert indian sim and
make sure no emergency option is displayed in global actions.
Bug: 31953703
Change-Id: I351e87320f3ffec76d1c1fc5aac78e5c48c0ac54

services/core/java/com/android/server/emergency/EmergencyAffordanceService.java

index cca9f10..353f450 100644 (file)
@@ -99,6 +99,7 @@ public class EmergencyAffordanceService extends SystemService {
     };
     private boolean mSimNeedsEmergencyAffordance;
     private boolean mNetworkNeedsEmergencyAffordance;
+    private boolean mVoiceCapable;
 
     private void requestCellScan() {
         mHandler.obtainMessage(CELL_INFO_STATE_CHANGED).sendToTarget();
@@ -125,8 +126,8 @@ public class EmergencyAffordanceService extends SystemService {
 
     private void updateEmergencyAffordanceNeeded() {
         synchronized (mLock) {
-            mEmergencyAffordanceNeeded = mSimNeedsEmergencyAffordance ||
-                    mNetworkNeedsEmergencyAffordance;
+            mEmergencyAffordanceNeeded = mVoiceCapable && (mSimNeedsEmergencyAffordance ||
+                    mNetworkNeedsEmergencyAffordance);
             Settings.Global.putInt(mContext.getContentResolver(),
                     Settings.Global.EMERGENCY_AFFORDANCE_NEEDED,
                     mEmergencyAffordanceNeeded ? 1 : 0);
@@ -157,6 +158,11 @@ public class EmergencyAffordanceService extends SystemService {
     public void onBootPhase(int phase) {
         if (phase == PHASE_THIRD_PARTY_APPS_CAN_START) {
             mTelephonyManager = mContext.getSystemService(TelephonyManager.class);
+            mVoiceCapable = mTelephonyManager.isVoiceCapable();
+            if (!mVoiceCapable) {
+                updateEmergencyAffordanceNeeded();
+                return;
+            }
             mSubscriptionManager = SubscriptionManager.from(mContext);
             HandlerThread thread = new HandlerThread(TAG);
             thread.start();