diff options
author | Weijie Wang <weijiew@codeaurora.org> | 2021-05-10 09:52:59 +0800 |
---|---|---|
committer | Weijie Wang <weijiew@codeaurora.org> | 2021-05-10 18:12:24 +0800 |
commit | 63c928be42e507815da14abdc3defc58c3a651e5 (patch) | |
tree | 414bb120a65ddb6598ea55bb38c1359a45f38055 /packages/SystemUI/src/com/android/keyguard/EmergencyButtonController.java | |
parent | 4ad8c00c6fa45ff89974e9b47ae0cca838b83b28 (diff) |
SystemUI: Fix emergency call button no response issue
The control logic of emergency call button is changed,
which leads to the emergency call button on the lock
screen doesn't work.
Rework the emergency call button on the lock screen to
adapt the new control logic
Change-Id: I8994f86f1df912cf193d7ed706e554b27805cf40
CRs-Fixed: 2928133
Diffstat (limited to 'packages/SystemUI/src/com/android/keyguard/EmergencyButtonController.java')
-rw-r--r-- | packages/SystemUI/src/com/android/keyguard/EmergencyButtonController.java | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/EmergencyButtonController.java b/packages/SystemUI/src/com/android/keyguard/EmergencyButtonController.java index 5f232eee4986..dda5d4b13370 100644 --- a/packages/SystemUI/src/com/android/keyguard/EmergencyButtonController.java +++ b/packages/SystemUI/src/com/android/keyguard/EmergencyButtonController.java @@ -26,7 +26,9 @@ import android.os.PowerManager; import android.os.SystemClock; import android.os.UserHandle; import android.telecom.TelecomManager; +import android.telephony.CellInfo; import android.telephony.ServiceState; +import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.util.Log; @@ -40,6 +42,7 @@ import com.android.systemui.statusbar.policy.ConfigurationController.Configurati import com.android.systemui.util.EmergencyDialerConstants; import com.android.systemui.util.ViewController; +import java.util.List; import javax.inject.Inject; /** View Controller for {@link com.android.keyguard.EmergencyButton}. */ @@ -55,22 +58,28 @@ public class EmergencyButtonController extends ViewController<EmergencyButton> { private final MetricsLogger mMetricsLogger; private EmergencyButtonCallback mEmergencyButtonCallback; + private boolean mIsCellAvailable; + private ServiceState mServiceState; private final KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() { @Override public void onSimStateChanged(int subId, int slotId, int simState) { updateEmergencyCallButton(); + requestCellInfoUpdate(); } @Override public void onPhoneStateChanged(int phoneState) { updateEmergencyCallButton(); + requestCellInfoUpdate(); } @Override public void onServiceStateChanged(int subId, ServiceState state) { + mServiceState = state; updateEmergencyCallButton(); + requestCellInfoUpdate(); } }; @@ -119,7 +128,8 @@ public class EmergencyButtonController extends ViewController<EmergencyButton> { mView.updateEmergencyCallButton( mTelecomManager != null && mTelecomManager.isInCall(), mTelephonyManager.isVoiceCapable(), - mKeyguardUpdateMonitor.isSimPinVoiceSecure()); + mKeyguardUpdateMonitor.isSimPinVoiceSecure(), + isEmergencyCapable()); } } @@ -160,6 +170,33 @@ public class EmergencyButtonController extends ViewController<EmergencyButton> { } } + private void requestCellInfoUpdate(){ + TelephonyManager tmWithoutSim = mTelephonyManager + .createForSubscriptionId(SubscriptionManager.INVALID_SUBSCRIPTION_ID); + tmWithoutSim.requestCellInfoUpdate(getContext().getMainExecutor(), + new TelephonyManager.CellInfoCallback() { + @Override + public void onCellInfo(List<CellInfo> cellInfo) { + if (KeyguardConstants.DEBUG_SIM_STATES) { + Log.d(LOG_TAG, "requestCellInfoUpdate.onCellInfo cellInfoList.size=" + + (cellInfo == null ? 0 : cellInfo.size())); + } + if ( cellInfo == null || cellInfo.isEmpty()) { + mIsCellAvailable = false; + }else{ + mIsCellAvailable = true; + } + updateEmergencyCallButton(); + } + }); + } + + private boolean isEmergencyCapable() { + return (!mKeyguardUpdateMonitor.isOOS() + || mIsCellAvailable + || (mServiceState !=null && mServiceState.isEmergencyOnly())); + } + /** */ public interface EmergencyButtonCallback { /** */ |