am 28fffd58: Merge "CarrierText clear itself when no mob. data support" into lmp-mr1-dev

automerge: 9309db8

* commit '9309db894df916f0777745eaa3e41ab92930481d':
  CarrierText clear itself when no mob. data support
This commit is contained in:
Jason Monk
2014-12-10 19:09:42 +00:00
committed by android-build-merger

View File

@@ -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);
}
} }
/** /**