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

Commit 5acda46c authored by Pankaj Kanwar's avatar Pankaj Kanwar Committed by android-build-merger
Browse files

Merge "Improvements to pref network notification." into oc-dr1-dev

am: 97217bb7

Change-Id: I8023630d7beb478ca8979de3f9794a697f5d9f69
parents 40a02fda 97217bb7
Loading
Loading
Loading
Loading
+12 −3
Original line number Original line Diff line number Diff line
@@ -29,6 +29,7 @@ import android.os.PersistableBundle;
import android.provider.Settings;
import android.provider.Settings;
import android.telephony.CarrierConfigManager;
import android.telephony.CarrierConfigManager;
import android.telephony.Rlog;
import android.telephony.Rlog;
import android.telephony.ServiceState;


import com.android.internal.telephony.util.NotificationChannelController;
import com.android.internal.telephony.util.NotificationChannelController;


@@ -69,7 +70,7 @@ public class CarrierServiceStateTracker extends Handler {
                break;
                break;
            case CARRIER_EVENT_VOICE_DEREGISTRATION:
            case CARRIER_EVENT_VOICE_DEREGISTRATION:
            case CARRIER_EVENT_DATA_DEREGISTRATION:
            case CARRIER_EVENT_DATA_DEREGISTRATION:
                if (isGlobalModeOrRadioOffOrAirplaneMode()) {
                if (isGlobalModeOrRadioOffOrAirplaneMode() || isPhoneStillRegistered()) {
                    break;
                    break;
                }
                }
                mIsPhoneRegistered = false;
                mIsPhoneRegistered = false;
@@ -81,6 +82,14 @@ public class CarrierServiceStateTracker extends Handler {
        }
        }
    }
    }


    private boolean isPhoneStillRegistered() {
        if (mSST.mSS == null) {
            return true; //something has gone wrong, return true and not show the notification.
        }
        return (mSST.mSS.getVoiceRegState() == ServiceState.STATE_IN_SERVICE
                || mSST.mSS.getDataRegState() == ServiceState.STATE_IN_SERVICE);
    }

    /**
    /**
     * Returns true if the preferred network is set to 'Global' or the radio is off or in
     * Returns true if the preferred network is set to 'Global' or the radio is off or in
     * Airplane Mode else returns false.
     * Airplane Mode else returns false.
@@ -109,7 +118,6 @@ public class CarrierServiceStateTracker extends Handler {
     * Contains logic to decide when to create/cancel notifications.
     * Contains logic to decide when to create/cancel notifications.
     */
     */
    private void handleConfigChanges() {
    private void handleConfigChanges() {

        if (mDelay == UNINITIALIZED_DELAY_VALUE) {
        if (mDelay == UNINITIALIZED_DELAY_VALUE) {
            cancelNotification();
            cancelNotification();
            return;
            return;
@@ -188,6 +196,7 @@ public class CarrierServiceStateTracker extends Handler {
    private void cancelNotification() {
    private void cancelNotification() {
        Context context = mPhone.getContext();
        Context context = mPhone.getContext();
        mIsPhoneRegistered = true;
        mIsPhoneRegistered = true;
        removeMessages(SHOW_NOTIFICATION);
        NotificationManager notificationManager = (NotificationManager)
        NotificationManager notificationManager = (NotificationManager)
                context.getSystemService(Context.NOTIFICATION_SERVICE);
                context.getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.cancel(NOTIFICATION_ID);
        notificationManager.cancel(NOTIFICATION_ID);