Loading packages/Keyguard/src/com/android/keyguard/CarrierText.java +33 −3 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -48,6 +51,8 @@ public class CarrierText extends TextView { private KeyguardUpdateMonitor mKeyguardUpdateMonitor; private WifiManager mWifiManager; private KeyguardUpdateMonitorCallback mCallback = new KeyguardUpdateMonitorCallback() { @Override public void onRefreshCarrierInfo() { Loading Loading @@ -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) { Loading Loading @@ -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); Loading packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java +41 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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; } } }; Loading Loading @@ -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)); } } }; Loading Loading @@ -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); Loading Loading @@ -1057,6 +1074,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} */ Loading Loading
packages/Keyguard/src/com/android/keyguard/CarrierText.java +33 −3 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -48,6 +51,8 @@ public class CarrierText extends TextView { private KeyguardUpdateMonitor mKeyguardUpdateMonitor; private WifiManager mWifiManager; private KeyguardUpdateMonitorCallback mCallback = new KeyguardUpdateMonitorCallback() { @Override public void onRefreshCarrierInfo() { Loading Loading @@ -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) { Loading Loading @@ -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); Loading
packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java +41 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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; } } }; Loading Loading @@ -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)); } } }; Loading Loading @@ -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); Loading Loading @@ -1057,6 +1074,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} */ Loading