Merge "CarrierText clear itself when no mob. data support" into lmp-mr1-dev
This commit is contained in:
@@ -21,6 +21,7 @@ import java.util.Locale;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
|
import android.net.ConnectivityManager;
|
||||||
import android.telephony.SubscriptionInfo;
|
import android.telephony.SubscriptionInfo;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@@ -140,14 +141,23 @@ public class CarrierText extends TextView {
|
|||||||
@Override
|
@Override
|
||||||
protected void onAttachedToWindow() {
|
protected void onAttachedToWindow() {
|
||||||
super.onAttachedToWindow();
|
super.onAttachedToWindow();
|
||||||
mKeyguardUpdateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
|
if (ConnectivityManager.from(mContext).isNetworkSupported(
|
||||||
mKeyguardUpdateMonitor.registerCallback(mCallback);
|
ConnectivityManager.TYPE_MOBILE)) {
|
||||||
|
mKeyguardUpdateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
|
||||||
|
mKeyguardUpdateMonitor.registerCallback(mCallback);
|
||||||
|
} else {
|
||||||
|
// Don't listen and clear out the text when the device isn't a phone.
|
||||||
|
mKeyguardUpdateMonitor = null;
|
||||||
|
setText("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDetachedFromWindow() {
|
protected void onDetachedFromWindow() {
|
||||||
super.onDetachedFromWindow();
|
super.onDetachedFromWindow();
|
||||||
mKeyguardUpdateMonitor.removeCallback(mCallback);
|
if (mKeyguardUpdateMonitor != null) {
|
||||||
|
mKeyguardUpdateMonitor.removeCallback(mCallback);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user