diff options
author | Craig Mautner <cmautner@google.com> | 2012-10-23 17:01:20 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2012-10-23 17:01:20 -0700 |
commit | a170dcb7b6908d0ea4dd7c2717d2d2b1da59262c (patch) | |
tree | abe77c741c3d4959b60427a00b5428c21e898c94 /core/java/android/view/WindowManagerGlobal.java | |
parent | b68a3a47eff1f61322f3f65d1f9e89753676d8e7 (diff) | |
parent | 9e96c69e3e9ebdb820acd347b4691c32a5d76be4 (diff) | |
download | frameworks_base-a170dcb7b6908d0ea4dd7c2717d2d2b1da59262c.zip frameworks_base-a170dcb7b6908d0ea4dd7c2717d2d2b1da59262c.tar.gz frameworks_base-a170dcb7b6908d0ea4dd7c2717d2d2b1da59262c.tar.bz2 |
am 9e96c69e: am 6757572b: Merge "Add throwing InvalidDisplayException from addView." into jb-mr1-dev
* commit '9e96c69e3e9ebdb820acd347b4691c32a5d76be4':
Add throwing InvalidDisplayException from addView.
Diffstat (limited to 'core/java/android/view/WindowManagerGlobal.java')
-rw-r--r-- | core/java/android/view/WindowManagerGlobal.java | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/core/java/android/view/WindowManagerGlobal.java b/core/java/android/view/WindowManagerGlobal.java index 5cdc1ed..e8945aa 100644 --- a/core/java/android/view/WindowManagerGlobal.java +++ b/core/java/android/view/WindowManagerGlobal.java @@ -186,8 +186,8 @@ public final class WindowManagerGlobal { mSystemPropertyUpdater = new Runnable() { @Override public void run() { synchronized (mLock) { - for (ViewRootImpl root : mRoots) { - root.loadSystemProperties(); + for (ViewRootImpl viewRoot : mRoots) { + viewRoot.loadSystemProperties(); } } } @@ -242,7 +242,18 @@ public final class WindowManagerGlobal { } // do this last because it fires off messages to start doing things - root.setView(view, wparams, panelParentView); + try { + root.setView(view, wparams, panelParentView); + } catch (RuntimeException e) { + // BadTokenException or InvalidDisplayException, clean up. + synchronized (mLock) { + final int index = findViewLocked(view, false); + if (index >= 0) { + removeViewLocked(index, true); + } + } + throw e; + } } public void updateViewLayout(View view, ViewGroup.LayoutParams params) { @@ -360,20 +371,18 @@ public final class WindowManagerGlobal { } private int findViewLocked(View view, boolean required) { - synchronized (mLock) { - if (mViews != null) { - final int count = mViews.length; - for (int i = 0; i < count; i++) { - if (mViews[i] == view) { - return i; - } + if (mViews != null) { + final int count = mViews.length; + for (int i = 0; i < count; i++) { + if (mViews[i] == view) { + return i; } } - if (required) { - throw new IllegalArgumentException("View not attached to window manager"); - } - return -1; } + if (required) { + throw new IllegalArgumentException("View not attached to window manager"); + } + return -1; } public void startTrimMemory(int level) { |