diff options
| author | 2019-11-05 19:54:03 +0000 | |
|---|---|---|
| committer | 2019-11-05 19:54:03 +0000 | |
| commit | a7aeb79bf352e1d2c9d2743124b7d60b383f6f8a (patch) | |
| tree | 21e0f158a4315aa44564afa393e2daeb2589274f | |
| parent | f551ef90b66152478fe5d34e0aa9bc3fc0578dc0 (diff) | |
| parent | a43d0a712f86c3e8a8ccb5b1a9c90e9bf17cdf7e (diff) | |
Merge "Remove usage of hidden API in System UI"
5 files changed, 22 insertions, 7 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java index 9c0a71c1f81d..b1502b9a0d63 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPinView.java @@ -104,7 +104,12 @@ public class KeyguardSimPinView extends KeyguardPinBasedInputView { private void setLockedSimMessage() { boolean isEsimLocked = KeyguardEsimArea.isEsimLocked(mContext, mSubId); - int count = TelephonyManager.getDefault().getSimCount(); + int count = 1; + TelephonyManager telephonyManager = + (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); + if (telephonyManager != null) { + count = telephonyManager.getActiveModemCount(); + } Resources rez = getResources(); String msg; TypedArray array = mContext.obtainStyledAttributes(new int[] { R.attr.wallpaperTextColor }); diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java index fc888e11d3f5..70237a053e1e 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSimPukView.java @@ -164,7 +164,12 @@ public class KeyguardSimPukView extends KeyguardPinBasedInputView { } boolean isEsimLocked = KeyguardEsimArea.isEsimLocked(mContext, mSubId); - int count = TelephonyManager.getDefault().getSimCount(); + int count = 1; + TelephonyManager telephonyManager = + (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); + if (telephonyManager != null) { + count = telephonyManager.getActiveModemCount(); + } Resources rez = getResources(); String msg; TypedArray array = mContext.obtainStyledAttributes(new int[] { R.attr.wallpaperTextColor }); diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java index 6685db130d4a..0b0922a7766f 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -2649,8 +2649,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab // that don't return the complete set of values and have different types. In Keyguard we // need IccCardConstants, but TelephonyManager would only give us // TelephonyManager.SIM_STATE*, so we retrieve it manually. - final TelephonyManager tele = TelephonyManager.from(mContext); - int simState = tele.getSimState(slotId); + final TelephonyManager tele = + (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); + int simState = (tele != null) ? + tele.getSimState(slotId) : TelephonyManager.SIM_STATE_UNKNOWN; State state; try { state = State.intToState(simState); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java index e42432142927..12d357731560 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java @@ -649,7 +649,7 @@ public class NetworkControllerImpl extends BroadcastReceiver } private boolean hasAnySim() { - int simCount = mPhone.getSimCount(); + int simCount = mPhone.getActiveModemCount(); for (int i = 0; i < simCount; i++) { int state = mPhone.getSimState(i); if (state != TelephonyManager.SIM_STATE_ABSENT diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java index 075c6d40ca31..13c0db938ca0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java @@ -463,8 +463,11 @@ public class UserSwitcherController implements Dumpable { } private void listenForCallState() { - TelephonyManager.from(mContext).listen(mPhoneStateListener, - PhoneStateListener.LISTEN_CALL_STATE); + final TelephonyManager tele = + (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); + if (tele != null) { + tele.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CALL_STATE); + } } private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() { |