diff options
| -rw-r--r-- | services/core/java/com/android/server/am/ActivityRecord.java | 27 | ||||
| -rw-r--r-- | services/core/java/com/android/server/am/ActivityStackSupervisor.java | 17 |
2 files changed, 36 insertions, 8 deletions
diff --git a/services/core/java/com/android/server/am/ActivityRecord.java b/services/core/java/com/android/server/am/ActivityRecord.java index 18c8b322496c..ba2c0cdc003f 100644 --- a/services/core/java/com/android/server/am/ActivityRecord.java +++ b/services/core/java/com/android/server/am/ActivityRecord.java @@ -40,6 +40,7 @@ import static android.content.Intent.ACTION_MAIN; import static android.content.Intent.CATEGORY_HOME; import static android.content.Intent.CATEGORY_LAUNCHER; import static android.content.Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS; +import static android.content.Intent.FLAG_ACTIVITY_NO_HISTORY; import static android.content.pm.ActivityInfo.CONFIG_ORIENTATION; import static android.content.pm.ActivityInfo.CONFIG_SCREEN_LAYOUT; import static android.content.pm.ActivityInfo.CONFIG_SCREEN_SIZE; @@ -61,6 +62,7 @@ import static android.content.pm.ActivityInfo.RESIZE_MODE_FORCE_RESIZEABLE; import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE; import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION; import static android.content.pm.ActivityInfo.RESIZE_MODE_UNRESIZEABLE; +import static android.content.pm.ActivityInfo.FLAG_NO_HISTORY; import static android.content.pm.ActivityInfo.isFixedOrientationLandscape; import static android.content.pm.ActivityInfo.isFixedOrientationPortrait; import static android.content.res.Configuration.EMPTY; @@ -128,7 +130,6 @@ import android.content.pm.ApplicationInfo; import android.content.res.CompatibilityInfo; import android.content.res.Configuration; import android.graphics.Bitmap; -import android.graphics.Point; import android.graphics.Rect; import android.os.Bundle; import android.os.Debug; @@ -1951,13 +1952,9 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo if (!nowVisible) { nowVisible = true; lastVisibleTime = SystemClock.uptimeMillis(); - if (!idle) { - // Instead of doing the full stop routine here, let's just hide any activities - // we now can, and let them stop when the normal idle happens. - mStackSupervisor.processStoppingActivitiesLocked(null /* idleActivity */, - false /* remove */, true /* processPausingActivities */); - } else { - // If this activity was already idle, then we now need to make sure we perform + if (idle || mStackSupervisor.isStoppingNoHistoryActivity()) { + // If this activity was already idle or there is an activity that must be + // stopped immediately after visible, then we now need to make sure we perform // the full stop of any activities that are waiting to do so. This is because // we won't do that while they are still waiting for this one to become visible. final int size = mStackSupervisor.mActivitiesWaitingForVisibleActivity.size(); @@ -1970,6 +1967,11 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo mStackSupervisor.mActivitiesWaitingForVisibleActivity.clear(); mStackSupervisor.scheduleIdleLocked(); } + } else { + // Instead of doing the full stop routine here, let's just hide any activities + // we now can, and let them stop when the normal idle happens. + mStackSupervisor.processStoppingActivitiesLocked(null /* idleActivity */, + false /* remove */, true /* processPausingActivities */); } service.scheduleAppGcsLocked(); } @@ -2662,6 +2664,15 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo return true; } + /** + * Returns {@code true} if the associated activity has the no history flag set on it. + * {@code false} otherwise. + */ + boolean isNoHistory() { + return (intent.getFlags() & FLAG_ACTIVITY_NO_HISTORY) != 0 + || (info.flags & FLAG_NO_HISTORY) != 0; + } + void saveToXml(XmlSerializer out) throws IOException, XmlPullParserException { out.attribute(null, ATTR_ID, String.valueOf(createTime)); out.attribute(null, ATTR_LAUNCHEDFROMUID, String.valueOf(launchedFromUid)); diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java index 358d36dbe2b3..d5b54ca8bf39 100644 --- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java +++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java @@ -3500,6 +3500,23 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D return mService.mUserController.isCurrentProfileLocked(userId); } + /** + * Returns whether a stopping activity is present that should be stopped after visible, rather + * than idle. + * @return {@code true} if such activity is present. {@code false} otherwise. + */ + boolean isStoppingNoHistoryActivity() { + // Activities that are marked as nohistory should be stopped immediately after the resumed + // activity has become visible. + for (ActivityRecord record : mStoppingActivities) { + if (record.isNoHistory()) { + return true; + } + } + + return false; + } + final ArrayList<ActivityRecord> processStoppingActivitiesLocked(ActivityRecord idleActivity, boolean remove, boolean processPausingActivities) { ArrayList<ActivityRecord> stops = null; |