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

Commit 83bc2aaf authored by Jason Monk's avatar Jason Monk
Browse files

CarrierText clear itself when no mob. data support

Bug: 18552426
Change-Id: I48e7d1434861dc99284bb0b58c023c1d749e513a
parent fb967585
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