summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Murashkin <iam@google.com>2013-09-11 18:27:59 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-09-11 18:28:07 +0000
commit2cad64c0fbeba07bb546674e19cfb0166d7ec332 (patch)
tree7ec5d5625c648ea459f4c4ec17917dae633e26f2
parent444ae3a2e66b4404fa715ab46403da09079dd572 (diff)
parenta86ab640f7bb0bf3cb4eaed80473ca8c5d131903 (diff)
downloadframeworks_base-2cad64c0fbeba07bb546674e19cfb0166d7ec332.zip
frameworks_base-2cad64c0fbeba07bb546674e19cfb0166d7ec332.tar.gz
frameworks_base-2cad64c0fbeba07bb546674e19cfb0166d7ec332.tar.bz2
Merge "Surface: Change OutOfResourcesException to be a runtime exception" into klp-dev
-rw-r--r--api/current.txt4
-rw-r--r--core/java/android/view/HardwareRenderer.java114
-rw-r--r--core/java/android/view/Surface.java23
-rw-r--r--core/java/android/view/SurfaceControl.java16
-rw-r--r--core/java/android/view/SurfaceView.java94
-rw-r--r--core/java/android/view/ViewRootImpl.java117
-rw-r--r--core/jni/android/graphics/SurfaceTexture.cpp2
-rw-r--r--graphics/java/android/graphics/SurfaceTexture.java21
-rw-r--r--services/java/com/android/server/power/ElectronBeam.java7
-rw-r--r--services/java/com/android/server/wm/BlackFrame.java5
-rw-r--r--services/java/com/android/server/wm/DisplayMagnifier.java6
-rw-r--r--services/java/com/android/server/wm/FocusedStackFrame.java9
-rw-r--r--services/java/com/android/server/wm/ScreenRotationAnimation.java11
-rw-r--r--services/java/com/android/server/wm/StrictModeFlash.java3
-rw-r--r--services/java/com/android/server/wm/Watermark.java8
-rw-r--r--services/java/com/android/server/wm/WindowManagerService.java15
-rw-r--r--services/java/com/android/server/wm/WindowStateAnimator.java5
17 files changed, 269 insertions, 191 deletions
diff --git a/api/current.txt b/api/current.txt
index 9d3dd0f..5cc7176 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -9919,7 +9919,7 @@ package android.graphics {
method public abstract void onFrameAvailable(android.graphics.SurfaceTexture);
}
- public static class SurfaceTexture.OutOfResourcesException extends java.lang.Exception {
+ public static deprecated class SurfaceTexture.OutOfResourcesException extends java.lang.Exception {
ctor public SurfaceTexture.OutOfResourcesException();
ctor public SurfaceTexture.OutOfResourcesException(java.lang.String);
}
@@ -27304,7 +27304,7 @@ package android.view {
field public static final int ROTATION_90 = 1; // 0x1
}
- public static class Surface.OutOfResourcesException extends java.lang.Exception {
+ public static class Surface.OutOfResourcesException extends java.lang.RuntimeException {
ctor public Surface.OutOfResourcesException();
ctor public Surface.OutOfResourcesException(java.lang.String);
}
diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java
index ba64f6b..f215189 100644
--- a/core/java/android/view/HardwareRenderer.java
+++ b/core/java/android/view/HardwareRenderer.java
@@ -34,6 +34,8 @@ import android.os.SystemProperties;
import android.os.Trace;
import android.util.DisplayMetrics;
import android.util.Log;
+import android.view.Surface.OutOfResourcesException;
+
import com.google.android.gles_jni.EGLImpl;
import javax.microedition.khronos.egl.EGL10;
@@ -74,7 +76,7 @@ public abstract class HardwareRenderer {
* System property used to enable or disable dirty regions invalidation.
* This property is only queried if {@link #RENDER_DIRTY_REGIONS} is true.
* The default value of this property is assumed to be true.
- *
+ *
* Possible values:
* "true", to enable partial invalidates
* "false", to disable partial invalidates
@@ -134,7 +136,7 @@ public abstract class HardwareRenderer {
/**
* System property used to debug EGL configuration choice.
- *
+ *
* Possible values:
* "choice", print the chosen configuration only
* "all", print all possible configurations
@@ -147,7 +149,7 @@ public abstract class HardwareRenderer {
* Possible values:
* "true", to enable dirty regions debugging
* "false", to disable dirty regions debugging
- *
+ *
* @hide
*/
public static final String DEBUG_DIRTY_REGIONS_PROPERTY = "debug.hwui.show_dirty_regions";
@@ -208,14 +210,14 @@ public abstract class HardwareRenderer {
/**
* A process can set this flag to false to prevent the use of hardware
* rendering.
- *
+ *
* @hide
*/
public static boolean sRendererDisabled = false;
/**
* Further hardware renderer disabling for the system process.
- *
+ *
* @hide
*/
public static boolean sSystemRendererDisabled = false;
@@ -235,7 +237,7 @@ public abstract class HardwareRenderer {
/**
* Invoke this method to disable hardware rendering in the current process.
- *
+ *
* @hide
*/
public static void disable(boolean system) {
@@ -248,7 +250,7 @@ public abstract class HardwareRenderer {
/**
* Indicates whether hardware acceleration is available under any form for
* the view hierarchy.
- *
+ *
* @return True if the view hierarchy can potentially be hardware accelerated,
* false otherwise
*/
@@ -258,30 +260,30 @@ public abstract class HardwareRenderer {
/**
* Destroys the hardware rendering context.
- *
+ *
* @param full If true, destroys all associated resources.
*/
abstract void destroy(boolean full);
/**
* Initializes the hardware renderer for the specified surface.
- *
+ *
* @param surface The surface to hardware accelerate
- *
+ *
* @return True if the initialization was successful, false otherwise.
*/
- abstract boolean initialize(Surface surface) throws Surface.OutOfResourcesException;
-
+ abstract boolean initialize(Surface surface) throws OutOfResourcesException;
+
/**
* Updates the hardware renderer for the specified surface.
*
* @param surface The surface to hardware accelerate
*/
- abstract void updateSurface(Surface surface) throws Surface.OutOfResourcesException;
+ abstract void updateSurface(Surface surface) throws OutOfResourcesException;
/**
* Destroys the layers used by the specified view hierarchy.
- *
+ *
* @param view The root of the view hierarchy
*/
abstract void destroyLayers(View view);
@@ -289,11 +291,11 @@ public abstract class HardwareRenderer {
/**
* Destroys all hardware rendering resources associated with the specified
* view hierarchy.
- *
+ *
* @param view The root of the view hierarchy
*/
abstract void destroyHardwareResources(View view);
-
+
/**
* This method should be invoked whenever the current hardware renderer
* context should be reset.
@@ -306,7 +308,7 @@ public abstract class HardwareRenderer {
* This method should be invoked to ensure the hardware renderer is in
* valid state (for instance, to ensure the correct EGL context is bound
* to the current thread.)
- *
+ *
* @return true if the renderer is now valid, false otherwise
*/
abstract boolean validate();
@@ -314,7 +316,7 @@ public abstract class HardwareRenderer {
/**
* This method ensures the hardware renderer is in a valid state
* before executing the specified action.
- *
+ *
* This method will attempt to set a valid state even if the window
* the renderer is attached to was destroyed.
*
@@ -325,7 +327,7 @@ public abstract class HardwareRenderer {
/**
* Setup the hardware renderer for drawing. This is called whenever the
* size of the target surface changes or when the surface is first created.
- *
+ *
* @param width Width of the drawing surface.
* @param height Height of the drawing surface.
*/
@@ -384,7 +386,7 @@ public abstract class HardwareRenderer {
/**
* Sets the directory to use as a persistent storage for hardware rendering
* resources.
- *
+ *
* @param cacheDir A directory the current process can write to
*
* @hide
@@ -447,7 +449,7 @@ public abstract class HardwareRenderer {
/**
* Indicates that the specified hardware layer needs to be updated
* as soon as possible.
- *
+ *
* @param layer The hardware layer that needs an update
*
* @see #flushLayerUpdates()
@@ -481,7 +483,7 @@ public abstract class HardwareRenderer {
* Invoked before a view is drawn by a hardware renderer.
* This method can be used to apply transformations to the
* canvas but no drawing command should be issued.
- *
+ *
* @param canvas The Canvas used to render the view.
*/
void onHardwarePreDraw(HardwareCanvas canvas);
@@ -489,7 +491,7 @@ public abstract class HardwareRenderer {
/**
* Invoked after a view is drawn by a hardware renderer.
* It is safe to invoke drawing commands from this method.
- *
+ *
* @param canvas The Canvas used to render the view.
*/
void onHardwarePostDraw(HardwareCanvas canvas);
@@ -509,9 +511,9 @@ public abstract class HardwareRenderer {
/**
* Creates a new display list that can be used to record batches of
* drawing operations.
- *
+ *
* @param name The name of the display list, used for debugging purpose. May be null.
- *
+ *
* @return A new display list.
*
* @hide
@@ -521,20 +523,20 @@ public abstract class HardwareRenderer {
/**
* Creates a new hardware layer. A hardware layer built by calling this
* method will be treated as a texture layer, instead of as a render target.
- *
+ *
* @param isOpaque Whether the layer should be opaque or not
- *
+ *
* @return A hardware layer
*/
abstract HardwareLayer createHardwareLayer(boolean isOpaque);
/**
* Creates a new hardware layer.
- *
+ *
* @param width The minimum width of the layer
* @param height The minimum height of the layer
* @param isOpaque Whether the layer should be opaque or not
- *
+ *
* @return A hardware layer
*/
abstract HardwareLayer createHardwareLayer(int width, int height, boolean isOpaque);
@@ -544,7 +546,7 @@ public abstract class HardwareRenderer {
* specified hardware layer.
*
* @param layer The layer to render into using a {@link android.graphics.SurfaceTexture}
- *
+ *
* @return A {@link SurfaceTexture}
*/
abstract SurfaceTexture createSurfaceTexture(HardwareLayer layer);
@@ -560,11 +562,11 @@ public abstract class HardwareRenderer {
/**
* Detaches the specified functor from the current functor execution queue.
- *
+ *
* @param functor The native functor to remove from the execution queue.
- *
- * @see HardwareCanvas#callDrawGLFunction(int)
- * @see #attachFunctor(android.view.View.AttachInfo, int)
+ *
+ * @see HardwareCanvas#callDrawGLFunction(int)
+ * @see #attachFunctor(android.view.View.AttachInfo, int)
*/
abstract void detachFunctor(int functor);
@@ -591,12 +593,12 @@ public abstract class HardwareRenderer {
* @param width The width of the drawing surface.
* @param height The height of the drawing surface.
* @param surface The surface to hardware accelerate
- *
+ *
* @return true if the surface was initialized, false otherwise. Returning
* false might mean that the surface was already initialized.
*/
boolean initializeIfNeeded(int width, int height, Surface surface)
- throws Surface.OutOfResourcesException {
+ throws OutOfResourcesException {
if (isRequested()) {
// We lost the gl context, so recreate it.
if (!isEnabled()) {
@@ -618,10 +620,10 @@ public abstract class HardwareRenderer {
/**
* Creates a hardware renderer using OpenGL.
- *
+ *
* @param glVersion The version of OpenGL to use (1 for OpenGL 1, 11 for OpenGL 1.1, etc.)
* @param translucent True if the surface is translucent, false otherwise
- *
+ *
* @return A hardware renderer backed by OpenGL.
*/
static HardwareRenderer createGlRenderer(int glVersion, boolean translucent) {
@@ -636,7 +638,7 @@ public abstract class HardwareRenderer {
* Invoke this method when the system is running out of memory. This
* method will attempt to recover as much memory as possible, based on
* the specified hint.
- *
+ *
* @param level Hint about the amount of memory that should be trimmed,
* see {@link android.content.ComponentCallbacks}
*/
@@ -649,7 +651,7 @@ public abstract class HardwareRenderer {
* Starts the process of trimming memory. Usually this call will setup
* hardware rendering context and reclaim memory.Extra cleanup might
* be required by calling {@link #endTrimMemory()}.
- *
+ *
* @param level Hint about the amount of memory that should be trimmed,
* see {@link android.content.ComponentCallbacks}
*/
@@ -667,7 +669,7 @@ public abstract class HardwareRenderer {
/**
* Indicates whether hardware acceleration is currently enabled.
- *
+ *
* @return True if hardware acceleration is in use, false otherwise.
*/
boolean isEnabled() {
@@ -676,7 +678,7 @@ public abstract class HardwareRenderer {
/**
* Indicates whether hardware acceleration is currently enabled.
- *
+ *
* @param enabled True if the hardware renderer is in use, false otherwise.
*/
void setEnabled(boolean enabled) {
@@ -686,7 +688,7 @@ public abstract class HardwareRenderer {
/**
* Indicates whether hardware acceleration is currently request but not
* necessarily enabled yet.
- *
+ *
* @return True if requested, false otherwise.
*/
boolean isRequested() {
@@ -696,7 +698,7 @@ public abstract class HardwareRenderer {
/**
* Indicates whether hardware acceleration is currently requested but not
* necessarily enabled yet.
- *
+ *
* @return True to request hardware acceleration, false otherwise.
*/
void setRequested(boolean requested) {
@@ -837,7 +839,7 @@ public abstract class HardwareRenderer {
Thread mEglThread;
EGLSurface mEglSurface;
-
+
GL mGl;
HardwareCanvas mCanvas;
@@ -1050,7 +1052,7 @@ public abstract class HardwareRenderer {
}
@Override
- boolean initialize(Surface surface) throws Surface.OutOfResourcesException {
+ boolean initialize(Surface surface) throws OutOfResourcesException {
if (isRequested() && !isEnabled()) {
boolean contextCreated = initializeEgl();
mGl = createEglSurface(surface);
@@ -1078,9 +1080,9 @@ public abstract class HardwareRenderer {
}
return false;
}
-
+
@Override
- void updateSurface(Surface surface) throws Surface.OutOfResourcesException {
+ void updateSurface(Surface surface) throws OutOfResourcesException {
if (isRequested() && isEnabled()) {
createEglSurface(surface);
}
@@ -1094,15 +1096,15 @@ public abstract class HardwareRenderer {
synchronized (sEglLock) {
if (sEgl == null && sEglConfig == null) {
sEgl = (EGL10) EGLContext.getEGL();
-
+
// Get to the default display.
sEglDisplay = sEgl.eglGetDisplay(EGL_DEFAULT_DISPLAY);
-
+
if (sEglDisplay == EGL_NO_DISPLAY) {
throw new RuntimeException("eglGetDisplay failed "
+ GLUtils.getEGLErrorString(sEgl.eglGetError()));
}
-
+
// We can now initialize EGL for that display
int[] version = new int[2];
if (!sEgl.eglInitialize(sEglDisplay, version)) {
@@ -1216,7 +1218,7 @@ public abstract class HardwareRenderer {
Log.d(LOG_TAG, " CONFIG_CAVEAT = 0x" + Integer.toHexString(value[0]));
}
- GL createEglSurface(Surface surface) throws Surface.OutOfResourcesException {
+ GL createEglSurface(Surface surface) throws OutOfResourcesException {
// Check preconditions.
if (sEgl == null) {
throw new RuntimeException("egl not initialized");
@@ -1228,7 +1230,7 @@ public abstract class HardwareRenderer {
throw new RuntimeException("eglConfig not initialized");
}
if (Thread.currentThread() != mEglThread) {
- throw new IllegalStateException("HardwareRenderer cannot be used "
+ throw new IllegalStateException("HardwareRenderer cannot be used "
+ "from multiple threads");
}
@@ -1394,8 +1396,8 @@ public abstract class HardwareRenderer {
boolean canDraw() {
return mGl != null && mCanvas != null;
- }
-
+ }
+
int onPreDraw(Rect dirty) {
return DisplayList.STATUS_DONE;
}
@@ -1732,7 +1734,7 @@ public abstract class HardwareRenderer {
* Ensures the current EGL context and surface are the ones we expect.
* This method throws an IllegalStateException if invoked from a thread
* that did not initialize EGL.
- *
+ *
* @return {@link #SURFACE_STATE_ERROR} if the correct EGL context cannot be made current,
* {@link #SURFACE_STATE_UPDATED} if the EGL context was changed or
* {@link #SURFACE_STATE_SUCCESS} if the EGL context was the correct one
diff --git a/core/java/android/view/Surface.java b/core/java/android/view/Surface.java
index 409db84..1bfda2d 100644
--- a/core/java/android/view/Surface.java
+++ b/core/java/android/view/Surface.java
@@ -116,6 +116,7 @@ public class Surface implements Parcelable {
*
* @param surfaceTexture The {@link SurfaceTexture} that is updated by this
* Surface.
+ * @throws OutOfResourcesException if the surface could not be created.
*/
public Surface(SurfaceTexture surfaceTexture) {
if (surfaceTexture == null) {
@@ -124,12 +125,7 @@ public class Surface implements Parcelable {
synchronized (mLock) {
mName = surfaceTexture.toString();
- try {
- setNativeObjectLocked(nativeCreateFromSurfaceTexture(surfaceTexture));
- } catch (OutOfResourcesException ex) {
- // We can't throw OutOfResourcesException because it would be an API change.
- throw new RuntimeException(ex);
- }
+ setNativeObjectLocked(nativeCreateFromSurfaceTexture(surfaceTexture));
}
}
@@ -229,9 +225,12 @@ public class Surface implements Parcelable {
* The caller may also pass <code>null</code> instead, in the case where the
* entire surface should be redrawn.
* @return A canvas for drawing into the surface.
+ *
+ * @throws IllegalArgumentException If the inOutDirty rectangle is not valid.
+ * @throws OutOfResourcesException If the canvas cannot be locked.
*/
public Canvas lockCanvas(Rect inOutDirty)
- throws OutOfResourcesException, IllegalArgumentException {
+ throws Surface.OutOfResourcesException, IllegalArgumentException {
synchronized (mLock) {
checkNotReleasedLocked();
if (mLockedObject != 0) {
@@ -239,7 +238,7 @@ public class Surface implements Parcelable {
// double-lock, but that won't happen if mNativeObject was updated. We can't
// abandon the old mLockedObject because it might still be in use, so instead
// we just refuse to re-lock the Surface.
- throw new RuntimeException("Surface was already locked");
+ throw new IllegalStateException("Surface was already locked");
}
mLockedObject = nativeLockCanvas(mNativeObject, mCanvas, inOutDirty);
return mCanvas;
@@ -266,7 +265,7 @@ public class Surface implements Parcelable {
Integer.toHexString(mLockedObject) +")");
}
if (mLockedObject == 0) {
- throw new RuntimeException("Surface was not locked");
+ throw new IllegalStateException("Surface was not locked");
}
nativeUnlockCanvasAndPost(mLockedObject, canvas);
nativeRelease(mLockedObject);
@@ -411,9 +410,11 @@ public class Surface implements Parcelable {
}
/**
- * Exception thrown when a surface couldn't be created or resized.
+ * Exception thrown when a Canvas couldn't be locked with {@link Surface#lockCanvas}, or
+ * when a SurfaceTexture could not successfully be allocated.
*/
- public static class OutOfResourcesException extends Exception {
+ @SuppressWarnings("serial")
+ public static class OutOfResourcesException extends RuntimeException {
public OutOfResourcesException() {
}
public OutOfResourcesException(String name) {
diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java
index dc31e0b..b22d5cf 100644
--- a/core/java/android/view/SurfaceControl.java
+++ b/core/java/android/view/SurfaceControl.java
@@ -24,6 +24,7 @@ import android.view.Surface;
import android.os.IBinder;
import android.os.SystemProperties;
import android.util.Log;
+import android.view.Surface.OutOfResourcesException;
/**
* SurfaceControl
@@ -75,23 +76,12 @@ public class SurfaceControl {
private final CloseGuard mCloseGuard = CloseGuard.get();
- private String mName;
+ private final String mName;
int mNativeObject; // package visibility only for Surface.java access
private static final boolean HEADLESS = "1".equals(
SystemProperties.get("ro.config.headless", "0"));
- /**
- * Exception thrown when a surface couldn't be created or resized.
- */
- public static class OutOfResourcesException extends Exception {
- public OutOfResourcesException() {
- }
- public OutOfResourcesException(String name) {
- super(name);
- }
- }
-
/* flags used in constructor (keep in sync with ISurfaceComposerClient.h) */
/**
@@ -220,6 +210,8 @@ public class SurfaceControl {
* @param h The surface initial height.
* @param flags The surface creation flags. Should always include {@link #HIDDEN}
* in the creation flags.
+ *
+ * @throws throws OutOfResourcesException If the SurfaceControl cannot be created.
*/
public SurfaceControl(SurfaceSession session,
String name, int w, int h, int format, int flags)
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java
index 8b2b556..1e4b29f 100644
--- a/core/java/android/view/SurfaceView.java
+++ b/core/java/android/view/SurfaceView.java
@@ -43,7 +43,7 @@ import java.util.concurrent.locks.ReentrantLock;
* You can control the format of this surface and, if you like, its size; the
* SurfaceView takes care of placing the surface at the correct location on the
* screen
- *
+ *
* <p>The surface is Z ordered so that it is behind the window holding its
* SurfaceView; the SurfaceView punches a hole in its window to allow its
* surface to be displayed. The view hierarchy will take care of correctly
@@ -52,7 +52,7 @@ import java.util.concurrent.locks.ReentrantLock;
* buttons on top of the Surface, though note however that it can have an
* impact on performance since a full alpha-blended composite will be performed
* each time the Surface changes.
- *
+ *
* <p> The transparent region that makes the surface visible is based on the
* layout positions in the view hierarchy. If the post-layout transform
* properties are used to draw a sibling view on top of the SurfaceView, the
@@ -60,16 +60,16 @@ import java.util.concurrent.locks.ReentrantLock;
*
* <p>Access to the underlying surface is provided via the SurfaceHolder interface,
* which can be retrieved by calling {@link #getHolder}.
- *
+ *
* <p>The Surface will be created for you while the SurfaceView's window is
* visible; you should implement {@link SurfaceHolder.Callback#surfaceCreated}
* and {@link SurfaceHolder.Callback#surfaceDestroyed} to discover when the
* Surface is created and destroyed as the window is shown and hidden.
- *
+ *
* <p>One of the purposes of this class is to provide a surface in which a
* secondary thread can render into the screen. If you are going to use it
* this way, you need to be aware of some threading semantics:
- *
+ *
* <ul>
* <li> All SurfaceView and
* {@link SurfaceHolder.Callback SurfaceHolder.Callback} methods will be called
@@ -91,7 +91,7 @@ public class SurfaceView extends View {
= new ArrayList<SurfaceHolder.Callback>();
final int[] mLocation = new int[2];
-
+
final ReentrantLock mSurfaceLock = new ReentrantLock();
final Surface mSurface = new Surface(); // Current surface in use
final Surface mNewSurface = new Surface(); // New surface we are switching to
@@ -106,13 +106,13 @@ public class SurfaceView extends View {
final Rect mOverscanInsets = new Rect();
final Rect mContentInsets = new Rect();
final Configuration mConfiguration = new Configuration();
-
+
static final int KEEP_SCREEN_ON_MSG = 1;
static final int GET_NEW_SURFACE_MSG = 2;
static final int UPDATE_WINDOW_MSG = 3;
-
+
int mWindowType = WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA;
-
+
boolean mIsCreating = false;
final Handler mHandler = new Handler() {
@@ -131,14 +131,15 @@ public class SurfaceView extends View {
}
}
};
-
+
final ViewTreeObserver.OnScrollChangedListener mScrollChangedListener
= new ViewTreeObserver.OnScrollChangedListener() {
+ @Override
public void onScrollChanged() {
updateWindow(false, false);
}
};
-
+
boolean mRequestedVisible = false;
boolean mWindowVisibility = false;
boolean mViewVisibility = false;
@@ -152,7 +153,7 @@ public class SurfaceView extends View {
boolean mHaveFrame = false;
boolean mSurfaceCreated = false;
long mLastLockTime = 0;
-
+
boolean mVisible = false;
int mLeft = -1;
int mTop = -1;
@@ -169,7 +170,7 @@ public class SurfaceView extends View {
new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
- // reposition ourselves where the surface is
+ // reposition ourselves where the surface is
mHaveFrame = getWidth() > 0 && getHeight() > 0;
updateWindow(false, false);
return true;
@@ -181,7 +182,7 @@ public class SurfaceView extends View {
super(context);
init();
}
-
+
public SurfaceView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
@@ -195,11 +196,11 @@ public class SurfaceView extends View {
private void init() {
setWillNotDraw(true);
}
-
+
/**
* Return the SurfaceHolder providing access and control over this
* SurfaceView's underlying surface.
- *
+ *
* @return SurfaceHolder The holder of the surface.
*/
public SurfaceHolder getHolder() {
@@ -285,7 +286,7 @@ public class SurfaceView extends View {
: getDefaultSize(0, heightMeasureSpec);
setMeasuredDimension(width, height);
}
-
+
/** @hide */
@Override
protected boolean setFrame(int left, int top, int right, int bottom) {
@@ -299,7 +300,7 @@ public class SurfaceView extends View {
if (mWindowType == WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) {
return super.gatherTransparentRegion(region);
}
-
+
boolean opaque = true;
if ((mPrivateFlags & PFLAG_SKIP_DRAW) == 0) {
// this view draws, remove it from the transparent region
@@ -350,10 +351,10 @@ public class SurfaceView extends View {
* regular surface view in the window (but still behind the window itself).
* This is typically used to place overlays on top of an underlying media
* surface view.
- *
+ *
* <p>Note that this must be set before the surface view's containing
* window is attached to the window manager.
- *
+ *
* <p>Calling this overrides any previous call to {@link #setZOrderOnTop}.
*/
public void setZOrderMediaOverlay(boolean isMediaOverlay) {
@@ -361,7 +362,7 @@ public class SurfaceView extends View {
? WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY
: WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA;
}
-
+
/**
* Control whether the surface view's surface is placed on top of its
* window. Normally it is placed behind the window, to allow it to
@@ -369,10 +370,10 @@ public class SurfaceView extends View {
* hierarchy. By setting this, you cause it to be placed above the
* window. This means that none of the contents of the window this
* SurfaceView is in will be visible on top of its surface.
- *
+ *
* <p>Note that this must be set before the surface view's containing
* window is attached to the window manager.
- *
+ *
* <p>Calling this overrides any previous call to {@link #setZOrderMediaOverlay}.
*/
public void setZOrderOnTop(boolean onTop) {
@@ -427,7 +428,7 @@ public class SurfaceView extends View {
if (mTranslator != null) {
mSurface.setCompatibilityTranslator(mTranslator);
}
-
+
int myWidth = mRequestedWidth;
if (myWidth <= 0) myWidth = getWidth();
int myHeight = mRequestedHeight;
@@ -458,7 +459,7 @@ public class SurfaceView extends View {
mFormat = mRequestedFormat;
// Scaling/Translate window's layout here because mLayout is not used elsewhere.
-
+
// Places the window relative
mLayout.x = mLeft;
mLayout.y = mTop;
@@ -467,7 +468,7 @@ public class SurfaceView extends View {
if (mTranslator != null) {
mTranslator.translateLayoutParamsInAppWindowToScreen(mLayout);
}
-
+
mLayout.format = mRequestedFormat;
mLayout.flags |=WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
@@ -489,7 +490,7 @@ public class SurfaceView extends View {
mSession.addToDisplayWithoutInputChannel(mWindow, mWindow.mSeq, mLayout,
mVisible ? VISIBLE : GONE, display.getDisplayId(), mContentInsets);
}
-
+
boolean realSizeChanged;
boolean reportDrawNeeded;
@@ -501,7 +502,7 @@ public class SurfaceView extends View {
reportDrawNeeded = mReportDrawNeeded;
mReportDrawNeeded = false;
mDrawingStopped = !visible;
-
+
if (DEBUG) Log.i(TAG, "Cur surface: " + mSurface);
relayoutResult = mSession.relayout(
@@ -527,7 +528,7 @@ public class SurfaceView extends View {
mSurfaceFrame.right = (int) (mWinFrame.width() * appInvertedScale + 0.5f);
mSurfaceFrame.bottom = (int) (mWinFrame.height() * appInvertedScale + 0.5f);
}
-
+
final int surfaceWidth = mSurfaceFrame.right;
final int surfaceHeight = mSurfaceFrame.bottom;
realSizeChanged = mLastSurfaceWidth != surfaceWidth
@@ -667,10 +668,12 @@ public class SurfaceView extends View {
}
}
+ @Override
public void dispatchAppVisibility(boolean visible) {
// The point of SurfaceView is to let the app control the surface.
}
+ @Override
public void dispatchGetNewSurface() {
SurfaceView surfaceView = mSurfaceView.get();
if (surfaceView != null) {
@@ -679,10 +682,12 @@ public class SurfaceView extends View {
}
}
+ @Override
public void windowFocusChanged(boolean hasFocus, boolean touchEnabled) {
Log.w("SurfaceView", "Unexpected focus in surface: focus=" + hasFocus + ", touchEnabled=" + touchEnabled);
}
+ @Override
public void executeCommand(String command, String parameters, ParcelFileDescriptor out) {
}
@@ -690,30 +695,34 @@ public class SurfaceView extends View {
int mCurHeight = -1;
}
- private SurfaceHolder mSurfaceHolder = new SurfaceHolder() {
-
+ private final SurfaceHolder mSurfaceHolder = new SurfaceHolder() {
+
private static final String LOG_TAG = "SurfaceHolder";
-
+
+ @Override
public boolean isCreating() {
return mIsCreating;
}
+ @Override
public void addCallback(Callback callback) {
synchronized (mCallbacks) {
- // This is a linear search, but in practice we'll
+ // This is a linear search, but in practice we'll
// have only a couple callbacks, so it doesn't matter.
- if (mCallbacks.contains(callback) == false) {
+ if (mCallbacks.contains(callback) == false) {
mCallbacks.add(callback);
}
}
}
+ @Override
public void removeCallback(Callback callback) {
synchronized (mCallbacks) {
mCallbacks.remove(callback);
}
}
-
+
+ @Override
public void setFixedSize(int width, int height) {
if (mRequestedWidth != width || mRequestedHeight != height) {
mRequestedWidth = width;
@@ -722,6 +731,7 @@ public class SurfaceView extends View {
}
}
+ @Override
public void setSizeFromLayout() {
if (mRequestedWidth != -1 || mRequestedHeight != -1) {
mRequestedWidth = mRequestedHeight = -1;
@@ -729,6 +739,7 @@ public class SurfaceView extends View {
}
}
+ @Override
public void setFormat(int format) {
// for backward compatibility reason, OPAQUE always
@@ -745,15 +756,17 @@ public class SurfaceView extends View {
/**
* @deprecated setType is now ignored.
*/
+ @Override
@Deprecated
public void setType(int type) { }
+ @Override
public void setKeepScreenOn(boolean screenOn) {
Message msg = mHandler.obtainMessage(KEEP_SCREEN_ON_MSG);
msg.arg1 = screenOn ? 1 : 0;
mHandler.sendMessage(msg);
}
-
+
/**
* Gets a {@link Canvas} for drawing into the SurfaceView's Surface
*
@@ -763,6 +776,7 @@ public class SurfaceView extends View {
* The caller must redraw the entire surface.
* @return A canvas for drawing into the surface.
*/
+ @Override
public Canvas lockCanvas() {
return internalLockCanvas(null);
}
@@ -782,6 +796,7 @@ public class SurfaceView extends View {
* entire surface should be redrawn.
* @return A canvas for drawing into the surface.
*/
+ @Override
public Canvas lockCanvas(Rect inOutDirty) {
return internalLockCanvas(inOutDirty);
}
@@ -806,7 +821,7 @@ public class SurfaceView extends View {
mLastLockTime = SystemClock.uptimeMillis();
return c;
}
-
+
// If the Surface is not ready to be drawn, then return null,
// but throttle calls to this function so it isn't called more
// than every 100ms.
@@ -821,7 +836,7 @@ public class SurfaceView extends View {
}
mLastLockTime = now;
mSurfaceLock.unlock();
-
+
return null;
}
@@ -831,15 +846,18 @@ public class SurfaceView extends View {
*
* @param canvas The canvas previously obtained from {@link #lockCanvas}.
*/
+ @Override
public void unlockCanvasAndPost(Canvas canvas) {
mSurface.unlockCanvasAndPost(canvas);
mSurfaceLock.unlock();
}
+ @Override
public Surface getSurface() {
return mSurface;
}
+ @Override
public Rect getSurfaceFrame() {
return mSurfaceFrame;
}
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index c7d61eb..50d5d45 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -68,6 +68,7 @@ import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.Interpolator;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager;
+import android.view.Surface.OutOfResourcesException;
import android.widget.Scroller;
import com.android.internal.R;
@@ -187,7 +188,7 @@ public final class ViewRootImpl implements ViewParent,
InputQueue mInputQueue;
FallbackEventHandler mFallbackEventHandler;
Choreographer mChoreographer;
-
+
final Rect mTempRect; // used in the transaction to not thrash the heap.
final Rect mVisRect; // used to retrieve visible rect of focused view.
@@ -278,8 +279,8 @@ public final class ViewRootImpl implements ViewParent,
volatile Object mLocalDragState;
final PointF mDragPoint = new PointF();
final PointF mLastTouchPoint = new PointF();
-
- private boolean mProfileRendering;
+
+ private boolean mProfileRendering;
private Choreographer.FrameCallback mRenderProfiler;
private boolean mRenderProfilingEnabled;
@@ -291,7 +292,7 @@ public final class ViewRootImpl implements ViewParent,
private int mFpsNumFrames;
private final ArrayList<DisplayList> mDisplayLists = new ArrayList<DisplayList>();
-
+
/**
* see {@link #playSoundEffect(int)}
*/
@@ -332,7 +333,7 @@ public final class ViewRootImpl implements ViewParent,
int localValue;
int localChanges;
}
-
+
public ViewRootImpl(Context context, Display display) {
mContext = context;
mWindowSession = WindowManagerGlobal.getWindowSession();
@@ -383,13 +384,13 @@ public final class ViewRootImpl implements ViewParent,
}
}
}
-
+
public static void addConfigCallback(ComponentCallbacks callback) {
synchronized (sConfigCallbacks) {
sConfigCallbacks.add(callback);
}
}
-
+
// FIXME for perf testing only
private boolean mProfile = false;
@@ -514,7 +515,7 @@ public final class ViewRootImpl implements ViewParent,
attrs.restore();
}
}
-
+
if (mTranslator != null) {
mTranslator.translateRectInScreenToAppWindow(mAttachInfo.mContentInsets);
}
@@ -680,7 +681,7 @@ public final class ViewRootImpl implements ViewParent,
if (mTranslator != null) return;
// Try to enable hardware acceleration if requested
- final boolean hardwareAccelerated =
+ final boolean hardwareAccelerated =
(attrs.flags & WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) != 0;
if (hardwareAccelerated) {
@@ -707,7 +708,7 @@ public final class ViewRootImpl implements ViewParent,
// Don't enable hardware acceleration when we're not on the main thread
if (!HardwareRenderer.sSystemRendererDisabled &&
Looper.getMainLooper() != Looper.myLooper()) {
- Log.w(HardwareRenderer.LOG_TAG, "Attempting to initialize hardware "
+ Log.w(HardwareRenderer.LOG_TAG, "Attempting to initialize hardware "
+ "acceleration outside of the main thread, aborting");
return;
}
@@ -918,6 +919,7 @@ public final class ViewRootImpl implements ViewParent,
return r.intersect(0, 0, mWidth, mHeight);
}
+ @Override
public void bringChildToFront(View child) {
}
@@ -1152,9 +1154,9 @@ public final class ViewRootImpl implements ViewParent,
mLastInCompatMode = true;
}
}
-
+
mWindowAttributesChangesFlag = 0;
-
+
Rect frame = mWinFrame;
if (mFirst) {
mFullRedrawNeeded = true;
@@ -1522,7 +1524,7 @@ public final class ViewRootImpl implements ViewParent,
try {
hwInitialized = mAttachInfo.mHardwareRenderer.initialize(
mHolder.getSurface());
- } catch (Surface.OutOfResourcesException e) {
+ } catch (OutOfResourcesException e) {
handleOutOfResourcesException(e);
return;
}
@@ -1549,7 +1551,7 @@ public final class ViewRootImpl implements ViewParent,
mFullRedrawNeeded = true;
try {
mAttachInfo.mHardwareRenderer.updateSurface(mHolder.getSurface());
- } catch (Surface.OutOfResourcesException e) {
+ } catch (OutOfResourcesException e) {
handleOutOfResourcesException(e);
return;
}
@@ -1644,23 +1646,23 @@ public final class ViewRootImpl implements ViewParent,
|| mHeight != host.getMeasuredHeight() || contentInsetsChanged) {
int childWidthMeasureSpec = getRootMeasureSpec(mWidth, lp.width);
int childHeightMeasureSpec = getRootMeasureSpec(mHeight, lp.height);
-
+
if (DEBUG_LAYOUT) Log.v(TAG, "Ooops, something changed! mWidth="
+ mWidth + " measuredWidth=" + host.getMeasuredWidth()
+ " mHeight=" + mHeight
+ " measuredHeight=" + host.getMeasuredHeight()
+ " coveredInsetsChanged=" + contentInsetsChanged);
-
+
// Ask host how big it wants to be
performMeasure(childWidthMeasureSpec, childHeightMeasureSpec);
-
+
// Implementation of weights from WindowManager.LayoutParams
// We just grow the dimensions as needed and re-measure if
// needs be
int width = host.getMeasuredWidth();
int height = host.getMeasuredHeight();
boolean measureAgain = false;
-
+
if (lp.horizontalWeight > 0.0f) {
width += (int) ((mWidth - width) * lp.horizontalWeight);
childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(width,
@@ -1673,14 +1675,14 @@ public final class ViewRootImpl implements ViewParent,
MeasureSpec.EXACTLY);
measureAgain = true;
}
-
+
if (measureAgain) {
if (DEBUG_LAYOUT) Log.v(TAG,
"And hey let's measure once more: width=" + width
+ " height=" + height);
performMeasure(childWidthMeasureSpec, childHeightMeasureSpec);
}
-
+
layoutRequested = true;
}
}
@@ -1851,7 +1853,7 @@ public final class ViewRootImpl implements ViewParent,
}
mPendingTransitions.clear();
}
-
+
performDraw();
}
} else {
@@ -2078,6 +2080,7 @@ public final class ViewRootImpl implements ViewParent,
return validLayoutRequesters;
}
+ @Override
public void requestTransparentRegion(View child) {
// the test below should not fail unless someone is messing with us
checkThread();
@@ -2128,10 +2131,12 @@ public final class ViewRootImpl implements ViewParent,
int mResizeAlpha;
final Paint mResizePaint = new Paint();
+ @Override
public void onHardwarePreDraw(HardwareCanvas canvas) {
canvas.translate(0, -mHardwareYOffset);
}
+ @Override
public void onHardwarePostDraw(HardwareCanvas canvas) {
if (mResizeBuffer != null) {
mResizePaint.setAlpha(mResizeAlpha);
@@ -2365,7 +2370,7 @@ public final class ViewRootImpl implements ViewParent,
try {
attachInfo.mHardwareRenderer.initializeIfNeeded(mWidth, mHeight,
mHolder.getSurface());
- } catch (Surface.OutOfResourcesException e) {
+ } catch (OutOfResourcesException e) {
handleOutOfResourcesException(e);
return;
}
@@ -2741,6 +2746,7 @@ public final class ViewRootImpl implements ViewParent,
mAccessibilityFocusedVirtualView = node;
}
+ @Override
public void requestChildFocus(View child, View focused) {
if (DEBUG_INPUT_RESIZE) {
Log.v(TAG, "Request child focus: focus now " + focused);
@@ -2749,6 +2755,7 @@ public final class ViewRootImpl implements ViewParent,
scheduleTraversals();
}
+ @Override
public void clearChildFocus(View child) {
if (DEBUG_INPUT_RESIZE) {
Log.v(TAG, "Clearing child focus");
@@ -2762,6 +2769,7 @@ public final class ViewRootImpl implements ViewParent,
return null;
}
+ @Override
public void focusableViewAvailable(View v) {
checkThread();
if (mView != null) {
@@ -2783,6 +2791,7 @@ public final class ViewRootImpl implements ViewParent,
}
}
+ @Override
public void recomputeViewAttributes(View child) {
checkThread();
if (mView == child) {
@@ -3076,7 +3085,7 @@ public final class ViewRootImpl implements ViewParent,
try {
mAttachInfo.mHardwareRenderer.initializeIfNeeded(
mWidth, mHeight, mHolder.getSurface());
- } catch (Surface.OutOfResourcesException e) {
+ } catch (OutOfResourcesException e) {
Log.e(TAG, "OutOfResourcesException locking surface", e);
try {
if (!mWindowSession.outOfMemory(mWindow)) {
@@ -4990,7 +4999,7 @@ public final class ViewRootImpl implements ViewParent,
// most recent data.
mSeq = args.seq;
mAttachInfo.mForceReportNewAttributes = true;
- scheduleTraversals();
+ scheduleTraversals();
}
if (mView == null) return;
if (args.localChanges != 0) {
@@ -5080,7 +5089,7 @@ public final class ViewRootImpl implements ViewParent,
if (restore) {
params.restore();
}
-
+
if (mTranslator != null) {
mTranslator.translateRectInScreenToAppWinFrame(mWinFrame);
mTranslator.translateRectInScreenToAppWindow(mPendingOverscanInsets);
@@ -5093,6 +5102,7 @@ public final class ViewRootImpl implements ViewParent,
/**
* {@inheritDoc}
*/
+ @Override
public void playSoundEffect(int effectId) {
checkThread();
@@ -5133,6 +5143,7 @@ public final class ViewRootImpl implements ViewParent,
/**
* {@inheritDoc}
*/
+ @Override
public boolean performHapticFeedback(int effectId, boolean always) {
try {
return mWindowSession.performHapticFeedback(mWindow, effectId, always);
@@ -5144,6 +5155,7 @@ public final class ViewRootImpl implements ViewParent,
/**
* {@inheritDoc}
*/
+ @Override
public View focusSearch(View focused, int direction) {
checkThread();
if (!(mView instanceof ViewGroup)) {
@@ -5155,7 +5167,7 @@ public final class ViewRootImpl implements ViewParent,
public void debug() {
mView.debug();
}
-
+
public void dumpGfxInfo(int[] info) {
info[0] = info[1] = 0;
if (mView != null) {
@@ -5574,8 +5586,8 @@ public final class ViewRootImpl implements ViewParent,
final class InvalidateOnAnimationRunnable implements Runnable {
private boolean mPosted;
- private ArrayList<View> mViews = new ArrayList<View>();
- private ArrayList<AttachInfo.InvalidateInfo> mViewRects =
+ private final ArrayList<View> mViews = new ArrayList<View>();
+ private final ArrayList<AttachInfo.InvalidateInfo> mViewRects =
new ArrayList<AttachInfo.InvalidateInfo>();
private View[] mTempViews;
private AttachInfo.InvalidateInfo[] mTempViewRects;
@@ -5813,20 +5825,25 @@ public final class ViewRootImpl implements ViewParent,
}
}
+ @Override
public boolean showContextMenuForChild(View originalView) {
return false;
}
+ @Override
public ActionMode startActionModeForChild(View originalView, ActionMode.Callback callback) {
return null;
}
+ @Override
public void createContextMenu(ContextMenu menu) {
}
+ @Override
public void childDrawableStateChanged(View child) {
}
+ @Override
public boolean requestSendAccessibilityEvent(View child, AccessibilityEvent event) {
if (mView == null) {
return false;
@@ -5958,10 +5975,12 @@ public final class ViewRootImpl implements ViewParent,
}
}
+ @Override
public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) {
// ViewAncestor never intercepts touch event, so this can be a no-op
}
+ @Override
public boolean requestChildRectangleOnScreen(View child, Rect rectangle, boolean immediate) {
final boolean scrolled = scrollToRectOrFocus(rectangle, immediate);
if (rectangle != null) {
@@ -5977,6 +5996,7 @@ public final class ViewRootImpl implements ViewParent,
return scrolled;
}
+ @Override
public void childHasTransientStateChanged(View child, boolean hasTransientState) {
// Do nothing.
}
@@ -5997,20 +6017,23 @@ public final class ViewRootImpl implements ViewParent,
// Not currently interesting -- from changing between fixed and layout size.
}
+ @Override
public void setFormat(int format) {
((RootViewSurfaceTaker)mView).setSurfaceFormat(format);
}
+ @Override
public void setType(int type) {
((RootViewSurfaceTaker)mView).setSurfaceType(type);
}
-
+
@Override
public void onUpdateSurface() {
// We take care of format and type changes on our own.
throw new IllegalStateException("Shouldn't be here");
}
+ @Override
public boolean isCreating() {
return mIsCreating;
}
@@ -6020,7 +6043,8 @@ public final class ViewRootImpl implements ViewParent,
throw new UnsupportedOperationException(
"Currently only support sizing from layout");
}
-
+
+ @Override
public void setKeepScreenOn(boolean screenOn) {
((RootViewSurfaceTaker)mView).setSurfaceKeepScreenOn(screenOn);
}
@@ -6035,6 +6059,7 @@ public final class ViewRootImpl implements ViewParent,
mWindowSession = viewAncestor.mWindowSession;
}
+ @Override
public void resized(Rect frame, Rect overscanInsets, Rect contentInsets,
Rect visibleInsets, boolean reportDraw, Configuration newConfig) {
final ViewRootImpl viewAncestor = mViewAncestor.get();
@@ -6052,6 +6077,7 @@ public final class ViewRootImpl implements ViewParent,
}
}
+ @Override
public void dispatchAppVisibility(boolean visible) {
final ViewRootImpl viewAncestor = mViewAncestor.get();
if (viewAncestor != null) {
@@ -6059,6 +6085,7 @@ public final class ViewRootImpl implements ViewParent,
}
}
+ @Override
public void dispatchScreenState(boolean on) {
final ViewRootImpl viewAncestor = mViewAncestor.get();
if (viewAncestor != null) {
@@ -6066,6 +6093,7 @@ public final class ViewRootImpl implements ViewParent,
}
}
+ @Override
public void dispatchGetNewSurface() {
final ViewRootImpl viewAncestor = mViewAncestor.get();
if (viewAncestor != null) {
@@ -6073,6 +6101,7 @@ public final class ViewRootImpl implements ViewParent,
}
}
+ @Override
public void windowFocusChanged(boolean hasFocus, boolean inTouchMode) {
final ViewRootImpl viewAncestor = mViewAncestor.get();
if (viewAncestor != null) {
@@ -6089,6 +6118,7 @@ public final class ViewRootImpl implements ViewParent,
}
}
+ @Override
public void executeCommand(String command, String parameters, ParcelFileDescriptor out) {
final ViewRootImpl viewAncestor = mViewAncestor.get();
if (viewAncestor != null) {
@@ -6119,14 +6149,16 @@ public final class ViewRootImpl implements ViewParent,
}
}
}
-
+
+ @Override
public void closeSystemDialogs(String reason) {
final ViewRootImpl viewAncestor = mViewAncestor.get();
if (viewAncestor != null) {
viewAncestor.dispatchCloseSystemDialogs(reason);
}
}
-
+
+ @Override
public void dispatchWallpaperOffsets(float x, float y, float xStep, float yStep,
boolean sync) {
if (sync) {
@@ -6137,6 +6169,7 @@ public final class ViewRootImpl implements ViewParent,
}
}
+ @Override
public void dispatchWallpaperCommand(String action, int x, int y,
int z, Bundle extras, boolean sync) {
if (sync) {
@@ -6148,6 +6181,7 @@ public final class ViewRootImpl implements ViewParent,
}
/* Drag/drop */
+ @Override
public void dispatchDragEvent(DragEvent event) {
final ViewRootImpl viewAncestor = mViewAncestor.get();
if (viewAncestor != null) {
@@ -6155,6 +6189,7 @@ public final class ViewRootImpl implements ViewParent,
}
}
+ @Override
public void dispatchSystemUiVisibilityChanged(int seq, int globalVisibility,
int localValue, int localChanges) {
final ViewRootImpl viewAncestor = mViewAncestor.get();
@@ -6164,6 +6199,7 @@ public final class ViewRootImpl implements ViewParent,
}
}
+ @Override
public void doneAnimating() {
final ViewRootImpl viewAncestor = mViewAncestor.get();
if (viewAncestor != null) {
@@ -6178,50 +6214,63 @@ public final class ViewRootImpl implements ViewParent,
}
}
- private SurfaceHolder mHolder = new SurfaceHolder() {
+ private final SurfaceHolder mHolder = new SurfaceHolder() {
// we only need a SurfaceHolder for opengl. it would be nice
// to implement everything else though, especially the callback
// support (opengl doesn't make use of it right now, but eventually
// will).
+ @Override
public Surface getSurface() {
return mSurface;
}
+ @Override
public boolean isCreating() {
return false;
}
+ @Override
public void addCallback(Callback callback) {
}
+ @Override
public void removeCallback(Callback callback) {
}
+ @Override
public void setFixedSize(int width, int height) {
}
+ @Override
public void setSizeFromLayout() {
}
+ @Override
public void setFormat(int format) {
}
+ @Override
public void setType(int type) {
}
+ @Override
public void setKeepScreenOn(boolean screenOn) {
}
+ @Override
public Canvas lockCanvas() {
return null;
}
+ @Override
public Canvas lockCanvas(Rect dirty) {
return null;
}
+ @Override
public void unlockCanvasAndPost(Canvas canvas) {
}
+ @Override
public Rect getSurfaceFrame() {
return null;
}
@@ -6316,6 +6365,7 @@ public final class ViewRootImpl implements ViewParent,
*/
final class AccessibilityInteractionConnectionManager
implements AccessibilityStateChangeListener {
+ @Override
public void onAccessibilityStateChanged(boolean enabled) {
if (enabled) {
ensureConnection();
@@ -6491,6 +6541,7 @@ public final class ViewRootImpl implements ViewParent,
public View mSource;
public long mLastEventTimeMillis;
+ @Override
public void run() {
// The accessibility may be turned off while we were waiting so check again.
if (AccessibilityManager.getInstance(mContext).isEnabled()) {
diff --git a/core/jni/android/graphics/SurfaceTexture.cpp b/core/jni/android/graphics/SurfaceTexture.cpp
index bacfdf6..0c9b3bc 100644
--- a/core/jni/android/graphics/SurfaceTexture.cpp
+++ b/core/jni/android/graphics/SurfaceTexture.cpp
@@ -37,7 +37,7 @@
namespace android {
static const char* const OutOfResourcesException =
- "android/graphics/SurfaceTexture$OutOfResourcesException";
+ "android/view/Surface$OutOfResourcesException";
static const char* const IllegalStateException = "java/lang/IllegalStateException";
const char* const kSurfaceTextureClassPathName = "android/graphics/SurfaceTexture";
diff --git a/graphics/java/android/graphics/SurfaceTexture.java b/graphics/java/android/graphics/SurfaceTexture.java
index e8d6f16..b910a24 100644
--- a/graphics/java/android/graphics/SurfaceTexture.java
+++ b/graphics/java/android/graphics/SurfaceTexture.java
@@ -21,6 +21,7 @@ import java.lang.ref.WeakReference;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
+import android.view.Surface;
/**
* Captures frames from an image stream as an OpenGL ES texture.
@@ -80,8 +81,12 @@ public class SurfaceTexture {
}
/**
- * Exception thrown when a surface couldn't be created or resized
+ * Exception thrown when a SurfaceTexture couldn't be created or resized.
+ *
+ * @deprecated No longer thrown. {@link Surface.OutOfResourcesException} is used instead.
*/
+ @SuppressWarnings("serial")
+ @Deprecated
public static class OutOfResourcesException extends Exception {
public OutOfResourcesException() {
}
@@ -94,6 +99,8 @@ public class SurfaceTexture {
* Construct a new SurfaceTexture to stream images to a given OpenGL texture.
*
* @param texName the OpenGL texture object name (e.g. generated via glGenTextures)
+ *
+ * @throws OutOfResourcesException If the SurfaceTexture cannot be created.
*/
public SurfaceTexture(int texName) {
init(texName, false);
@@ -113,6 +120,8 @@ public class SurfaceTexture {
*
* @param texName the OpenGL texture object name (e.g. generated via glGenTextures)
* @param singleBufferMode whether the SurfaceTexture will be in single buffered mode.
+ *
+ * @throws throws OutOfResourcesException If the SurfaceTexture cannot be created.
*/
public SurfaceTexture(int texName, boolean singleBufferMode) {
init(texName, singleBufferMode);
@@ -140,9 +149,9 @@ public class SurfaceTexture {
* android.view.Surface#lockCanvas} is called. For OpenGL ES, the EGLSurface should be
* destroyed (via eglDestroySurface), made not-current (via eglMakeCurrent), and then recreated
* (via eglCreateWindowSurface) to ensure that the new default size has taken effect.
- *
+ *
* The width and height parameters must be no greater than the minimum of
- * GL_MAX_VIEWPORT_DIMS and GL_MAX_TEXTURE_SIZE (see
+ * GL_MAX_VIEWPORT_DIMS and GL_MAX_TEXTURE_SIZE (see
* {@link javax.microedition.khronos.opengles.GL10#glGetIntegerv glGetIntegerv}).
* An error due to invalid dimensions might not be reported until
* updateTexImage() is called.
@@ -267,6 +276,7 @@ public class SurfaceTexture {
nativeRelease();
}
+ @Override
protected void finalize() throws Throwable {
try {
nativeFinalize();
@@ -305,7 +315,7 @@ public class SurfaceTexture {
}
}
- private void init(int texName, boolean singleBufferMode) {
+ private void init(int texName, boolean singleBufferMode) throws Surface.OutOfResourcesException {
Looper looper;
if ((looper = Looper.myLooper()) != null) {
mEventHandler = new EventHandler(looper);
@@ -317,7 +327,8 @@ public class SurfaceTexture {
nativeInit(texName, singleBufferMode, new WeakReference<SurfaceTexture>(this));
}
- private native void nativeInit(int texName, boolean singleBufferMode, Object weakSelf);
+ private native void nativeInit(int texName, boolean singleBufferMode, Object weakSelf)
+ throws Surface.OutOfResourcesException;
private native void nativeFinalize();
private native void nativeGetTransformMatrix(float[] mtx);
private native long nativeGetTimestamp();
diff --git a/services/java/com/android/server/power/ElectronBeam.java b/services/java/com/android/server/power/ElectronBeam.java
index 0d92f66..729bd16 100644
--- a/services/java/com/android/server/power/ElectronBeam.java
+++ b/services/java/com/android/server/power/ElectronBeam.java
@@ -35,6 +35,7 @@ import android.util.FloatMath;
import android.util.Slog;
import android.view.Display;
import android.view.DisplayInfo;
+import android.view.Surface.OutOfResourcesException;
import android.view.Surface;
import android.view.SurfaceControl;
import android.view.SurfaceSession;
@@ -94,7 +95,7 @@ final class ElectronBeam {
// Texture names. We only use one texture, which contains the screenshot.
private final int[] mTexNames = new int[1];
private boolean mTexNamesGenerated;
- private float mTexMatrix[] = new float[16];
+ private final float mTexMatrix[] = new float[16];
// Vertex and corresponding texture coordinates.
// We have 4 2D vertices, so 8 elements. The vertices form a quad.
@@ -515,7 +516,7 @@ final class ElectronBeam {
mSurfaceControl = new SurfaceControl(mSurfaceSession,
"ElectronBeam", mDisplayWidth, mDisplayHeight,
PixelFormat.OPAQUE, flags);
- } catch (SurfaceControl.OutOfResourcesException ex) {
+ } catch (OutOfResourcesException ex) {
Slog.e(TAG, "Unable to create surface.", ex);
return false;
}
@@ -525,7 +526,7 @@ final class ElectronBeam {
mSurfaceControl.setSize(mDisplayWidth, mDisplayHeight);
mSurface = new Surface();
mSurface.copyFrom(mSurfaceControl);
-
+
mSurfaceLayout = new NaturalSurfaceLayout(mDisplayManager, mSurfaceControl);
mSurfaceLayout.onDisplayTransaction();
} finally {
diff --git a/services/java/com/android/server/wm/BlackFrame.java b/services/java/com/android/server/wm/BlackFrame.java
index 737d854..5aa266d 100644
--- a/services/java/com/android/server/wm/BlackFrame.java
+++ b/services/java/com/android/server/wm/BlackFrame.java
@@ -22,6 +22,7 @@ import android.graphics.Matrix;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.util.Slog;
+import android.view.Surface.OutOfResourcesException;
import android.view.SurfaceControl;
import android.view.SurfaceSession;
@@ -36,7 +37,7 @@ public class BlackFrame {
final SurfaceControl surface;
BlackSurface(SurfaceSession session, int layer, int l, int t, int r, int b, int layerStack)
- throws SurfaceControl.OutOfResourcesException {
+ throws OutOfResourcesException {
left = l;
top = t;
this.layer = layer;
@@ -112,7 +113,7 @@ public class BlackFrame {
}
public BlackFrame(SurfaceSession session, Rect outer, Rect inner, int layer, int layerStack,
- boolean forceDefaultOrientation) throws SurfaceControl.OutOfResourcesException {
+ boolean forceDefaultOrientation) throws OutOfResourcesException {
boolean success = false;
mForceDefaultOrientation = forceDefaultOrientation;
diff --git a/services/java/com/android/server/wm/DisplayMagnifier.java b/services/java/com/android/server/wm/DisplayMagnifier.java
index 0f51028..382d7b4 100644
--- a/services/java/com/android/server/wm/DisplayMagnifier.java
+++ b/services/java/com/android/server/wm/DisplayMagnifier.java
@@ -496,7 +496,7 @@ final class DisplayMagnifier {
mWindowManager.getDefaultDisplay().getRealSize(mTempPoint);
surfaceControl = new SurfaceControl(mWindowManagerService.mFxSession, SURFACE_TITLE,
mTempPoint.x, mTempPoint.y, PixelFormat.TRANSLUCENT, SurfaceControl.HIDDEN);
- } catch (SurfaceControl.OutOfResourcesException oore) {
+ } catch (OutOfResourcesException oore) {
/* ignore */
}
mSurfaceControl = surfaceControl;
@@ -629,7 +629,7 @@ final class DisplayMagnifier {
}
} catch (IllegalArgumentException iae) {
/* ignore */
- } catch (OutOfResourcesException oore) {
+ } catch (Surface.OutOfResourcesException oore) {
/* ignore */
}
if (canvas == null) {
@@ -644,7 +644,7 @@ final class DisplayMagnifier {
canvas.drawPath(path, mPaint);
mSurface.unlockCanvasAndPost(canvas);
-
+
if (mAlpha > 0) {
mSurfaceControl.show();
} else {
diff --git a/services/java/com/android/server/wm/FocusedStackFrame.java b/services/java/com/android/server/wm/FocusedStackFrame.java
index 9c18331..365b277 100644
--- a/services/java/com/android/server/wm/FocusedStackFrame.java
+++ b/services/java/com/android/server/wm/FocusedStackFrame.java
@@ -26,6 +26,7 @@ import android.graphics.Rect;
import android.graphics.Region;
import android.util.Slog;
import android.view.Display;
+import android.view.Surface.OutOfResourcesException;
import android.view.Surface;
import android.view.SurfaceControl;
import android.view.SurfaceSession;
@@ -39,9 +40,9 @@ class FocusedStackFrame {
private final SurfaceControl mSurfaceControl;
private final Surface mSurface = new Surface();
- private Rect mLastBounds = new Rect();
- private Rect mBounds = new Rect();
- private Rect mTmpDrawRect = new Rect();
+ private final Rect mLastBounds = new Rect();
+ private final Rect mBounds = new Rect();
+ private final Rect mTmpDrawRect = new Rect();
public FocusedStackFrame(Display display, SurfaceSession session) {
SurfaceControl ctrl = null;
@@ -56,7 +57,7 @@ class FocusedStackFrame {
ctrl.setLayerStack(display.getLayerStack());
ctrl.setAlpha(ALPHA);
mSurface.copyFrom(ctrl);
- } catch (SurfaceControl.OutOfResourcesException e) {
+ } catch (OutOfResourcesException e) {
}
mSurfaceControl = ctrl;
}
diff --git a/services/java/com/android/server/wm/ScreenRotationAnimation.java b/services/java/com/android/server/wm/ScreenRotationAnimation.java
index 7d90858..e630737 100644
--- a/services/java/com/android/server/wm/ScreenRotationAnimation.java
+++ b/services/java/com/android/server/wm/ScreenRotationAnimation.java
@@ -27,6 +27,7 @@ import android.graphics.Rect;
import android.util.Slog;
import android.view.Display;
import android.view.DisplayInfo;
+import android.view.Surface.OutOfResourcesException;
import android.view.Surface;
import android.view.SurfaceControl;
import android.view.SurfaceSession;
@@ -262,7 +263,7 @@ class ScreenRotationAnimation {
mSurfaceControl.setAlpha(0);
mSurfaceControl.show();
sur.destroy();
- } catch (SurfaceControl.OutOfResourcesException e) {
+ } catch (OutOfResourcesException e) {
Slog.w(TAG, "Unable to allocate freeze surface", e);
}
@@ -547,7 +548,7 @@ class ScreenRotationAnimation {
mCustomBlackFrame = new BlackFrame(session, outer, inner, FREEZE_LAYER + 3,
layerStack, false);
mCustomBlackFrame.setMatrix(mFrameInitialMatrix);
- } catch (SurfaceControl.OutOfResourcesException e) {
+ } catch (OutOfResourcesException e) {
Slog.w(TAG, "Unable to allocate black surface", e);
} finally {
SurfaceControl.closeTransaction();
@@ -587,7 +588,7 @@ class ScreenRotationAnimation {
mExitingBlackFrame = new BlackFrame(session, outer, inner, FREEZE_LAYER + 2,
layerStack, mForceDefaultOrientation);
mExitingBlackFrame.setMatrix(mFrameInitialMatrix);
- } catch (SurfaceControl.OutOfResourcesException e) {
+ } catch (OutOfResourcesException e) {
Slog.w(TAG, "Unable to allocate black surface", e);
} finally {
SurfaceControl.closeTransaction();
@@ -609,7 +610,7 @@ class ScreenRotationAnimation {
Rect inner = new Rect(0, 0, finalWidth, finalHeight);
mEnteringBlackFrame = new BlackFrame(session, outer, inner, FREEZE_LAYER,
layerStack, false);
- } catch (SurfaceControl.OutOfResourcesException e) {
+ } catch (OutOfResourcesException e) {
Slog.w(TAG, "Unable to allocate black surface", e);
} finally {
SurfaceControl.closeTransaction();
@@ -894,7 +895,7 @@ class ScreenRotationAnimation {
&& (mMoreStartEnter || mMoreStartExit || mMoreFinishEnter || mMoreFinishExit))
|| (USE_CUSTOM_BLACK_FRAME
&& (mMoreStartFrame || mMoreRotateFrame || mMoreFinishFrame))
- || mMoreRotateEnter || mMoreRotateExit
+ || mMoreRotateEnter || mMoreRotateExit
|| !mFinishAnimReady;
mSnapshotFinalMatrix.setConcat(mExitTransformation.getMatrix(), mSnapshotInitialMatrix);
diff --git a/services/java/com/android/server/wm/StrictModeFlash.java b/services/java/com/android/server/wm/StrictModeFlash.java
index 31628e3..fb5876b 100644
--- a/services/java/com/android/server/wm/StrictModeFlash.java
+++ b/services/java/com/android/server/wm/StrictModeFlash.java
@@ -23,6 +23,7 @@ import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.Region;
import android.view.Display;
+import android.view.Surface.OutOfResourcesException;
import android.view.Surface;
import android.view.SurfaceControl;
import android.view.SurfaceSession;
@@ -47,7 +48,7 @@ class StrictModeFlash {
ctrl.setPosition(0, 0);
ctrl.show();
mSurface.copyFrom(ctrl);
- } catch (SurfaceControl.OutOfResourcesException e) {
+ } catch (OutOfResourcesException e) {
}
mSurfaceControl = ctrl;
mDrawNeeded = true;
diff --git a/services/java/com/android/server/wm/Watermark.java b/services/java/com/android/server/wm/Watermark.java
index fedd314..e226e3d 100644
--- a/services/java/com/android/server/wm/Watermark.java
+++ b/services/java/com/android/server/wm/Watermark.java
@@ -27,10 +27,10 @@ import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
import android.view.Display;
+import android.view.Surface.OutOfResourcesException;
import android.view.Surface;
import android.view.SurfaceControl;
import android.view.SurfaceSession;
-import android.view.Surface.OutOfResourcesException;
/**
* Displays a watermark on top of the window manager's windows.
@@ -119,7 +119,7 @@ class Watermark {
ctrl.setPosition(0, 0);
ctrl.show();
mSurface.copyFrom(ctrl);
- } catch (SurfaceControl.OutOfResourcesException e) {
+ } catch (OutOfResourcesException e) {
}
mSurfaceControl = ctrl;
}
@@ -144,11 +144,11 @@ class Watermark {
try {
c = mSurface.lockCanvas(dirty);
} catch (IllegalArgumentException e) {
- } catch (OutOfResourcesException e) {
+ } catch (Surface.OutOfResourcesException e) {
}
if (c != null) {
c.drawColor(0, PorterDuff.Mode.CLEAR);
-
+
int deltaX = mDeltaX;
int deltaY = mDeltaY;
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index b8d2050..f5e0531 100644
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -116,6 +116,7 @@ import android.view.InputEventReceiver;
import android.view.KeyEvent;
import android.view.MagnificationSpec;
import android.view.MotionEvent;
+import android.view.Surface.OutOfResourcesException;
import android.view.Surface;
import android.view.SurfaceControl;
import android.view.SurfaceSession;
@@ -461,7 +462,7 @@ public class WindowManagerService extends IWindowManager.Stub
// This is held as long as we have the screen frozen, to give us time to
// perform a rotation animation when turning off shows the lock screen which
// changes the orientation.
- private PowerManager.WakeLock mScreenFrozenLock;
+ private final PowerManager.WakeLock mScreenFrozenLock;
final AppTransition mAppTransition;
boolean mStartingIconInTransition = false;
@@ -664,7 +665,7 @@ public class WindowManagerService extends IWindowManager.Stub
boolean mInTouchMode = true;
private ViewServer mViewServer;
- private ArrayList<WindowChangeListener> mWindowChangeListeners =
+ private final ArrayList<WindowChangeListener> mWindowChangeListeners =
new ArrayList<WindowChangeListener>();
private boolean mWindowsChanged = false;
@@ -6812,7 +6813,7 @@ public class WindowManagerService extends IWindowManager.Stub
} else {
Slog.w(TAG, "Drag already in progress");
}
- } catch (SurfaceControl.OutOfResourcesException e) {
+ } catch (OutOfResourcesException e) {
Slog.e(TAG, "Can't allocate drag surface w=" + width + " h=" + height, e);
if (mDragState != null) {
mDragState.reset();
@@ -8580,12 +8581,8 @@ public class WindowManagerService extends IWindowManager.Stub
mAppTransition.getStartingPoint(p);
appAnimator.thumbnailX = p.x;
appAnimator.thumbnailY = p.y;
- } catch (SurfaceControl.OutOfResourcesException e) {
- Slog.e(TAG, "Can't allocate thumbnail surface w=" + dirty.width()
- + " h=" + dirty.height(), e);
- appAnimator.clearThumbnail();
- } catch (Surface.OutOfResourcesException e) {
- Slog.e(TAG, "Can't allocate Canvas surface w=" + dirty.width()
+ } catch (OutOfResourcesException e) {
+ Slog.e(TAG, "Can't allocate thumbnail/Canvas surface w=" + dirty.width()
+ " h=" + dirty.height(), e);
appAnimator.clearThumbnail();
}
diff --git a/services/java/com/android/server/wm/WindowStateAnimator.java b/services/java/com/android/server/wm/WindowStateAnimator.java
index 73325cb..9245542 100644
--- a/services/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/java/com/android/server/wm/WindowStateAnimator.java
@@ -29,6 +29,7 @@ import android.util.Slog;
import android.view.Display;
import android.view.DisplayInfo;
import android.view.MagnificationSpec;
+import android.view.Surface.OutOfResourcesException;
import android.view.SurfaceControl;
import android.view.SurfaceSession;
import android.view.WindowManager;
@@ -480,7 +481,7 @@ class WindowStateAnimator {
private final Rect mWindowCrop = new Rect();
private boolean mShown = false;
private int mLayerStack;
- private String mName;
+ private final String mName;
public SurfaceTrace(SurfaceSession s,
String name, int w, int h, int format, int flags)
@@ -694,7 +695,7 @@ class WindowStateAnimator {
+ attrs.format + " flags=0x"
+ Integer.toHexString(flags)
+ " / " + this);
- } catch (SurfaceControl.OutOfResourcesException e) {
+ } catch (OutOfResourcesException e) {
mWin.mHasSurface = false;
Slog.w(TAG, "OutOfResourcesException creating surface");
mService.reclaimSomeSurfaceMemoryLocked(this, "create", true);