Revert "Close ActivityView and ActivityContainer cleanly."
This reverts commit 4a9f129874
.
Conflicts:
services/core/java/com/android/server/am/ActivityStackSupervisor.java
Change-Id: Ic1f4df7f4cb644de7ddebcdc8ce632b46c5ba8f2
This commit is contained in:
@ -354,11 +354,9 @@ public class ActivityView extends ViewGroup {
|
||||
private static class ActivityContainerWrapper {
|
||||
private final IActivityContainer mIActivityContainer;
|
||||
private final CloseGuard mGuard = CloseGuard.get();
|
||||
boolean mOpened; // Protected by mGuard.
|
||||
|
||||
ActivityContainerWrapper(IActivityContainer container) {
|
||||
mIActivityContainer = container;
|
||||
mOpened = true;
|
||||
mGuard.open("release");
|
||||
}
|
||||
|
||||
@ -426,17 +424,12 @@ public class ActivityView extends ViewGroup {
|
||||
}
|
||||
|
||||
void release() {
|
||||
synchronized (mGuard) {
|
||||
if (mOpened) {
|
||||
if (DEBUG) Log.v(TAG, "ActivityContainerWrapper: release called");
|
||||
try {
|
||||
mIActivityContainer.release();
|
||||
mGuard.close();
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
mOpened = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -32,11 +32,12 @@ import static com.android.server.am.ActivityManagerService.VALIDATE_TOKENS;
|
||||
|
||||
import static com.android.server.am.ActivityStackSupervisor.DEBUG_ADD_REMOVE;
|
||||
import static com.android.server.am.ActivityStackSupervisor.DEBUG_APP;
|
||||
import static com.android.server.am.ActivityStackSupervisor.DEBUG_CONTAINERS;
|
||||
import static com.android.server.am.ActivityStackSupervisor.DEBUG_SAVED_STATE;
|
||||
import static com.android.server.am.ActivityStackSupervisor.DEBUG_STATES;
|
||||
import static com.android.server.am.ActivityStackSupervisor.HOME_STACK_ID;
|
||||
|
||||
import static com.android.server.am.ActivityStackSupervisor.ActivityContainer.CONTAINER_STATE_HAS_SURFACE;
|
||||
|
||||
import com.android.internal.os.BatteryStatsImpl;
|
||||
import com.android.server.Watchdog;
|
||||
import com.android.server.am.ActivityManagerService.ItemMatcher;
|
||||
@ -1274,7 +1275,7 @@ final class ActivityStack {
|
||||
|
||||
ActivityRecord parent = mActivityContainer.mParentActivity;
|
||||
if ((parent != null && parent.state != ActivityState.RESUMED) ||
|
||||
!mActivityContainer.isAttachedLocked()) {
|
||||
!mActivityContainer.isAttached()) {
|
||||
// Do not resume this stack if its parent is not resumed.
|
||||
// TODO: If in a loop, make sure that parent stack resumeTopActivity is called 1st.
|
||||
return false;
|
||||
@ -2538,14 +2539,11 @@ final class ActivityStack {
|
||||
|| prevState == ActivityState.INITIALIZING) {
|
||||
// If this activity is already stopped, we can just finish
|
||||
// it right now.
|
||||
r.makeFinishing();
|
||||
boolean activityRemoved = destroyActivityLocked(r, true, oomAdj, "finish-imm");
|
||||
boolean activityRemoved = destroyActivityLocked(r, true,
|
||||
oomAdj, "finish-imm");
|
||||
if (activityRemoved) {
|
||||
mStackSupervisor.resumeTopActivitiesLocked();
|
||||
}
|
||||
if (DEBUG_CONTAINERS) Slog.d(TAG,
|
||||
"destroyActivityLocked: finishCurrentActivityLocked r=" + r +
|
||||
" destroy returned removed=" + activityRemoved);
|
||||
return activityRemoved ? null : r;
|
||||
}
|
||||
|
||||
@ -2914,7 +2912,6 @@ final class ActivityStack {
|
||||
if (r != null) {
|
||||
mHandler.removeMessages(DESTROY_TIMEOUT_MSG, r);
|
||||
}
|
||||
if (DEBUG_CONTAINERS) Slog.d(TAG, "activityDestroyedLocked: r=" + r);
|
||||
|
||||
if (isInStackLocked(token) != null) {
|
||||
if (r.state == ActivityState.DESTROYING) {
|
||||
@ -3672,7 +3669,7 @@ final class ActivityStack {
|
||||
mStacks.remove(this);
|
||||
mStacks.add(0, this);
|
||||
}
|
||||
mActivityContainer.onTaskListEmptyLocked();
|
||||
mActivityContainer.onTaskListEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,6 @@ public final class ActivityStackSupervisor implements DisplayListener {
|
||||
static final boolean DEBUG_SAVED_STATE = DEBUG || false;
|
||||
static final boolean DEBUG_STATES = DEBUG || false;
|
||||
static final boolean DEBUG_IDLE = DEBUG || false;
|
||||
static final boolean DEBUG_CONTAINERS = DEBUG || false;
|
||||
|
||||
public static final int HOME_STACK_ID = 0;
|
||||
|
||||
@ -128,7 +127,6 @@ public final class ActivityStackSupervisor implements DisplayListener {
|
||||
static final int HANDLE_DISPLAY_REMOVED = FIRST_SUPERVISOR_STACK_MSG + 7;
|
||||
static final int CONTAINER_CALLBACK_VISIBILITY = FIRST_SUPERVISOR_STACK_MSG + 8;
|
||||
static final int CONTAINER_CALLBACK_TASK_LIST_EMPTY = FIRST_SUPERVISOR_STACK_MSG + 9;
|
||||
static final int CONTAINER_TASK_LIST_EMPTY_TIMEOUT = FIRST_SUPERVISOR_STACK_MSG + 10;
|
||||
|
||||
private final static String VIRTUAL_DISPLAY_BASE_NAME = "ActivityViewVirtualDisplay";
|
||||
|
||||
@ -226,7 +224,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
|
||||
|
||||
// TODO: Add listener for removal of references.
|
||||
/** Mapping from (ActivityStack/TaskStack).mStackId to their current state */
|
||||
private SparseArray<ActivityContainer> mActivityContainers = new SparseArray<ActivityContainer>();
|
||||
SparseArray<ActivityContainer> mActivityContainers = new SparseArray<ActivityContainer>();
|
||||
|
||||
/** Mapping from displayId to display current state */
|
||||
private final SparseArray<ActivityDisplay> mActivityDisplays =
|
||||
@ -2163,10 +2161,8 @@ public final class ActivityStackSupervisor implements DisplayListener {
|
||||
|
||||
ActivityContainer createActivityContainer(ActivityRecord parentActivity,
|
||||
IActivityContainerCallback callback) {
|
||||
ActivityContainer activityContainer =
|
||||
new VirtualActivityContainer(parentActivity, callback);
|
||||
ActivityContainer activityContainer = new VirtualActivityContainer(parentActivity, callback);
|
||||
mActivityContainers.put(activityContainer.mStackId, activityContainer);
|
||||
if (DEBUG_CONTAINERS) Slog.d(TAG, "createActivityContainer: " + activityContainer);
|
||||
parentActivity.mChildContainers.add(activityContainer);
|
||||
return activityContainer;
|
||||
}
|
||||
@ -2175,8 +2171,6 @@ public final class ActivityStackSupervisor implements DisplayListener {
|
||||
final ArrayList<ActivityContainer> childStacks = parentActivity.mChildContainers;
|
||||
for (int containerNdx = childStacks.size() - 1; containerNdx >= 0; --containerNdx) {
|
||||
ActivityContainer container = childStacks.remove(containerNdx);
|
||||
if (DEBUG_CONTAINERS) Slog.d(TAG, "removeChildActivityContainers: removing " +
|
||||
container);
|
||||
container.release();
|
||||
}
|
||||
}
|
||||
@ -2184,8 +2178,11 @@ public final class ActivityStackSupervisor implements DisplayListener {
|
||||
void deleteActivityContainer(IActivityContainer container) {
|
||||
ActivityContainer activityContainer = (ActivityContainer)container;
|
||||
if (activityContainer != null) {
|
||||
if (DEBUG_CONTAINERS) Slog.d(TAG, "deleteActivityContainer: ",
|
||||
new RuntimeException("here").fillInStackTrace());
|
||||
activityContainer.mStack.finishAllActivitiesLocked();
|
||||
final ActivityRecord parent = activityContainer.mParentActivity;
|
||||
if (parent != null) {
|
||||
parent.mChildContainers.remove(activityContainer);
|
||||
}
|
||||
final int stackId = activityContainer.mStackId;
|
||||
mActivityContainers.remove(stackId);
|
||||
mWindowManager.removeStack(stackId);
|
||||
@ -2768,19 +2765,16 @@ public final class ActivityStackSupervisor implements DisplayListener {
|
||||
|
||||
@Override
|
||||
public void onDisplayAdded(int displayId) {
|
||||
Slog.v(TAG, "Display added displayId=" + displayId);
|
||||
mHandler.sendMessage(mHandler.obtainMessage(HANDLE_DISPLAY_ADDED, displayId, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisplayRemoved(int displayId) {
|
||||
Slog.v(TAG, "Display removed displayId=" + displayId);
|
||||
mHandler.sendMessage(mHandler.obtainMessage(HANDLE_DISPLAY_REMOVED, displayId, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisplayChanged(int displayId) {
|
||||
Slog.v(TAG, "Display changed displayId=" + displayId);
|
||||
mHandler.sendMessage(mHandler.obtainMessage(HANDLE_DISPLAY_CHANGED, displayId, 0));
|
||||
}
|
||||
|
||||
@ -2956,13 +2950,6 @@ public final class ActivityStackSupervisor implements DisplayListener {
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case CONTAINER_TASK_LIST_EMPTY_TIMEOUT: {
|
||||
synchronized (mService) {
|
||||
Slog.w(TAG, "Timeout waiting for all activities in task to finish. " +
|
||||
msg.obj);
|
||||
((ActivityContainer) msg.obj).onTaskListEmptyLocked();
|
||||
}
|
||||
} break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3019,11 +3006,9 @@ public final class ActivityStackSupervisor implements DisplayListener {
|
||||
|
||||
@Override
|
||||
public int getDisplayId() {
|
||||
synchronized (mService) {
|
||||
if (mActivityDisplay != null) {
|
||||
return mActivityDisplay.mDisplayId;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -3031,13 +3016,11 @@ public final class ActivityStackSupervisor implements DisplayListener {
|
||||
public boolean injectEvent(InputEvent event) {
|
||||
final long origId = Binder.clearCallingIdentity();
|
||||
try {
|
||||
synchronized (mService) {
|
||||
if (mActivityDisplay != null) {
|
||||
return mInputManagerInternal.injectInputEvent(event,
|
||||
mActivityDisplay.mDisplayId,
|
||||
InputManager.INJECT_INPUT_EVENT_MODE_ASYNC);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(origId);
|
||||
@ -3046,23 +3029,10 @@ public final class ActivityStackSupervisor implements DisplayListener {
|
||||
|
||||
@Override
|
||||
public void release() {
|
||||
synchronized (mService) {
|
||||
if (mContainerState == CONTAINER_STATE_FINISHING) {
|
||||
return;
|
||||
}
|
||||
mContainerState = CONTAINER_STATE_FINISHING;
|
||||
|
||||
final Message msg =
|
||||
mHandler.obtainMessage(CONTAINER_TASK_LIST_EMPTY_TIMEOUT, this);
|
||||
mHandler.sendMessageDelayed(msg, 1000);
|
||||
|
||||
long origId = Binder.clearCallingIdentity();
|
||||
try {
|
||||
mStack.finishAllActivitiesLocked();
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(origId);
|
||||
}
|
||||
}
|
||||
detachLocked();
|
||||
mWindowManager.removeStack(mStackId);
|
||||
}
|
||||
|
||||
private void detachLocked() {
|
||||
@ -3153,19 +3123,17 @@ public final class ActivityStackSupervisor implements DisplayListener {
|
||||
return ActivityStackSupervisor.this;
|
||||
}
|
||||
|
||||
boolean isAttachedLocked() {
|
||||
boolean isAttached() {
|
||||
return mActivityDisplay != null;
|
||||
}
|
||||
|
||||
void getBounds(Point outBounds) {
|
||||
synchronized (mService) {
|
||||
if (mActivityDisplay != null) {
|
||||
mActivityDisplay.getBounds(outBounds);
|
||||
} else {
|
||||
outBounds.set(0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Make sure every change to ActivityRecord.visible results in a call to this.
|
||||
void setVisible(boolean visible) {
|
||||
@ -3186,12 +3154,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
|
||||
return true;
|
||||
}
|
||||
|
||||
void onTaskListEmptyLocked() {
|
||||
mHandler.removeMessages(CONTAINER_TASK_LIST_EMPTY_TIMEOUT, this);
|
||||
if (!mStack.isHomeStack()) {
|
||||
detachLocked();
|
||||
deleteActivityContainer(this);
|
||||
}
|
||||
void onTaskListEmpty() {
|
||||
mHandler.obtainMessage(CONTAINER_CALLBACK_TASK_LIST_EMPTY, this).sendToTarget();
|
||||
}
|
||||
|
||||
@ -3210,7 +3173,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
|
||||
mParentActivity = parent;
|
||||
mCallback = callback;
|
||||
mContainerState = CONTAINER_STATE_NO_SURFACE;
|
||||
mIdString = "VirtualActivityContainer{" + mStackId + ", parent=" + mParentActivity + "}";
|
||||
mIdString = "VirtualActivtyContainer{" + mStackId + ", parent=" + mParentActivity + "}";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -3256,22 +3219,22 @@ public final class ActivityStackSupervisor implements DisplayListener {
|
||||
}
|
||||
}
|
||||
|
||||
setSurfaceIfReadyLocked();
|
||||
setSurfaceIfReady();
|
||||
|
||||
if (DEBUG_STACK) Slog.d(TAG, "setSurface: " + this + " to display="
|
||||
+ virtualActivityDisplay);
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean isAttachedLocked() {
|
||||
return mSurface != null && super.isAttachedLocked();
|
||||
boolean isAttached() {
|
||||
return mSurface != null && super.isAttached();
|
||||
}
|
||||
|
||||
@Override
|
||||
void setDrawn() {
|
||||
synchronized (mService) {
|
||||
mDrawn = true;
|
||||
setSurfaceIfReadyLocked();
|
||||
setSurfaceIfReady();
|
||||
}
|
||||
}
|
||||
|
||||
@ -3281,8 +3244,8 @@ public final class ActivityStackSupervisor implements DisplayListener {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setSurfaceIfReadyLocked() {
|
||||
if (DEBUG_STACK) Slog.v(TAG, "setSurfaceIfReadyLocked: mDrawn=" + mDrawn +
|
||||
private void setSurfaceIfReady() {
|
||||
if (DEBUG_STACK) Slog.v(TAG, "setSurfaceIfReady: mDrawn=" + mDrawn +
|
||||
" mContainerState=" + mContainerState + " mSurface=" + mSurface);
|
||||
if (mDrawn && mSurface != null && mContainerState == CONTAINER_STATE_NO_SURFACE) {
|
||||
((VirtualActivityDisplay) mActivityDisplay).setSurface(mSurface);
|
||||
|
Reference in New Issue
Block a user