am 449b32e8: am c641de01: Merge "Add event logging for tasks and stacks." into klp-dev

* commit '449b32e844b9bdadbcbca68e87f446b509e5e667':
  Add event logging for tasks and stacks.
This commit is contained in:
Craig Mautner
2013-11-12 11:24:43 -08:00
committed by Android Git Automerger
6 changed files with 30 additions and 19 deletions

View File

@@ -123,6 +123,18 @@ option java_package com.android.server
# ---------------------------
# Out of memory for surfaces.
31000 wm_no_surface_memory (Window|3),(PID|1|5),(Operation|3)
# Task created.
31001 wm_task_created (TaskId|1|5),(StackId|1|5)
# Task moved to top (1) or bottom (0).
31002 wm_task_moved (TaskId|1|5),(ToTop|1),(Index|1)
# Task removed with source explanation.
31003 wm_task_removed (TaskId|1|5),(Reason|3)
# Stack created.
31004 wm_stack_created (StackId|1|5),(RelativeBoxId|1|5),(Position|1),(Weight|1|6)
# Home stack moved to top (1) or bottom (0).
31005 wm_home_stack_moved (ToTop|1)
# Stack removed.
31006 wm_stack_removed (StackId|1|5)
# ---------------------------

View File

@@ -25,9 +25,11 @@ import android.app.ActivityManager.StackBoxInfo;
import android.graphics.Rect;
import android.graphics.Region;
import android.os.Debug;
import android.util.EventLog;
import android.util.Slog;
import android.view.Display;
import android.view.DisplayInfo;
import com.android.server.EventLogTags;
import java.io.PrintWriter;
import java.util.ArrayList;
@@ -97,9 +99,6 @@ class DisplayContent {
/** True when the home StackBox is at the top of mStackBoxes, false otherwise. */
private TaskStack mHomeStack = null;
/** Sorted most recent at top, oldest at [0]. */
ArrayList<TaskStack> mStackHistory = new ArrayList<TaskStack>();
/** Detect user tapping outside of current focused stack bounds .*/
StackTapPointerEventListener mTapDetector;
@@ -107,7 +106,7 @@ class DisplayContent {
Region mTouchExcludeRegion = new Region();
/** Save allocating when retrieving tasks */
ArrayList<Task> mTaskHistory = new ArrayList<Task>();
private ArrayList<Task> mTaskHistory = new ArrayList<Task>();
/** Save allocating when calculating rects */
Rect mTmpRect = new Rect();
@@ -160,12 +159,6 @@ class DisplayContent {
return mStackBoxes.get(0).mStack != mHomeStack;
}
void moveStack(TaskStack stack, boolean toTop) {
mStackHistory.remove(stack);
mStackHistory.add(toTop ? mStackHistory.size() : 0, stack);
mService.moveStackWindowsLocked(this);
}
public boolean isPrivate() {
return (mDisplay.getFlags() & Display.FLAG_PRIVATE) != 0;
}
@@ -200,6 +193,7 @@ class DisplayContent {
}
mTaskHistory.add(taskNdx, task);
EventLog.writeEvent(EventLogTags.WM_TASK_MOVED, task.taskId, toTop ? 1 : 0, taskNdx);
}
void removeTask(Task task) {
@@ -277,6 +271,8 @@ class DisplayContent {
if (newStack != null) {
layoutNeeded = true;
}
EventLog.writeEvent(EventLogTags.WM_STACK_CREATED, stackId, relativeStackBoxId, position,
(int)(weight * 100 + 0.5));
return newStack;
}
@@ -345,6 +341,7 @@ class DisplayContent {
boolean moveHomeStackBox(boolean toTop) {
if (DEBUG_STACK) Slog.d(TAG, "moveHomeStackBox: toTop=" + toTop + " Callers=" +
Debug.getCallers(4));
EventLog.writeEvent(EventLogTags.WM_HOME_STACK_MOVED, toTop ? 1 : 0);
switch (mStackBoxes.size()) {
case 0: throw new RuntimeException("moveHomeStackBox: No home StackBox!");
case 1: return false; // Only the home StackBox exists.

View File

@@ -243,10 +243,6 @@ public class StackBox {
/** Remove this box and propagate its sibling's content up to their parent.
* @return The first stackId of the resulting StackBox. */
int remove() {
if (mStack != null) {
if (DEBUG_STACK) Slog.i(TAG, "StackBox.remove: removing stackId=" + mStack.mStackId);
mDisplayContent.mStackHistory.remove(mStack);
}
mDisplayContent.layoutNeeded = true;
if (mParent == null) {

View File

@@ -16,6 +16,9 @@
package com.android.server.wm;
import android.util.EventLog;
import com.android.server.EventLogTags;
class Task {
// private final String TAG = "TaskGroup";
TaskStack mStack;
@@ -41,6 +44,8 @@ class Task {
boolean removeAppToken(AppWindowToken wtoken) {
mAppTokens.remove(wtoken);
if (mAppTokens.size() == 0) {
EventLog.writeEvent(com.android.server.EventLogTags.WM_TASK_REMOVED, taskId,
"removeAppToken: last token");
mStack.removeTask(this);
return true;
}

View File

@@ -21,8 +21,10 @@ import static com.android.server.wm.WindowManagerService.TAG;
import android.graphics.Rect;
import android.os.Debug;
import android.util.EventLog;
import android.util.Slog;
import android.util.TypedValue;
import com.android.server.EventLogTags;
import static com.android.server.am.ActivityStackSupervisor.HOME_STACK_ID;
@@ -45,7 +47,7 @@ public class TaskStack {
/** The Tasks that define this stack. Oldest Tasks are at the bottom. The ordering must match
* mTaskHistory in the ActivityStack with the same mStackId */
private ArrayList<Task> mTasks = new ArrayList<Task>();
private final ArrayList<Task> mTasks = new ArrayList<Task>();
/** The StackBox this sits in. */
StackBox mStackBox;
@@ -70,7 +72,6 @@ public class TaskStack {
mService = service;
mStackId = stackId;
mDisplayContent = displayContent;
final int displayId = displayContent.getDisplayId();
mDimLayer = new DimLayer(service, this);
mAnimationBackgroundSurface = new DimLayer(service, this);
}
@@ -152,6 +153,7 @@ public class TaskStack {
int remove() {
mAnimationBackgroundSurface.destroySurface();
mDimLayer.destroySurface();
EventLog.writeEvent(EventLogTags.WM_STACK_REMOVED, mStackId);
return mStackBox.remove();
}

View File

@@ -3397,10 +3397,10 @@ public class WindowManagerService extends IWindowManager.Stub
if (stack == null) {
throw new IllegalArgumentException("addAppToken: invalid stackId=" + stackId);
}
EventLog.writeEvent(EventLogTags.WM_TASK_CREATED, taskId, stackId);
Task task = new Task(atoken, stack, userId);
mTaskIdToTask.put(taskId, task);
stack.addTask(task, true);
stack.getDisplayContent().moveStack(stack, true);
return task;
}
@@ -4791,7 +4791,6 @@ public class WindowManagerService extends IWindowManager.Stub
displayContent.moveHomeStackBox(isHomeStackTask);
}
stack.moveTaskToTop(task);
displayContent.moveStack(stack, true);
}
} finally {
Binder.restoreCallingIdentity(origId);
@@ -4845,7 +4844,6 @@ public class WindowManagerService extends IWindowManager.Stub
weight);
if (stack != null) {
mStackIdToStack.put(stackId, stack);
displayContent.moveStack(stack, true);
performLayoutAndPlaceSurfacesLocked();
return;
}
@@ -4877,6 +4875,7 @@ public class WindowManagerService extends IWindowManager.Stub
return;
}
final TaskStack stack = task.mStack;
EventLog.writeEvent(EventLogTags.WM_TASK_REMOVED, taskId, "removeTask");
stack.removeTask(task);
stack.getDisplayContent().layoutNeeded = true;
}