diff options
Diffstat (limited to 'services/java')
11 files changed, 322 insertions, 159 deletions
diff --git a/services/java/com/android/server/DevicePolicyManagerService.java b/services/java/com/android/server/DevicePolicyManagerService.java index 0f5ad66..7609613 100644 --- a/services/java/com/android/server/DevicePolicyManagerService.java +++ b/services/java/com/android/server/DevicePolicyManagerService.java @@ -2118,16 +2118,6 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } pw.println(" "); - pw.print(" mActivePasswordQuality=0x"); - pw.println(Integer.toHexString(mActivePasswordQuality)); - pw.print(" mActivePasswordLength="); pw.println(mActivePasswordLength); - pw.print(" mActivePasswordUpperCase="); pw.println(mActivePasswordUpperCase); - pw.print(" mActivePasswordLowerCase="); pw.println(mActivePasswordLowerCase); - pw.print(" mActivePasswordLetters="); pw.println(mActivePasswordLetters); - pw.print(" mActivePasswordNumeric="); pw.println(mActivePasswordNumeric); - pw.print(" mActivePasswordSymbols="); pw.println(mActivePasswordSymbols); - pw.print(" mActivePasswordNonLetter="); pw.println(mActivePasswordNonLetter); - pw.print(" mFailedPasswordAttempts="); pw.println(mFailedPasswordAttempts); pw.print(" mPasswordOwner="); pw.println(mPasswordOwner); } } diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index eaecd4c..9dd4a91 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -229,7 +229,7 @@ class ServerThread extends Thread { Slog.i(TAG, "Window Manager"); wm = WindowManagerService.main(context, power, factoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL, - !firstBoot); + !firstBoot, onlyCore); ServiceManager.addService(Context.WINDOW_SERVICE, wm); inputManager = wm.getInputManagerService(); ServiceManager.addService(Context.INPUT_SERVICE, inputManager); diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index 63455ee..f482552 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -3577,8 +3577,7 @@ public final class ActivityManagerService extends ActivityManagerNative for (int i=mMainStack.mHistory.size()-1; i>=0; i--) { ActivityRecord r = (ActivityRecord)mMainStack.mHistory.get(i); - if ((r.info.flags&ActivityInfo.FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS) != 0 - && (r.intent.getFlags()&Intent.FLAG_ACTIVITY_CLOSE_SYSTEM_DIALOGS) == 0) { + if ((r.info.flags&ActivityInfo.FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS) != 0) { r.stack.finishActivityLocked(r, i, Activity.RESULT_CANCELED, null, "close-sys"); } @@ -4573,6 +4572,21 @@ public final class ActivityManagerService extends ActivityManagerNative return false; } + public boolean isIntentSenderAnActivity(IIntentSender pendingResult) { + if (!(pendingResult instanceof PendingIntentRecord)) { + return false; + } + try { + PendingIntentRecord res = (PendingIntentRecord)pendingResult; + if (res.key.type == ActivityManager.INTENT_SENDER_ACTIVITY) { + return true; + } + return false; + } catch (ClassCastException e) { + } + return false; + } + public void setProcessLimit(int max) { enforceCallingPermission(android.Manifest.permission.SET_PROCESS_LIMIT, "setProcessLimit()"); diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java index e2d6d98..b276494 100755 --- a/services/java/com/android/server/am/ActivityStack.java +++ b/services/java/com/android/server/am/ActivityStack.java @@ -1129,6 +1129,11 @@ final class ActivityStack { resumeTopActivityLocked(prev); } else { checkReadyForSleepLocked(); + if (topRunningActivityLocked(null) == null) { + // If there are no more activities available to run, then + // do resume anyway to start something. + resumeTopActivityLocked(null); + } } if (prev != null) { @@ -2559,10 +2564,6 @@ final class ActivityStack { mDismissKeyguardOnNextActivity = false; mService.mWindowManager.dismissKeyguard(); } - if (err >= ActivityManager.START_SUCCESS && - (launchFlags&Intent.FLAG_ACTIVITY_CLOSE_SYSTEM_DIALOGS) != 0) { - mService.closeSystemDialogsLocked(Process.myUid(), "launch"); - } return err; } @@ -3413,6 +3414,7 @@ final class ActivityStack { IApplicationThread sendThumbnail = null; boolean booting = false; boolean enableScreen = false; + boolean activityRemoved = false; synchronized (mService) { ActivityRecord r = ActivityRecord.forToken(token); @@ -3519,7 +3521,7 @@ final class ActivityStack { for (i=0; i<NF; i++) { ActivityRecord r = (ActivityRecord)finishes.get(i); synchronized (mService) { - destroyActivityLocked(r, true, false, "finish-idle"); + activityRemoved = destroyActivityLocked(r, true, false, "finish-idle"); } } @@ -3541,6 +3543,10 @@ final class ActivityStack { mService.enableScreenAfterBoot(); } + if (activityRemoved) { + resumeTopActivityLocked(null); + } + return res; } @@ -3780,7 +3786,11 @@ final class ActivityStack { || prevState == ActivityState.INITIALIZING) { // If this activity is already stopped, we can just finish // it right now. - return destroyActivityLocked(r, true, true, "finish-imm") ? null : r; + boolean activityRemoved = destroyActivityLocked(r, true, true, "finish-imm"); + if (activityRemoved) { + resumeTopActivityLocked(null); + } + return activityRemoved ? null : r; } else { // Need to go through the full pause cycle to get this // activity into the stopped state and then finish it. @@ -3844,6 +3854,10 @@ final class ActivityStack { } // Get rid of any pending idle timeouts. + removeTimeoutsForActivityLocked(r); + } + + private void removeTimeoutsForActivityLocked(ActivityRecord r) { mHandler.removeMessages(PAUSE_TIMEOUT_MSG, r); mHandler.removeMessages(STOP_TIMEOUT_MSG, r); mHandler.removeMessages(IDLE_TIMEOUT_MSG, r); @@ -3897,6 +3911,7 @@ final class ActivityStack { final void destroyActivitiesLocked(ProcessRecord owner, boolean oomAdj, String reason) { boolean lastIsOpaque = false; + boolean activityRemoved = false; for (int i=mHistory.size()-1; i>=0; i--) { ActivityRecord r = mHistory.get(i); if (r.finishing) { @@ -3920,9 +3935,14 @@ final class ActivityStack { if (DEBUG_SWITCH) Slog.v(TAG, "Destroying " + r + " in state " + r.state + " resumed=" + mResumedActivity + " pausing=" + mPausingActivity); - destroyActivityLocked(r, true, oomAdj, reason); + if (destroyActivityLocked(r, true, oomAdj, reason)) { + activityRemoved = true; + } } } + if (activityRemoved) { + resumeTopActivityLocked(null); + } } /** @@ -4027,23 +4047,28 @@ final class ActivityStack { final void activityDestroyed(IBinder token) { synchronized (mService) { - ActivityRecord r = ActivityRecord.forToken(token); - if (r != null) { - mHandler.removeMessages(DESTROY_TIMEOUT_MSG, r); - } - - int index = indexOfActivityLocked(r); - if (index >= 0) { - if (r.state == ActivityState.DESTROYING) { - final long origId = Binder.clearCallingIdentity(); - removeActivityFromHistoryLocked(r); - Binder.restoreCallingIdentity(origId); + final long origId = Binder.clearCallingIdentity(); + try { + ActivityRecord r = ActivityRecord.forToken(token); + if (r != null) { + mHandler.removeMessages(DESTROY_TIMEOUT_MSG, r); + } + + int index = indexOfActivityLocked(r); + if (index >= 0) { + if (r.state == ActivityState.DESTROYING) { + cleanUpActivityLocked(r, true, true); + removeActivityFromHistoryLocked(r); + } } + resumeTopActivityLocked(null); + } finally { + Binder.restoreCallingIdentity(origId); } } } - private static void removeHistoryRecordsForAppLocked(ArrayList list, ProcessRecord app) { + private void removeHistoryRecordsForAppLocked(ArrayList list, ProcessRecord app) { int i = list.size(); if (localLOGV) Slog.v( TAG, "Removing app " + app + " from list " + list @@ -4056,6 +4081,7 @@ final class ActivityStack { if (r.app == app) { if (localLOGV) Slog.v(TAG, "Removing this entry!"); list.remove(i); + removeTimeoutsForActivityLocked(r); } } } diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java index 9a79f86..e20cd02 100644 --- a/services/java/com/android/server/pm/PackageManagerService.java +++ b/services/java/com/android/server/pm/PackageManagerService.java @@ -1087,7 +1087,8 @@ public class PackageManagerService extends IPackageManager.Stub { /* * If the package is scanned, it's not erased. */ - if (mPackages.containsKey(ps.name)) { + final PackageParser.Package scannedPkg = mPackages.get(ps.name); + if (scannedPkg != null) { /* * If the system app is both scanned and in the * disabled packages list, then it must have been @@ -1096,7 +1097,9 @@ public class PackageManagerService extends IPackageManager.Stub { * application can be scanned. */ if (mSettings.isDisabledSystemPackageLPr(ps.name)) { - mPackages.remove(ps.name); + Slog.i(TAG, "Expecting better updatd system app for " + ps.name + + "; removing system app"); + removePackageLI(scannedPkg, true); } continue; @@ -8626,6 +8629,10 @@ public class PackageManagerService extends IPackageManager.Stub { } pw.print(" ["); pw.print(entry.getKey()); pw.println("]:"); pw.print(" "); pw.println(p.toString()); + if (p.info != null && p.info.applicationInfo != null) { + final String appInfo = p.info.applicationInfo.toString(); + pw.print(" applicationInfo="); pw.println(appInfo); + } } } diff --git a/services/java/com/android/server/pm/Settings.java b/services/java/com/android/server/pm/Settings.java index 91cd458..d031686 100644 --- a/services/java/com/android/server/pm/Settings.java +++ b/services/java/com/android/server/pm/Settings.java @@ -2459,6 +2459,7 @@ final class Settings { pw.print(" nativeLibraryPath="); pw.println(ps.nativeLibraryPathString); pw.print(" versionCode="); pw.println(ps.versionCode); if (ps.pkg != null) { + pw.print(" applicationInfo="); pw.println(ps.pkg.applicationInfo.toString()); pw.print(" flags="); printFlags(pw, ps.pkg.applicationInfo.flags, FLAG_DUMP_SPEC); pw.println(); pw.print(" versionName="); pw.println(ps.pkg.mVersionName); pw.print(" dataDir="); pw.println(ps.pkg.applicationInfo.dataDir); @@ -2592,6 +2593,10 @@ final class Settings { pw.print(" compat name="); pw.println(ps.name); } + if (ps.pkg != null && ps.pkg.applicationInfo != null) { + pw.print(" applicationInfo="); + pw.println(ps.pkg.applicationInfo.toString()); + } pw.print(" userId="); pw.println(ps.appId); pw.print(" sharedUser="); diff --git a/services/java/com/android/server/wm/AppWindowAnimator.java b/services/java/com/android/server/wm/AppWindowAnimator.java index 1953ad7..13e8bc5 100644 --- a/services/java/com/android/server/wm/AppWindowAnimator.java +++ b/services/java/com/android/server/wm/AppWindowAnimator.java @@ -35,6 +35,10 @@ public class AppWindowAnimator { // AppWindowToken animations. int animLayerAdjustment; + // Propagated from AppWindowToken.allDrawn, to determine when + // the state changes. + boolean allDrawn; + // Special surface for thumbnail animation. Surface thumbnail; int thumbnailTransactionSeq; diff --git a/services/java/com/android/server/wm/AppWindowToken.java b/services/java/com/android/server/wm/AppWindowToken.java index bf35154..6ecbb8e 100644 --- a/services/java/com/android/server/wm/AppWindowToken.java +++ b/services/java/com/android/server/wm/AppWindowToken.java @@ -241,12 +241,18 @@ class AppWindowToken extends WindowToken { pw.print(prefix); pw.print("paused="); pw.println(paused); } if (numInterestingWindows != 0 || numDrawnWindows != 0 - || inPendingTransaction || allDrawn) { + || allDrawn || mAppAnimator.allDrawn) { pw.print(prefix); pw.print("numInterestingWindows="); pw.print(numInterestingWindows); pw.print(" numDrawnWindows="); pw.print(numDrawnWindows); pw.print(" inPendingTransaction="); pw.print(inPendingTransaction); - pw.print(" allDrawn="); pw.println(allDrawn); + pw.print(" allDrawn="); pw.print(allDrawn); + pw.print(" (animator="); pw.print(mAppAnimator.allDrawn); + pw.println(")"); + } + if (inPendingTransaction) { + pw.print(prefix); pw.print("inPendingTransaction="); + pw.println(inPendingTransaction); } if (startingData != null || removed || firstWindowDrawn) { pw.print(prefix); pw.print("startingData="); pw.print(startingData); diff --git a/services/java/com/android/server/wm/WindowAnimator.java b/services/java/com/android/server/wm/WindowAnimator.java index 758b6e7..fdd8aab 100644 --- a/services/java/com/android/server/wm/WindowAnimator.java +++ b/services/java/com/android/server/wm/WindowAnimator.java @@ -38,7 +38,6 @@ public class WindowAnimator { ArrayList<WindowStateAnimator> mWinAnimators = new ArrayList<WindowStateAnimator>(); boolean mAnimating; - boolean mTokenMayBeDrawn; boolean mForceHiding; WindowState mWindowAnimationBackground; int mWindowAnimationBackgroundColor; @@ -57,7 +56,7 @@ public class WindowAnimator { /** Skip repeated AppWindowTokens initialization. Note that AppWindowsToken's version of this * is a long initialized to Long.MIN_VALUE so that it doesn't match this value on startup. */ - private int mTransactionSequence; + private int mAnimTransactionSequence; /** The one and only screen rotation if one is happening */ ScreenRotationAnimation mScreenRotationAnimation = null; @@ -194,7 +193,7 @@ public class WindowAnimator { } private void updateWindowsAndWallpaperLocked() { - ++mTransactionSequence; + ++mAnimTransactionSequence; ArrayList<WindowStateAnimator> unForceHiding = null; boolean wallpaperInUnForceHiding = false; @@ -332,59 +331,22 @@ public class WindowAnimator { } final AppWindowToken atoken = win.mAppToken; - if (atoken != null && (!atoken.allDrawn || atoken.mAppAnimator.freezingScreen)) { - if (atoken.lastTransactionSequence != mTransactionSequence) { - atoken.lastTransactionSequence = mTransactionSequence; - atoken.numInterestingWindows = atoken.numDrawnWindows = 0; - atoken.startingDisplayed = false; - } - if ((win.isOnScreen() || winAnimator.mAttrType - == WindowManager.LayoutParams.TYPE_BASE_APPLICATION) - && !win.mExiting && !win.mDestroying) { - if (WindowManagerService.DEBUG_VISIBILITY || - WindowManagerService.DEBUG_ORIENTATION) { - Slog.v(TAG, "Eval win " + win + ": isDrawn=" + win.isDrawnLw() - + ", isAnimating=" + winAnimator.isAnimating()); - if (!win.isDrawnLw()) { - Slog.v(TAG, "Not displayed: s=" + winAnimator.mSurface - + " pv=" + win.mPolicyVisibility - + " mDrawState=" + winAnimator.mDrawState - + " ah=" + win.mAttachedHidden - + " th=" + atoken.hiddenRequested - + " a=" + winAnimator.mAnimating); - } - } - if (win != atoken.startingWindow) { - if (!atoken.mAppAnimator.freezingScreen || !win.mAppFreezing) { - atoken.numInterestingWindows++; - if (win.isDrawnLw()) { - atoken.numDrawnWindows++; - if (WindowManagerService.DEBUG_VISIBILITY || - WindowManagerService.DEBUG_ORIENTATION) Slog.v(TAG, - "tokenMayBeDrawn: " + atoken - + " freezingScreen=" + atoken.mAppAnimator.freezingScreen - + " mAppFreezing=" + win.mAppFreezing); - mTokenMayBeDrawn = true; - } + if (winAnimator.mDrawState == WindowStateAnimator.READY_TO_SHOW) { + if (atoken == null || atoken.allDrawn) { + if (winAnimator.performShowLocked()) { + mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM; + if (WindowManagerService.DEBUG_LAYOUT_REPEATS) { + mService.debugLayoutRepeats("updateWindowsAndWallpaperLocked 5", + mPendingLayoutChanges); } - } else if (win.isDrawnLw()) { - atoken.startingDisplayed = true; - } - } - } else if (winAnimator.mDrawState == WindowStateAnimator.READY_TO_SHOW) { - if (winAnimator.performShowLocked()) { - mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM; - if (WindowManagerService.DEBUG_LAYOUT_REPEATS) { - mService.debugLayoutRepeats("updateWindowsAndWallpaperLocked 5", - mPendingLayoutChanges); } } } final AppWindowAnimator appAnimator = atoken == null ? null : atoken.mAppAnimator; if (appAnimator != null && appAnimator.thumbnail != null) { - if (appAnimator.thumbnailTransactionSeq != mTransactionSequence) { - appAnimator.thumbnailTransactionSeq = mTransactionSequence; + if (appAnimator.thumbnailTransactionSeq != mAnimTransactionSequence) { + appAnimator.thumbnailTransactionSeq = mAnimTransactionSequence; appAnimator.thumbnailLayer = 0; } if (appAnimator.thumbnailLayer < winAnimator.mAnimLayer) { @@ -414,39 +376,32 @@ public class WindowAnimator { final int NT = appTokens.size(); for (int i=0; i<NT; i++) { AppWindowToken wtoken = appTokens.get(i); - if (wtoken.mAppAnimator.freezingScreen) { - int numInteresting = wtoken.numInterestingWindows; - if (numInteresting > 0 && wtoken.numDrawnWindows >= numInteresting) { - if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(TAG, - "allDrawn: " + wtoken - + " interesting=" + numInteresting - + " drawn=" + wtoken.numDrawnWindows); - wtoken.mAppAnimator.showAllWindowsLocked(); - mService.unsetAppFreezingScreenLocked(wtoken, false, true); - if (WindowManagerService.DEBUG_ORIENTATION) Slog.i(TAG, - "Setting mOrientationChangeComplete=true because wtoken " - + wtoken + " numInteresting=" + numInteresting - + " numDrawn=" + wtoken.numDrawnWindows); - // This will set mOrientationChangeComplete and cause a pass through layout. - mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER; - } - } else if (!wtoken.allDrawn) { - int numInteresting = wtoken.numInterestingWindows; - if (numInteresting > 0 && wtoken.numDrawnWindows >= numInteresting) { - if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(TAG, - "allDrawn: " + wtoken - + " interesting=" + numInteresting - + " drawn=" + wtoken.numDrawnWindows); - wtoken.allDrawn = true; - mPendingLayoutChanges |= PhoneWindowManager.FINISH_LAYOUT_REDO_ANIM; - if (WindowManagerService.DEBUG_LAYOUT_REPEATS) { - mService.debugLayoutRepeats("testTokenMayBeDrawnLocked", - mPendingLayoutChanges); - } + final boolean allDrawn = wtoken.allDrawn; + if (allDrawn != wtoken.mAppAnimator.allDrawn) { + wtoken.mAppAnimator.allDrawn = allDrawn; + if (allDrawn) { + // The token has now changed state to having all + // windows shown... what to do, what to do? + if (wtoken.mAppAnimator.freezingScreen) { + wtoken.mAppAnimator.showAllWindowsLocked(); + mService.unsetAppFreezingScreenLocked(wtoken, false, true); + if (WindowManagerService.DEBUG_ORIENTATION) Slog.i(TAG, + "Setting mOrientationChangeComplete=true because wtoken " + + wtoken + " numInteresting=" + wtoken.numInterestingWindows + + " numDrawn=" + wtoken.numDrawnWindows); + // This will set mOrientationChangeComplete and cause a pass through layout. + mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER; + } else { + mPendingLayoutChanges |= PhoneWindowManager.FINISH_LAYOUT_REDO_ANIM; + if (WindowManagerService.DEBUG_LAYOUT_REPEATS) { + mService.debugLayoutRepeats("testTokenMayBeDrawnLocked", + mPendingLayoutChanges); + } - // We can now show all of the drawn windows! - if (!mService.mOpeningApps.contains(wtoken)) { - mAnimating |= wtoken.mAppAnimator.showAllWindowsLocked(); + // We can now show all of the drawn windows! + if (!mService.mOpeningApps.contains(wtoken)) { + mAnimating |= wtoken.mAppAnimator.showAllWindowsLocked(); + } } } } @@ -454,7 +409,6 @@ public class WindowAnimator { } private void performAnimationsLocked() { - mTokenMayBeDrawn = false; mForceHiding = false; mDetachedWallpaper = null; mWindowAnimationBackground = null; @@ -465,9 +419,7 @@ public class WindowAnimator { mPendingActions |= WALLPAPER_ACTION_PENDING; } - if (mTokenMayBeDrawn) { - testTokenMayBeDrawnLocked(); - } + testTokenMayBeDrawnLocked(); } synchronized void animate() { @@ -584,18 +536,23 @@ public class WindowAnimator { } public void dump(PrintWriter pw, String prefix, boolean dumpAll) { - if (mWindowDetachedWallpaper != null) { - pw.print(" mWindowDetachedWallpaper="); pw.println(mWindowDetachedWallpaper); - } - if (mWindowAnimationBackgroundSurface != null) { - pw.println(" mWindowAnimationBackgroundSurface:"); - mWindowAnimationBackgroundSurface.printTo(" ", pw); - } - if (mDimAnimator != null) { - pw.println(" mDimAnimator:"); - mDimAnimator.printTo(" ", pw); - } else { - pw.println( " no DimAnimator "); + if (dumpAll) { + if (mWindowDetachedWallpaper != null) { + pw.print(prefix); pw.print("mWindowDetachedWallpaper="); + pw.println(mWindowDetachedWallpaper); + } + pw.print(prefix); pw.print("mAnimTransactionSequence="); + pw.println(mAnimTransactionSequence); + if (mWindowAnimationBackgroundSurface != null) { + pw.print(prefix); pw.print("mWindowAnimationBackgroundSurface:"); + mWindowAnimationBackgroundSurface.printTo(prefix + " ", pw); + } + if (mDimAnimator != null) { + pw.print(prefix); pw.print("mDimAnimator:"); + mDimAnimator.printTo(prefix + " ", pw); + } else { + pw.print(prefix); pw.print("no DimAnimator "); + } } } diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java index 73bfe8e..c850bd2 100755 --- a/services/java/com/android/server/wm/WindowManagerService.java +++ b/services/java/com/android/server/wm/WindowManagerService.java @@ -96,6 +96,7 @@ import android.util.DisplayMetrics; import android.util.EventLog; import android.util.FloatMath; import android.util.Log; +import android.util.LogPrinter; import android.util.Pair; import android.util.Slog; import android.util.SparseIntArray; @@ -642,6 +643,10 @@ public class WindowManagerService extends IWindowManager.Stub } LayoutFields mInnerFields = new LayoutFields(); + /** Skip repeated AppWindowTokens initialization. Note that AppWindowsToken's version of this + * is a long initialized to Long.MIN_VALUE so that it doesn't match this value on startup. */ + private int mTransactionSequence; + /** Only do a maximum of 6 repeated layouts. After that quit */ private int mLayoutRepeatCount; @@ -758,9 +763,15 @@ public class WindowManagerService extends IWindowManager.Stub // The desired scaling factor for compatible apps. float mCompatibleScreenScale; + // If true, only the core apps and services are being launched because the device + // is in a special boot mode, such as being encrypted or waiting for a decryption password. + // For example, when this flag is true, there will be no wallpaper service. + final boolean mOnlyCore; + public static WindowManagerService main(Context context, - PowerManagerService pm, boolean haveInputMethods, boolean allowBootMsgs) { - WMThread thr = new WMThread(context, pm, haveInputMethods, allowBootMsgs); + PowerManagerService pm, boolean haveInputMethods, boolean allowBootMsgs, + boolean onlyCore) { + WMThread thr = new WMThread(context, pm, haveInputMethods, allowBootMsgs, onlyCore); thr.start(); synchronized (thr) { @@ -781,21 +792,25 @@ public class WindowManagerService extends IWindowManager.Stub private final PowerManagerService mPM; private final boolean mHaveInputMethods; private final boolean mAllowBootMessages; + private final boolean mOnlyCore; public WMThread(Context context, PowerManagerService pm, - boolean haveInputMethods, boolean allowBootMsgs) { + boolean haveInputMethods, boolean allowBootMsgs, boolean onlyCore) { super("WindowManager"); mContext = context; mPM = pm; mHaveInputMethods = haveInputMethods; mAllowBootMessages = allowBootMsgs; + mOnlyCore = onlyCore; } @Override public void run() { Looper.prepare(); + //Looper.myLooper().setMessageLogging(new LogPrinter( + // android.util.Log.DEBUG, TAG, android.util.Log.LOG_ID_SYSTEM)); WindowManagerService s = new WindowManagerService(mContext, mPM, - mHaveInputMethods, mAllowBootMessages); + mHaveInputMethods, mAllowBootMessages, mOnlyCore); android.os.Process.setThreadPriority( android.os.Process.THREAD_PRIORITY_DISPLAY); android.os.Process.setCanSelfBackground(false); @@ -858,10 +873,11 @@ public class WindowManagerService extends IWindowManager.Stub } private WindowManagerService(Context context, PowerManagerService pm, - boolean haveInputMethods, boolean showBootMsgs) { + boolean haveInputMethods, boolean showBootMsgs, boolean onlyCore) { mContext = context; mHaveInputMethods = haveInputMethods; mAllowBootMessages = showBootMsgs; + mOnlyCore = onlyCore; mLimitedAlphaCompositing = context.getResources().getBoolean( com.android.internal.R.bool.config_sf_limitedAlpha); mHeadless = "1".equals(SystemProperties.get(SYSTEM_HEADLESS, "0")); @@ -3573,7 +3589,7 @@ public class WindowManagerService extends IWindowManager.Stub public void setAppGroupId(IBinder token, int groupId) { if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS, - "setAppStartingIcon()")) { + "setAppGroupId()")) { throw new SecurityException("Requires MANAGE_APP_TOKENS permission"); } @@ -3996,7 +4012,7 @@ public class WindowManagerService extends IWindowManager.Stub CharSequence nonLocalizedLabel, int labelRes, int icon, int windowFlags, IBinder transferFrom, boolean createIfNeeded) { if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS, - "setAppStartingIcon()")) { + "setAppStartingWindow()")) { throw new SecurityException("Requires MANAGE_APP_TOKENS permission"); } @@ -4052,12 +4068,13 @@ public class WindowManagerService extends IWindowManager.Stub startingWindow.mToken = wtoken; startingWindow.mRootToken = wtoken; startingWindow.mAppToken = wtoken; - if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v(TAG, - "Removing starting window: " + startingWindow); + if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE || DEBUG_STARTING_WINDOW) { + Slog.v(TAG, "Removing starting window: " + startingWindow); + } mWindows.remove(startingWindow); mWindowsChanged = true; - if (DEBUG_ADD_REMOVE) Slog.v(TAG, "Removing starting " + startingWindow - + " from " + ttoken); + if (DEBUG_ADD_REMOVE) Slog.v(TAG, + "Removing starting " + startingWindow + " from " + ttoken); ttoken.windows.remove(startingWindow); ttoken.allAppWindows.remove(startingWindow); addWindowToListInOrderLocked(startingWindow, true); @@ -4144,6 +4161,8 @@ public class WindowManagerService extends IWindowManager.Stub // show a starting window -- the current effect (a full-screen // opaque starting window that fades away to the real contents // when it is ready) does not work for this. + if (DEBUG_STARTING_WINDOW) Slog.v(TAG, "Checking theme of starting window: 0x" + + Integer.toHexString(theme)); if (theme != 0) { AttributeCache.Entry ent = AttributeCache.instance().get(pkg, theme, com.android.internal.R.styleable.Window); @@ -4152,6 +4171,15 @@ public class WindowManagerService extends IWindowManager.Stub // pretend like we didn't see that. return; } + if (DEBUG_STARTING_WINDOW) Slog.v(TAG, "Translucent=" + + ent.array.getBoolean( + com.android.internal.R.styleable.Window_windowIsTranslucent, false) + + " Floating=" + + ent.array.getBoolean( + com.android.internal.R.styleable.Window_windowIsFloating, false) + + " ShowWallpaper=" + + ent.array.getBoolean( + com.android.internal.R.styleable.Window_windowShowWallpaper, false)); if (ent.array.getBoolean( com.android.internal.R.styleable.Window_windowIsTranslucent, false)) { return; @@ -4175,6 +4203,7 @@ public class WindowManagerService extends IWindowManager.Stub } } + if (DEBUG_STARTING_WINDOW) Slog.v(TAG, "Creating StartingData"); mStartingIconInTransition = true; wtoken.startingData = new StartingData(pkg, theme, compatInfo, nonLocalizedLabel, labelRes, icon, windowFlags); @@ -4182,6 +4211,7 @@ public class WindowManagerService extends IWindowManager.Stub // Note: we really want to do sendMessageAtFrontOfQueue() because we // want to process the message ASAP, before any other queued // messages. + if (DEBUG_STARTING_WINDOW) Slog.v(TAG, "Enqueueing ADD_STARTING"); mH.sendMessageAtFrontOfQueue(m); } } @@ -5191,7 +5221,8 @@ public class WindowManagerService extends IWindowManager.Stub Slog.i(TAG, "performEnableScreen: mDisplayEnabled=" + mDisplayEnabled + " mForceDisplayEnabled=" + mForceDisplayEnabled + " mShowingBootMessages=" + mShowingBootMessages - + " mSystemBooted=" + mSystemBooted, here); + + " mSystemBooted=" + mSystemBooted + + " mOnlyCore=" + mOnlyCore, here); } if (mDisplayEnabled) { return; @@ -5209,7 +5240,8 @@ public class WindowManagerService extends IWindowManager.Stub // wallpaper, don't bother waiting for it boolean haveWallpaper = false; boolean wallpaperEnabled = mContext.getResources().getBoolean( - com.android.internal.R.bool.config_enableWallpaperService); + com.android.internal.R.bool.config_enableWallpaperService) + && !mOnlyCore; boolean haveKeyguard = true; final int N = mWindows.size(); for (int i=0; i<N; i++) { @@ -5285,6 +5317,9 @@ public class WindowManagerService extends IWindowManager.Stub } catch (RemoteException ex) { Slog.e(TAG, "Boot completed: SurfaceFlinger is dead!"); } + + // Enable input dispatch. + mInputMonitor.setEventDispatchingLw(mEventDispatchingEnabled); } mPolicy.enableScreenAfterBoot(); @@ -6636,7 +6671,8 @@ public class WindowManagerService extends IWindowManager.Stub // ------------------------------------------------------------- final InputMonitor mInputMonitor = new InputMonitor(this); - + private boolean mEventDispatchingEnabled; + public void pauseKeyDispatching(IBinder _token) { if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS, "pauseKeyDispatching()")) { @@ -6672,7 +6708,10 @@ public class WindowManagerService extends IWindowManager.Stub } synchronized (mWindowMap) { - mInputMonitor.setEventDispatchingLw(enabled); + mEventDispatchingEnabled = enabled; + if (mDisplayEnabled) { + mInputMonitor.setEventDispatchingLw(enabled); + } sendScreenStatusToClientsLocked(); } } @@ -8444,6 +8483,26 @@ public class WindowManagerService extends IWindowManager.Stub } } + private void updateAllDrawnLocked() { + // See if any windows have been drawn, so they (and others + // associated with them) can now be shown. + final ArrayList<AppWindowToken> appTokens = mAnimatingAppTokens; + final int NT = appTokens.size(); + for (int i=0; i<NT; i++) { + AppWindowToken wtoken = appTokens.get(i); + if (!wtoken.allDrawn) { + int numInteresting = wtoken.numInterestingWindows; + if (numInteresting > 0 && wtoken.numDrawnWindows >= numInteresting) { + if (WindowManagerService.DEBUG_VISIBILITY) Slog.v(TAG, + "allDrawn: " + wtoken + + " interesting=" + numInteresting + + " drawn=" + wtoken.numDrawnWindows); + wtoken.allDrawn = true; + } + } + } + } + // "Something has changed! Let's make it correct now." private final void performLayoutAndPlaceSurfacesLockedInner( boolean recoveringMemory) { @@ -8483,6 +8542,7 @@ public class WindowManagerService extends IWindowManager.Stub mInnerFields.mHoldScreen = null; mInnerFields.mScreenBrightness = -1; mInnerFields.mButtonBrightness = -1; + mTransactionSequence++; if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION performLayoutAndPlaceSurfaces"); @@ -8560,6 +8620,7 @@ public class WindowManagerService extends IWindowManager.Stub mInnerFields.mSyswin = false; boolean focusDisplayed = false; + boolean updateAllDrawn = false; final int N = mWindows.size(); for (i=N-1; i>=0; i--) { WindowState w = mWindows.get(i); @@ -8616,6 +8677,53 @@ public class WindowManagerService extends IWindowManager.Stub } winAnimator.setSurfaceBoundaries(recoveringMemory); + + final AppWindowToken atoken = w.mAppToken; + if (DEBUG_STARTING_WINDOW && atoken != null && w == atoken.startingWindow) { + Slog.d(TAG, "updateWindows: starting " + w + " isOnScreen=" + + w.isOnScreen() + " allDrawn=" + atoken.allDrawn + + " freezingScreen=" + atoken.mAppAnimator.freezingScreen); + } + if (atoken != null && (!atoken.allDrawn || atoken.mAppAnimator.freezingScreen)) { + if (atoken.lastTransactionSequence != mTransactionSequence) { + atoken.lastTransactionSequence = mTransactionSequence; + atoken.numInterestingWindows = atoken.numDrawnWindows = 0; + atoken.startingDisplayed = false; + } + if ((w.isOnScreen() || winAnimator.mAttrType + == WindowManager.LayoutParams.TYPE_BASE_APPLICATION) + && !w.mExiting && !w.mDestroying) { + if (WindowManagerService.DEBUG_VISIBILITY || + WindowManagerService.DEBUG_ORIENTATION) { + Slog.v(TAG, "Eval win " + w + ": isDrawn=" + w.isDrawnLw() + + ", isAnimating=" + winAnimator.isAnimating()); + if (!w.isDrawnLw()) { + Slog.v(TAG, "Not displayed: s=" + winAnimator.mSurface + + " pv=" + w.mPolicyVisibility + + " mDrawState=" + winAnimator.mDrawState + + " ah=" + w.mAttachedHidden + + " th=" + atoken.hiddenRequested + + " a=" + winAnimator.mAnimating); + } + } + if (w != atoken.startingWindow) { + if (!atoken.mAppAnimator.freezingScreen || !w.mAppFreezing) { + atoken.numInterestingWindows++; + if (w.isDrawnLw()) { + atoken.numDrawnWindows++; + if (WindowManagerService.DEBUG_VISIBILITY || + WindowManagerService.DEBUG_ORIENTATION) Slog.v(TAG, + "tokenMayBeDrawn: " + atoken + + " freezingScreen=" + atoken.mAppAnimator.freezingScreen + + " mAppFreezing=" + w.mAppFreezing); + updateAllDrawn = true; + } + } + } else if (w.isDrawnLw()) { + atoken.startingDisplayed = true; + } + } + } } if (someoneLosingFocus && w == mCurrentFocus && w.isDisplayedLw()) { @@ -8625,6 +8733,10 @@ public class WindowManagerService extends IWindowManager.Stub updateResizingWindows(w); } + if (updateAllDrawn) { + updateAllDrawnLocked(); + } + if (focusDisplayed) { mH.sendEmptyMessage(H.REPORT_LOSING_FOCUS); } @@ -9753,7 +9865,8 @@ public class WindowManagerService extends IWindowManager.Stub } pw.print(" mSystemBooted="); pw.print(mSystemBooted); pw.print(" mDisplayEnabled="); pw.println(mDisplayEnabled); - pw.print(" mLayoutNeeded="); pw.println(mLayoutNeeded); + pw.print(" mLayoutNeeded="); pw.print(mLayoutNeeded); + pw.print("mTransactionSequence="); pw.println(mTransactionSequence); pw.print(" mDisplayFrozen="); pw.print(mDisplayFrozen); pw.print(" mWindowsFreezingScreen="); pw.print(mWindowsFreezingScreen); pw.print(" mAppsFreezingScreen="); pw.print(mAppsFreezingScreen); @@ -9814,6 +9927,8 @@ public class WindowManagerService extends IWindowManager.Stub } pw.print(" mStartingIconInTransition="); pw.print(mStartingIconInTransition); pw.print(" mSkipAppTransitionAnimation="); pw.println(mSkipAppTransitionAnimation); + pw.println(" Window Animator:"); + mAnimator.dump(pw, " ", dumpAll); } } diff --git a/services/java/com/android/server/wm/WindowStateAnimator.java b/services/java/com/android/server/wm/WindowStateAnimator.java index 109161a..03e52fe 100644 --- a/services/java/com/android/server/wm/WindowStateAnimator.java +++ b/services/java/com/android/server/wm/WindowStateAnimator.java @@ -120,6 +120,16 @@ class WindowStateAnimator { static final int READY_TO_SHOW = 3; /** Set when the window has been shown in the screen the first time. */ static final int HAS_DRAWN = 4; + static String drawStateToString(int state) { + switch (state) { + case NO_SURFACE: return "NO_SURFACE"; + case DRAW_PENDING: return "DRAW_PENDING"; + case COMMIT_DRAW_PENDING: return "COMMIT_DRAW_PENDING"; + case READY_TO_SHOW: return "READY_TO_SHOW"; + case HAS_DRAWN: return "HAS_DRAWN"; + default: return Integer.toString(state); + } + } int mDrawState; /** Was this window last hidden? */ @@ -399,10 +409,19 @@ class WindowStateAnimator { } boolean finishDrawingLocked() { + if (DEBUG_STARTING_WINDOW && + mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) { + Slog.v(TAG, "Finishing drawing window " + mWin + ": mDrawState=" + + drawStateToString(mDrawState)); + } if (mDrawState == DRAW_PENDING) { if (DEBUG_SURFACE_TRACE || DEBUG_ANIM || SHOW_TRANSACTIONS || DEBUG_ORIENTATION) Slog.v(TAG, "finishDrawingLocked: mDrawState=COMMIT_DRAW_PENDING " + this + " in " + mSurface); + if (DEBUG_STARTING_WINDOW && + mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) { + Slog.v(TAG, "Draw state now committed in " + mWin); + } mDrawState = COMMIT_DRAW_PENDING; return true; } @@ -411,11 +430,17 @@ class WindowStateAnimator { // This must be called while inside a transaction. boolean commitFinishDrawingLocked(long currentTime) { + if (DEBUG_STARTING_WINDOW && + mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) { + Slog.i(TAG, "commitFinishDrawingLocked: " + mWin + " cur mDrawState=" + + drawStateToString(mDrawState)); + } if (mDrawState != COMMIT_DRAW_PENDING) { return false; } - if (DEBUG_SURFACE_TRACE || DEBUG_ANIM) + if (DEBUG_SURFACE_TRACE || DEBUG_ANIM) { Slog.i(TAG, "commitFinishDrawingLocked: mDrawState=READY_TO_SHOW " + mSurface); + } mDrawState = READY_TO_SHOW; final boolean starting = mWin.mAttrs.type == TYPE_APPLICATION_STARTING; final AppWindowToken atoken = mWin.mAppToken; @@ -1214,7 +1239,8 @@ class WindowStateAnimator { // This must be called while inside a transaction. boolean performShowLocked() { - if (DEBUG_VISIBILITY) { + if (DEBUG_VISIBILITY || (DEBUG_STARTING_WINDOW && + mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING)) { RuntimeException e = null; if (!WindowManagerService.HIDE_STACK_CRAWLS) { e = new RuntimeException(); @@ -1223,12 +1249,7 @@ class WindowStateAnimator { Slog.v(TAG, "performShow on " + this + ": mDrawState=" + mDrawState + " readyForDisplay=" + mWin.isReadyForDisplayIgnoringKeyguard() - + " starting=" + (mWin.mAttrs.type == TYPE_APPLICATION_STARTING), e); - } - if (mDrawState == READY_TO_SHOW && mWin.isReadyForDisplayIgnoringKeyguard()) { - if (SHOW_TRANSACTIONS || DEBUG_ORIENTATION) - WindowManagerService.logSurface(mWin, "SHOW (performShowLocked)", null); - if (DEBUG_VISIBILITY) Slog.v(TAG, "Showing " + this + + " starting=" + (mWin.mAttrs.type == TYPE_APPLICATION_STARTING) + " during animation: policyVis=" + mWin.mPolicyVisibility + " attHidden=" + mWin.mAttachedHidden + " tok.hiddenRequested=" @@ -1237,7 +1258,24 @@ class WindowStateAnimator { + (mWin.mAppToken != null ? mWin.mAppToken.hidden : false) + " animating=" + mAnimating + " tok animating=" - + (mWin.mAppToken != null ? mWin.mAppToken.mAppAnimator.animating : false)); + + (mWin.mAppToken != null ? mWin.mAppToken.mAppAnimator.animating : false), e); + } + if (mDrawState == READY_TO_SHOW && mWin.isReadyForDisplayIgnoringKeyguard()) { + if (SHOW_TRANSACTIONS || DEBUG_ORIENTATION) + WindowManagerService.logSurface(mWin, "SHOW (performShowLocked)", null); + if (DEBUG_VISIBILITY || (DEBUG_STARTING_WINDOW && + mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING)) { + Slog.v(TAG, "Showing " + this + + " during animation: policyVis=" + mWin.mPolicyVisibility + + " attHidden=" + mWin.mAttachedHidden + + " tok.hiddenRequested=" + + (mWin.mAppToken != null ? mWin.mAppToken.hiddenRequested : false) + + " tok.hidden=" + + (mWin.mAppToken != null ? mWin.mAppToken.hidden : false) + + " animating=" + mAnimating + + " tok animating=" + + (mWin.mAppToken != null ? mWin.mAppToken.mAppAnimator.animating : false)); + } mService.enableScreenIfNeededLocked(); @@ -1425,7 +1463,8 @@ class WindowStateAnimator { if (mSurface != null) { if (dumpAll) { pw.print(prefix); pw.print("mSurface="); pw.println(mSurface); - pw.print(prefix); pw.print("mDrawState="); pw.print(mDrawState); + pw.print(prefix); pw.print("mDrawState="); + pw.print(drawStateToString(mDrawState)); pw.print(" mLastHidden="); pw.println(mLastHidden); } pw.print(prefix); pw.print("Surface: shown="); pw.print(mSurfaceShown); |
