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

Commit 34dbd6c3 authored by Jack Yu's avatar Jack Yu
Browse files

Display no data notification in certain scenarios

For some carriers, display no data notification when
setup data permanently failed (i.e. retry will not hapen)

Bug: 169648447
Test: Manual
Change-Id: Ic6395529e3cbf90fe1f9fbbe06528764fffb92b8
parent 440c34dd
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,
@@ -2925,6 +2928,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);
        }
    }

    /**
@@ -3095,6 +3108,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,