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

Commit c8d0589c authored by Lorenzo Colitti's avatar Lorenzo Colitti
Browse files

Don't use a high-priority notification on auto-join.

If the device connects to a network automatically and not through
user action, a high-priority notification is intrusive and is
inconsistent with other networking notifications, which are
usually only high priority if the network is manually selected.

Bug: 130766237
Test: see next CL in patch series
Change-Id: I8824f2d1a0efeb6cb75e430ef5159ebce0018779
parent dff977d0
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -3599,21 +3599,31 @@ public class ConnectivityService extends IConnectivityManager.Stub

    private void showNetworkNotification(NetworkAgentInfo nai, NotificationType type) {
        final String action;
        final boolean highPriority;
        switch (type) {
            case LOGGED_IN:
                action = Settings.ACTION_WIFI_SETTINGS;
                mHandler.removeMessages(EVENT_TIMEOUT_NOTIFICATION);
                mHandler.sendMessageDelayed(mHandler.obtainMessage(EVENT_TIMEOUT_NOTIFICATION,
                        nai.network.netId, 0), TIMEOUT_NOTIFICATION_DELAY_MS);
                // High priority because it is a direct result of the user logging in to a portal.
                highPriority = true;
                break;
            case NO_INTERNET:
                action = ConnectivityManager.ACTION_PROMPT_UNVALIDATED;
                // High priority because it is only displayed for explicitly selected networks.
                highPriority = true;
                break;
            case LOST_INTERNET:
                action = ConnectivityManager.ACTION_PROMPT_LOST_VALIDATION;
                // High priority because it could help the user avoid unexpected data usage.
                highPriority = true;
                break;
            case PARTIAL_CONNECTIVITY:
                action = ConnectivityManager.ACTION_PROMPT_PARTIAL_CONNECTIVITY;
                // Don't bother the user with a high-priority notification if the network was not
                // explicitly selected by the user.
                highPriority = nai.networkMisc.explicitlySelected;
                break;
            default:
                Slog.wtf(TAG, "Unknown notification type " + type);
@@ -3630,7 +3640,8 @@ public class ConnectivityService extends IConnectivityManager.Stub

        PendingIntent pendingIntent = PendingIntent.getActivityAsUser(
                mContext, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT, null, UserHandle.CURRENT);
        mNotifier.showNotification(nai.network.netId, type, nai, null, pendingIntent, true);

        mNotifier.showNotification(nai.network.netId, type, nai, null, pendingIntent, highPriority);
    }

    private boolean shouldPromptUnvalidated(NetworkAgentInfo nai) {