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

Commit 851704d4 authored by Julia Reynolds's avatar Julia Reynolds Committed by mse1969
Browse files

DO NOT MERGE Crash invalid FGS notifications

Test: CTS, ActivityManagerProcessStateTest
Fixes: 191981182
Change-Id: I13a0202b25c8118db47edba11a93c1939c94b392
Merged-In: I13a0202b25c8118db47edba11a93c1939c94b392
(cherry picked from commit 6f657f8f)
(cherry picked from commit b6b2906e)
Merged-In: I13a0202b25c8118db47edba11a93c1939c94b392

Backport to P:
Make method Notification.isForegroundService() public, as it is the case
in Android 10 and later, see Ia13c1aac0cf91c400594df96ce267e768133f8d1

Change-Id: I214b6ab4f6ecab332fb8b3293fbc3b2212790b38
parent 91d81c76
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -5208,8 +5208,9 @@ public class Notification implements Parcelable

    /**
     * @return whether this notification is a foreground service notification
     * @hide
     */
    private boolean isForegroundService() {
    public boolean isForegroundService() {
        return (flags & Notification.FLAG_FOREGROUND_SERVICE) != 0;
    }

+5 −2
Original line number Diff line number Diff line
@@ -3535,8 +3535,11 @@ public class NotificationManagerService extends SystemService {
                notification.flags &= ~Notification.FLAG_CAN_COLORIZE;
            }

        } catch (NameNotFoundException e) {
            Slog.e(TAG, "Cannot create a context for sending app", e);
        } catch (Exception e) {
            if (notification.isForegroundService()) {
                throw new SecurityException("Invalid FGS notification", e);
            }
            Slog.e(TAG, "Cannot fix notification", e);
            return;
        }