am 402ad701: am bd966fb0: am e35c2d2f: am 3aa1b1e5: Merge "Lock screen text: consider possible WFC service in APM" into mnc-dev
* commit '402ad701c5cd6f3043c00c5109d0416c4a16858e': Lock screen text: consider possible WFC service in APM
This commit is contained in:
@@ -23,8 +23,11 @@ import java.util.Objects;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
|
import android.net.wifi.WifiManager;
|
||||||
|
import android.telephony.ServiceState;
|
||||||
import android.telephony.SubscriptionInfo;
|
import android.telephony.SubscriptionInfo;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.method.SingleLineTransformationMethod;
|
import android.text.method.SingleLineTransformationMethod;
|
||||||
@@ -48,6 +51,8 @@ public class CarrierText extends TextView {
|
|||||||
|
|
||||||
private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
||||||
|
|
||||||
|
private WifiManager mWifiManager;
|
||||||
|
|
||||||
private KeyguardUpdateMonitorCallback mCallback = new KeyguardUpdateMonitorCallback() {
|
private KeyguardUpdateMonitorCallback mCallback = new KeyguardUpdateMonitorCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onRefreshCarrierInfo() {
|
public void onRefreshCarrierInfo() {
|
||||||
@@ -93,24 +98,46 @@ public class CarrierText extends TextView {
|
|||||||
a.recycle();
|
a.recycle();
|
||||||
}
|
}
|
||||||
setTransformationMethod(new CarrierTextTransformationMethod(mContext, useAllCaps));
|
setTransformationMethod(new CarrierTextTransformationMethod(mContext, useAllCaps));
|
||||||
|
|
||||||
|
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateCarrierText() {
|
protected void updateCarrierText() {
|
||||||
boolean allSimsMissing = true;
|
boolean allSimsMissing = true;
|
||||||
|
boolean anySimReadyAndInService = false;
|
||||||
CharSequence displayText = null;
|
CharSequence displayText = null;
|
||||||
|
|
||||||
List<SubscriptionInfo> subs = mKeyguardUpdateMonitor.getSubscriptionInfo(false);
|
List<SubscriptionInfo> subs = mKeyguardUpdateMonitor.getSubscriptionInfo(false);
|
||||||
final int N = subs.size();
|
final int N = subs.size();
|
||||||
if (DEBUG) Log.d(TAG, "updateCarrierText(): " + N);
|
if (DEBUG) Log.d(TAG, "updateCarrierText(): " + N);
|
||||||
for (int i = 0; i < N; i++) {
|
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 carrierName = subs.get(i).getCarrierName();
|
||||||
CharSequence carrierTextForSimState = getCarrierTextForSimState(simState, carrierName);
|
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) {
|
if (carrierTextForSimState != null) {
|
||||||
allSimsMissing = false;
|
allSimsMissing = false;
|
||||||
displayText = concatenate(displayText, carrierTextForSimState);
|
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 (allSimsMissing) {
|
||||||
if (N != 0) {
|
if (N != 0) {
|
||||||
@@ -152,7 +179,10 @@ public class CarrierText extends TextView {
|
|||||||
getContext().getText(R.string.keyguard_missing_sim_message_short), text);
|
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);
|
displayText = getContext().getString(R.string.airplane_mode);
|
||||||
}
|
}
|
||||||
setText(displayText);
|
setText(displayText);
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ import com.android.internal.telephony.TelephonyIntents;
|
|||||||
import android.hardware.fingerprint.FingerprintManager;
|
import android.hardware.fingerprint.FingerprintManager;
|
||||||
import android.hardware.fingerprint.FingerprintManager.AuthenticationCallback;
|
import android.hardware.fingerprint.FingerprintManager.AuthenticationCallback;
|
||||||
import android.hardware.fingerprint.FingerprintManager.AuthenticationResult;
|
import android.hardware.fingerprint.FingerprintManager.AuthenticationResult;
|
||||||
|
import android.telephony.ServiceState;
|
||||||
import android.telephony.SubscriptionInfo;
|
import android.telephony.SubscriptionInfo;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener;
|
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_FACE_UNLOCK_STATE_CHANGED = 327;
|
||||||
private static final int MSG_SIM_SUBSCRIPTION_INFO_CHANGED = 328;
|
private static final int MSG_SIM_SUBSCRIPTION_INFO_CHANGED = 328;
|
||||||
private static final int MSG_AIRPLANE_MODE_CHANGED = 329;
|
private static final int MSG_AIRPLANE_MODE_CHANGED = 329;
|
||||||
|
private static final int MSG_SERVICE_STATE_CHANGE = 330;
|
||||||
|
|
||||||
private static KeyguardUpdateMonitor sInstance;
|
private static KeyguardUpdateMonitor sInstance;
|
||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
HashMap<Integer, SimData> mSimDatas = new HashMap<Integer, SimData>();
|
HashMap<Integer, SimData> mSimDatas = new HashMap<Integer, SimData>();
|
||||||
|
HashMap<Integer, ServiceState> mServiceStates = new HashMap<Integer, ServiceState>();
|
||||||
|
|
||||||
private int mRingMode;
|
private int mRingMode;
|
||||||
private int mPhoneState;
|
private int mPhoneState;
|
||||||
@@ -226,6 +229,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
|
|||||||
case MSG_AIRPLANE_MODE_CHANGED:
|
case MSG_AIRPLANE_MODE_CHANGED:
|
||||||
handleAirplaneModeChanged();
|
handleAirplaneModeChanged();
|
||||||
break;
|
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);
|
mHandler.sendEmptyMessage(MSG_AIRPLANE_MODE_CHANGED);
|
||||||
} else if (Intent.ACTION_BOOT_COMPLETED.equals(action)) {
|
} else if (Intent.ACTION_BOOT_COMPLETED.equals(action)) {
|
||||||
dispatchBootCompleted();
|
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_TIMEZONE_CHANGED);
|
||||||
filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED);
|
filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED);
|
||||||
filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
|
filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
|
||||||
|
filter.addAction(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED);
|
||||||
filter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
|
filter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
|
||||||
filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
|
filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
|
||||||
context.registerReceiver(mBroadcastReceiver, filter);
|
context.registerReceiver(mBroadcastReceiver, filter);
|
||||||
@@ -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}
|
* Handle {@link #MSG_KEYGUARD_VISIBILITY_CHANGED}
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user