Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 28fffd58 authored by Jason Monk's avatar Jason Monk Committed by Android (Google) Code Review
Browse files

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

parents 33cd463b 83bc2aaf
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import java.util.Locale;

import android.content.Context;
import android.content.res.TypedArray;
import android.net.ConnectivityManager;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.text.TextUtils;
@@ -140,15 +141,24 @@ public class CarrierText extends TextView {
    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        if (ConnectivityManager.from(mContext).isNetworkSupported(
                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
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        if (mKeyguardUpdateMonitor != null) {
            mKeyguardUpdateMonitor.removeCallback(mCallback);
        }
    }

    /**
     * Top-level function for creating carrier text. Makes text based on simState, PLMN