diff options
Diffstat (limited to 'services/java/com')
7 files changed, 326 insertions, 157 deletions
diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java index a2684fb..9c80b51 100644 --- a/services/java/com/android/server/InputMethodManagerService.java +++ b/services/java/com/android/server/InputMethodManagerService.java @@ -427,6 +427,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub // Uh oh, current input method is no longer around! // Pick another one... Slog.i(TAG, "Current input method removed: " + curInputMethodId); + mStatusBar.setIMEButtonVisible(mCurToken, false); if (!chooseNewDefaultIMELocked()) { changed = true; curIm = null; @@ -1020,9 +1021,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } if (subtype != mCurrentSubtype) { synchronized (mMethodMap) { + if (subtype != null) { + setSelectedInputMethodAndSubtypeLocked(info, subtypeId, true); + } if (mCurMethod != null) { try { - setSelectedInputMethodAndSubtypeLocked(info, subtypeId, true); if (mInputShown) { // If mInputShown is false, there is no IME button on the // system bar. @@ -1797,19 +1800,14 @@ public class InputMethodManagerService extends IInputMethodManager.Stub }); if (showSubtypes) { - mDialogBuilder.setPositiveButton(com.android.internal.R.string.more_item_label, + mDialogBuilder.setPositiveButton( + com.android.internal.R.string.configure_input_methods, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { showConfigureInputMethods(); } }); } - mDialogBuilder.setNegativeButton(com.android.internal.R.string.cancel, - new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int whichButton) { - hideInputMethodMenu(); - } - }); mSwitchingDialog = mDialogBuilder.create(); mSwitchingDialog.getWindow().setType( WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG); diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java index b196f74..26060e6 100644 --- a/services/java/com/android/server/PackageManagerService.java +++ b/services/java/com/android/server/PackageManagerService.java @@ -7453,6 +7453,10 @@ class PackageManagerService extends IPackageManager.Stub { static class PackageSignatures { private Signature[] mSignatures; + PackageSignatures(PackageSignatures orig) { + mSignatures = orig.mSignatures.clone(); + } + PackageSignatures(Signature[] sigs) { assignSignatures(sigs); } @@ -7788,6 +7792,12 @@ class PackageManagerService extends IPackageManager.Stub { setFlags(pkgFlags); } + GrantedPermissions(GrantedPermissions base) { + pkgFlags = base.pkgFlags; + grantedPermissions = (HashSet<String>) base.grantedPermissions.clone(); + gids = base.gids.clone(); + } + void setFlags(int pkgFlags) { this.pkgFlags = pkgFlags & ( ApplicationInfo.FLAG_SYSTEM | @@ -7815,7 +7825,7 @@ class PackageManagerService extends IPackageManager.Stub { int versionCode; boolean uidError; - + PackageSignatures signatures = new PackageSignatures(); boolean permissionsFixed; @@ -7841,6 +7851,44 @@ class PackageManagerService extends IPackageManager.Stub { init(codePath, resourcePath, nativeLibraryPathString, pVersionCode); } + /** + * New instance of PackageSetting with one-level-deep cloning. + */ + PackageSettingBase(PackageSettingBase base) { + super(base); + + name = base.name; + realName = base.realName; + codePath = base.codePath; + codePathString = base.codePathString; + resourcePath = base.resourcePath; + resourcePathString = base.resourcePathString; + nativeLibraryPathString = base.nativeLibraryPathString; + obbPathString = base.obbPathString; + timeStamp = base.timeStamp; + firstInstallTime = base.firstInstallTime; + lastUpdateTime = base.lastUpdateTime; + versionCode = base.versionCode; + + uidError = base.uidError; + + signatures = new PackageSignatures(base.signatures); + + permissionsFixed = base.permissionsFixed; + haveGids = base.haveGids; + + disabledComponents = (HashSet<String>) base.disabledComponents.clone(); + + enabledComponents = (HashSet<String>) base.enabledComponents.clone(); + + enabled = base.enabled; + installStatus = base.installStatus; + + origPackage = base.origPackage; + + installerPackageName = base.installerPackageName; + } + void init(File codePath, File resourcePath, String nativeLibraryPathString, int pVersionCode) { this.codePath = codePath; @@ -7871,6 +7919,9 @@ class PackageManagerService extends IPackageManager.Stub { timeStamp = newStamp; } + /** + * Make a shallow copy of this package settings. + */ public void copyFrom(PackageSettingBase base) { grantedPermissions = base.grantedPermissions; gids = base.gids; @@ -7930,18 +7981,16 @@ class PackageManagerService extends IPackageManager.Stub { pkgFlags); } + /** + * New instance of PackageSetting replicating the original settings. + * Note that it keeps the same PackageParser.Package instance. + */ PackageSetting(PackageSetting orig) { - super(orig.name, orig.realName, orig.codePath, orig.resourcePath, - orig.nativeLibraryPathString, orig.versionCode, orig.pkgFlags); - copyFrom(orig); - } - - public void copyFrom(PackageSetting base) { - super.copyFrom((PackageSettingBase) base); + super(orig); - userId = base.userId; - sharedUser = base.sharedUser; - pkg = base.pkg; + userId = orig.userId; + pkg = orig.pkg; + sharedUser = orig.sharedUser; } @Override @@ -8173,7 +8222,7 @@ class PackageManagerService extends IPackageManager.Stub { // a little trick... when we install the new package, we don't // want to modify the existing PackageSetting for the built-in // version. so at this point we need a new PackageSetting that - // is okay to much with. + // is okay to muck with. PackageSetting newp = new PackageSetting(p); replacePackageLP(name, newp); return true; diff --git a/services/java/com/android/server/ScreenRotationAnimation.java b/services/java/com/android/server/ScreenRotationAnimation.java index 19cc203..2ad9cbe 100644 --- a/services/java/com/android/server/ScreenRotationAnimation.java +++ b/services/java/com/android/server/ScreenRotationAnimation.java @@ -60,7 +60,8 @@ class ScreenRotationAnimation { final Matrix mSnapshotFinalMatrix = new Matrix(); final float[] mTmpFloats = new float[9]; - public ScreenRotationAnimation(Context context, Display display, SurfaceSession session) { + public ScreenRotationAnimation(Context context, Display display, SurfaceSession session, + boolean inTransaction) { mContext = context; mDisplay = display; @@ -84,60 +85,70 @@ class ScreenRotationAnimation { mOriginalWidth = mDisplayMetrics.widthPixels; mOriginalHeight = mDisplayMetrics.heightPixels; - Surface.openTransaction(); - - try { - mSurface = new Surface(session, 0, "FreezeSurface", - -1, mWidth, mHeight, PixelFormat.OPAQUE, 0); - mSurface.setLayer(WindowManagerService.TYPE_LAYER_MULTIPLIER * 200); - } catch (Surface.OutOfResourcesException e) { - Slog.w(TAG, "Unable to allocate freeze surface", e); + if (!inTransaction) { + if (WindowManagerService.SHOW_TRANSACTIONS) Slog.i(WindowManagerService.TAG, + ">>> OPEN TRANSACTION ScreenRotationAnimation"); + Surface.openTransaction(); } - if (false) { + try { try { - int size = mOriginalWidth > mOriginalHeight ? mOriginalWidth : mOriginalHeight; - mBlackSurface = new Surface(session, 0, "BlackSurface", - -1, size, size, PixelFormat.OPAQUE, Surface.FX_SURFACE_DIM); - mBlackSurface.setAlpha(1.0f); - mBlackSurface.setLayer(0); + mSurface = new Surface(session, 0, "FreezeSurface", + -1, mWidth, mHeight, PixelFormat.OPAQUE, 0); + mSurface.setLayer(WindowManagerService.TYPE_LAYER_MULTIPLIER * 200); } catch (Surface.OutOfResourcesException e) { - Slog.w(TAG, "Unable to allocate black surface", e); + Slog.w(TAG, "Unable to allocate freeze surface", e); } - } + + if (false) { + try { + int size = mOriginalWidth > mOriginalHeight ? mOriginalWidth : mOriginalHeight; + mBlackSurface = new Surface(session, 0, "BlackSurface", + -1, size, size, PixelFormat.OPAQUE, Surface.FX_SURFACE_DIM); + mBlackSurface.setAlpha(1.0f); + mBlackSurface.setLayer(0); + } catch (Surface.OutOfResourcesException e) { + Slog.w(TAG, "Unable to allocate black surface", e); + } + } + + setRotation(display.getRotation()); + + if (mSurface != null) { + Rect dirty = new Rect(0, 0, mWidth, mHeight); + Canvas c = null; + try { + c = mSurface.lockCanvas(dirty); + } catch (IllegalArgumentException e) { + Slog.w(TAG, "Unable to lock surface", e); + return; + } catch (Surface.OutOfResourcesException e) { + Slog.w(TAG, "Unable to lock surface", e); + return; + } + if (c == null) { + Slog.w(TAG, "Null surface"); + return; + } - setRotation(display.getRotation()); + if (screenshot != null) { + c.drawBitmap(screenshot, 0, 0, new Paint(0)); + } else { + c.drawColor(Color.GREEN); + } - if (mSurface != null) { - Rect dirty = new Rect(0, 0, mWidth, mHeight); - Canvas c = null; - try { - c = mSurface.lockCanvas(dirty); - } catch (IllegalArgumentException e) { - Slog.w(TAG, "Unable to lock surface", e); - return; - } catch (Surface.OutOfResourcesException e) { - Slog.w(TAG, "Unable to lock surface", e); - return; + mSurface.unlockCanvasAndPost(c); } - if (c == null) { - Slog.w(TAG, "Null surface"); - return; + } finally { + if (!inTransaction) { + Surface.closeTransaction(); + if (WindowManagerService.SHOW_TRANSACTIONS) Slog.i(WindowManagerService.TAG, + "<<< CLOSE TRANSACTION ScreenRotationAnimation"); } if (screenshot != null) { - c.drawBitmap(screenshot, 0, 0, new Paint(0)); - } else { - c.drawColor(Color.GREEN); + screenshot.recycle(); } - - mSurface.unlockCanvasAndPost(c); - } - - Surface.closeTransaction(); - - if (screenshot != null) { - screenshot.recycle(); } } diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java index e9bf624..8d9cb31 100644 --- a/services/java/com/android/server/WindowManagerService.java +++ b/services/java/com/android/server/WindowManagerService.java @@ -149,6 +149,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdog.Monitor { static final String TAG = "WindowManager"; static final boolean DEBUG = false; + static final boolean DEBUG_ADD_REMOVE = false; static final boolean DEBUG_FOCUS = false; static final boolean DEBUG_ANIM = false; static final boolean DEBUG_LAYOUT = false; @@ -158,6 +159,7 @@ public class WindowManagerService extends IWindowManager.Stub static final boolean DEBUG_INPUT_METHOD = false; static final boolean DEBUG_VISIBILITY = false; static final boolean DEBUG_WINDOW_MOVEMENT = false; + static final boolean DEBUG_TOKEN_MOVEMENT = false; static final boolean DEBUG_ORIENTATION = false; static final boolean DEBUG_CONFIGURATION = false; static final boolean DEBUG_APP_TRANSITIONS = false; @@ -296,12 +298,6 @@ public class WindowManagerService extends IWindowManager.Stub new HashMap<IBinder, WindowToken>(); /** - * The same tokens as mTokenMap, stored in a list for efficient iteration - * over them. - */ - final ArrayList<WindowToken> mTokenList = new ArrayList<WindowToken>(); - - /** * Window tokens that are in the process of exiting, but still * on screen for animations. */ @@ -310,7 +306,7 @@ public class WindowManagerService extends IWindowManager.Stub /** * Z-ordered (bottom-most first) list of all application tokens, for * controlling the ordering of windows in different applications. This - * contains WindowToken objects. + * contains AppWindowToken objects. */ final ArrayList<AppWindowToken> mAppTokens = new ArrayList<AppWindowToken>(); @@ -344,6 +340,11 @@ public class WindowManagerService extends IWindowManager.Stub final ArrayList<WindowState> mPendingRemove = new ArrayList<WindowState>(); /** + * Used when processing mPendingRemove to avoid working on the original array. + */ + WindowState[] mPendingRemoveTmp = new WindowState[20]; + + /** * Windows whose surface should be destroyed. */ final ArrayList<WindowState> mDestroySurface = new ArrayList<WindowState>(); @@ -360,6 +361,12 @@ public class WindowManagerService extends IWindowManager.Stub */ ArrayList<WindowState> mForceRemoves; + /** + * Used when rebuilding window list to keep track of windows that have + * been removed. + */ + WindowState[] mRebuildTmp = new WindowState[20]; + IInputMethodManager mInputMethodManager; SurfaceSession mFxSession; @@ -685,7 +692,7 @@ public class WindowManagerService extends IWindowManager.Stub // deferred rotation if (performRotation) { if (DEBUG_ORIENTATION) Slog.d(TAG, "Performing post-drag rotation"); - boolean changed = setRotationUncheckedLocked(rotation, animFlags); + boolean changed = setRotationUncheckedLocked(rotation, animFlags, false); if (changed) { sendNewConfiguration(); } @@ -696,9 +703,14 @@ public class WindowManagerService extends IWindowManager.Stub final int myPid = Process.myPid(); // Move the surface to the given touch + if (SHOW_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION notifyMoveLw"); mSurface.openTransaction(); - mSurface.setPosition((int)(x - mThumbOffsetX), (int)(y - mThumbOffsetY)); - mSurface.closeTransaction(); + try { + mSurface.setPosition((int)(x - mThumbOffsetX), (int)(y - mThumbOffsetY)); + } finally { + mSurface.closeTransaction(); + if (SHOW_TRANSACTIONS) Slog.i(TAG, "<<< CLOSE TRANSACTION notifyMoveLw"); + } // Tell the affected window WindowState touchedWin = getTouchedWinAtPointLw(x, y); @@ -1089,7 +1101,7 @@ public class WindowManagerService extends IWindowManager.Stub private void placeWindowAfter(WindowState pos, WindowState window) { final int i = mWindows.indexOf(pos); - if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT) Slog.v( + if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v( TAG, "Adding window " + window + " at " + (i+1) + " of " + mWindows.size() + " (after " + pos + ")"); mWindows.add(i+1, window); @@ -1098,7 +1110,7 @@ public class WindowManagerService extends IWindowManager.Stub private void placeWindowBefore(WindowState pos, WindowState window) { final int i = mWindows.indexOf(pos); - if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT) Slog.v( + if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v( TAG, "Adding window " + window + " at " + i + " of " + mWindows.size() + " (before " + pos + ")"); mWindows.add(i, window); @@ -1156,9 +1168,10 @@ public class WindowManagerService extends IWindowManager.Stub //apptoken note that the window could be a floating window //that was created later or a window at the top of the list of //windows associated with this token. - if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT) Slog.v( - TAG, "Adding window " + win + " at " - + (newIdx+1) + " of " + N); + if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) { + Slog.v(TAG, "Adding window " + win + " at " + + (newIdx+1) + " of " + N); + } localmWindows.add(newIdx+1, win); mWindowsChanged = true; } @@ -1237,9 +1250,10 @@ public class WindowManagerService extends IWindowManager.Stub break; } } - if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT) Slog.v( - TAG, "Adding window " + win + " at " - + i + " of " + N); + if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) { + Slog.v(TAG, "Adding window " + win + " at " + + i + " of " + N); + } localmWindows.add(i, win); mWindowsChanged = true; } @@ -1255,13 +1269,14 @@ public class WindowManagerService extends IWindowManager.Stub } } if (i < 0) i = 0; - if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT) Slog.v( + if (DEBUG_FOCUS || DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v( TAG, "Adding window " + win + " at " + i + " of " + N); localmWindows.add(i, win); mWindowsChanged = true; } if (addToToken) { + if (DEBUG_ADD_REMOVE) Slog.v(TAG, "Adding " + win + " to " + token); token.windows.add(tokenWindowsPos, win); } @@ -1284,6 +1299,7 @@ public class WindowManagerService extends IWindowManager.Stub // in the same sublayer. if (wSublayer >= sublayer) { if (addToToken) { + if (DEBUG_ADD_REMOVE) Slog.v(TAG, "Adding " + win + " to " + token); token.windows.add(i, win); } placeWindowBefore( @@ -1295,6 +1311,7 @@ public class WindowManagerService extends IWindowManager.Stub // in the same sublayer. if (wSublayer > sublayer) { if (addToToken) { + if (DEBUG_ADD_REMOVE) Slog.v(TAG, "Adding " + win + " to " + token); token.windows.add(i, win); } placeWindowBefore(w, win); @@ -1304,6 +1321,7 @@ public class WindowManagerService extends IWindowManager.Stub } if (i >= NA) { if (addToToken) { + if (DEBUG_ADD_REMOVE) Slog.v(TAG, "Adding " + win + " to " + token); token.windows.add(win); } if (sublayer < 0) { @@ -1478,7 +1496,7 @@ public class WindowManagerService extends IWindowManager.Stub int pos = findDesiredInputMethodWindowIndexLocked(true); if (pos >= 0) { win.mTargetAppToken = mInputMethodTarget.mAppToken; - if (DEBUG_WINDOW_MOVEMENT) Slog.v( + if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v( TAG, "Adding input method window " + win + " at " + pos); mWindows.add(pos, win); mWindowsChanged = true; @@ -2028,9 +2046,10 @@ public class WindowManagerService extends IWindowManager.Stub } // Now stick it in. - if (DEBUG_WALLPAPER || DEBUG_WINDOW_MOVEMENT) Slog.v(TAG, - "Moving wallpaper " + wallpaper - + " from " + oldIndex + " to " + foundI); + if (DEBUG_WALLPAPER || DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) { + Slog.v(TAG, "Moving wallpaper " + wallpaper + + " from " + oldIndex + " to " + foundI); + } localmWindows.add(foundI, wallpaper); mWindowsChanged = true; @@ -2349,7 +2368,6 @@ public class WindowManagerService extends IWindowManager.Stub if (addToken) { mTokenMap.put(attrs.token, token); - mTokenList.add(token); } win.attach(); mWindowMap.put(client.asBinder(), win); @@ -2417,7 +2435,7 @@ public class WindowManagerService extends IWindowManager.Stub TAG, "New client " + client.asBinder() + ": window=" + win); - if (win.isVisibleOrAdding() && updateOrientationFromAppTokensLocked()) { + if (win.isVisibleOrAdding() && updateOrientationFromAppTokensLocked(false)) { reportNewConfig = true; } } @@ -2504,7 +2522,7 @@ public class WindowManagerService extends IWindowManager.Stub // So just update orientation if needed. if (wasVisible && computeForcedAppOrientationLocked() != mForcedAppOrientation - && updateOrientationFromAppTokensLocked()) { + && updateOrientationFromAppTokensLocked(false)) { mH.sendEmptyMessage(H.SEND_NEW_CONFIGURATION); } updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL); @@ -2512,6 +2530,18 @@ public class WindowManagerService extends IWindowManager.Stub } private void removeWindowInnerLocked(Session session, WindowState win) { + if (win.mRemoved) { + // Nothing to do. + return; + } + + for (int i=win.mChildWindows.size()-1; i>=0; i--) { + WindowState cwin = win.mChildWindows.get(i); + Slog.w(TAG, "Force-removing child win " + cwin + " from container " + + win); + removeWindowInnerLocked(cwin.mSession, cwin); + } + win.mRemoved = true; if (mInputMethodTarget == win) { @@ -2527,8 +2557,10 @@ public class WindowManagerService extends IWindowManager.Stub mPolicy.removeWindowLw(win); win.removeLocked(); + if (DEBUG_ADD_REMOVE) Slog.v(TAG, "removeWindowInnerLocked: " + win); mWindowMap.remove(win.mClient.asBinder()); mWindows.remove(win); + mPendingRemove.remove(win); mWindowsChanged = true; if (DEBUG_WINDOW_MOVEMENT) Slog.v(TAG, "Final remove of window: " + win); @@ -2540,6 +2572,7 @@ public class WindowManagerService extends IWindowManager.Stub final WindowToken token = win.mToken; final AppWindowToken atoken = win.mAppToken; + if (DEBUG_ADD_REMOVE) Slog.v(TAG, "Removing " + win + " from " + token); token.windows.remove(win); if (atoken != null) { atoken.allAppWindows.remove(win); @@ -2550,7 +2583,6 @@ public class WindowManagerService extends IWindowManager.Stub if (token.windows.size() == 0) { if (!token.explicit) { mTokenMap.remove(token.token); - mTokenList.remove(token); } else if (atoken != null) { atoken.firstWindowDrawn = false; } @@ -2610,15 +2642,17 @@ public class WindowManagerService extends IWindowManager.Stub synchronized (mWindowMap) { WindowState w = windowForClientLocked(session, client, false); if ((w != null) && (w.mSurface != null)) { - if (SHOW_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION"); + if (SHOW_TRANSACTIONS) Slog.i(TAG, + ">>> OPEN TRANSACTION setTransparentRegion"); Surface.openTransaction(); try { if (SHOW_TRANSACTIONS) logSurface(w, "transparentRegionHint=" + region, null); w.mSurface.setTransparentRegionHint(region); } finally { - if (SHOW_TRANSACTIONS) Slog.i(TAG, "<<< CLOSE TRANSACTION"); Surface.closeTransaction(); + if (SHOW_TRANSACTIONS) Slog.i(TAG, + "<<< CLOSE TRANSACTION setTransparentRegion"); } } } @@ -2956,7 +2990,7 @@ public class WindowManagerService extends IWindowManager.Stub if (assignLayers) { assignLayersLocked(); } - configChanged = updateOrientationFromAppTokensLocked(); + configChanged = updateOrientationFromAppTokensLocked(false); performLayoutAndPlaceSurfacesLocked(); if (displayed && win.mIsWallpaper) { updateWallpaperOffsetLocked(win, mDisplay.getWidth(), @@ -3313,7 +3347,6 @@ public class WindowManagerService extends IWindowManager.Stub } wtoken = new WindowToken(token, type, true); mTokenMap.put(token, wtoken); - mTokenList.add(wtoken); if (type == TYPE_WALLPAPER) { mWallpaperTokens.add(wtoken); } @@ -3329,7 +3362,6 @@ public class WindowManagerService extends IWindowManager.Stub final long origId = Binder.clearCallingIdentity(); synchronized(mWindowMap) { WindowToken wtoken = mTokenMap.remove(token); - mTokenList.remove(wtoken); if (wtoken != null) { boolean delayed = false; if (!wtoken.hidden) { @@ -3405,10 +3437,9 @@ public class WindowManagerService extends IWindowManager.Stub wtoken.groupId = groupId; wtoken.appFullscreen = fullscreen; wtoken.requestedOrientation = requestedOrientation; + if (DEBUG_TOKEN_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v(TAG, "addAppToken: " + wtoken); mAppTokens.add(addPos, wtoken); - if (localLOGV) Slog.v(TAG, "Adding new app token: " + wtoken); mTokenMap.put(token.asBinder(), wtoken); - mTokenList.add(wtoken); // Application tokens start out hidden. wtoken.hidden = true; @@ -3525,7 +3556,7 @@ public class WindowManagerService extends IWindowManager.Stub long ident = Binder.clearCallingIdentity(); synchronized(mWindowMap) { - if (updateOrientationFromAppTokensLocked()) { + if (updateOrientationFromAppTokensLocked(false)) { if (freezeThisOneIfNeeded != null) { AppWindowToken wtoken = findAppWindowToken( freezeThisOneIfNeeded); @@ -3547,7 +3578,7 @@ public class WindowManagerService extends IWindowManager.Stub if (currentConfig.diff(mTempConfiguration) != 0) { mWaitingForConfig = true; mLayoutNeeded = true; - startFreezingDisplayLocked(); + startFreezingDisplayLocked(false); config = new Configuration(mTempConfiguration); } } @@ -3572,8 +3603,8 @@ public class WindowManagerService extends IWindowManager.Stub * @see android.view.IWindowManager#updateOrientationFromAppTokens( * android.os.IBinder) */ - boolean updateOrientationFromAppTokensLocked() { - if (mDisplayFrozen) { + boolean updateOrientationFromAppTokensLocked(boolean inTransaction) { + if (mDisplayFrozen || mOpeningApps.size() > 0 || mClosingApps.size() > 0) { // If the display is frozen, some activities may be in the middle // of restarting, and thus have removed their old window. If the // window has the flag to hide the lock screen, then the lock screen @@ -3593,7 +3624,8 @@ public class WindowManagerService extends IWindowManager.Stub //action like disabling/enabling sensors etc., mPolicy.setCurrentOrientationLw(req); if (setRotationUncheckedLocked(WindowManagerPolicy.USE_LAST_ROTATION, - mLastRotationFlags | Surface.FLAGS_ORIENTATION_ANIMATION_DISABLE)) { + mLastRotationFlags | Surface.FLAGS_ORIENTATION_ANIMATION_DISABLE, + inTransaction)) { changed = true; } } @@ -3819,10 +3851,12 @@ public class WindowManagerService extends IWindowManager.Stub startingWindow.mToken = wtoken; startingWindow.mRootToken = wtoken; startingWindow.mAppToken = wtoken; - if (DEBUG_WINDOW_MOVEMENT) Slog.v(TAG, + if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v(TAG, "Removing starting window: " + startingWindow); mWindows.remove(startingWindow); mWindowsChanged = true; + if (DEBUG_ADD_REMOVE) Slog.v(TAG, "Removing starting " + startingWindow + + " from " + ttoken); ttoken.windows.remove(startingWindow); ttoken.allAppWindows.remove(startingWindow); addWindowToListInOrderLocked(startingWindow, true); @@ -4168,7 +4202,7 @@ public class WindowManagerService extends IWindowManager.Stub wtoken.freezingScreen = true; mAppsFreezingScreen++; if (mAppsFreezingScreen == 1) { - startFreezingDisplayLocked(); + startFreezingDisplayLocked(false); mH.removeMessages(H.APP_FREEZE_TIMEOUT); mH.sendMessageDelayed(mH.obtainMessage(H.APP_FREEZE_TIMEOUT), 5000); @@ -4237,7 +4271,6 @@ public class WindowManagerService extends IWindowManager.Stub final long origId = Binder.clearCallingIdentity(); synchronized(mWindowMap) { WindowToken basewtoken = mTokenMap.remove(token); - mTokenList.remove(basewtoken); if (basewtoken != null && (wtoken=basewtoken.appWindowToken) != null) { if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "Removing app token: " + wtoken); delayed = setTokenVisibilityLocked(wtoken, null, false, WindowManagerPolicy.TRANSIT_UNSET, true); @@ -4257,6 +4290,8 @@ public class WindowManagerService extends IWindowManager.Stub + " animating=" + wtoken.animating); if (delayed) { // set the token aside because it has an active animation to be finished + if (DEBUG_ADD_REMOVE || DEBUG_TOKEN_MOVEMENT) Slog.v(TAG, + "removeAppToken make exiting: " + wtoken); mExitingAppTokens.add(wtoken); } else { // Make sure there is no animation running on this token, @@ -4265,6 +4300,8 @@ public class WindowManagerService extends IWindowManager.Stub wtoken.animation = null; wtoken.animating = false; } + if (DEBUG_ADD_REMOVE || DEBUG_TOKEN_MOVEMENT) Slog.v(TAG, + "removeAppToken: " + wtoken); mAppTokens.remove(wtoken); wtoken.removed = true; if (wtoken.startingData != null) { @@ -4391,18 +4428,21 @@ public class WindowManagerService extends IWindowManager.Stub if (!added && cwin.mSubLayer >= 0) { if (DEBUG_WINDOW_MOVEMENT) Slog.v(TAG, "Re-adding child window at " + index + ": " + cwin); + win.mRebuilding = false; mWindows.add(index, win); index++; added = true; } if (DEBUG_WINDOW_MOVEMENT) Slog.v(TAG, "Re-adding window at " + index + ": " + cwin); + cwin.mRebuilding = false; mWindows.add(index, cwin); index++; } if (!added) { if (DEBUG_WINDOW_MOVEMENT) Slog.v(TAG, "Re-adding window at " + index + ": " + win); + win.mRebuilding = false; mWindows.add(index, win); index++; } @@ -4428,6 +4468,9 @@ public class WindowManagerService extends IWindowManager.Stub if (DEBUG_REORDER) Slog.v(TAG, "Initial app tokens:"); if (DEBUG_REORDER) dumpAppTokensLocked(); final AppWindowToken wtoken = findAppWindowToken(token); + if (DEBUG_TOKEN_MOVEMENT || DEBUG_REORDER) Slog.v(TAG, + "Start moving token " + wtoken + " initially at " + + mAppTokens.indexOf(wtoken)); if (wtoken == null || !mAppTokens.remove(wtoken)) { Slog.w(TAG, "Attempting to reorder token that doesn't exist: " + token + " (" + wtoken + ")"); @@ -4435,6 +4478,7 @@ public class WindowManagerService extends IWindowManager.Stub } mAppTokens.add(index, wtoken); if (DEBUG_REORDER) Slog.v(TAG, "Moved " + token + " to " + index + ":"); + else if (DEBUG_TOKEN_MOVEMENT) Slog.v(TAG, "Moved " + token + " to " + index); if (DEBUG_REORDER) dumpAppTokensLocked(); final long origId = Binder.clearCallingIdentity(); @@ -4462,6 +4506,8 @@ public class WindowManagerService extends IWindowManager.Stub for (int i=0; i<N; i++) { IBinder token = tokens.get(i); final AppWindowToken wtoken = findAppWindowToken(token); + if (DEBUG_REORDER || DEBUG_TOKEN_MOVEMENT) Slog.v(TAG, + "Temporarily removing " + wtoken + " from " + mAppTokens.indexOf(wtoken)); if (!mAppTokens.remove(wtoken)) { Slog.w(TAG, "Attempting to reorder token that doesn't exist: " + token + " (" + wtoken + ")"); @@ -4535,6 +4581,8 @@ public class WindowManagerService extends IWindowManager.Stub for (int i=0; i<N; i++) { AppWindowToken wt = findAppWindowToken(tokens.get(i)); if (wt != null) { + if (DEBUG_TOKEN_MOVEMENT || DEBUG_REORDER) Slog.v(TAG, + "Adding next to top: " + wt); mAppTokens.add(wt); if (mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) { mToTopApps.remove(wt); @@ -4567,6 +4615,8 @@ public class WindowManagerService extends IWindowManager.Stub for (int i=0; i<N; i++) { AppWindowToken wt = findAppWindowToken(tokens.get(i)); if (wt != null) { + if (DEBUG_TOKEN_MOVEMENT) Slog.v(TAG, + "Adding next to bottom: " + wt + " at " + pos); mAppTokens.add(pos, wt); if (mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) { mToTopApps.remove(wt); @@ -4934,12 +4984,17 @@ public class WindowManagerService extends IWindowManager.Stub } } + if (SHOW_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION showStrictModeViolation"); Surface.openTransaction(); - if (mStrictModeFlash == null) { - mStrictModeFlash = new StrictModeFlash(mDisplay, mFxSession); + try { + if (mStrictModeFlash == null) { + mStrictModeFlash = new StrictModeFlash(mDisplay, mFxSession); + } + mStrictModeFlash.setVisibility(on); + } finally { + Surface.closeTransaction(); + if (SHOW_TRANSACTIONS) Slog.i(TAG, "<<< CLOSE TRANSACTION showStrictModeViolation"); } - mStrictModeFlash.setVisibility(on); - Surface.closeTransaction(); } } @@ -5084,7 +5139,7 @@ public class WindowManagerService extends IWindowManager.Stub long origId = Binder.clearCallingIdentity(); boolean changed; synchronized(mWindowMap) { - changed = setRotationUncheckedLocked(rotation, animFlags); + changed = setRotationUncheckedLocked(rotation, animFlags, false); } if (changed || alwaysSendConfiguration) { @@ -5102,7 +5157,7 @@ public class WindowManagerService extends IWindowManager.Stub * Returns null if the rotation has been changed. In this case YOU * MUST CALL setNewConfiguration() TO UNFREEZE THE SCREEN. */ - public boolean setRotationUncheckedLocked(int rotation, int animFlags) { + public boolean setRotationUncheckedLocked(int rotation, int animFlags, boolean inTransaction) { if (mDragState != null) { // Potential rotation during a drag. Don't do the rotation now, but make // a note to perform the rotation later. @@ -5137,17 +5192,28 @@ public class WindowManagerService extends IWindowManager.Stub 2000); mWaitingForConfig = true; mLayoutNeeded = true; - startFreezingDisplayLocked(); + startFreezingDisplayLocked(inTransaction); Slog.i(TAG, "Setting rotation to " + rotation + ", animFlags=" + animFlags); mInputManager.setDisplayOrientation(0, rotation); if (mDisplayEnabled) { if (CUSTOM_SCREEN_ROTATION) { Surface.freezeDisplay(0); - Surface.openTransaction(); - if (mScreenRotationAnimation != null) { - mScreenRotationAnimation.setRotation(rotation); + if (!inTransaction) { + if (SHOW_TRANSACTIONS) Slog.i(TAG, + ">>> OPEN TRANSACTION setRotationUnchecked"); + Surface.openTransaction(); + } + try { + if (mScreenRotationAnimation != null) { + mScreenRotationAnimation.setRotation(rotation); + } + } finally { + if (!inTransaction) { + Surface.closeTransaction(); + if (SHOW_TRANSACTIONS) Slog.i(TAG, + "<<< CLOSE TRANSACTION setRotationUnchecked"); + } } - Surface.closeTransaction(); Surface.setOrientation(0, rotation, animFlags); Surface.unfreezeDisplay(0); } else { @@ -5566,7 +5632,13 @@ public class WindowManagerService extends IWindowManager.Stub public Configuration computeNewConfiguration() { synchronized (mWindowMap) { - return computeNewConfigurationLocked(); + Configuration config = computeNewConfigurationLocked(); + if (config == null && mWaitingForConfig) { + // Nothing changed but we are waiting for something... stop that! + mWaitingForConfig = false; + performLayoutAndPlaceSurfacesLocked(); + } + return config; } } @@ -5952,7 +6024,7 @@ public class WindowManagerService extends IWindowManager.Stub * ordinary dispatch. */ public boolean interceptKeyBeforeDispatching( InputWindowHandle focus, KeyEvent event, int policyFlags) { - WindowState windowState = (WindowState) focus.windowState; + WindowState windowState = focus != null ? (WindowState) focus.windowState : null; return mPolicy.interceptKeyBeforeDispatching(windowState, event, policyFlags); } @@ -5960,7 +6032,7 @@ public class WindowManagerService extends IWindowManager.Stub * the application did not handle. */ public KeyEvent dispatchUnhandledKey( InputWindowHandle focus, KeyEvent event, int policyFlags) { - WindowState windowState = (WindowState) focus.windowState; + WindowState windowState = focus != null ? (WindowState) focus.windowState : null; return mPolicy.dispatchUnhandledKey(windowState, event, policyFlags); } @@ -6509,6 +6581,7 @@ public class WindowManagerService extends IWindowManager.Stub // Make the surface visible at the proper location final Surface surface = mDragState.mSurface; + if (SHOW_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION performDrag"); Surface.openTransaction(); try { surface.setPosition((int)(touchX - thumbCenterX), @@ -6518,6 +6591,7 @@ public class WindowManagerService extends IWindowManager.Stub surface.show(); } finally { Surface.closeTransaction(); + if (SHOW_TRANSACTIONS) Slog.i(TAG, "<<< CLOSE TRANSACTION performDrag"); } } @@ -6840,6 +6914,10 @@ public class WindowManagerService extends IWindowManager.Stub // Is this window now (or just being) removed? boolean mRemoved; + // Temp for keeping track of windows that have been removed when + // rebuilding window list. + boolean mRebuilding; + // For debugging, this is the last information given to the surface flinger. boolean mSurfaceShown; int mSurfaceX, mSurfaceY, mSurfaceW, mSurfaceH; @@ -6892,6 +6970,7 @@ public class WindowManagerService extends IWindowManager.Stub + TYPE_LAYER_OFFSET; mSubLayer = mPolicy.subWindowTypeToLayerLw(a.type); mAttachedWindow = attachedWindow; + if (DEBUG_ADD_REMOVE) Slog.v(TAG, "Adding " + this + " to " + mAttachedWindow); mAttachedWindow.mChildWindows.add(this); mLayoutAttached = mAttrs.type != WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG; @@ -7197,9 +7276,8 @@ public class WindowManagerService extends IWindowManager.Stub + ", set left=" + mFrame.left + " top=" + mFrame.top + ", animLayer=" + mAnimLayer); if (SHOW_TRANSACTIONS) { - Slog.i(TAG, ">>> OPEN TRANSACTION"); - if (SHOW_TRANSACTIONS) logSurface(this, - "CREATE pos=(" + mFrame.left + "," + mFrame.top + ") (" + + Slog.i(TAG, ">>> OPEN TRANSACTION createSurfaceLocked"); + logSurface(this, "CREATE pos=(" + mFrame.left + "," + mFrame.top + ") (" + mFrame.width() + "x" + mFrame.height() + "), layer=" + mAnimLayer + " HIDE", null); } @@ -7224,8 +7302,8 @@ public class WindowManagerService extends IWindowManager.Stub } mLastHidden = true; } finally { - if (SHOW_TRANSACTIONS) Slog.i(TAG, "<<< CLOSE TRANSACTION"); Surface.closeTransaction(); + if (SHOW_TRANSACTIONS) Slog.i(TAG, "<<< CLOSE TRANSACTION createSurfaceLocked"); } if (localLOGV) Slog.v( TAG, "Created surface " + this); @@ -7897,6 +7975,7 @@ public class WindowManagerService extends IWindowManager.Stub disposeInputChannel(); if (mAttachedWindow != null) { + if (DEBUG_ADD_REMOVE) Slog.v(TAG, "Removing " + this + " from " + mAttachedWindow); mAttachedWindow.mChildWindows.remove(this); } destroySurfaceLocked(); @@ -9146,12 +9225,18 @@ public class WindowManagerService extends IWindowManager.Stub int lastWallpaper = -1; int numRemoved = 0; + if (mRebuildTmp.length < NW) { + mRebuildTmp = new WindowState[NW+10]; + } + // First remove all existing app windows. i=0; while (i < NW) { WindowState w = mWindows.get(i); if (w.mAppToken != null) { WindowState win = mWindows.remove(i); + win.mRebuilding = true; + mRebuildTmp[numRemoved] = win; mWindowsChanged = true; if (DEBUG_WINDOW_MOVEMENT) Slog.v(TAG, "Rebuild removing window: " + win); @@ -9189,6 +9274,21 @@ public class WindowManagerService extends IWindowManager.Stub if (i != numRemoved) { Slog.w(TAG, "Rebuild removed " + numRemoved + " windows but added " + i); + for (i=0; i<numRemoved; i++) { + WindowState ws = mRebuildTmp[i]; + if (ws.mRebuilding) { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + ws.dump(pw, ""); + pw.flush(); + Slog.w(TAG, "This window was lost: " + ws); + Slog.w(TAG, sw.toString()); + } + } + Slog.w(TAG, "Current app token list:"); + dumpAppTokensLocked(); + Slog.w(TAG, "Final window list:"); + dumpWindowsLocked(); } } @@ -9261,7 +9361,7 @@ public class WindowManagerService extends IWindowManager.Stub try { if (mForceRemoves != null) { recoveringMemory = true; - // Wait a little it for things to settle down, and off we go. + // Wait a little bit for things to settle down, and off we go. for (int i=0; i<mForceRemoves.size(); i++) { WindowState ws = mForceRemoves.get(i); Slog.i(TAG, "Force removing: " + ws); @@ -9284,14 +9384,17 @@ public class WindowManagerService extends IWindowManager.Stub try { performLayoutAndPlaceSurfacesLockedInner(recoveringMemory); - int i = mPendingRemove.size()-1; - if (i >= 0) { - while (i >= 0) { - WindowState w = mPendingRemove.get(i); - removeWindowInnerLocked(w.mSession, w); - i--; + int N = mPendingRemove.size(); + if (N > 0) { + if (mPendingRemoveTmp.length < N) { + mPendingRemoveTmp = new WindowState[N+10]; } + mPendingRemove.toArray(mPendingRemoveTmp); mPendingRemove.clear(); + for (int i=0; i<N; i++) { + WindowState w = mPendingRemoveTmp[i]; + removeWindowInnerLocked(w.mSession, w); + } mInLayout = false; assignLayersLocked(); @@ -9469,7 +9572,7 @@ public class WindowManagerService extends IWindowManager.Stub createWatermark = true; } - if (SHOW_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION"); + if (SHOW_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION performLayoutAndPlaceSurfaces"); Surface.openTransaction(); @@ -9507,7 +9610,7 @@ public class WindowManagerService extends IWindowManager.Stub } if ((changes&WindowManagerPolicy.FINISH_LAYOUT_REDO_CONFIG) != 0) { if (DEBUG_LAYOUT) Slog.v(TAG, "Computing new config from layout"); - if (updateOrientationFromAppTokensLocked()) { + if (updateOrientationFromAppTokensLocked(true)) { mLayoutNeeded = true; mH.sendEmptyMessage(H.SEND_NEW_CONFIGURATION); } @@ -9735,12 +9838,9 @@ public class WindowManagerService extends IWindowManager.Stub if (tokenMayBeDrawn) { // See if any windows have been drawn, so they (and others // associated with them) can now be shown. - final int NT = mTokenList.size(); + final int NT = mAppTokens.size(); for (i=0; i<NT; i++) { - AppWindowToken wtoken = mTokenList.get(i).appWindowToken; - if (wtoken == null) { - continue; - } + AppWindowToken wtoken = mAppTokens.get(i); if (wtoken.freezingScreen) { int numInteresting = wtoken.numInterestingWindows; if (numInteresting > 0 && wtoken.numDrawnWindows >= numInteresting) { @@ -9966,7 +10066,8 @@ public class WindowManagerService extends IWindowManager.Stub // This has changed the visibility of windows, so perform // a new layout to get them all up-to-date. - changes |= PhoneWindowManager.FINISH_LAYOUT_REDO_LAYOUT; + changes |= PhoneWindowManager.FINISH_LAYOUT_REDO_LAYOUT + | WindowManagerPolicy.FINISH_LAYOUT_REDO_CONFIG; mLayoutNeeded = true; if (!moveInputMethodWindowsIfNeededLocked(true)) { assignLayersLocked(); @@ -10192,7 +10293,7 @@ public class WindowManagerService extends IWindowManager.Stub // as running out of memory), don't take down the // entire system. Slog.e(TAG, "Failure updating surface of " + w - + "size=(" + width + "x" + height + + " size=(" + width + "x" + height + "), pos=(" + w.mShownFrame.left + "," + w.mShownFrame.top + ")", e); if (!recoveringMemory) { @@ -10543,8 +10644,6 @@ public class WindowManagerService extends IWindowManager.Stub } mBlurShown = false; } - - if (SHOW_TRANSACTIONS) Slog.i(TAG, "<<< CLOSE TRANSACTION"); } catch (RuntimeException e) { Slog.e(TAG, "Unhandled exception in Window Manager", e); } @@ -10553,6 +10652,8 @@ public class WindowManagerService extends IWindowManager.Stub Surface.closeTransaction(); + if (SHOW_TRANSACTIONS) Slog.i(TAG, "<<< CLOSE TRANSACTION performLayoutAndPlaceSurfaces"); + if (mWatermark != null) { mWatermark.drawIfNeeded(); } @@ -10642,6 +10743,8 @@ public class WindowManagerService extends IWindowManager.Stub // soon as their animations are complete token.animation = null; token.animating = false; + if (DEBUG_ADD_REMOVE || DEBUG_TOKEN_MOVEMENT) Slog.v(TAG, + "performLayout: App token exiting now removed" + token); mAppTokens.remove(token); mExitingAppTokens.remove(i); } @@ -10753,7 +10856,7 @@ public class WindowManagerService extends IWindowManager.Stub } return true; } catch (RuntimeException e) { - Slog.w(TAG, "Failure showing surface " + win.mSurface + " in " + win); + Slog.w(TAG, "Failure showing surface " + win.mSurface + " in " + win, e); } reclaimSomeSurfaceMemoryLocked(win, "show"); @@ -10788,6 +10891,7 @@ public class WindowManagerService extends IWindowManager.Stub + " token=" + win.mToken + " pid=" + ws.mSession.mPid + " uid=" + ws.mSession.mUid); + if (SHOW_TRANSACTIONS) logSurface(ws, "LEAK DESTROY", null); ws.mSurface.destroy(); ws.mSurfaceShown = false; ws.mSurface = null; @@ -10795,10 +10899,11 @@ public class WindowManagerService extends IWindowManager.Stub i--; N--; leakedSurface = true; - } else if (win.mAppToken != null && win.mAppToken.clientHidden) { + } else if (ws.mAppToken != null && ws.mAppToken.clientHidden) { Slog.w(TAG, "LEAKED SURFACE (app token hidden): " + ws + " surface=" + ws.mSurface + " token=" + win.mAppToken); + if (SHOW_TRANSACTIONS) logSurface(ws, "LEAK DESTROY", null); ws.mSurface.destroy(); ws.mSurfaceShown = false; ws.mSurface = null; @@ -10836,6 +10941,7 @@ public class WindowManagerService extends IWindowManager.Stub // surface and ask the app to request another one. Slog.w(TAG, "Looks like we have reclaimed some memory, clearing surface for retry."); if (surface != null) { + if (SHOW_TRANSACTIONS) logSurface(win, "RECOVER DESTROY", null); surface.destroy(); win.mSurfaceShown = false; win.mSurface = null; @@ -10963,7 +11069,7 @@ public class WindowManagerService extends IWindowManager.Stub return result; } - private void startFreezingDisplayLocked() { + private void startFreezingDisplayLocked(boolean inTransaction) { if (mDisplayFrozen) { return; } @@ -11005,7 +11111,7 @@ public class WindowManagerService extends IWindowManager.Stub } if (mScreenRotationAnimation == null) { mScreenRotationAnimation = new ScreenRotationAnimation(mContext, - mDisplay, mFxSession); + mDisplay, mFxSession, inTransaction); } } else { Surface.freezeDisplay(0); @@ -11046,7 +11152,7 @@ public class WindowManagerService extends IWindowManager.Stub // to avoid inconsistent states. However, something interesting // could have actually changed during that time so re-evaluate it // now to catch that. - if (updateOrientationFromAppTokensLocked()) { + if (updateOrientationFromAppTokensLocked(false)) { mH.sendEmptyMessage(H.SEND_NEW_CONFIGURATION); } @@ -11351,14 +11457,6 @@ public class WindowManagerService extends IWindowManager.Stub token.dump(pw, " "); } } - if (mTokenList.size() > 0) { - pw.println(" "); - pw.println(" Window token list:"); - for (int i=0; i<mTokenList.size(); i++) { - pw.print(" #"); pw.print(i); pw.print(": "); - pw.println(mTokenList.get(i)); - } - } if (mWallpaperTokens.size() > 0) { pw.println(" "); pw.println(" Wallpaper tokens:"); @@ -11482,6 +11580,8 @@ public class WindowManagerService extends IWindowManager.Stub } else { pw.println(" NO DISPLAY"); } + pw.println(" Policy:"); + mPolicy.dump(" ", fd, pw, args); } } diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index 761dcd1..17ef88d 100755 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -2612,6 +2612,7 @@ public final class ActivityManagerService extends ActivityManagerNative if (localLOGV) Slog.v( TAG, "Removing this entry! frozen=" + r.haveState + " finishing=" + r.finishing); + r.makeFinishing(); mMainStack.mHistory.remove(i); r.inHistory = false; @@ -6607,7 +6608,7 @@ public final class ActivityManagerService extends ActivityManagerNative if (r.state == ActivityState.RESUMED || r.state == ActivityState.PAUSING || r.state == ActivityState.PAUSED) { - if (!r.isHomeActivity) { + if (!r.isHomeActivity || mHomeProcess != r.app) { Slog.w(TAG, " Force finishing activity " + r.intent.getComponent().flattenToShortString()); r.stack.finishActivityLocked(r, index, diff --git a/services/java/com/android/server/am/ActivityRecord.java b/services/java/com/android/server/am/ActivityRecord.java index 72ea7ce..e29da1c 100644 --- a/services/java/com/android/server/am/ActivityRecord.java +++ b/services/java/com/android/server/am/ActivityRecord.java @@ -321,6 +321,15 @@ class ActivityRecord extends IApplicationToken.Stub { } } + void makeFinishing() { + if (!finishing) { + finishing = true; + if (task != null) { + task.numActivities--; + } + } + } + UriPermissionOwner getUriPermissionsLocked() { if (uriPermissions == null) { uriPermissions = new UriPermissionOwner(service, this); diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java index eee9f7e..bc00478 100644 --- a/services/java/com/android/server/am/ActivityStack.java +++ b/services/java/com/android/server/am/ActivityStack.java @@ -50,7 +50,6 @@ import android.content.res.Resources; import android.graphics.Bitmap; import android.net.Uri; import android.os.Binder; -import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Message; @@ -3071,7 +3070,7 @@ public class ActivityStack { return false; } - r.finishing = true; + r.makeFinishing(); EventLog.writeEvent(EventLogTags.AM_FINISH_ACTIVITY, System.identityHashCode(r), r.task.taskId, r.shortComponentName, reason); @@ -3276,6 +3275,7 @@ public class ActivityStack { private final void removeActivityFromHistoryLocked(ActivityRecord r) { if (r.state != ActivityState.DESTROYED) { + r.makeFinishing(); mHistory.remove(r); r.inHistory = false; r.state = ActivityState.DESTROYED; @@ -3440,6 +3440,7 @@ public class ActivityStack { ActivityRecord hr = (ActivityRecord)mHistory.get(i); if (hr.isHomeActivity) { homeTask = hr.task; + break; } } if (homeTask != null) { |