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

Commit 04a4d876 authored by Jack Yu's avatar Jack Yu Committed by Android (Google) Code Review
Browse files

Merge "Display no data notification in certain scenarios" into sc-dev

parents e459d64d 34dbd6c3
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,
@@ -2929,6 +2932,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);
        }
    }

    /**
@@ -3099,6 +3112,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,