import static android.content.pm.ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE;
import static android.content.pm.ActivityInfo.CONFIG_UI_MODE;
import static android.content.pm.ActivityInfo.FLAG_ALWAYS_FOCUSABLE;
+import static android.content.pm.ActivityInfo.FLAG_SHOW_WHEN_LOCKED;
import static android.content.pm.ActivityInfo.FLAG_EXCLUDE_FROM_RECENTS;
import static android.content.pm.ActivityInfo.FLAG_IMMERSIVE;
import static android.content.pm.ActivityInfo.FLAG_MULTIPROCESS;
import static android.content.pm.ActivityInfo.FLAG_SHOW_FOR_ALL_USERS;
import static android.content.pm.ActivityInfo.FLAG_STATE_NOT_NEEDED;
+import static android.content.pm.ActivityInfo.FLAG_TURN_SCREEN_ON;
import static android.content.pm.ActivityInfo.LAUNCH_MULTIPLE;
import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_INSTANCE;
import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_TASK;
import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_VISIBILITY;
import static com.android.server.am.ActivityManagerDebugConfig.TAG_AM;
import static com.android.server.am.ActivityManagerDebugConfig.TAG_WITH_CLASS_NAME;
-import static com.android.server.am.ActivityManagerService.IS_USER_BUILD;
import static com.android.server.am.ActivityManagerService.TAKE_FULLSCREEN_SCREENSHOTS;
import static com.android.server.am.ActivityStack.ActivityState.DESTROYED;
import static com.android.server.am.ActivityStack.ActivityState.DESTROYING;
// handle calculating override configuration from the bounds.
private final Rect mBounds = new Rect();
+ private boolean mShowWhenLocked;
+ private boolean mTurnScreenOn;
+
/**
* Temp configs used in {@link #ensureActivityConfigurationLocked(int, boolean)}
*/
requestedVrComponent = (aInfo.requestedVrComponent == null) ?
null : ComponentName.unflattenFromString(aInfo.requestedVrComponent);
+
+ mShowWhenLocked = (aInfo.flags & FLAG_SHOW_WHEN_LOCKED) != 0;
+ mTurnScreenOn = (aInfo.flags & FLAG_TURN_SCREEN_ON) != 0;
}
AppWindowContainerController getWindowContainerController() {
return (info.flags & FLAG_ALWAYS_FOCUSABLE) != 0;
}
- /**
- * @return true if the activity contains windows that have
- * {@link LayoutParams#FLAG_SHOW_WHEN_LOCKED} set
- */
- boolean hasShowWhenLockedWindows() {
- return service.mWindowManager.containsShowWhenLockedWindow(appToken);
- }
/**
* @return true if the activity contains windows that have
}
void makeFinishingLocked() {
- if (!finishing) {
- final ActivityStack stack = getStack();
- if (stack != null && this == stack.getVisibleBehindActivity()) {
- // A finishing activity should not remain as visible in the background
- mStackSupervisor.requestVisibleBehindLocked(this, false);
- }
- finishing = true;
- if (stopped) {
- clearOptionsLocked();
- }
+ if (finishing) {
+ return;
+ }
+ finishing = true;
+ if (stopped) {
+ clearOptionsLocked();
+ }
- if (service != null) {
- service.mTaskChangeNotificationController.notifyTaskStackChanged();
- }
+ if (service != null) {
+ service.mTaskChangeNotificationController.notifyTaskStackChanged();
}
}
intent, getUriPermissionsLocked(), userId);
final ReferrerIntent rintent = new ReferrerIntent(intent, referrer);
boolean unsent = true;
- final ActivityStack stack = getStack();
- final boolean isTopActivityInStack =
- stack != null && stack.topRunningActivityLocked() == this;
- final boolean isTopActivityWhileSleeping =
- service.isSleepingLocked() && isTopActivityInStack;
+ final boolean isTopActivityWhileSleeping = service.isSleepingLocked() && isTopRunningActivity();
// We want to immediately deliver the intent to the activity if:
// - It is currently resumed or paused. i.e. it is currently visible to the user and we want
*
* @see {@link ActivityStack#checkKeyguardVisibility}
*/
- boolean shouldBeVisibleIgnoringKeyguard(boolean behindTranslucentActivity,
- boolean stackVisibleBehind, ActivityRecord visibleBehind,
- boolean behindFullscreenActivity) {
+ boolean shouldBeVisibleIgnoringKeyguard(boolean behindFullscreenActivity) {
if (!okToShowLocked()) {
return false;
}
- // mLaunchingBehind: Activities launching behind are at the back of the task stack
- // but must be drawn initially for the animation as though they were visible.
- final boolean activityVisibleBehind =
- (behindTranslucentActivity || stackVisibleBehind) && visibleBehind == this;
-
- boolean isVisible =
- !behindFullscreenActivity || mLaunchTaskBehind || activityVisibleBehind;
+ boolean isVisible = !behindFullscreenActivity || mLaunchTaskBehind;
if (service.mSupportsLeanbackOnly && isVisible && isRecentsActivity()) {
// On devices that support leanback only (Android TV), Recents activity can only be
returningOptions = null;
- if (stack.getVisibleBehindActivity() == this) {
- // When resuming an activity, require it to call requestVisibleBehind() again.
- stack.setVisibleBehindActivity(null /* ActivityRecord */);
+ if (canTurnScreenOn()) {
+ mStackSupervisor.wakeUp("turnScreenOnFlag");
+ } else {
+ // If the screen is going to turn on because the caller explicitly requested it and
+ // the keyguard is not showing don't attempt to sleep. Otherwise the Activity will
+ // pause and then resume again later, which will result in a double life-cycle event.
+ mStackSupervisor.checkReadyForSleepLocked();
}
- mStackSupervisor.checkReadyForSleepLocked();
}
final void activityStoppedLocked(Bundle newIcicle, PersistableBundle newPersistentState,
mWindowContainerController.notifyAppStopped();
- if (stack.getVisibleBehindActivity() == this) {
- mStackSupervisor.requestVisibleBehindLocked(this, false /* visible */);
- }
if (finishing) {
clearOptionsLocked();
} else {
}
void startLaunchTickingLocked() {
- if (IS_USER_BUILD) {
+ if (Build.IS_USER) {
return;
}
if (launchTickTime == 0) {
return info.applicationInfo.uid;
}
+ void setShowWhenLocked(boolean showWhenLocked) {
+ mShowWhenLocked = showWhenLocked;
+ }
+
+ /**
+ * @return true if the activity contains windows that have
+ * {@link LayoutParams#FLAG_SHOW_WHEN_LOCKED} set or if the activity has set
+ * {@link #mShowWhenLocked}.
+ */
+ boolean canShowWhenLocked() {
+ return mShowWhenLocked || service.mWindowManager.containsShowWhenLockedWindow(appToken);
+ }
+
+ void setTurnScreenOn(boolean turnScreenOn) {
+ mTurnScreenOn = turnScreenOn;
+ }
+
+ /**
+ * Determines whether this ActivityRecord can turn the screen on. It checks whether the flag
+ * {@link #mTurnScreenOn} is set and checks whether the ActivityRecord should be visible
+ * depending on Keyguard state
+ *
+ * @return true if the screen can be turned on, false otherwise.
+ */
+ boolean canTurnScreenOn() {
+ final ActivityStack stack = getStack();
+ return mTurnScreenOn && stack != null &&
+ stack.checkKeyguardVisibility(this, true /* shouldBeVisible */, true /* isTop */);
+ }
+
+ boolean getTurnScreenOnFlag() {
+ return mTurnScreenOn;
+ }
+
+ boolean isTopRunningActivity() {
+ return mStackSupervisor.topRunningActivityLocked() == this;
+ }
+
@Override
public String toString() {
if (stringName != null) {