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

Commit fe9372a3 authored by Jack Yu's avatar Jack Yu Committed by Automerger Merge Worker
Browse files

Merge "Display no data notification in certain scenarios" am: c301c890

Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/1660785

Change-Id: I54b3689524d00d9e2b86109b0993477ad2a1c9c2
parents a78dae91 c301c890
Loading
Loading
Loading
Loading
+41 −0
Original line number Diff line number Diff line
@@ -261,6 +261,9 @@ public class DcTracker extends Handler {
    private static final String INTENT_DATA_STALL_ALARM_EXTRA_TRANSPORT_TYPE =
            "data_stall_alarm_extra_transport_type";

    // Unique id for no data notification on setup data permanently failed.
    private static final int NO_DATA_NOTIFICATION = 1001;

    /** The higher index has higher priority. */
    private static final DctConstants.State[] DATA_CONNECTION_STATE_PRIORITIES = {
            DctConstants.State.IDLE,
@@ -2905,6 +2908,16 @@ public class DcTracker extends Handler {

        startNetStatPoll();
        startDataStallAlarm(DATA_STALL_NOT_SUSPECTED);

        PersistableBundle b = getCarrierConfig();
        if (apnContext.getApnTypeBitmask() == ApnSetting.TYPE_DEFAULT
                && b.getBoolean(CarrierConfigManager
                .KEY_DISPLAY_NO_DATA_NOTIFICATION_ON_PERMANENT_FAILURE_BOOL)) {
            NotificationManager notificationManager = (NotificationManager)
                    mPhone.getContext().getSystemService(Context.NOTIFICATION_SERVICE);
            notificationManager.cancel(Integer.toString(mPhone.getSubId()),
                    NO_DATA_NOTIFICATION);
        }
    }

    /**
@@ -3082,6 +3095,34 @@ public class DcTracker extends Handler {
                log("cause=" + DataFailCause.toString(cause)
                        + ", mark apn as permanent failed. apn = " + apn);
                apnContext.markApnPermanentFailed(apn);

                PersistableBundle b = getCarrierConfig();
                if (apnContext.getApnTypeBitmask() == ApnSetting.TYPE_DEFAULT
                        && b.getBoolean(CarrierConfigManager
                        .KEY_DISPLAY_NO_DATA_NOTIFICATION_ON_PERMANENT_FAILURE_BOOL)) {
                    NotificationManager notificationManager = (NotificationManager)
                            mPhone.getContext().getSystemService(Context.NOTIFICATION_SERVICE);

                    CharSequence title = mPhone.getContext().getText(
                            com.android.internal.R.string.RestrictedOnDataTitle);
                    CharSequence details = mPhone.getContext().getText(
                            com.android.internal.R.string.RestrictedStateContent);

                    Notification notification = new Notification.Builder(mPhone.getContext(),
                            NotificationChannelController.CHANNEL_ID_MOBILE_DATA_STATUS)
                            .setWhen(System.currentTimeMillis())
                            .setAutoCancel(true)
                            .setSmallIcon(com.android.internal.R.drawable.stat_sys_warning)
                            .setTicker(title)
                            .setColor(mPhone.getContext().getResources().getColor(
                                    com.android.internal.R.color.system_notification_accent_color))
                            .setContentTitle(title)
                            .setStyle(new Notification.BigTextStyle().bigText(details))
                            .setContentText(details)
                            .build();
                    notificationManager.notify(Integer.toString(mPhone.getSubId()),
                            NO_DATA_NOTIFICATION, notification);
                }
            }

            int newRequestType = calculateNewRetryRequestType(handoverFailureMode, requestType,