Loading services/core/java/com/android/server/wm/ActivityTaskManagerService.java +10 −0 Original line number Diff line number Diff line Loading @@ -311,6 +311,9 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { public static final int KEY_DISPATCHING_TIMEOUT_MS = 5 * 1000; // How long we wait until we timeout on key dispatching during instrumentation. static final int INSTRUMENTATION_KEY_DISPATCHING_TIMEOUT_MS = 60 * 1000; // How long we permit background activity starts after an activity in the process // started or finished. static final long ACTIVITY_BG_START_GRACE_PERIOD_MS = 10 * 1000; /** Used to indicate that an app transition should be animated. */ static final boolean ANIMATE = true; Loading Loading @@ -1575,6 +1578,13 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } } } // note down that the process has finished an activity and is in background activity // starts grace period if (r.app != null) { r.app.setLastActivityFinishTimeIfNeeded(SystemClock.uptimeMillis()); } final long origId = Binder.clearCallingIdentity(); try { boolean res; Loading services/core/java/com/android/server/wm/WindowProcessController.java +29 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import static com.android.server.wm.ActivityTaskManagerDebugConfig.POSTFIX_CONFI import static com.android.server.wm.ActivityTaskManagerDebugConfig.POSTFIX_RELEASE; import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_ATM; import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_WITH_CLASS_NAME; import static com.android.server.wm.ActivityTaskManagerService.ACTIVITY_BG_START_GRACE_PERIOD_MS; import static com.android.server.wm.ActivityTaskManagerService.INSTRUMENTATION_KEY_DISPATCHING_TIMEOUT_MS; import static com.android.server.wm.ActivityTaskManagerService.KEY_DISPATCHING_TIMEOUT_MS; import static com.android.server.wm.ActivityTaskManagerService.RELAUNCH_REASON_NONE; Loading @@ -50,6 +51,7 @@ import android.content.pm.ApplicationInfo; import android.content.res.Configuration; import android.os.Message; import android.os.RemoteException; import android.os.SystemClock; import android.util.ArraySet; import android.util.Log; import android.util.Slog; Loading Loading @@ -163,6 +165,11 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio private final ArrayList<TaskRecord> mRecentTasks = new ArrayList<>(); // The most recent top-most activity that was resumed in the process for pre-Q app. private ActivityRecord mPreQTopResumedActivity = null; // The last time an activity was launched in the process private long mLastActivityLaunchTime; // The last time an activity was finished in the process while the process participated // in a visible task private long mLastActivityFinishTime; // Last configuration that was reported to the process. private final Configuration mLastReportedConfiguration; Loading Loading @@ -372,6 +379,20 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio return mUsingWrapper; } void setLastActivityLaunchTime(long launchTime) { if (launchTime <= mLastActivityLaunchTime) { return; } mLastActivityLaunchTime = launchTime; } void setLastActivityFinishTimeIfNeeded(long finishTime) { if (finishTime <= mLastActivityFinishTime || !hasActivityInVisibleTask()) { return; } mLastActivityFinishTime = finishTime; } public void setAllowBackgroundActivityStarts(boolean allowBackgroundActivityStarts) { mAllowBackgroundActivityStarts = allowBackgroundActivityStarts; } Loading @@ -381,6 +402,12 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio if (mAllowBackgroundActivityStarts) { return true; } // allow if any activity in the caller has either started or finished very recently final long now = SystemClock.uptimeMillis(); if (now - mLastActivityLaunchTime < ACTIVITY_BG_START_GRACE_PERIOD_MS || now - mLastActivityFinishTime < ACTIVITY_BG_START_GRACE_PERIOD_MS) { return true; } // allow if the proc is instrumenting with background activity starts privs if (mInstrumentingWithBackgroundActivityStartPrivileges) { return true; Loading Loading @@ -457,6 +484,8 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio } void addActivityIfNeeded(ActivityRecord r) { // even if we already track this activity, note down that it has been launched setLastActivityLaunchTime(r.lastLaunchTime); if (mActivities.contains(r)) { return; } Loading Loading
services/core/java/com/android/server/wm/ActivityTaskManagerService.java +10 −0 Original line number Diff line number Diff line Loading @@ -311,6 +311,9 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { public static final int KEY_DISPATCHING_TIMEOUT_MS = 5 * 1000; // How long we wait until we timeout on key dispatching during instrumentation. static final int INSTRUMENTATION_KEY_DISPATCHING_TIMEOUT_MS = 60 * 1000; // How long we permit background activity starts after an activity in the process // started or finished. static final long ACTIVITY_BG_START_GRACE_PERIOD_MS = 10 * 1000; /** Used to indicate that an app transition should be animated. */ static final boolean ANIMATE = true; Loading Loading @@ -1575,6 +1578,13 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } } } // note down that the process has finished an activity and is in background activity // starts grace period if (r.app != null) { r.app.setLastActivityFinishTimeIfNeeded(SystemClock.uptimeMillis()); } final long origId = Binder.clearCallingIdentity(); try { boolean res; Loading
services/core/java/com/android/server/wm/WindowProcessController.java +29 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import static com.android.server.wm.ActivityTaskManagerDebugConfig.POSTFIX_CONFI import static com.android.server.wm.ActivityTaskManagerDebugConfig.POSTFIX_RELEASE; import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_ATM; import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_WITH_CLASS_NAME; import static com.android.server.wm.ActivityTaskManagerService.ACTIVITY_BG_START_GRACE_PERIOD_MS; import static com.android.server.wm.ActivityTaskManagerService.INSTRUMENTATION_KEY_DISPATCHING_TIMEOUT_MS; import static com.android.server.wm.ActivityTaskManagerService.KEY_DISPATCHING_TIMEOUT_MS; import static com.android.server.wm.ActivityTaskManagerService.RELAUNCH_REASON_NONE; Loading @@ -50,6 +51,7 @@ import android.content.pm.ApplicationInfo; import android.content.res.Configuration; import android.os.Message; import android.os.RemoteException; import android.os.SystemClock; import android.util.ArraySet; import android.util.Log; import android.util.Slog; Loading Loading @@ -163,6 +165,11 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio private final ArrayList<TaskRecord> mRecentTasks = new ArrayList<>(); // The most recent top-most activity that was resumed in the process for pre-Q app. private ActivityRecord mPreQTopResumedActivity = null; // The last time an activity was launched in the process private long mLastActivityLaunchTime; // The last time an activity was finished in the process while the process participated // in a visible task private long mLastActivityFinishTime; // Last configuration that was reported to the process. private final Configuration mLastReportedConfiguration; Loading Loading @@ -372,6 +379,20 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio return mUsingWrapper; } void setLastActivityLaunchTime(long launchTime) { if (launchTime <= mLastActivityLaunchTime) { return; } mLastActivityLaunchTime = launchTime; } void setLastActivityFinishTimeIfNeeded(long finishTime) { if (finishTime <= mLastActivityFinishTime || !hasActivityInVisibleTask()) { return; } mLastActivityFinishTime = finishTime; } public void setAllowBackgroundActivityStarts(boolean allowBackgroundActivityStarts) { mAllowBackgroundActivityStarts = allowBackgroundActivityStarts; } Loading @@ -381,6 +402,12 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio if (mAllowBackgroundActivityStarts) { return true; } // allow if any activity in the caller has either started or finished very recently final long now = SystemClock.uptimeMillis(); if (now - mLastActivityLaunchTime < ACTIVITY_BG_START_GRACE_PERIOD_MS || now - mLastActivityFinishTime < ACTIVITY_BG_START_GRACE_PERIOD_MS) { return true; } // allow if the proc is instrumenting with background activity starts privs if (mInstrumentingWithBackgroundActivityStartPrivileges) { return true; Loading Loading @@ -457,6 +484,8 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio } void addActivityIfNeeded(ActivityRecord r) { // even if we already track this activity, note down that it has been launched setLastActivityLaunchTime(r.lastLaunchTime); if (mActivities.contains(r)) { return; } Loading