Don't throw ANR if onTimeout flag is disabled.

Bug: 327566365
Test: atest CtsFgsTimeoutTestCases
(cherry picked from commit 21492dcd91c86fa06c423fbe60876a219421892f)
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:78f268a3bbbba1233aba5ba675563b2b62d90f76)
Merged-In: I6601fd1af8cd617bae5e3c3deb1019d65c5e3908
Change-Id: I6601fd1af8cd617bae5e3c3deb1019d65c5e3908
diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java
index b8e09cc..24eba4a 100644
--- a/services/core/java/com/android/server/am/ActiveServices.java
+++ b/services/core/java/com/android/server/am/ActiveServices.java
@@ -3696,7 +3696,9 @@
             // is not "now". Compute the time from "now" when starting the anr timer.
             final long anrTime = sr.getEarliestStopTypeAndTime().second
                     + mAm.mConstants.mFgsAnrExtraWaitDuration - SystemClock.uptimeMillis();
-            mFGSAnrTimer.start(sr, anrTime);
+            if (android.app.Flags.introduceNewServiceOntimeoutCallback()) {
+                mFGSAnrTimer.start(sr, anrTime);
+            }
         }
     }