resolved conflicts for merge of 33264596 to ics-aah

Change-Id: I1b0b2c3a63d97d49940666ceec71293bdbab4e2e
This commit is contained in:
Jason Simmons
2011-08-25 09:57:48 -07:00
11 changed files with 331 additions and 122 deletions

View File

@@ -50,11 +50,9 @@ import com.android.server.am.BatteryStatsService;
import android.Manifest;
import android.app.ActivityManagerNative;
import android.app.IActivityManager;
import android.app.ProgressDialog;
import android.app.StatusBarManager;
import android.app.admin.DevicePolicyManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
@@ -164,6 +162,7 @@ public class WindowManagerService extends IWindowManager.Stub
static final boolean DEBUG_REORDER = false;
static final boolean DEBUG_WALLPAPER = false;
static final boolean DEBUG_DRAG = false;
static final boolean DEBUG_SCREEN_ON = false;
static final boolean SHOW_SURFACE_ALLOC = false;
static final boolean SHOW_TRANSACTIONS = false;
static final boolean HIDE_STACK_CRAWLS = true;
@@ -411,6 +410,7 @@ public class WindowManagerService extends IWindowManager.Stub
boolean mSafeMode;
boolean mDisplayEnabled = false;
boolean mSystemBooted = false;
boolean mForceDisplayEnabled = false;
boolean mShowingBootMessages = false;
int mInitialDisplayWidth = 0;
int mInitialDisplayHeight = 0;
@@ -2193,7 +2193,7 @@ public class WindowManagerService extends IWindowManager.Stub
// to hold off on removing the window until the animation is done.
// If the display is frozen, just remove immediately, since the
// animation wouldn't be seen.
if (win.mSurface != null && !mDisplayFrozen && mPolicy.isScreenOn()) {
if (win.mSurface != null && !mDisplayFrozen && mDisplayEnabled && mPolicy.isScreenOn()) {
// If we are not currently running the exit animation, we
// need to see about starting one.
if (wasVisible=win.isWinVisibleLw()) {
@@ -2540,6 +2540,12 @@ public class WindowManagerService extends IWindowManager.Stub
win.mRelayoutCalled = true;
final int oldVisibility = win.mViewVisibility;
win.mViewVisibility = viewVisibility;
if (DEBUG_SCREEN_ON) {
RuntimeException stack = new RuntimeException();
stack.fillInStackTrace();
Slog.i(TAG, "Relayout " + win + ": oldVis=" + oldVisibility
+ " newVis=" + viewVisibility, stack);
}
if (viewVisibility == View.VISIBLE &&
(win.mAppToken == null || !win.mAppToken.clientHidden)) {
displayed = !win.isVisibleLw();
@@ -2560,7 +2566,7 @@ public class WindowManagerService extends IWindowManager.Stub
if (displayed) {
if (win.mSurface != null && !win.mDrawPending
&& !win.mCommitDrawPending && !mDisplayFrozen
&& mPolicy.isScreenOn()) {
&& mDisplayEnabled && mPolicy.isScreenOn()) {
applyEnterAnimationLocked(win);
}
if ((win.mAttrs.flags
@@ -2853,7 +2859,7 @@ public class WindowManagerService extends IWindowManager.Stub
// frozen, there is no reason to animate and it can cause strange
// artifacts when we unfreeze the display if some different animation
// is running.
if (!mDisplayFrozen && mPolicy.isScreenOn()) {
if (!mDisplayFrozen && mDisplayEnabled && mPolicy.isScreenOn()) {
int anim = mPolicy.selectAnimationLw(win, transit);
int attr = -1;
Animation a = null;
@@ -2939,7 +2945,7 @@ public class WindowManagerService extends IWindowManager.Stub
// frozen, there is no reason to animate and it can cause strange
// artifacts when we unfreeze the display if some different animation
// is running.
if (!mDisplayFrozen && mPolicy.isScreenOn()) {
if (!mDisplayFrozen && mDisplayEnabled && mPolicy.isScreenOn()) {
Animation a;
if (mNextAppTransitionPackage != null) {
a = loadAnimation(mNextAppTransitionPackage, enter ?
@@ -3505,7 +3511,7 @@ public class WindowManagerService extends IWindowManager.Stub
if (DEBUG_APP_TRANSITIONS) Slog.v(
TAG, "Prepare app transition: transit=" + transit
+ " mNextAppTransition=" + mNextAppTransition);
if (!mDisplayFrozen && mPolicy.isScreenOn()) {
if (!mDisplayFrozen && mDisplayEnabled && mPolicy.isScreenOn()) {
if (mNextAppTransition == WindowManagerPolicy.TRANSIT_UNSET
|| mNextAppTransition == WindowManagerPolicy.TRANSIT_NONE) {
mNextAppTransition = transit;
@@ -3589,7 +3595,7 @@ public class WindowManagerService extends IWindowManager.Stub
// If the display is frozen, we won't do anything until the
// actual window is displayed so there is no reason to put in
// the starting window.
if (mDisplayFrozen || !mPolicy.isScreenOn()) {
if (mDisplayFrozen || !mDisplayEnabled || !mPolicy.isScreenOn()) {
return;
}
@@ -3871,7 +3877,7 @@ public class WindowManagerService extends IWindowManager.Stub
// If we are preparing an app transition, then delay changing
// the visibility of this token until we execute that transition.
if (!mDisplayFrozen && mPolicy.isScreenOn()
if (!mDisplayFrozen && mDisplayEnabled && mPolicy.isScreenOn()
&& mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) {
// Already in requested state, don't do anything more.
if (wtoken.hiddenRequested != visible) {
@@ -4692,6 +4698,10 @@ public class WindowManagerService extends IWindowManager.Stub
}
mSystemBooted = true;
hideBootMessagesLocked();
// If the screen still doesn't come up after 30 seconds, give
// up and turn it on.
Message msg = mH.obtainMessage(H.BOOT_TIMEOUT);
mH.sendMessageDelayed(msg, 30*1000);
}
performEnableScreen();
@@ -4707,6 +4717,17 @@ public class WindowManagerService extends IWindowManager.Stub
mH.sendMessage(mH.obtainMessage(H.ENABLE_SCREEN));
}
public void performBootTimeout() {
synchronized(mWindowMap) {
if (mDisplayEnabled) {
return;
}
Slog.w(TAG, "***** BOOT TIMEOUT: forcing display enabled");
mForceDisplayEnabled = true;
}
performEnableScreen();
}
public void performEnableScreen() {
synchronized(mWindowMap) {
if (mDisplayEnabled) {
@@ -4716,19 +4737,55 @@ public class WindowManagerService extends IWindowManager.Stub
return;
}
// Don't enable the screen until all existing windows
// have been drawn.
final int N = mWindows.size();
for (int i=0; i<N; i++) {
WindowState w = mWindows.get(i);
if (w.isVisibleLw() && !w.mObscured && !w.isDrawnLw()) {
if (!mForceDisplayEnabled) {
// Don't enable the screen until all existing windows
// have been drawn.
boolean haveBootMsg = false;
boolean haveApp = false;
boolean haveWallpaper = false;
boolean haveKeyguard = false;
final int N = mWindows.size();
for (int i=0; i<N; i++) {
WindowState w = mWindows.get(i);
if (w.isVisibleLw() && !w.mObscured && !w.isDrawnLw()) {
return;
}
if (w.isDrawnLw()) {
if (w.mAttrs.type == WindowManager.LayoutParams.TYPE_BOOT_PROGRESS) {
haveBootMsg = true;
} else if (w.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION) {
haveApp = true;
} else if (w.mAttrs.type == WindowManager.LayoutParams.TYPE_WALLPAPER) {
haveWallpaper = true;
} else if (w.mAttrs.type == WindowManager.LayoutParams.TYPE_KEYGUARD) {
haveKeyguard = true;
}
}
}
if (DEBUG_SCREEN_ON) {
Slog.i(TAG, "******** booted=" + mSystemBooted + " msg=" + mShowingBootMessages
+ " haveBoot=" + haveBootMsg + " haveApp=" + haveApp
+ " haveWall=" + haveWallpaper + " haveKeyguard=" + haveKeyguard);
}
// If we are turning on the screen to show the boot message,
// don't do it until the boot message is actually displayed.
if (!mSystemBooted && !haveBootMsg) {
return;
}
// If we are turning on the screen after the boot is completed
// normally, don't do so until we have the application and
// wallpaper.
if (mSystemBooted && ((!haveApp && !haveKeyguard) || !haveWallpaper)) {
return;
}
}
mDisplayEnabled = true;
if (DEBUG_SCREEN_ON) Slog.i(TAG, "******************** ENABLING SCREEN!");
if (false) {
Slog.i(TAG, "ENABLING SCREEN!");
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
this.dump(null, pw, null);
@@ -6245,6 +6302,7 @@ public class WindowManagerService extends IWindowManager.Stub
public static final int DRAG_START_TIMEOUT = 20;
public static final int DRAG_END_TIMEOUT = 21;
public static final int REPORT_HARD_KEYBOARD_STATUS_CHANGE = 22;
public static final int BOOT_TIMEOUT = 23;
private Session mLastReportedHold;
@@ -6555,6 +6613,11 @@ public class WindowManagerService extends IWindowManager.Stub
break;
}
case BOOT_TIMEOUT: {
performBootTimeout();
break;
}
case APP_FREEZE_TIMEOUT: {
synchronized (mWindowMap) {
Slog.w(TAG, "App freeze timeout expired.");
@@ -8306,7 +8369,7 @@ public class WindowManagerService extends IWindowManager.Stub
if (mDimAnimator != null && mDimAnimator.mDimShown) {
animating |= mDimAnimator.updateSurface(dimming, currentTime,
mDisplayFrozen || !mPolicy.isScreenOn());
mDisplayFrozen || !mDisplayEnabled || !mPolicy.isScreenOn());
}
if (!blurring && mBlurShown) {
@@ -8504,12 +8567,44 @@ public class WindowManagerService extends IWindowManager.Stub
mH.sendEmptyMessage(H.SEND_NEW_CONFIGURATION);
}
}
mWindowMap.notifyAll();
// Check to see if we are now in a state where the screen should
// be enabled, because the window obscured flags have changed.
enableScreenIfNeededLocked();
}
public void waitForAllDrawn() {
synchronized (mWindowMap) {
while (true) {
final int N = mWindows.size();
boolean okay = true;
for (int i=0; i<N && okay; i++) {
WindowState w = mWindows.get(i);
if (DEBUG_SCREEN_ON) {
Slog.i(TAG, "Window " + w + " vis=" + w.isVisibleLw()
+ " obscured=" + w.mObscured + " drawn=" + w.isDrawnLw());
}
if (w.isVisibleLw() && !w.mObscured && !w.isDrawnLw()) {
if (DEBUG_SCREEN_ON) {
Slog.i(TAG, "Window not yet drawn: " + w);
}
okay = false;
break;
}
}
if (okay) {
return;
}
try {
mWindowMap.wait();
} catch (InterruptedException e) {
}
}
}
}
/**
* Must be called with the main window manager lock held.
*/