Loading api/current.xml +13 −0 Original line number Diff line number Diff line Loading @@ -188518,6 +188518,19 @@ <parameter name="get" type="boolean"> </parameter> </method> <method name="takeSurface" return="void" abstract="true" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="callback" type="android.view.SurfaceHolder.Callback"> </parameter> </method> <method name="togglePanel" return="void" abstract="true" core/java/android/service/wallpaper/WallpaperService.java +9 −16 Original line number Diff line number Diff line Loading @@ -522,20 +522,14 @@ public abstract class WallpaperService extends Service { } try { SurfaceHolder.Callback callbacks[] = null; synchronized (mSurfaceHolder.mCallbacks) { final int N = mSurfaceHolder.mCallbacks.size(); if (N > 0) { callbacks = new SurfaceHolder.Callback[N]; mSurfaceHolder.mCallbacks.toArray(callbacks); } } mSurfaceHolder.ungetCallbacks(); if (surfaceCreating) { mIsCreating = true; if (DEBUG) Log.v(TAG, "onSurfaceCreated(" + mSurfaceHolder + "): " + this); onSurfaceCreated(mSurfaceHolder); SurfaceHolder.Callback callbacks[] = mSurfaceHolder.getCallbacks(); if (callbacks != null) { for (SurfaceHolder.Callback c : callbacks) { c.surfaceCreated(mSurfaceHolder); Loading @@ -557,6 +551,7 @@ public abstract class WallpaperService extends Service { + "): " + this); onSurfaceChanged(mSurfaceHolder, mFormat, mCurWidth, mCurHeight); SurfaceHolder.Callback callbacks[] = mSurfaceHolder.getCallbacks(); if (callbacks != null) { for (SurfaceHolder.Callback c : callbacks) { c.surfaceChanged(mSurfaceHolder, mFormat, Loading Loading @@ -698,15 +693,13 @@ public abstract class WallpaperService extends Service { void reportSurfaceDestroyed() { if (mSurfaceCreated) { mSurfaceCreated = false; SurfaceHolder.Callback callbacks[]; synchronized (mSurfaceHolder.mCallbacks) { callbacks = new SurfaceHolder.Callback[ mSurfaceHolder.mCallbacks.size()]; mSurfaceHolder.mCallbacks.toArray(callbacks); } mSurfaceHolder.ungetCallbacks(); SurfaceHolder.Callback callbacks[] = mSurfaceHolder.getCallbacks(); if (callbacks != null) { for (SurfaceHolder.Callback c : callbacks) { c.surfaceDestroyed(mSurfaceHolder); } } if (DEBUG) Log.v(TAG, "onSurfaceDestroyed(" + mSurfaceHolder + "): " + this); onSurfaceDestroyed(mSurfaceHolder); Loading core/java/android/view/SurfaceHolder.java +0 −1 Original line number Diff line number Diff line Loading @@ -182,7 +182,6 @@ public interface SurfaceHolder { /** * Enable or disable option to keep the screen turned on while this * surface is displayed. The default is false, allowing it to turn off. * Enabling the option effectivelty. * This is safe to call from any thread. * * @param screenOn Supply to true to force the screen to stay on, false Loading core/java/android/view/ViewRoot.java +122 −1 Original line number Diff line number Diff line Loading @@ -16,8 +16,10 @@ package android.view; import com.android.internal.view.BaseSurfaceHolder; import com.android.internal.view.IInputMethodCallback; import com.android.internal.view.IInputMethodSession; import com.android.internal.view.RootViewSurfaceTaker; import android.graphics.Canvas; import android.graphics.PixelFormat; Loading Loading @@ -135,6 +137,11 @@ public final class ViewRoot extends Handler implements ViewParent, int mViewVisibility; boolean mAppVisible = true; SurfaceHolder.Callback mSurfaceHolderCallback; BaseSurfaceHolder mSurfaceHolder; boolean mIsCreating; boolean mDrawingAllowed; final Region mTransparentRegion; final Region mPreviousTransparentRegion; Loading Loading @@ -440,6 +447,13 @@ public final class ViewRoot extends Handler implements ViewParent, mView = view; mWindowAttributes.copyFrom(attrs); attrs = mWindowAttributes; if (view instanceof RootViewSurfaceTaker) { mSurfaceHolderCallback = ((RootViewSurfaceTaker)view).willYouTakeTheSurface(); if (mSurfaceHolderCallback != null) { mSurfaceHolder = new TakenSurfaceHolder(); } } Resources resources = mView.getContext().getResources(); CompatibilityInfo compatibilityInfo = resources.getCompatibilityInfo(); mTranslator = compatibilityInfo.getTranslator(); Loading Loading @@ -695,6 +709,7 @@ public final class ViewRoot extends Handler implements ViewParent, boolean windowResizesToFitContent = false; boolean fullRedrawNeeded = mFullRedrawNeeded; boolean newSurface = false; boolean surfaceChanged = false; WindowManager.LayoutParams lp = mWindowAttributes; int desiredWindowWidth; Loading @@ -713,6 +728,7 @@ public final class ViewRoot extends Handler implements ViewParent, WindowManager.LayoutParams params = null; if (mWindowAttributesChanged) { mWindowAttributesChanged = false; surfaceChanged = true; params = lp; } Rect frame = mWinFrame; Loading Loading @@ -899,11 +915,18 @@ public final class ViewRoot extends Handler implements ViewParent, } } if (mSurfaceHolder != null) { mSurfaceHolder.mSurfaceLock.lock(); mDrawingAllowed = true; lp.format = mSurfaceHolder.getRequestedFormat(); lp.type = mSurfaceHolder.getRequestedType(); } boolean initialized = false; boolean contentInsetsChanged = false; boolean visibleInsetsChanged; try { boolean hadSurface = mSurface.isValid(); try { int fl = 0; if (params != null) { fl = params.flags; Loading Loading @@ -978,6 +1001,7 @@ public final class ViewRoot extends Handler implements ViewParent, } } catch (RemoteException e) { } if (DEBUG_ORIENTATION) Log.v( "ViewRoot", "Relayout returned: frame=" + frame + ", surface=" + mSurface); Loading @@ -990,6 +1014,57 @@ public final class ViewRoot extends Handler implements ViewParent, mWidth = frame.width(); mHeight = frame.height(); if (mSurfaceHolder != null) { // The app owns the surface; tell it about what is going on. if (mSurface.isValid()) { // XXX .copyFrom() doesn't work! //mSurfaceHolder.mSurface.copyFrom(mSurface); mSurfaceHolder.mSurface = mSurface; } mSurfaceHolder.mSurfaceLock.unlock(); if (mSurface.isValid()) { if (!hadSurface) { mSurfaceHolder.ungetCallbacks(); mIsCreating = true; mSurfaceHolderCallback.surfaceCreated(mSurfaceHolder); SurfaceHolder.Callback callbacks[] = mSurfaceHolder.getCallbacks(); if (callbacks != null) { for (SurfaceHolder.Callback c : callbacks) { c.surfaceCreated(mSurfaceHolder); } } surfaceChanged = true; } if (surfaceChanged) { mSurfaceHolderCallback.surfaceChanged(mSurfaceHolder, lp.format, mWidth, mHeight); SurfaceHolder.Callback callbacks[] = mSurfaceHolder.getCallbacks(); if (callbacks != null) { for (SurfaceHolder.Callback c : callbacks) { c.surfaceChanged(mSurfaceHolder, lp.format, mWidth, mHeight); } } } mIsCreating = false; } else if (hadSurface) { mSurfaceHolder.ungetCallbacks(); SurfaceHolder.Callback callbacks[] = mSurfaceHolder.getCallbacks(); mSurfaceHolderCallback.surfaceDestroyed(mSurfaceHolder); if (callbacks != null) { for (SurfaceHolder.Callback c : callbacks) { c.surfaceDestroyed(mSurfaceHolder); } } mSurfaceHolder.mSurfaceLock.lock(); // Make surface invalid. //mSurfaceHolder.mSurface.copyFrom(mSurface); mSurfaceHolder.mSurface = new Surface(); mSurfaceHolder.mSurfaceLock.unlock(); } } if (initialized) { mGlCanvas.setViewport((int) (mWidth * appScale + 0.5f), (int) (mHeight * appScale + 0.5f)); Loading Loading @@ -1281,6 +1356,12 @@ public final class ViewRoot extends Handler implements ViewParent, boolean scalingRequired = mAttachInfo.mScalingRequired; Rect dirty = mDirty; if (mSurfaceHolder != null) { // The app owns the surface, we won't draw. dirty.setEmpty(); return; } if (mUseGL) { if (!dirty.isEmpty()) { Canvas canvas = mGlCanvas; Loading Loading @@ -2828,6 +2909,46 @@ public final class ViewRoot extends Handler implements ViewParent, return scrollToRectOrFocus(rectangle, immediate); } class TakenSurfaceHolder extends BaseSurfaceHolder { @Override public boolean onAllowLockCanvas() { return mDrawingAllowed; } @Override public void onRelayoutContainer() { // Not currently interesting -- from changing between fixed and layout size. } public void setFormat(int format) { ((RootViewSurfaceTaker)mView).setSurfaceFormat(format); } 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"); } public boolean isCreating() { return mIsCreating; } @Override public void setFixedSize(int width, int height) { throw new UnsupportedOperationException( "Currently only support sizing from layout"); } public void setKeepScreenOn(boolean screenOn) { ((RootViewSurfaceTaker)mView).setSurfaceKeepScreenOn(screenOn); } } static class InputMethodCallback extends IInputMethodCallback.Stub { private WeakReference<ViewRoot> mViewRoot; Loading core/java/android/view/Window.java +8 −0 Original line number Diff line number Diff line Loading @@ -479,6 +479,14 @@ public abstract class Window { return mCallback; } /** * Take ownership of this window's surface. The window's view hierarchy * will no longer draw into the surface, though it will otherwise continue * to operate (such as for receiving input events). The given SurfaceHolder * callback will be used to tell you about state changes to the surface. */ public abstract void takeSurface(SurfaceHolder.Callback callback); /** * Return whether this window is being displayed with a floating style * (based on the {@link android.R.attr#windowIsFloating} attribute in Loading Loading
api/current.xml +13 −0 Original line number Diff line number Diff line Loading @@ -188518,6 +188518,19 @@ <parameter name="get" type="boolean"> </parameter> </method> <method name="takeSurface" return="void" abstract="true" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="callback" type="android.view.SurfaceHolder.Callback"> </parameter> </method> <method name="togglePanel" return="void" abstract="true"
core/java/android/service/wallpaper/WallpaperService.java +9 −16 Original line number Diff line number Diff line Loading @@ -522,20 +522,14 @@ public abstract class WallpaperService extends Service { } try { SurfaceHolder.Callback callbacks[] = null; synchronized (mSurfaceHolder.mCallbacks) { final int N = mSurfaceHolder.mCallbacks.size(); if (N > 0) { callbacks = new SurfaceHolder.Callback[N]; mSurfaceHolder.mCallbacks.toArray(callbacks); } } mSurfaceHolder.ungetCallbacks(); if (surfaceCreating) { mIsCreating = true; if (DEBUG) Log.v(TAG, "onSurfaceCreated(" + mSurfaceHolder + "): " + this); onSurfaceCreated(mSurfaceHolder); SurfaceHolder.Callback callbacks[] = mSurfaceHolder.getCallbacks(); if (callbacks != null) { for (SurfaceHolder.Callback c : callbacks) { c.surfaceCreated(mSurfaceHolder); Loading @@ -557,6 +551,7 @@ public abstract class WallpaperService extends Service { + "): " + this); onSurfaceChanged(mSurfaceHolder, mFormat, mCurWidth, mCurHeight); SurfaceHolder.Callback callbacks[] = mSurfaceHolder.getCallbacks(); if (callbacks != null) { for (SurfaceHolder.Callback c : callbacks) { c.surfaceChanged(mSurfaceHolder, mFormat, Loading Loading @@ -698,15 +693,13 @@ public abstract class WallpaperService extends Service { void reportSurfaceDestroyed() { if (mSurfaceCreated) { mSurfaceCreated = false; SurfaceHolder.Callback callbacks[]; synchronized (mSurfaceHolder.mCallbacks) { callbacks = new SurfaceHolder.Callback[ mSurfaceHolder.mCallbacks.size()]; mSurfaceHolder.mCallbacks.toArray(callbacks); } mSurfaceHolder.ungetCallbacks(); SurfaceHolder.Callback callbacks[] = mSurfaceHolder.getCallbacks(); if (callbacks != null) { for (SurfaceHolder.Callback c : callbacks) { c.surfaceDestroyed(mSurfaceHolder); } } if (DEBUG) Log.v(TAG, "onSurfaceDestroyed(" + mSurfaceHolder + "): " + this); onSurfaceDestroyed(mSurfaceHolder); Loading
core/java/android/view/SurfaceHolder.java +0 −1 Original line number Diff line number Diff line Loading @@ -182,7 +182,6 @@ public interface SurfaceHolder { /** * Enable or disable option to keep the screen turned on while this * surface is displayed. The default is false, allowing it to turn off. * Enabling the option effectivelty. * This is safe to call from any thread. * * @param screenOn Supply to true to force the screen to stay on, false Loading
core/java/android/view/ViewRoot.java +122 −1 Original line number Diff line number Diff line Loading @@ -16,8 +16,10 @@ package android.view; import com.android.internal.view.BaseSurfaceHolder; import com.android.internal.view.IInputMethodCallback; import com.android.internal.view.IInputMethodSession; import com.android.internal.view.RootViewSurfaceTaker; import android.graphics.Canvas; import android.graphics.PixelFormat; Loading Loading @@ -135,6 +137,11 @@ public final class ViewRoot extends Handler implements ViewParent, int mViewVisibility; boolean mAppVisible = true; SurfaceHolder.Callback mSurfaceHolderCallback; BaseSurfaceHolder mSurfaceHolder; boolean mIsCreating; boolean mDrawingAllowed; final Region mTransparentRegion; final Region mPreviousTransparentRegion; Loading Loading @@ -440,6 +447,13 @@ public final class ViewRoot extends Handler implements ViewParent, mView = view; mWindowAttributes.copyFrom(attrs); attrs = mWindowAttributes; if (view instanceof RootViewSurfaceTaker) { mSurfaceHolderCallback = ((RootViewSurfaceTaker)view).willYouTakeTheSurface(); if (mSurfaceHolderCallback != null) { mSurfaceHolder = new TakenSurfaceHolder(); } } Resources resources = mView.getContext().getResources(); CompatibilityInfo compatibilityInfo = resources.getCompatibilityInfo(); mTranslator = compatibilityInfo.getTranslator(); Loading Loading @@ -695,6 +709,7 @@ public final class ViewRoot extends Handler implements ViewParent, boolean windowResizesToFitContent = false; boolean fullRedrawNeeded = mFullRedrawNeeded; boolean newSurface = false; boolean surfaceChanged = false; WindowManager.LayoutParams lp = mWindowAttributes; int desiredWindowWidth; Loading @@ -713,6 +728,7 @@ public final class ViewRoot extends Handler implements ViewParent, WindowManager.LayoutParams params = null; if (mWindowAttributesChanged) { mWindowAttributesChanged = false; surfaceChanged = true; params = lp; } Rect frame = mWinFrame; Loading Loading @@ -899,11 +915,18 @@ public final class ViewRoot extends Handler implements ViewParent, } } if (mSurfaceHolder != null) { mSurfaceHolder.mSurfaceLock.lock(); mDrawingAllowed = true; lp.format = mSurfaceHolder.getRequestedFormat(); lp.type = mSurfaceHolder.getRequestedType(); } boolean initialized = false; boolean contentInsetsChanged = false; boolean visibleInsetsChanged; try { boolean hadSurface = mSurface.isValid(); try { int fl = 0; if (params != null) { fl = params.flags; Loading Loading @@ -978,6 +1001,7 @@ public final class ViewRoot extends Handler implements ViewParent, } } catch (RemoteException e) { } if (DEBUG_ORIENTATION) Log.v( "ViewRoot", "Relayout returned: frame=" + frame + ", surface=" + mSurface); Loading @@ -990,6 +1014,57 @@ public final class ViewRoot extends Handler implements ViewParent, mWidth = frame.width(); mHeight = frame.height(); if (mSurfaceHolder != null) { // The app owns the surface; tell it about what is going on. if (mSurface.isValid()) { // XXX .copyFrom() doesn't work! //mSurfaceHolder.mSurface.copyFrom(mSurface); mSurfaceHolder.mSurface = mSurface; } mSurfaceHolder.mSurfaceLock.unlock(); if (mSurface.isValid()) { if (!hadSurface) { mSurfaceHolder.ungetCallbacks(); mIsCreating = true; mSurfaceHolderCallback.surfaceCreated(mSurfaceHolder); SurfaceHolder.Callback callbacks[] = mSurfaceHolder.getCallbacks(); if (callbacks != null) { for (SurfaceHolder.Callback c : callbacks) { c.surfaceCreated(mSurfaceHolder); } } surfaceChanged = true; } if (surfaceChanged) { mSurfaceHolderCallback.surfaceChanged(mSurfaceHolder, lp.format, mWidth, mHeight); SurfaceHolder.Callback callbacks[] = mSurfaceHolder.getCallbacks(); if (callbacks != null) { for (SurfaceHolder.Callback c : callbacks) { c.surfaceChanged(mSurfaceHolder, lp.format, mWidth, mHeight); } } } mIsCreating = false; } else if (hadSurface) { mSurfaceHolder.ungetCallbacks(); SurfaceHolder.Callback callbacks[] = mSurfaceHolder.getCallbacks(); mSurfaceHolderCallback.surfaceDestroyed(mSurfaceHolder); if (callbacks != null) { for (SurfaceHolder.Callback c : callbacks) { c.surfaceDestroyed(mSurfaceHolder); } } mSurfaceHolder.mSurfaceLock.lock(); // Make surface invalid. //mSurfaceHolder.mSurface.copyFrom(mSurface); mSurfaceHolder.mSurface = new Surface(); mSurfaceHolder.mSurfaceLock.unlock(); } } if (initialized) { mGlCanvas.setViewport((int) (mWidth * appScale + 0.5f), (int) (mHeight * appScale + 0.5f)); Loading Loading @@ -1281,6 +1356,12 @@ public final class ViewRoot extends Handler implements ViewParent, boolean scalingRequired = mAttachInfo.mScalingRequired; Rect dirty = mDirty; if (mSurfaceHolder != null) { // The app owns the surface, we won't draw. dirty.setEmpty(); return; } if (mUseGL) { if (!dirty.isEmpty()) { Canvas canvas = mGlCanvas; Loading Loading @@ -2828,6 +2909,46 @@ public final class ViewRoot extends Handler implements ViewParent, return scrollToRectOrFocus(rectangle, immediate); } class TakenSurfaceHolder extends BaseSurfaceHolder { @Override public boolean onAllowLockCanvas() { return mDrawingAllowed; } @Override public void onRelayoutContainer() { // Not currently interesting -- from changing between fixed and layout size. } public void setFormat(int format) { ((RootViewSurfaceTaker)mView).setSurfaceFormat(format); } 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"); } public boolean isCreating() { return mIsCreating; } @Override public void setFixedSize(int width, int height) { throw new UnsupportedOperationException( "Currently only support sizing from layout"); } public void setKeepScreenOn(boolean screenOn) { ((RootViewSurfaceTaker)mView).setSurfaceKeepScreenOn(screenOn); } } static class InputMethodCallback extends IInputMethodCallback.Stub { private WeakReference<ViewRoot> mViewRoot; Loading
core/java/android/view/Window.java +8 −0 Original line number Diff line number Diff line Loading @@ -479,6 +479,14 @@ public abstract class Window { return mCallback; } /** * Take ownership of this window's surface. The window's view hierarchy * will no longer draw into the surface, though it will otherwise continue * to operate (such as for receiving input events). The given SurfaceHolder * callback will be used to tell you about state changes to the surface. */ public abstract void takeSurface(SurfaceHolder.Callback callback); /** * Return whether this window is being displayed with a floating style * (based on the {@link android.R.attr#windowIsFloating} attribute in Loading