Loading core/java/com/android/internal/os/TimeoutRecord.java +0 −8 Original line number Diff line number Diff line Loading @@ -45,7 +45,6 @@ public class TimeoutRecord { TimeoutKind.APP_REGISTERED, TimeoutKind.SHORT_FGS_TIMEOUT, TimeoutKind.JOB_SERVICE, TimeoutKind.FGS_TIMEOUT, }) @Retention(RetentionPolicy.SOURCE) Loading @@ -60,7 +59,6 @@ public class TimeoutRecord { int SHORT_FGS_TIMEOUT = 8; int JOB_SERVICE = 9; int APP_START = 10; int FGS_TIMEOUT = 11; } /** Kind of timeout, e.g. BROADCAST_RECEIVER, etc. */ Loading Loading @@ -188,12 +186,6 @@ public class TimeoutRecord { return TimeoutRecord.endingNow(TimeoutKind.SHORT_FGS_TIMEOUT, reason); } /** Record for a "foreground service" timeout. */ @NonNull public static TimeoutRecord forFgsTimeout(String reason) { return TimeoutRecord.endingNow(TimeoutKind.FGS_TIMEOUT, reason); } /** Record for a job related timeout. */ @NonNull public static TimeoutRecord forJobService(String reason) { Loading core/java/com/android/internal/os/anr/AnrLatencyTracker.java +0 −3 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import static com.android.internal.os.TimeoutRecord.TimeoutKind; import static com.android.internal.util.FrameworkStatsLog.ANRLATENCY_REPORTED__ANR_TYPE__BROADCAST_OF_INTENT; import static com.android.internal.util.FrameworkStatsLog.ANRLATENCY_REPORTED__ANR_TYPE__CONTENT_PROVIDER_NOT_RESPONDING; import static com.android.internal.util.FrameworkStatsLog.ANRLATENCY_REPORTED__ANR_TYPE__EXECUTING_SERVICE; import static com.android.internal.util.FrameworkStatsLog.ANRLATENCY_REPORTED__ANR_TYPE__FGS_TIMEOUT; import static com.android.internal.util.FrameworkStatsLog.ANRLATENCY_REPORTED__ANR_TYPE__INPUT_DISPATCHING_TIMEOUT; import static com.android.internal.util.FrameworkStatsLog.ANRLATENCY_REPORTED__ANR_TYPE__INPUT_DISPATCHING_TIMEOUT_NO_FOCUSED_WINDOW; import static com.android.internal.util.FrameworkStatsLog.ANRLATENCY_REPORTED__ANR_TYPE__JOB_SERVICE; Loading Loading @@ -549,8 +548,6 @@ public class AnrLatencyTracker implements AutoCloseable { return ANRLATENCY_REPORTED__ANR_TYPE__SHORT_FGS_TIMEOUT; case TimeoutKind.JOB_SERVICE: return ANRLATENCY_REPORTED__ANR_TYPE__JOB_SERVICE; case TimeoutKind.FGS_TIMEOUT: return ANRLATENCY_REPORTED__ANR_TYPE__FGS_TIMEOUT; default: return ANRLATENCY_REPORTED__ANR_TYPE__UNKNOWN_ANR_TYPE; } Loading services/core/java/com/android/server/am/ActiveServices.java +15 −32 Original line number Diff line number Diff line Loading @@ -499,8 +499,6 @@ public final class ActiveServices { private final ServiceAnrTimer mShortFGSAnrTimer; // ActivityManagerConstants.DEFAULT_SERVICE_START_FOREGROUND_TIMEOUT_MS private final ServiceAnrTimer mServiceFGAnrTimer; // see ServiceRecord#getEarliestStopTypeAndTime() private final ServiceAnrTimer mFGSAnrTimer; /** * Mapping of uid to {fgs_type, fgs_info} for time limited fgs types such as dataSync and Loading Loading @@ -784,9 +782,6 @@ public final class ActiveServices { this.mServiceFGAnrTimer = new ServiceAnrTimer(service, ActivityManagerService.SERVICE_FOREGROUND_TIMEOUT_MSG, "SERVICE_FOREGROUND_TIMEOUT"); this.mFGSAnrTimer = new ServiceAnrTimer(service, ActivityManagerService.SERVICE_FGS_CRASH_TIMEOUT_MSG, "FGS_TIMEOUT"); } void systemServicesReady() { Loading Loading @@ -3811,8 +3806,9 @@ public final class ActiveServices { if (!sr.isFgsTimeLimited()) { // Reset timers since new type does not have a timeout. mFGSAnrTimer.cancel(sr); mAm.mHandler.removeMessages(ActivityManagerService.SERVICE_FGS_TIMEOUT_MSG, sr); mAm.mHandler.removeMessages( ActivityManagerService.SERVICE_FGS_CRASH_TIMEOUT_MSG, sr); return; } } Loading @@ -3834,9 +3830,9 @@ public final class ActiveServices { } fgsTypeInfo.noteFgsFgsStart(nowUptime); // We'll cancel the previous ANR timer and start a fresh one below. mFGSAnrTimer.cancel(sr); // We'll cancel the timeout and crash messages and post a fresh one below. mAm.mHandler.removeMessages(ActivityManagerService.SERVICE_FGS_TIMEOUT_MSG, sr); mAm.mHandler.removeMessages(ActivityManagerService.SERVICE_FGS_CRASH_TIMEOUT_MSG, sr); final Message msg = mAm.mHandler.obtainMessage( ActivityManagerService.SERVICE_FGS_TIMEOUT_MSG, sr); Loading Loading @@ -3864,8 +3860,8 @@ public final class ActiveServices { fgsTypeInfo.decNumParallelServices(); } Slog.d(TAG_SERVICE, "Stop FGS timeout: " + sr); mFGSAnrTimer.cancel(sr); mAm.mHandler.removeMessages(ActivityManagerService.SERVICE_FGS_TIMEOUT_MSG, sr); mAm.mHandler.removeMessages(ActivityManagerService.SERVICE_FGS_CRASH_TIMEOUT_MSG, sr); } void onUidRemovedLocked(int uid) { Loading @@ -3892,7 +3888,8 @@ public final class ActiveServices { synchronized (mAm) { final int fgsType = getTimeLimitedFgsType(sr.foregroundServiceType); if (fgsType == ServiceInfo.FOREGROUND_SERVICE_TYPE_NONE || sr.app == null) { mFGSAnrTimer.discard(sr); mAm.mHandler.removeMessages( ActivityManagerService.SERVICE_FGS_CRASH_TIMEOUT_MSG, sr); return; } Loading @@ -3901,8 +3898,9 @@ public final class ActiveServices { final long nowUptime = SystemClock.uptimeMillis(); if (lastTopTime != Long.MIN_VALUE && constantTimeLimit > (nowUptime - lastTopTime)) { // Discard any other messages for this service mFGSAnrTimer.discard(sr); mAm.mHandler.removeMessages(ActivityManagerService.SERVICE_FGS_TIMEOUT_MSG, sr); mAm.mHandler.removeMessages( ActivityManagerService.SERVICE_FGS_CRASH_TIMEOUT_MSG, sr); // The app was in the TOP state after the FGS was started so its time allowance // should be counted from that time since this is considered a user interaction final Message msg = mAm.mHandler.obtainMessage( Loading @@ -3913,7 +3911,6 @@ public final class ActiveServices { Slog.e(TAG_SERVICE, "FGS (" + ServiceInfo.foregroundServiceTypeToLabel(fgsType) + ") timed out: " + sr); mFGSAnrTimer.accept(sr); traceInstant("FGS timed out: ", sr); final TimeLimitedFgsInfo fgsTypeInfo = getFgsTimeLimitedInfo(sr.appInfo.uid, fgsType); Loading @@ -3940,7 +3937,9 @@ public final class ActiveServices { } // Crash the service after giving the service some time to clean up. mFGSAnrTimer.start(sr, mAm.mConstants.mFgsCrashExtraWaitDuration); final Message msg = mAm.mHandler.obtainMessage( ActivityManagerService.SERVICE_FGS_CRASH_TIMEOUT_MSG, sr); mAm.mHandler.sendMessageDelayed(msg, mAm.mConstants.mFgsCrashExtraWaitDuration); } } Loading @@ -3963,8 +3962,9 @@ public final class ActiveServices { + ServiceInfo.foregroundServiceTypeToLabel(fgsType) + " did not stop within its timeout: " + sr.getComponentName(); if (android.app.Flags.gateFgsTimeoutAnrBehavior()) { // Log a WTF instead of throwing an ANR while the new behavior is gated. if (android.app.Flags.gateFgsTimeoutAnrBehavior() || !android.app.Flags.enableFgsTimeoutCrashBehavior()) { // Log a WTF instead of crashing the app while the new behavior is gated. Slog.wtf(TAG, reason); return; } Loading @@ -3981,23 +3981,6 @@ public final class ActiveServices { .createExtrasForService(sr.getComponentName())); } } } else { // ANR the app if the new crash behavior is not enabled final TimeoutRecord tr = TimeoutRecord.forFgsTimeout(reason); tr.mLatencyTracker.waitingOnAMSLockStarted(); synchronized (mAm) { tr.mLatencyTracker.waitingOnAMSLockEnded(); Slog.e(TAG_SERVICE, "FGS ANR'ed: " + sr); traceInstant("FGS ANR: ", sr); if (sr.app != null) { mAm.appNotResponding(sr.app, tr); } // TODO: Can we close the ANR dialog here, if it's still shown? Currently, the ANR // dialog really doesn't remember the "cause" (especially if there have been // multiple ANRs), so it's not doable. } } } Loading Loading
core/java/com/android/internal/os/TimeoutRecord.java +0 −8 Original line number Diff line number Diff line Loading @@ -45,7 +45,6 @@ public class TimeoutRecord { TimeoutKind.APP_REGISTERED, TimeoutKind.SHORT_FGS_TIMEOUT, TimeoutKind.JOB_SERVICE, TimeoutKind.FGS_TIMEOUT, }) @Retention(RetentionPolicy.SOURCE) Loading @@ -60,7 +59,6 @@ public class TimeoutRecord { int SHORT_FGS_TIMEOUT = 8; int JOB_SERVICE = 9; int APP_START = 10; int FGS_TIMEOUT = 11; } /** Kind of timeout, e.g. BROADCAST_RECEIVER, etc. */ Loading Loading @@ -188,12 +186,6 @@ public class TimeoutRecord { return TimeoutRecord.endingNow(TimeoutKind.SHORT_FGS_TIMEOUT, reason); } /** Record for a "foreground service" timeout. */ @NonNull public static TimeoutRecord forFgsTimeout(String reason) { return TimeoutRecord.endingNow(TimeoutKind.FGS_TIMEOUT, reason); } /** Record for a job related timeout. */ @NonNull public static TimeoutRecord forJobService(String reason) { Loading
core/java/com/android/internal/os/anr/AnrLatencyTracker.java +0 −3 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import static com.android.internal.os.TimeoutRecord.TimeoutKind; import static com.android.internal.util.FrameworkStatsLog.ANRLATENCY_REPORTED__ANR_TYPE__BROADCAST_OF_INTENT; import static com.android.internal.util.FrameworkStatsLog.ANRLATENCY_REPORTED__ANR_TYPE__CONTENT_PROVIDER_NOT_RESPONDING; import static com.android.internal.util.FrameworkStatsLog.ANRLATENCY_REPORTED__ANR_TYPE__EXECUTING_SERVICE; import static com.android.internal.util.FrameworkStatsLog.ANRLATENCY_REPORTED__ANR_TYPE__FGS_TIMEOUT; import static com.android.internal.util.FrameworkStatsLog.ANRLATENCY_REPORTED__ANR_TYPE__INPUT_DISPATCHING_TIMEOUT; import static com.android.internal.util.FrameworkStatsLog.ANRLATENCY_REPORTED__ANR_TYPE__INPUT_DISPATCHING_TIMEOUT_NO_FOCUSED_WINDOW; import static com.android.internal.util.FrameworkStatsLog.ANRLATENCY_REPORTED__ANR_TYPE__JOB_SERVICE; Loading Loading @@ -549,8 +548,6 @@ public class AnrLatencyTracker implements AutoCloseable { return ANRLATENCY_REPORTED__ANR_TYPE__SHORT_FGS_TIMEOUT; case TimeoutKind.JOB_SERVICE: return ANRLATENCY_REPORTED__ANR_TYPE__JOB_SERVICE; case TimeoutKind.FGS_TIMEOUT: return ANRLATENCY_REPORTED__ANR_TYPE__FGS_TIMEOUT; default: return ANRLATENCY_REPORTED__ANR_TYPE__UNKNOWN_ANR_TYPE; } Loading
services/core/java/com/android/server/am/ActiveServices.java +15 −32 Original line number Diff line number Diff line Loading @@ -499,8 +499,6 @@ public final class ActiveServices { private final ServiceAnrTimer mShortFGSAnrTimer; // ActivityManagerConstants.DEFAULT_SERVICE_START_FOREGROUND_TIMEOUT_MS private final ServiceAnrTimer mServiceFGAnrTimer; // see ServiceRecord#getEarliestStopTypeAndTime() private final ServiceAnrTimer mFGSAnrTimer; /** * Mapping of uid to {fgs_type, fgs_info} for time limited fgs types such as dataSync and Loading Loading @@ -784,9 +782,6 @@ public final class ActiveServices { this.mServiceFGAnrTimer = new ServiceAnrTimer(service, ActivityManagerService.SERVICE_FOREGROUND_TIMEOUT_MSG, "SERVICE_FOREGROUND_TIMEOUT"); this.mFGSAnrTimer = new ServiceAnrTimer(service, ActivityManagerService.SERVICE_FGS_CRASH_TIMEOUT_MSG, "FGS_TIMEOUT"); } void systemServicesReady() { Loading Loading @@ -3811,8 +3806,9 @@ public final class ActiveServices { if (!sr.isFgsTimeLimited()) { // Reset timers since new type does not have a timeout. mFGSAnrTimer.cancel(sr); mAm.mHandler.removeMessages(ActivityManagerService.SERVICE_FGS_TIMEOUT_MSG, sr); mAm.mHandler.removeMessages( ActivityManagerService.SERVICE_FGS_CRASH_TIMEOUT_MSG, sr); return; } } Loading @@ -3834,9 +3830,9 @@ public final class ActiveServices { } fgsTypeInfo.noteFgsFgsStart(nowUptime); // We'll cancel the previous ANR timer and start a fresh one below. mFGSAnrTimer.cancel(sr); // We'll cancel the timeout and crash messages and post a fresh one below. mAm.mHandler.removeMessages(ActivityManagerService.SERVICE_FGS_TIMEOUT_MSG, sr); mAm.mHandler.removeMessages(ActivityManagerService.SERVICE_FGS_CRASH_TIMEOUT_MSG, sr); final Message msg = mAm.mHandler.obtainMessage( ActivityManagerService.SERVICE_FGS_TIMEOUT_MSG, sr); Loading Loading @@ -3864,8 +3860,8 @@ public final class ActiveServices { fgsTypeInfo.decNumParallelServices(); } Slog.d(TAG_SERVICE, "Stop FGS timeout: " + sr); mFGSAnrTimer.cancel(sr); mAm.mHandler.removeMessages(ActivityManagerService.SERVICE_FGS_TIMEOUT_MSG, sr); mAm.mHandler.removeMessages(ActivityManagerService.SERVICE_FGS_CRASH_TIMEOUT_MSG, sr); } void onUidRemovedLocked(int uid) { Loading @@ -3892,7 +3888,8 @@ public final class ActiveServices { synchronized (mAm) { final int fgsType = getTimeLimitedFgsType(sr.foregroundServiceType); if (fgsType == ServiceInfo.FOREGROUND_SERVICE_TYPE_NONE || sr.app == null) { mFGSAnrTimer.discard(sr); mAm.mHandler.removeMessages( ActivityManagerService.SERVICE_FGS_CRASH_TIMEOUT_MSG, sr); return; } Loading @@ -3901,8 +3898,9 @@ public final class ActiveServices { final long nowUptime = SystemClock.uptimeMillis(); if (lastTopTime != Long.MIN_VALUE && constantTimeLimit > (nowUptime - lastTopTime)) { // Discard any other messages for this service mFGSAnrTimer.discard(sr); mAm.mHandler.removeMessages(ActivityManagerService.SERVICE_FGS_TIMEOUT_MSG, sr); mAm.mHandler.removeMessages( ActivityManagerService.SERVICE_FGS_CRASH_TIMEOUT_MSG, sr); // The app was in the TOP state after the FGS was started so its time allowance // should be counted from that time since this is considered a user interaction final Message msg = mAm.mHandler.obtainMessage( Loading @@ -3913,7 +3911,6 @@ public final class ActiveServices { Slog.e(TAG_SERVICE, "FGS (" + ServiceInfo.foregroundServiceTypeToLabel(fgsType) + ") timed out: " + sr); mFGSAnrTimer.accept(sr); traceInstant("FGS timed out: ", sr); final TimeLimitedFgsInfo fgsTypeInfo = getFgsTimeLimitedInfo(sr.appInfo.uid, fgsType); Loading @@ -3940,7 +3937,9 @@ public final class ActiveServices { } // Crash the service after giving the service some time to clean up. mFGSAnrTimer.start(sr, mAm.mConstants.mFgsCrashExtraWaitDuration); final Message msg = mAm.mHandler.obtainMessage( ActivityManagerService.SERVICE_FGS_CRASH_TIMEOUT_MSG, sr); mAm.mHandler.sendMessageDelayed(msg, mAm.mConstants.mFgsCrashExtraWaitDuration); } } Loading @@ -3963,8 +3962,9 @@ public final class ActiveServices { + ServiceInfo.foregroundServiceTypeToLabel(fgsType) + " did not stop within its timeout: " + sr.getComponentName(); if (android.app.Flags.gateFgsTimeoutAnrBehavior()) { // Log a WTF instead of throwing an ANR while the new behavior is gated. if (android.app.Flags.gateFgsTimeoutAnrBehavior() || !android.app.Flags.enableFgsTimeoutCrashBehavior()) { // Log a WTF instead of crashing the app while the new behavior is gated. Slog.wtf(TAG, reason); return; } Loading @@ -3981,23 +3981,6 @@ public final class ActiveServices { .createExtrasForService(sr.getComponentName())); } } } else { // ANR the app if the new crash behavior is not enabled final TimeoutRecord tr = TimeoutRecord.forFgsTimeout(reason); tr.mLatencyTracker.waitingOnAMSLockStarted(); synchronized (mAm) { tr.mLatencyTracker.waitingOnAMSLockEnded(); Slog.e(TAG_SERVICE, "FGS ANR'ed: " + sr); traceInstant("FGS ANR: ", sr); if (sr.app != null) { mAm.appNotResponding(sr.app, tr); } // TODO: Can we close the ANR dialog here, if it's still shown? Currently, the ANR // dialog really doesn't remember the "cause" (especially if there have been // multiple ANRs), so it's not doable. } } } Loading