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

Commit fadfa6cc authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Ensure notification visibility on stopForeground(false)" into sc-dev am: 2591e466

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15288334

Change-Id: I7c5808a6137469824209d78d140620a3904453e3
parents 92b381d4 2591e466
Loading
Loading
Loading
Loading
+22 −14
Original line number Original line Diff line number Diff line
@@ -1934,6 +1934,28 @@ public final class ActiveServices {
                if (smap != null) {
                if (smap != null) {
                    decActiveForegroundAppLocked(smap, r);
                    decActiveForegroundAppLocked(smap, r);
                }
                }

                // Adjust notification handling before setting isForeground to false, because
                // that state is relevant to the notification policy side.
                // Leave the time-to-display as already set: re-entering foreground mode will
                // only resume the previous quiet timeout, or will display immediately if the
                // deferral period had already passed.
                if ((flags & Service.STOP_FOREGROUND_REMOVE) != 0) {
                    cancelForegroundNotificationLocked(r);
                    r.foregroundId = 0;
                    r.foregroundNoti = null;
                } else if (r.appInfo.targetSdkVersion >= Build.VERSION_CODES.LOLLIPOP) {
                    // if it's been deferred, force to visibility
                    if (!r.mFgsNotificationShown) {
                        r.postNotification();
                    }
                    dropFgsNotificationStateLocked(r);
                    if ((flags & Service.STOP_FOREGROUND_DETACH) != 0) {
                        r.foregroundId = 0;
                        r.foregroundNoti = null;
                    }
                }

                r.isForeground = false;
                r.isForeground = false;
                r.mFgsExitTime = SystemClock.uptimeMillis();
                r.mFgsExitTime = SystemClock.uptimeMillis();
                ServiceState stracker = r.getTracker();
                ServiceState stracker = r.getTracker();
@@ -1957,20 +1979,6 @@ public final class ActiveServices {
                    updateServiceForegroundLocked(r.app.mServices, true);
                    updateServiceForegroundLocked(r.app.mServices, true);
                }
                }
            }
            }
            // Leave the time-to-display as already set: re-entering foreground mode will
            // only resume the previous quiet timeout, or will display immediately if the
            // deferral period had already passed.
            if ((flags & Service.STOP_FOREGROUND_REMOVE) != 0) {
                cancelForegroundNotificationLocked(r);
                r.foregroundId = 0;
                r.foregroundNoti = null;
            } else if (r.appInfo.targetSdkVersion >= Build.VERSION_CODES.LOLLIPOP) {
                dropFgsNotificationStateLocked(r);
                if ((flags & Service.STOP_FOREGROUND_DETACH) != 0) {
                    r.foregroundId = 0;
                    r.foregroundNoti = null;
                }
            }
        }
        }
    }
    }