summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCraig Mautner <cmautner@google.com>2012-10-23 16:53:31 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-10-23 16:53:32 -0700
commit6757572b39d3802c4d7b69467b5ebf69a96c208b (patch)
tree6ee8b0460f826dca63aaa6a3263fa17f3dcbcc71
parentc63aa9621821b3f1e32292362cce76cd1899d932 (diff)
parent6018aeec27914f138f36b00d8f00136a87562fd3 (diff)
downloadframeworks_base-6757572b39d3802c4d7b69467b5ebf69a96c208b.zip
frameworks_base-6757572b39d3802c4d7b69467b5ebf69a96c208b.tar.gz
frameworks_base-6757572b39d3802c4d7b69467b5ebf69a96c208b.tar.bz2
Merge "Add throwing InvalidDisplayException from addView." into jb-mr1-dev
-rw-r--r--api/17.txt9
-rw-r--r--api/current.txt7
-rw-r--r--core/java/android/app/Presentation.java10
-rw-r--r--core/java/android/view/ViewManager.java10
-rw-r--r--core/java/android/view/ViewRootImpl.java18
-rw-r--r--core/java/android/view/WindowManager.java13
-rw-r--r--core/java/android/view/WindowManagerGlobal.java37
7 files changed, 78 insertions, 26 deletions
diff --git a/api/17.txt b/api/17.txt
index 84c2a93..31ed755 100644
--- a/api/17.txt
+++ b/api/17.txt
@@ -7094,7 +7094,7 @@ package android.content.res {
method public int getIndexCount();
method public int getInt(int, int);
method public int getInteger(int, int);
- method public deprecated int getLayoutDimension(int, java.lang.String);
+ method public int getLayoutDimension(int, java.lang.String);
method public int getLayoutDimension(int, int);
method public java.lang.String getNonResourceString(int);
method public java.lang.String getPositionDescription();
@@ -8263,6 +8263,7 @@ package android.graphics {
method public int getScaledWidth(int);
method public final int getWidth();
method public final boolean hasAlpha();
+ method public final boolean hasMipMap();
method public final boolean isMutable();
method public final boolean isPremultiplied();
method public final boolean isRecycled();
@@ -8271,6 +8272,7 @@ package android.graphics {
method public boolean sameAs(android.graphics.Bitmap);
method public void setDensity(int);
method public void setHasAlpha(boolean);
+ method public final void setHasMipMap(boolean);
method public void setPixel(int, int, int);
method public void setPixels(int[], int, int, int, int, int, int);
method public void writeToParcel(android.os.Parcel, int);
@@ -25975,6 +25977,11 @@ package android.view {
ctor public WindowManager.BadTokenException(java.lang.String);
}
+ public static class WindowManager.InvalidDisplayException extends java.lang.RuntimeException {
+ ctor public WindowManager.InvalidDisplayException();
+ ctor public WindowManager.InvalidDisplayException(java.lang.String);
+ }
+
public static class WindowManager.LayoutParams extends android.view.ViewGroup.LayoutParams implements android.os.Parcelable {
ctor public WindowManager.LayoutParams();
ctor public WindowManager.LayoutParams(int);
diff --git a/api/current.txt b/api/current.txt
index 5462aee..31ed755 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -16151,7 +16151,7 @@ package android.os {
public class Looper {
method public void dump(android.util.Printer, java.lang.String);
- method public static synchronized android.os.Looper getMainLooper();
+ method public static android.os.Looper getMainLooper();
method public java.lang.Thread getThread();
method public static void loop();
method public static android.os.Looper myLooper();
@@ -25977,6 +25977,11 @@ package android.view {
ctor public WindowManager.BadTokenException(java.lang.String);
}
+ public static class WindowManager.InvalidDisplayException extends java.lang.RuntimeException {
+ ctor public WindowManager.InvalidDisplayException();
+ ctor public WindowManager.InvalidDisplayException(java.lang.String);
+ }
+
public static class WindowManager.LayoutParams extends android.view.ViewGroup.LayoutParams implements android.os.Parcelable {
ctor public WindowManager.LayoutParams();
ctor public WindowManager.LayoutParams(int);
diff --git a/core/java/android/app/Presentation.java b/core/java/android/app/Presentation.java
index b5e5244..20b27c5 100644
--- a/core/java/android/app/Presentation.java
+++ b/core/java/android/app/Presentation.java
@@ -141,6 +141,16 @@ public class Presentation extends Dialog {
}
/**
+ * Inherited from {@link Dialog#show}. Will throw
+ * {@link android.view.WindowManager.InvalidDisplayException} if the specified secondary
+ * {@link Display} can't be found.
+ */
+ @Override
+ public void show() {
+ super.show();
+ }
+
+ /**
* Called by the system when the {@link Display} to which the presentation
* is attached has been removed.
*
diff --git a/core/java/android/view/ViewManager.java b/core/java/android/view/ViewManager.java
index 7f318c1..ab6856f 100644
--- a/core/java/android/view/ViewManager.java
+++ b/core/java/android/view/ViewManager.java
@@ -21,6 +21,16 @@ package android.view;
*/
public interface ViewManager
{
+ /**
+ * Assign the passed LayoutParams to the passed View and add the view to the window.
+ * <p>Throws {@link android.view.WindowManager.BadTokenException} for certain programming
+ * errors, such as adding a second view to a window without removing the first view.
+ * <p>Throws {@link android.view.WindowManager.InvalidDisplayException} if the window is on a
+ * secondary {@link Display} and the specified display can't be found
+ * (see {@link android.app.Presentation}).
+ * @param view The view to be added to this window.
+ * @param params The LayoutParams to assign to view.
+ */
public void addView(View view, ViewGroup.LayoutParams params);
public void updateViewLayout(View view, ViewGroup.LayoutParams params);
public void removeView(View view);
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index cd63f07..a3360bc 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -556,7 +556,6 @@ public final class ViewRootImpl implements ViewParent,
mPendingVisibleInsets.set(0, 0, 0, 0);
if (DEBUG_LAYOUT) Log.v(TAG, "Added window " + mWindow);
if (res < WindowManagerGlobal.ADD_OKAY) {
- mView = null;
mAttachInfo.mRootView = null;
mAdded = false;
mFallbackEventHandler.setView(null);
@@ -592,6 +591,10 @@ public final class ViewRootImpl implements ViewParent,
throw new WindowManager.BadTokenException(
"Unable to add window " + mWindow +
" -- permission denied for this window type");
+ case WindowManagerGlobal.ADD_INVALID_DISPLAY:
+ throw new WindowManager.InvalidDisplayException(
+ "Unable to add window " + mWindow +
+ " -- the specified display can not be found");
}
throw new RuntimeException(
"Unable to add window -- unknown error code " + res);
@@ -808,27 +811,21 @@ public final class ViewRootImpl implements ViewParent,
}
}
- /**
- * {@inheritDoc}
- */
+ @Override
public void requestFitSystemWindows() {
checkThread();
mFitSystemWindowsRequested = true;
scheduleTraversals();
}
- /**
- * {@inheritDoc}
- */
+ @Override
public void requestLayout() {
checkThread();
mLayoutRequested = true;
scheduleTraversals();
}
- /**
- * {@inheritDoc}
- */
+ @Override
public boolean isLayoutRequested() {
return mLayoutRequested;
}
@@ -848,6 +845,7 @@ public final class ViewRootImpl implements ViewParent,
}
}
+ @Override
public void invalidateChild(View child, Rect dirty) {
invalidateChildInParent(null, dirty);
}
diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java
index 4c97414..01923e2 100644
--- a/core/java/android/view/WindowManager.java
+++ b/core/java/android/view/WindowManager.java
@@ -62,6 +62,19 @@ public interface WindowManager extends ViewManager {
}
/**
+ * Exception that is thrown when calling {@link #addView} to a secondary display that cannot
+ * be found. See {@link android.app.Presentation} for more information on secondary displays.
+ */
+ public static class InvalidDisplayException extends RuntimeException {
+ public InvalidDisplayException() {
+ }
+
+ public InvalidDisplayException(String name) {
+ super(name);
+ }
+ }
+
+ /**
* Returns the {@link Display} upon which this {@link WindowManager} instance
* will create new windows.
* <p>
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) {