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

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

Merge "Display no data notification in certain scenarios" into sc-dev am: 04a4d876

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

Change-Id: Ieeed3ffcaf1f9982a74e8a445b517ab78d81da1b
parents 05b55862 04a4d876
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,