diff options
author | Etan Cohen <etancohen@google.com> | 2015-07-06 16:19:04 -0700 |
---|---|---|
committer | Etan Cohen <etancohen@google.com> | 2015-07-08 11:38:25 -0700 |
commit | 47051d8e6dfcede55fa926c38bc06a6314fe6e4f (patch) | |
tree | fb4a3543fc4102e00afbf6e0de9fa81c90571b19 /packages/Keyguard/src/com | |
parent | fede4258fa1bf880c2b88ebea3c886003662fc74 (diff) | |
download | frameworks_base-47051d8e6dfcede55fa926c38bc06a6314fe6e4f.zip frameworks_base-47051d8e6dfcede55fa926c38bc06a6314fe6e4f.tar.gz frameworks_base-47051d8e6dfcede55fa926c38bc06a6314fe6e4f.tar.bz2 |
Lock screen text: consider possible WFC service in APM
Bug: 22302226
Change-Id: Icd885b45ced2b57665fbed54ec6caac36839db6c
Diffstat (limited to 'packages/Keyguard/src/com')
-rw-r--r-- | packages/Keyguard/src/com/android/keyguard/CarrierText.java | 36 | ||||
-rw-r--r-- | packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java | 41 |
2 files changed, 74 insertions, 3 deletions
diff --git a/packages/Keyguard/src/com/android/keyguard/CarrierText.java b/packages/Keyguard/src/com/android/keyguard/CarrierText.java index e083c9c..e89caf7 100644 --- a/packages/Keyguard/src/com/android/keyguard/CarrierText.java +++ b/packages/Keyguard/src/com/android/keyguard/CarrierText.java @@ -23,8 +23,11 @@ import java.util.Objects; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.content.res.Resources; import android.content.res.TypedArray; import android.net.ConnectivityManager; +import android.net.wifi.WifiManager; +import android.telephony.ServiceState; import android.telephony.SubscriptionInfo; import android.text.TextUtils; import android.text.method.SingleLineTransformationMethod; @@ -48,6 +51,8 @@ public class CarrierText extends TextView { private KeyguardUpdateMonitor mKeyguardUpdateMonitor; + private WifiManager mWifiManager; + private KeyguardUpdateMonitorCallback mCallback = new KeyguardUpdateMonitorCallback() { @Override public void onRefreshCarrierInfo() { @@ -93,24 +98,46 @@ public class CarrierText extends TextView { a.recycle(); } setTransformationMethod(new CarrierTextTransformationMethod(mContext, useAllCaps)); + + mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); } protected void updateCarrierText() { boolean allSimsMissing = true; + boolean anySimReadyAndInService = false; CharSequence displayText = null; List<SubscriptionInfo> subs = mKeyguardUpdateMonitor.getSubscriptionInfo(false); final int N = subs.size(); if (DEBUG) Log.d(TAG, "updateCarrierText(): " + N); for (int i = 0; i < N; i++) { - State simState = mKeyguardUpdateMonitor.getSimState(subs.get(i).getSubscriptionId()); + int subId = subs.get(i).getSubscriptionId(); + State simState = mKeyguardUpdateMonitor.getSimState(subId); CharSequence carrierName = subs.get(i).getCarrierName(); CharSequence carrierTextForSimState = getCarrierTextForSimState(simState, carrierName); - if (DEBUG) Log.d(TAG, "Handling " + simState + " " + carrierName); + if (DEBUG) { + Log.d(TAG, "Handling (subId=" + subId + "): " + simState + " " + carrierName); + } if (carrierTextForSimState != null) { allSimsMissing = false; displayText = concatenate(displayText, carrierTextForSimState); } + if (simState == IccCardConstants.State.READY) { + ServiceState ss = mKeyguardUpdateMonitor.mServiceStates.get(subId); + if (ss != null && ss.getDataRegState() == ServiceState.STATE_IN_SERVICE) { + // hack for WFC (IWLAN) not turning off immediately once + // Wi-Fi is disassociated or disabled + if (ss.getRilDataRadioTechnology() != ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN + || (mWifiManager.isWifiEnabled() + && mWifiManager.getConnectionInfo() != null + && mWifiManager.getConnectionInfo().getBSSID() != null)) { + if (DEBUG) { + Log.d(TAG, "SIM ready and in service: subId=" + subId + ", ss=" + ss); + } + anySimReadyAndInService = true; + } + } + } } if (allSimsMissing) { if (N != 0) { @@ -152,7 +179,10 @@ public class CarrierText extends TextView { getContext().getText(R.string.keyguard_missing_sim_message_short), text); } } - if (WirelessUtils.isAirplaneModeOn(mContext)) { + + // APM (airplane mode) != no carrier state. There are carrier services + // (e.g. WFC = Wi-Fi calling) which may operate in APM. + if (!anySimReadyAndInService && WirelessUtils.isAirplaneModeOn(mContext)) { displayText = getContext().getString(R.string.airplane_mode); } setText(displayText); diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java index a0174a7..581c15b 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -56,6 +56,7 @@ import com.android.internal.telephony.TelephonyIntents; import android.hardware.fingerprint.FingerprintManager; import android.hardware.fingerprint.FingerprintManager.AuthenticationCallback; import android.hardware.fingerprint.FingerprintManager.AuthenticationResult; +import android.telephony.ServiceState; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener; @@ -118,11 +119,13 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { private static final int MSG_FACE_UNLOCK_STATE_CHANGED = 327; private static final int MSG_SIM_SUBSCRIPTION_INFO_CHANGED = 328; private static final int MSG_AIRPLANE_MODE_CHANGED = 329; + private static final int MSG_SERVICE_STATE_CHANGE = 330; private static KeyguardUpdateMonitor sInstance; private final Context mContext; HashMap<Integer, SimData> mSimDatas = new HashMap<Integer, SimData>(); + HashMap<Integer, ServiceState> mServiceStates = new HashMap<Integer, ServiceState>(); private int mRingMode; private int mPhoneState; @@ -226,6 +229,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { case MSG_AIRPLANE_MODE_CHANGED: handleAirplaneModeChanged(); break; + case MSG_SERVICE_STATE_CHANGE: + handleServiceStateChange(msg.arg1, (ServiceState) msg.obj); + break; } } }; @@ -503,6 +509,16 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { mHandler.sendEmptyMessage(MSG_AIRPLANE_MODE_CHANGED); } else if (Intent.ACTION_BOOT_COMPLETED.equals(action)) { dispatchBootCompleted(); + } else if (TelephonyIntents.ACTION_SERVICE_STATE_CHANGED.equals(action)) { + ServiceState serviceState = ServiceState.newFromBundle(intent.getExtras()); + int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY, + SubscriptionManager.INVALID_SUBSCRIPTION_ID); + if (DEBUG) { + Log.v(TAG, "action " + action + " serviceState=" + serviceState + " subId=" + + subId); + } + mHandler.sendMessage( + mHandler.obtainMessage(MSG_SERVICE_STATE_CHANGE, subId, 0, serviceState)); } } }; @@ -738,6 +754,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { filter.addAction(Intent.ACTION_TIMEZONE_CHANGED); filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED); filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED); + filter.addAction(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED); filter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED); filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION); context.registerReceiver(mBroadcastReceiver, filter); @@ -1058,6 +1075,30 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { } /** + * Handle {@link #MSG_SERVICE_STATE_CHANGE} + */ + private void handleServiceStateChange(int subId, ServiceState serviceState) { + if (DEBUG) { + Log.d(TAG, + "handleServiceStateChange(subId=" + subId + ", serviceState=" + serviceState); + } + + if (!SubscriptionManager.isValidSubscriptionId(subId)) { + Log.w(TAG, "invalid subId in handleServiceStateChange()"); + return; + } + + mServiceStates.put(subId, serviceState); + + for (int j = 0; j < mCallbacks.size(); j++) { + KeyguardUpdateMonitorCallback cb = mCallbacks.get(j).get(); + if (cb != null) { + cb.onRefreshCarrierInfo(); + } + } + } + + /** * Handle {@link #MSG_KEYGUARD_VISIBILITY_CHANGED} */ private void handleKeyguardVisibilityChanged(int showing) { |