Merge "Add throwing InvalidDisplayException from addView." into jb-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
6757572b39
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -140,6 +140,16 @@ public class Presentation extends Dialog {
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -61,6 +61,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.
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user