Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>From <a href="https://android.googlesource.com/platform/frameworks/base.git/+/android-4.2.2_r1/services/java/com/android/server/am/ActiveServices.java" rel="noreferrer">com/android/server/am/ActiveServices.java</a> (not exposed)</p> <pre><code>// How long we wait for a service to finish executing. static final int SERVICE_TIMEOUT = 20*1000; // How long a service needs to be running until restarting its process // is no longer considered to be a relaunch of the service. static final int SERVICE_RESTART_DURATION = 5*1000; // How long a service needs to be running until it will start back at // SERVICE_RESTART_DURATION after being killed. static final int SERVICE_RESET_RUN_DURATION = 60*1000; // Multiplying factor to increase restart duration time by, for each time // a service is killed before it has run for SERVICE_RESET_RUN_DURATION. static final int SERVICE_RESTART_DURATION_FACTOR = 4; // The minimum amount of time between restarting services that we allow. // That is, when multiple services are restarting, we won't allow each // to restart less than this amount of time from the last one. static final int SERVICE_MIN_RESTART_TIME_BETWEEN = 10*1000; // Maximum amount of time for there to be no activity on a service before // we consider it non-essential and allow its process to go on the // LRU background list. static final int MAX_SERVICE_INACTIVITY = 30*60*1000; </code></pre> <p>What's happening for you probably is your service is dying quicker then <code>SERVICE_RESET_RUN_DURATION</code> and then restart time is multiplied by <code>SERVICE_RESTART_DURATION_FACTOR</code>.</p> <p>Starting from line #881:</p> <pre><code> // If it has been a "reasonably long time" since the service // was started, then reset our restart duration back to // the beginning, so we don't infinitely increase the duration // on a service that just occasionally gets killed (which is // a normal case, due to process being killed to reclaim memory). if (now &gt; (r.restartTime+resetTime)) { r.restartCount = 1; r.restartDelay = minDuration; } else { if ((r.serviceInfo.applicationInfo.flags &amp;ApplicationInfo.FLAG_PERSISTENT) != 0) { // Services in peristent processes will restart much more // quickly, since they are pretty important. (Think SystemUI). r.restartDelay += minDuration/2; } else { r.restartDelay *= SERVICE_RESTART_DURATION_FACTOR; if (r.restartDelay &lt; minDuration) { r.restartDelay = minDuration; } } } </code></pre> <p>Line below does the backing off your service.</p> <pre><code>r.restartDelay *= SERVICE_RESTART_DURATION_FACTOR; </code></pre> <p>So you should fix the case if your service is dying before running for <code>SERVICE_RESET_RUN_DURATION</code>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload