summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Riddle Hsu <riddlehsu@google.com> 2020-08-17 06:40:23 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2020-08-17 06:40:23 +0000
commit8f859343d3c809574a553b6754e879380070a251 (patch)
tree9487d1eb1c0d8bd4718b6e1815e1a1cdae04f74a
parent4859c973f75bc9fa1926d4d81ec795a9c696f37d (diff)
parent5e0e77966fd008ce662252ce1a1ef85c71543032 (diff)
Merge "Consolidate mDrawn and reportedDrawn"
-rw-r--r--services/core/java/com/android/server/wm/ActivityMetricsLogger.java4
-rw-r--r--services/core/java/com/android/server/wm/ActivityRecord.java30
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/ActivityMetricsLaunchObserverTests.java12
3 files changed, 23 insertions, 23 deletions
diff --git a/services/core/java/com/android/server/wm/ActivityMetricsLogger.java b/services/core/java/com/android/server/wm/ActivityMetricsLogger.java
index 7565d8f9647c..6e9526afa962 100644
--- a/services/core/java/com/android/server/wm/ActivityMetricsLogger.java
+++ b/services/core/java/com/android/server/wm/ActivityMetricsLogger.java
@@ -542,7 +542,7 @@ class ActivityMetricsLogger {
+ " processSwitch=" + processSwitch + " info=" + info);
}
- if (launchedActivity.mDrawn) {
+ if (launchedActivity.isReportedDrawn()) {
// Launched activity is already visible. We cannot measure windows drawn delay.
abort(info, "launched activity already visible");
return;
@@ -681,7 +681,7 @@ class ActivityMetricsLogger {
/** @return {@code true} if the given task has an activity will be drawn. */
private static boolean hasActivityToBeDrawn(Task t) {
- return t.forAllActivities((r) -> r.mVisibleRequested && !r.mDrawn && !r.finishing);
+ return t.forAllActivities(r -> r.mVisibleRequested && !r.isReportedDrawn() && !r.finishing);
}
private void checkVisibility(Task t, ActivityRecord r) {
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java
index e4f28546a5fd..4e05a138c543 100644
--- a/services/core/java/com/android/server/wm/ActivityRecord.java
+++ b/services/core/java/com/android/server/wm/ActivityRecord.java
@@ -499,7 +499,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
// and reporting to the client that it is hidden.
private boolean mSetToSleep; // have we told the activity to sleep?
boolean nowVisible; // is this activity's window visible?
- boolean mDrawn; // is this activity's window drawn?
boolean mClientVisibilityDeferred;// was the visibility change message to client deferred?
boolean idle; // has the activity gone idle?
boolean hasBeenLaunched;// has this activity ever been launched?
@@ -564,8 +563,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
private boolean mClientVisible;
boolean firstWindowDrawn;
- // Last drawn state we reported to the app token.
- private boolean reportedDrawn;
+ /** Whether the visible window(s) of this activity is drawn. */
+ private boolean mReportedDrawn;
private final WindowState.UpdateReportedVisibilityResults mReportedVisibilityResults =
new WindowState.UpdateReportedVisibilityResults();
@@ -927,7 +926,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
pw.println(prefix + "mVisibleRequested=" + mVisibleRequested
+ " mVisible=" + mVisible + " mClientVisible=" + mClientVisible
+ ((mDeferHidingClient) ? " mDeferHidingClient=" + mDeferHidingClient : "")
- + " reportedDrawn=" + reportedDrawn + " reportedVisible=" + reportedVisible);
+ + " reportedDrawn=" + mReportedDrawn + " reportedVisible=" + reportedVisible);
if (paused) {
pw.print(prefix); pw.print("paused="); pw.println(paused);
}
@@ -1591,7 +1590,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
keysPaused = false;
inHistory = false;
nowVisible = false;
- mDrawn = false;
mClientVisible = true;
idle = false;
hasBeenLaunched = false;
@@ -5404,11 +5402,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
}
/** Called when the windows associated app window container are drawn. */
- void onWindowsDrawn(boolean drawn, long timestampNs) {
- mDrawn = drawn;
- if (!drawn) {
- return;
- }
+ private void onWindowsDrawn(long timestampNs) {
final TransitionInfoSnapshot info = mStackSupervisor
.getActivityMetricsLogger().notifyWindowsDrawn(this, timestampNs);
final boolean validInfo = info != null;
@@ -5514,7 +5508,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
if (!nowGone) {
// If the app is not yet gone, then it can only become visible/drawn.
if (!nowDrawn) {
- nowDrawn = reportedDrawn;
+ nowDrawn = mReportedDrawn;
}
if (!nowVisible) {
nowVisible = reportedVisible;
@@ -5522,9 +5516,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
}
if (DEBUG_VISIBILITY) Slog.v(TAG, "VIS " + this + ": interesting="
+ numInteresting + " visible=" + numVisible);
- if (nowDrawn != reportedDrawn) {
- onWindowsDrawn(nowDrawn, SystemClock.elapsedRealtimeNanos());
- reportedDrawn = nowDrawn;
+ if (nowDrawn != mReportedDrawn) {
+ if (nowDrawn) {
+ onWindowsDrawn(SystemClock.elapsedRealtimeNanos());
+ }
+ mReportedDrawn = nowDrawn;
}
if (nowVisible != reportedVisible) {
if (DEBUG_VISIBILITY) Slog.v(TAG,
@@ -5538,6 +5534,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
}
}
+ boolean isReportedDrawn() {
+ return mReportedDrawn;
+ }
+
boolean isClientVisible() {
return mClientVisible;
}
@@ -7677,7 +7677,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
proto.write(VISIBLE_REQUESTED, mVisibleRequested);
proto.write(CLIENT_VISIBLE, mClientVisible);
proto.write(DEFER_HIDING_CLIENT, mDeferHidingClient);
- proto.write(REPORTED_DRAWN, reportedDrawn);
+ proto.write(REPORTED_DRAWN, mReportedDrawn);
proto.write(REPORTED_VISIBLE, reportedVisible);
proto.write(NUM_INTERESTING_WINDOWS, mNumInterestingWindows);
proto.write(NUM_DRAWN_WINDOWS, mNumDrawnWindows);
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityMetricsLaunchObserverTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityMetricsLaunchObserverTests.java
index 46c3e22da38c..eb78172cd562 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityMetricsLaunchObserverTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityMetricsLaunchObserverTests.java
@@ -20,6 +20,7 @@ import static android.app.ActivityManager.START_SUCCESS;
import static android.app.ActivityManager.START_TASK_TO_FRONT;
import static android.content.ComponentName.createRelative;
+import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.mock;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verifyNoMoreInteractions;
@@ -176,7 +177,8 @@ public class ActivityMetricsLaunchObserverTests extends WindowTestsBase {
public void testOnActivityLaunchCancelled_hasDrawn() {
onActivityLaunched(mTopActivity);
- mTopActivity.mVisibleRequested = mTopActivity.mDrawn = true;
+ mTopActivity.mVisibleRequested = true;
+ doReturn(true).when(mTopActivity).isReportedDrawn();
// Cannot time already-visible activities.
notifyActivityLaunched(START_TASK_TO_FRONT, mTopActivity);
@@ -187,16 +189,14 @@ public class ActivityMetricsLaunchObserverTests extends WindowTestsBase {
@Test
public void testOnActivityLaunchCancelled_finishedBeforeDrawn() {
- mTopActivity.mVisibleRequested = mTopActivity.mDrawn = true;
+ mTopActivity.mVisibleRequested = true;
+ doReturn(true).when(mTopActivity).isReportedDrawn();
- // Suppress resume when creating the record because we want to notify logger manually.
- mSupervisor.beginDeferResume();
// Create an activity with different process that meets process switch.
final ActivityRecord noDrawnActivity = new ActivityBuilder(mAtm)
.setTask(mTopActivity.getTask())
.setProcessName("other")
.build();
- mSupervisor.readyToResume();
notifyActivityLaunching(noDrawnActivity.intent);
notifyActivityLaunched(START_SUCCESS, noDrawnActivity);
@@ -294,7 +294,7 @@ public class ActivityMetricsLaunchObserverTests extends WindowTestsBase {
public void testOnActivityLaunchCancelledTrampoline() {
onActivityLaunchedTrampoline();
- mTopActivity.mDrawn = true;
+ doReturn(true).when(mTopActivity).isReportedDrawn();
// Cannot time already-visible activities.
notifyActivityLaunched(START_TASK_TO_FRONT, mTopActivity);