summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/inputmethodservice/ExtractEditText.java23
-rw-r--r--core/java/android/inputmethodservice/InputMethodService.java26
-rw-r--r--core/java/android/service/wallpaper/WallpaperService.java4
-rw-r--r--core/java/android/view/GLES20Canvas.java17
-rw-r--r--core/java/android/view/HardwareRenderer.java12
-rw-r--r--core/java/android/view/IWindowSession.aidl13
-rw-r--r--core/java/android/view/SurfaceView.java152
-rw-r--r--core/java/android/view/ViewRootImpl.java39
-rw-r--r--core/java/android/view/WindowManagerImpl.java27
-rw-r--r--core/java/android/widget/TextView.java78
-rw-r--r--core/res/res/anim/app_starting_exit.xml3
-rw-r--r--core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerStressTestRunner.java3
-rw-r--r--core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java4
-rw-r--r--core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/NetworkState.java11
-rw-r--r--core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/ConnectivityManagerMobileTest.java131
-rw-r--r--core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/WifiConnectionTest.java7
-rw-r--r--core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/stress/WifiStressTest.java12
-rw-r--r--include/media/AudioTrack.h2
-rw-r--r--libs/hwui/FontRenderer.cpp12
-rw-r--r--libs/hwui/OpenGLRenderer.cpp6
-rwxr-xr-xmedia/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java14
-rw-r--r--media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/mediarecorder/MediaRecorderTest.java8
-rw-r--r--media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/MediaPlayerPerformance.java147
-rwxr-xr-xpolicy/src/com/android/internal/policy/impl/PhoneWindowManager.java9
-rw-r--r--services/java/com/android/server/wm/Session.java8
-rw-r--r--services/java/com/android/server/wm/WindowManagerService.java59
-rw-r--r--services/java/com/android/server/wm/WindowState.java74
-rw-r--r--tests/FrameworkPerf/res/layout/main.xml17
-rw-r--r--tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java30
-rw-r--r--tests/FrameworkPerf/src/com/android/frameworkperf/TestArgs.java3
-rw-r--r--tests/FrameworkPerf/src/com/android/frameworkperf/TestService.java17
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java6
32 files changed, 641 insertions, 333 deletions
diff --git a/core/java/android/inputmethodservice/ExtractEditText.java b/core/java/android/inputmethodservice/ExtractEditText.java
index 4fc63ed2d917..72431f3615b6 100644
--- a/core/java/android/inputmethodservice/ExtractEditText.java
+++ b/core/java/android/inputmethodservice/ExtractEditText.java
@@ -156,4 +156,27 @@ public class ExtractEditText extends EditText {
mIME.onViewClicked(false);
}
}
+
+ /**
+ * Delete the range of text, supposedly valid
+ * @hide
+ */
+ @Override
+ protected void deleteText_internal(int start, int end) {
+ // Do not call the super method. This will change the source TextView instead, which
+ // will update the ExtractTextView.
+ mIME.onExtractedDeleteText(start, end);
+ }
+
+ /**
+ * Replaces the range of text [start, end[ by replacement text
+ * @hide
+ */
+ @Override
+ protected void replaceText_internal(int start, int end, CharSequence text) {
+ // Do not call the super method. This will change the source TextView instead, which
+ // will update the ExtractTextView.
+ mIME.onExtractedReplaceText(start, end, text);
+ }
+
}
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java
index 60188eab2250..02839dbe6770 100644
--- a/core/java/android/inputmethodservice/InputMethodService.java
+++ b/core/java/android/inputmethodservice/InputMethodService.java
@@ -1982,7 +1982,29 @@ public class InputMethodService extends AbstractInputMethodService {
conn.setSelection(start, end);
}
}
-
+
+ /**
+ * @hide
+ */
+ public void onExtractedDeleteText(int start, int end) {
+ InputConnection conn = getCurrentInputConnection();
+ if (conn != null) {
+ conn.setSelection(start, start);
+ conn.deleteSurroundingText(0, end-start);
+ }
+ }
+
+ /**
+ * @hide
+ */
+ public void onExtractedReplaceText(int start, int end, CharSequence text) {
+ InputConnection conn = getCurrentInputConnection();
+ if (conn != null) {
+ conn.setComposingRegion(start, end);
+ conn.commitText(text, 1);
+ }
+ }
+
/**
* This is called when the user has clicked on the extracted text view,
* when running in fullscreen mode. The default implementation hides
@@ -1998,7 +2020,7 @@ public class InputMethodService extends AbstractInputMethodService {
setCandidatesViewShown(false);
}
}
-
+
/**
* This is called when the user has performed a cursor movement in the
* extracted text view, when it is running in fullscreen mode. The default
diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java
index a9a628a59a2e..18167b601d32 100644
--- a/core/java/android/service/wallpaper/WallpaperService.java
+++ b/core/java/android/service/wallpaper/WallpaperService.java
@@ -608,7 +608,7 @@ public abstract class WallpaperService extends Service {
final int relayoutResult = mSession.relayout(
mWindow, mWindow.mSeq, mLayout, mWidth, mHeight,
- View.VISIBLE, false, mWinFrame, mContentInsets,
+ View.VISIBLE, 0, mWinFrame, mContentInsets,
mVisibleInsets, mConfiguration, mSurfaceHolder.mSurface);
if (DEBUG) Log.v(TAG, "New surface: " + mSurfaceHolder.mSurface
@@ -654,7 +654,7 @@ public abstract class WallpaperService extends Service {
}
redrawNeeded |= creating
- || (relayoutResult&WindowManagerImpl.RELAYOUT_FIRST_TIME) != 0;
+ || (relayoutResult&WindowManagerImpl.RELAYOUT_RES_FIRST_TIME) != 0;
if (forceReport || creating || surfaceCreating
|| formatChanged || sizeChanged) {
diff --git a/core/java/android/view/GLES20Canvas.java b/core/java/android/view/GLES20Canvas.java
index 67d9033d1084..aa0bfd2e0fe4 100644
--- a/core/java/android/view/GLES20Canvas.java
+++ b/core/java/android/view/GLES20Canvas.java
@@ -737,8 +737,21 @@ class GLES20Canvas extends HardwareCanvas {
// Shaders are ignored when drawing bitmaps
int modifiers = paint != null ? setupModifiers(bitmap, paint) : MODIFIER_NONE;
final int nativePaint = paint == null ? 0 : paint.mNativePaint;
- nDrawBitmap(mRenderer, bitmap.mNativeBitmap, bitmap.mBuffer, src.left, src.top, src.right,
- src.bottom, dst.left, dst.top, dst.right, dst.bottom, nativePaint);
+
+ float left, top, right, bottom;
+ if (src == null) {
+ left = top = 0;
+ right = bitmap.getWidth();
+ bottom = bitmap.getHeight();
+ } else {
+ left = src.left;
+ right = src.right;
+ top = src.top;
+ bottom = src.bottom;
+ }
+
+ nDrawBitmap(mRenderer, bitmap.mNativeBitmap, bitmap.mBuffer, left, top, right, bottom,
+ dst.left, dst.top, dst.right, dst.bottom, nativePaint);
if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers);
}
diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java
index f77cf7e8398b..ccb64895703c 100644
--- a/core/java/android/view/HardwareRenderer.java
+++ b/core/java/android/view/HardwareRenderer.java
@@ -219,6 +219,13 @@ public abstract class HardwareRenderer {
abstract int getHeight();
/**
+ * Gets the current canvas associated with this HardwareRenderer.
+ *
+ * @return the current HardwareCanvas
+ */
+ abstract HardwareCanvas getCanvas();
+
+ /**
* Sets the directory to use as a persistent storage for hardware rendering
* resources.
*
@@ -783,6 +790,11 @@ public abstract class HardwareRenderer {
return mHeight;
}
+ @Override
+ HardwareCanvas getCanvas() {
+ return mCanvas;
+ }
+
boolean canDraw() {
return mGl != null && mCanvas != null;
}
diff --git a/core/java/android/view/IWindowSession.aidl b/core/java/android/view/IWindowSession.aidl
index 282d7be6d9fb..53d6e1f20281 100644
--- a/core/java/android/view/IWindowSession.aidl
+++ b/core/java/android/view/IWindowSession.aidl
@@ -54,9 +54,8 @@ interface IWindowSession {
* @param requestedWidth The width the window wants to be.
* @param requestedHeight The height the window wants to be.
* @param viewVisibility Window root view's visibility.
- * @param insetsPending Set to true if the client will be later giving
- * internal insets; as a result, the window will not impact other window
- * layouts until the insets are given.
+ * @param flags Request flags: {@link WindowManagerImpl#RELAYOUT_INSETS_PENDING},
+ * {@link WindowManagerImpl#RELAYOUT_DEFER_SURFACE_DESTROY}.
* @param outFrame Rect in which is placed the new position/size on
* screen.
* @param outContentInsets Rect in which is placed the offsets from
@@ -80,11 +79,17 @@ interface IWindowSession {
*/
int relayout(IWindow window, int seq, in WindowManager.LayoutParams attrs,
int requestedWidth, int requestedHeight, int viewVisibility,
- boolean insetsPending, out Rect outFrame, out Rect outContentInsets,
+ int flags, out Rect outFrame, out Rect outContentInsets,
out Rect outVisibleInsets, out Configuration outConfig,
out Surface outSurface);
/**
+ * If a call to relayout() asked to have the surface destroy deferred,
+ * it must call this once it is okay to destroy that surface.
+ */
+ void performDeferredDestroy(IWindow window);
+
+ /**
* Called by a client to report that it ran out of graphics memory.
*/
boolean outOfMemory(IWindow window);
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java
index 9a57ea0679c4..0e684907ae0a 100644
--- a/core/java/android/view/SurfaceView.java
+++ b/core/java/android/view/SurfaceView.java
@@ -16,7 +16,6 @@
package android.view;
-import android.util.DisplayMetrics;
import com.android.internal.view.BaseIWindow;
import android.content.Context;
@@ -82,7 +81,6 @@ import java.util.concurrent.locks.ReentrantLock;
public class SurfaceView extends View {
static private final String TAG = "SurfaceView";
static private final boolean DEBUG = false;
- static private final boolean localLOGV = DEBUG ? true : false;
final ArrayList<SurfaceHolder.Callback> mCallbacks
= new ArrayList<SurfaceHolder.Callback>();
@@ -90,7 +88,8 @@ public class SurfaceView extends View {
final int[] mLocation = new int[2];
final ReentrantLock mSurfaceLock = new ReentrantLock();
- final Surface mSurface = new Surface();
+ Surface mSurface = new Surface(); // Current surface in use
+ Surface mNewSurface = new Surface(); // New surface we are switching to
boolean mDrawingStopped = true;
final WindowManager.LayoutParams mLayout
@@ -145,8 +144,7 @@ public class SurfaceView extends View {
int mRequestedFormat = PixelFormat.RGB_565;
boolean mHaveFrame = false;
- boolean mDestroyReportNeeded = false;
- boolean mNewSurfaceNeeded = false;
+ boolean mSurfaceCreated = false;
long mLastLockTime = 0;
boolean mVisible = false;
@@ -236,46 +234,6 @@ public class SurfaceView extends View {
updateWindow(false, false);
}
- /**
- * This method is not intended for general use. It was created
- * temporarily to improve performance of 3D layers in Launcher
- * and should be removed and fixed properly.
- *
- * Do not call this method. Ever.
- *
- * @hide
- */
- protected void showSurface() {
- if (mSession != null) {
- updateWindow(true, false);
- }
- }
-
- /**
- * This method is not intended for general use. It was created
- * temporarily to improve performance of 3D layers in Launcher
- * and should be removed and fixed properly.
- *
- * Do not call this method. Ever.
- *
- * @hide
- */
- protected void hideSurface() {
- if (mSession != null && mWindow != null) {
- mSurfaceLock.lock();
- try {
- DisplayMetrics metrics = getResources().getDisplayMetrics();
- mLayout.x = metrics.widthPixels * 3;
- mSession.relayout(mWindow, mWindow.mSeq, mLayout, mWidth, mHeight, VISIBLE, false,
- mWinFrame, mContentInsets, mVisibleInsets, mConfiguration, mSurface);
- } catch (RemoteException e) {
- // Ignore
- } finally {
- mSurfaceLock.unlock();
- }
- }
- }
-
@Override
protected void onDetachedFromWindow() {
if (mGlobalListenersAdded) {
@@ -444,14 +402,13 @@ public class SurfaceView extends View {
final boolean creating = mWindow == null;
final boolean formatChanged = mFormat != mRequestedFormat;
final boolean sizeChanged = mWidth != myWidth || mHeight != myHeight;
- final boolean visibleChanged = mVisible != mRequestedVisible
- || mNewSurfaceNeeded;
+ final boolean visibleChanged = mVisible != mRequestedVisible;
if (force || creating || formatChanged || sizeChanged || visibleChanged
|| mLeft != mLocation[0] || mTop != mLocation[1]
|| mUpdateWindowNeeded || mReportDrawNeeded || redrawNeeded) {
- if (localLOGV) Log.i(TAG, "Changes: creating=" + creating
+ if (DEBUG) Log.i(TAG, "Changes: creating=" + creating
+ " format=" + formatChanged + " size=" + sizeChanged
+ " visible=" + visibleChanged
+ " left=" + (mLeft != mLocation[0])
@@ -496,15 +453,11 @@ public class SurfaceView extends View {
mVisible ? VISIBLE : GONE, mContentInsets);
}
- if (visibleChanged && (!visible || mNewSurfaceNeeded)) {
- reportSurfaceDestroyed();
- }
-
- mNewSurfaceNeeded = false;
-
boolean realSizeChanged;
boolean reportDrawNeeded;
-
+
+ int relayoutResult;
+
mSurfaceLock.lock();
try {
mUpdateWindowNeeded = false;
@@ -512,17 +465,21 @@ public class SurfaceView extends View {
mReportDrawNeeded = false;
mDrawingStopped = !visible;
- final int relayoutResult = mSession.relayout(
+ if (DEBUG) Log.i(TAG, "Cur surface: " + mSurface);
+
+ relayoutResult = mSession.relayout(
mWindow, mWindow.mSeq, mLayout, mWidth, mHeight,
- visible ? VISIBLE : GONE, false, mWinFrame, mContentInsets,
- mVisibleInsets, mConfiguration, mSurface);
- if ((relayoutResult&WindowManagerImpl.RELAYOUT_FIRST_TIME) != 0) {
+ visible ? VISIBLE : GONE,
+ WindowManagerImpl.RELAYOUT_DEFER_SURFACE_DESTROY,
+ mWinFrame, mContentInsets,
+ mVisibleInsets, mConfiguration, mNewSurface);
+ if ((relayoutResult&WindowManagerImpl.RELAYOUT_RES_FIRST_TIME) != 0) {
mReportDrawNeeded = true;
}
-
- if (localLOGV) Log.i(TAG, "New surface: " + mSurface
+
+ if (DEBUG) Log.i(TAG, "New surface: " + mNewSurface
+ ", vis=" + visible + ", frame=" + mWinFrame);
-
+
mSurfaceFrame.left = 0;
mSurfaceFrame.top = 0;
if (mTranslator == null) {
@@ -547,28 +504,54 @@ public class SurfaceView extends View {
try {
redrawNeeded |= creating | reportDrawNeeded;
- if (visible) {
- mDestroyReportNeeded = true;
+ SurfaceHolder.Callback callbacks[] = null;
- SurfaceHolder.Callback callbacks[];
- synchronized (mCallbacks) {
- callbacks = new SurfaceHolder.Callback[mCallbacks.size()];
- mCallbacks.toArray(callbacks);
+ final boolean surfaceChanged =
+ (relayoutResult&WindowManagerImpl.RELAYOUT_RES_SURFACE_CHANGED) != 0;
+ if (mSurfaceCreated && (surfaceChanged || (!visible && visibleChanged))) {
+ mSurfaceCreated = false;
+ if (mSurface.isValid()) {
+ if (DEBUG) Log.i(TAG, "visibleChanged -- surfaceDestroyed");
+ callbacks = getSurfaceCallbacks();
+ for (SurfaceHolder.Callback c : callbacks) {
+ c.surfaceDestroyed(mSurfaceHolder);
+ }
}
+ }
+
+ Surface tmpSurface = mSurface;
+ mSurface = mNewSurface;
+ mNewSurface = tmpSurface;
+ mNewSurface.release();
- if (visibleChanged) {
+ if (visible) {
+ if (!mSurfaceCreated && (surfaceChanged || visibleChanged)) {
+ mSurfaceCreated = true;
mIsCreating = true;
+ if (DEBUG) Log.i(TAG, "visibleChanged -- surfaceCreated");
+ if (callbacks == null) {
+ callbacks = getSurfaceCallbacks();
+ }
for (SurfaceHolder.Callback c : callbacks) {
c.surfaceCreated(mSurfaceHolder);
}
}
if (creating || formatChanged || sizeChanged
|| visibleChanged || realSizeChanged) {
+ if (DEBUG) Log.i(TAG, "surfaceChanged -- format=" + mFormat
+ + " w=" + myWidth + " h=" + myHeight);
+ if (callbacks == null) {
+ callbacks = getSurfaceCallbacks();
+ }
for (SurfaceHolder.Callback c : callbacks) {
c.surfaceChanged(mSurfaceHolder, mFormat, myWidth, myHeight);
}
}
if (redrawNeeded) {
+ if (DEBUG) Log.i(TAG, "surfaceRedrawNeeded");
+ if (callbacks == null) {
+ callbacks = getSurfaceCallbacks();
+ }
for (SurfaceHolder.Callback c : callbacks) {
if (c instanceof SurfaceHolder.Callback2) {
((SurfaceHolder.Callback2)c).surfaceRedrawNeeded(
@@ -576,41 +559,34 @@ public class SurfaceView extends View {
}
}
}
- } else {
- mSurface.release();
}
} finally {
mIsCreating = false;
if (redrawNeeded) {
+ if (DEBUG) Log.i(TAG, "finishedDrawing");
mSession.finishDrawing(mWindow);
}
+ mSession.performDeferredDestroy(mWindow);
}
} catch (RemoteException ex) {
}
- if (localLOGV) Log.v(
+ if (DEBUG) Log.v(
TAG, "Layout: x=" + mLayout.x + " y=" + mLayout.y +
" w=" + mLayout.width + " h=" + mLayout.height +
", frame=" + mSurfaceFrame);
}
}
- private void reportSurfaceDestroyed() {
- if (mDestroyReportNeeded) {
- mDestroyReportNeeded = false;
- SurfaceHolder.Callback callbacks[];
- synchronized (mCallbacks) {
- callbacks = new SurfaceHolder.Callback[mCallbacks.size()];
- mCallbacks.toArray(callbacks);
- }
- for (SurfaceHolder.Callback c : callbacks) {
- c.surfaceDestroyed(mSurfaceHolder);
- }
+ private SurfaceHolder.Callback[] getSurfaceCallbacks() {
+ SurfaceHolder.Callback callbacks[];
+ synchronized (mCallbacks) {
+ callbacks = new SurfaceHolder.Callback[mCallbacks.size()];
+ mCallbacks.toArray(callbacks);
}
- super.onDetachedFromWindow();
+ return callbacks;
}
void handleGetNewSurface() {
- mNewSurfaceNeeded = true;
updateWindow(false, false);
}
@@ -636,7 +612,7 @@ public class SurfaceView extends View {
Rect visibleInsets, boolean reportDraw, Configuration newConfig) {
SurfaceView surfaceView = mSurfaceView.get();
if (surfaceView != null) {
- if (localLOGV) Log.v(
+ if (DEBUG) Log.v(
"SurfaceView", surfaceView + " got resized: w=" +
w + " h=" + h + ", cur w=" + mCurWidth + " h=" + mCurHeight);
surfaceView.mSurfaceLock.lock();
@@ -754,7 +730,7 @@ public class SurfaceView extends View {
private final Canvas internalLockCanvas(Rect dirty) {
mSurfaceLock.lock();
- if (localLOGV) Log.i(TAG, "Locking canvas... stopped="
+ if (DEBUG) Log.i(TAG, "Locking canvas... stopped="
+ mDrawingStopped + ", win=" + mWindow);
Canvas c = null;
@@ -774,7 +750,7 @@ public class SurfaceView extends View {
}
}
- if (localLOGV) Log.i(TAG, "Returned canvas: " + c);
+ if (DEBUG) Log.i(TAG, "Returned canvas: " + c);
if (c != null) {
mLastLockTime = SystemClock.uptimeMillis();
return c;
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 18d5c40fc804..5060f83e7a99 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -1217,7 +1217,8 @@ public final class ViewRootImpl extends Handler implements ViewParent,
disposeResizeBuffer();
boolean completed = false;
- HardwareCanvas canvas = null;
+ HardwareCanvas hwRendererCanvas = mAttachInfo.mHardwareRenderer.getCanvas();
+ HardwareCanvas layerCanvas = null;
try {
if (mResizeBuffer == null) {
mResizeBuffer = mAttachInfo.mHardwareRenderer.createHardwareLayer(
@@ -1226,12 +1227,12 @@ public final class ViewRootImpl extends Handler implements ViewParent,
mResizeBuffer.getHeight() != mHeight) {
mResizeBuffer.resize(mWidth, mHeight);
}
- canvas = mResizeBuffer.start(mAttachInfo.mHardwareCanvas);
- canvas.setViewport(mWidth, mHeight);
- canvas.onPreDraw(null);
- final int restoreCount = canvas.save();
+ layerCanvas = mResizeBuffer.start(hwRendererCanvas);
+ layerCanvas.setViewport(mWidth, mHeight);
+ layerCanvas.onPreDraw(null);
+ final int restoreCount = layerCanvas.save();
- canvas.drawColor(0xff000000, PorterDuff.Mode.SRC);
+ layerCanvas.drawColor(0xff000000, PorterDuff.Mode.SRC);
int yoff;
final boolean scrolling = mScroller != null
@@ -1243,27 +1244,27 @@ public final class ViewRootImpl extends Handler implements ViewParent,
yoff = mScrollY;
}
- canvas.translate(0, -yoff);
+ layerCanvas.translate(0, -yoff);
if (mTranslator != null) {
- mTranslator.translateCanvas(canvas);
+ mTranslator.translateCanvas(layerCanvas);
}
- mView.draw(canvas);
+ mView.draw(layerCanvas);
mResizeBufferStartTime = SystemClock.uptimeMillis();
mResizeBufferDuration = mView.getResources().getInteger(
com.android.internal.R.integer.config_mediumAnimTime);
completed = true;
- canvas.restoreToCount(restoreCount);
+ layerCanvas.restoreToCount(restoreCount);
} catch (OutOfMemoryError e) {
Log.w(TAG, "Not enough memory for content change anim buffer", e);
} finally {
- if (canvas != null) {
- canvas.onPostDraw();
+ if (layerCanvas != null) {
+ layerCanvas.onPostDraw();
}
if (mResizeBuffer != null) {
- mResizeBuffer.end(mAttachInfo.mHardwareCanvas);
+ mResizeBuffer.end(hwRendererCanvas);
if (!completed) {
mResizeBuffer.destroy();
mResizeBuffer = null;
@@ -1426,7 +1427,7 @@ public final class ViewRootImpl extends Handler implements ViewParent,
if (!mStopped) {
boolean focusChangedDueToTouchMode = ensureTouchModeLocally(
- (relayoutResult&WindowManagerImpl.RELAYOUT_IN_TOUCH_MODE) != 0);
+ (relayoutResult&WindowManagerImpl.RELAYOUT_RES_IN_TOUCH_MODE) != 0);
if (focusChangedDueToTouchMode || mWidth != host.getMeasuredWidth()
|| mHeight != host.getMeasuredHeight() || contentInsetsChanged) {
childWidthMeasureSpec = getRootMeasureSpec(mWidth, lp.width);
@@ -1637,7 +1638,7 @@ public final class ViewRootImpl extends Handler implements ViewParent,
mLastDrawDurationNanos = System.nanoTime() - drawStartTime;
}
- if ((relayoutResult&WindowManagerImpl.RELAYOUT_FIRST_TIME) != 0
+ if ((relayoutResult&WindowManagerImpl.RELAYOUT_RES_FIRST_TIME) != 0
|| mReportNextDraw) {
if (LOCAL_LOGV) {
Log.v(TAG, "FINISHED DRAWING: " + mWindowAttributes.getTitle());
@@ -1670,7 +1671,7 @@ public final class ViewRootImpl extends Handler implements ViewParent,
}
// We were supposed to report when we are done drawing. Since we canceled the
// draw, remember it here.
- if ((relayoutResult&WindowManagerImpl.RELAYOUT_FIRST_TIME) != 0) {
+ if ((relayoutResult&WindowManagerImpl.RELAYOUT_RES_FIRST_TIME) != 0) {
mReportNextDraw = true;
}
if (fullRedrawNeeded) {
@@ -3585,8 +3586,8 @@ public final class ViewRootImpl extends Handler implements ViewParent,
mWindow, mSeq, params,
(int) (mView.getMeasuredWidth() * appScale + 0.5f),
(int) (mView.getMeasuredHeight() * appScale + 0.5f),
- viewVisibility, insetsPending, mWinFrame,
- mPendingContentInsets, mPendingVisibleInsets,
+ viewVisibility, insetsPending ? WindowManagerImpl.RELAYOUT_INSETS_PENDING : 0,
+ mWinFrame, mPendingContentInsets, mPendingVisibleInsets,
mPendingConfiguration, mSurface);
//Log.d(TAG, "<<<<<< BACK FROM relayout");
if (restore) {
@@ -3716,7 +3717,7 @@ public final class ViewRootImpl extends Handler implements ViewParent,
// animation info.
try {
if ((relayoutWindow(mWindowAttributes, viewVisibility, false)
- & WindowManagerImpl.RELAYOUT_FIRST_TIME) != 0) {
+ & WindowManagerImpl.RELAYOUT_RES_FIRST_TIME) != 0) {
sWindowSession.finishDrawing(mWindow);
}
} catch (RemoteException e) {
diff --git a/core/java/android/view/WindowManagerImpl.java b/core/java/android/view/WindowManagerImpl.java
index dfd1d5538030..d7113374bdc3 100644
--- a/core/java/android/view/WindowManagerImpl.java
+++ b/core/java/android/view/WindowManagerImpl.java
@@ -63,15 +63,34 @@ public class WindowManagerImpl implements WindowManager {
* The user is navigating with keys (not the touch screen), so
* navigational focus should be shown.
*/
- public static final int RELAYOUT_IN_TOUCH_MODE = 0x1;
+ public static final int RELAYOUT_RES_IN_TOUCH_MODE = 0x1;
/**
* This is the first time the window is being drawn,
* so the client must call drawingFinished() when done
*/
- public static final int RELAYOUT_FIRST_TIME = 0x2;
-
+ public static final int RELAYOUT_RES_FIRST_TIME = 0x2;
+ /**
+ * The window manager has changed the surface from the last call.
+ */
+ public static final int RELAYOUT_RES_SURFACE_CHANGED = 0x4;
+
+ /**
+ * Flag for relayout: the client will be later giving
+ * internal insets; as a result, the window will not impact other window
+ * layouts until the insets are given.
+ */
+ public static final int RELAYOUT_INSETS_PENDING = 0x1;
+
+ /**
+ * Flag for relayout: the client may be currently using the current surface,
+ * so if it is to be destroyed as a part of the relayout the destroy must
+ * be deferred until later. The client will call performDeferredDestroy()
+ * when it is okay.
+ */
+ public static final int RELAYOUT_DEFER_SURFACE_DESTROY = 0x2;
+
public static final int ADD_FLAG_APP_VISIBLE = 0x2;
- public static final int ADD_FLAG_IN_TOUCH_MODE = RELAYOUT_IN_TOUCH_MODE;
+ public static final int ADD_FLAG_IN_TOUCH_MODE = RELAYOUT_RES_IN_TOUCH_MODE;
public static final int ADD_OKAY = 0;
public static final int ADD_BAD_APP_TOKEN = -1;
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 4d7690de995c..c24d928350a2 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -7629,6 +7629,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
list.get(i).onTextChanged(text, start, before, after);
}
}
+
+ updateSpellCheckSpans(start, start + after);
+
+ // Hide the controllers as soon as text is modified (typing, procedural...)
+ // We do not hide the span controllers, since they can be added when a new text is
+ // inserted into the text view (voice IME).
+ hideCursorControllers();
}
/**
@@ -7668,15 +7675,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
sendOnTextChanged(buffer, start, before, after);
onTextChanged(buffer, start, before, after);
-
- updateSpellCheckSpans(start, start + after);
-
- // Hide the controllers if the amount of content changed
- if (before != after) {
- // We do not hide the span controllers, as they can be added when a new text is
- // inserted into the text view
- hideCursorControllers();
- }
}
/**
@@ -7979,16 +7977,12 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
@Override
public void onClick(View view) {
if (view == mDeleteTextView) {
- deleteText();
- }
- }
-
- private void deleteText() {
- Editable editable = (Editable) mText;
- int start = editable.getSpanStart(mEasyEditSpan);
- int end = editable.getSpanEnd(mEasyEditSpan);
- if (start >= 0 && end >= 0) {
- editable.delete(start, end);
+ Editable editable = (Editable) mText;
+ int start = editable.getSpanStart(mEasyEditSpan);
+ int end = editable.getSpanEnd(mEasyEditSpan);
+ if (start >= 0 && end >= 0) {
+ deleteText_internal(start, end);
+ }
}
}
@@ -9113,7 +9107,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
case ID_CUT:
setPrimaryClip(ClipData.newPlainText(null, getTransformedText(min, max)));
- ((Editable) mText).delete(min, max);
+ deleteText_internal(min, max);
stopSelectionActionMode();
return true;
@@ -9144,7 +9138,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
if (Character.isSpaceChar(charBefore) && Character.isSpaceChar(charAfter)) {
// Two spaces at beginning of paste: remove one
final int originalLength = mText.length();
- ((Editable) mText).delete(min - 1, min);
+ deleteText_internal(min - 1, min);
// Due to filters, there is no guarantee that exactly one character was
// removed: count instead.
final int delta = mText.length() - originalLength;
@@ -9154,7 +9148,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
!Character.isSpaceChar(charAfter) && charAfter != '\n') {
// No space at beginning of paste: add one
final int originalLength = mText.length();
- ((Editable) mText).replace(min, min, " ");
+ replaceText_internal(min, min, " ");
// Taking possible filters into account as above.
final int delta = mText.length() - originalLength;
min += delta;
@@ -9168,11 +9162,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
if (Character.isSpaceChar(charBefore) && Character.isSpaceChar(charAfter)) {
// Two spaces at end of paste: remove one
- ((Editable) mText).delete(max, max + 1);
+ deleteText_internal(max, max + 1);
} else if (!Character.isSpaceChar(charBefore) && charBefore != '\n' &&
!Character.isSpaceChar(charAfter) && charAfter != '\n') {
// No space at end of paste: add one
- ((Editable) mText).replace(max, max, " ");
+ replaceText_internal(max, max, " ");
}
}
}
@@ -9884,9 +9878,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
- TextView textView = (TextView) view;
Editable editable = (Editable) mText;
-
SuggestionInfo suggestionInfo = mSuggestionInfos[position];
if (suggestionInfo.suggestionIndex == DELETE_TEXT) {
@@ -9900,7 +9892,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
Character.isSpaceChar(editable.charAt(spanUnionStart - 1)))) {
spanUnionEnd = spanUnionEnd + 1;
}
- editable.replace(spanUnionStart, spanUnionEnd, "");
+ deleteText_internal(spanUnionStart, spanUnionEnd);
}
hide();
return;
@@ -9921,6 +9913,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
intent.setFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK);
getContext().startActivity(intent);
// There is no way to know if the word was indeed added. Re-check.
+ // TODO The ExtractEditText should remove the span in the original text instead
editable.removeSpan(suggestionInfo.suggestionSpan);
updateSpellCheckSpans(spanStart, spanEnd);
} else {
@@ -9948,9 +9941,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
final int suggestionStart = suggestionInfo.suggestionStart;
final int suggestionEnd = suggestionInfo.suggestionEnd;
- final String suggestion = textView.getText().subSequence(
+ final String suggestion = suggestionInfo.text.subSequence(
suggestionStart, suggestionEnd).toString();
- editable.replace(spanStart, spanEnd, suggestion);
+ replaceText_internal(spanStart, spanEnd, suggestion);
// Notify source IME of the suggestion pick. Do this before swaping texts.
if (!TextUtils.isEmpty(
@@ -9974,6 +9967,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
// way to assign them a valid range after replacement
if (suggestionSpansStarts[i] <= spanStart &&
suggestionSpansEnds[i] >= spanEnd) {
+ // TODO The ExtractEditText should restore these spans in the original text
editable.setSpan(suggestionSpans[i], suggestionSpansStarts[i],
suggestionSpansEnds[i] + lengthDifference, suggestionSpansFlags[i]);
}
@@ -10840,7 +10834,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
// Handles can not cross and selection is at least one character
final int selectionEnd = getSelectionEnd();
- if (offset >= selectionEnd) offset = selectionEnd - 1;
+ if (offset >= selectionEnd) offset = Math.max(0, selectionEnd - 1);
positionAtCursorOffset(offset, false);
}
@@ -10882,7 +10876,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
// Handles can not cross and selection is at least one character
final int selectionStart = getSelectionStart();
- if (offset <= selectionStart) offset = selectionStart + 1;
+ if (offset <= selectionStart) offset = Math.min(selectionStart + 1, mText.length());
positionAtCursorOffset(offset, false);
}
@@ -11254,7 +11248,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
int max = extractRangeEndFromLong(minMax);
Selection.setSelection((Spannable) mText, max);
- ((Editable) mText).replace(min, max, content);
+ replaceText_internal(min, max, content);
if (dragDropIntoItself) {
int dragSourceStart = dragLocalState.start;
@@ -11267,7 +11261,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
// Delete original selection
- ((Editable) mText).delete(dragSourceStart, dragSourceEnd);
+ deleteText_internal(dragSourceStart, dragSourceEnd);
// Make sure we do not leave two adjacent spaces.
if ((dragSourceStart == 0 ||
@@ -11276,7 +11270,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
Character.isSpaceChar(mTransformed.charAt(dragSourceStart)))) {
final int pos = dragSourceStart == mText.length() ?
dragSourceStart - 1 : dragSourceStart;
- ((Editable) mText).delete(pos, pos + 1);
+ deleteText_internal(pos, pos + 1);
}
}
}
@@ -11437,6 +11431,22 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
}
}
+ /**
+ * Deletes the range of text [start, end[.
+ * @hide
+ */
+ protected void deleteText_internal(int start, int end) {
+ ((Editable) mText).delete(start, end);
+ }
+
+ /**
+ * Replaces the range of text [start, end[ by replacement text
+ * @hide
+ */
+ protected void replaceText_internal(int start, int end, CharSequence text) {
+ ((Editable) mText).replace(start, end, text);
+ }
+
@ViewDebug.ExportedProperty(category = "text")
private CharSequence mText;
private CharSequence mTransformed;
diff --git a/core/res/res/anim/app_starting_exit.xml b/core/res/res/anim/app_starting_exit.xml
index ee8d80bb0a74..60e4109837d4 100644
--- a/core/res/res/anim/app_starting_exit.xml
+++ b/core/res/res/anim/app_starting_exit.xml
@@ -18,7 +18,8 @@
*/
-->
-<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@interpolator/decelerate_quad">
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+ android:detachWallpaper="true" android:interpolator="@interpolator/decelerate_quad">
<alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="160" />
</set>
diff --git a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerStressTestRunner.java b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerStressTestRunner.java
index d23dfd32705a..3ffa085ae0b7 100644
--- a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerStressTestRunner.java
+++ b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerStressTestRunner.java
@@ -38,7 +38,8 @@ public class ConnectivityManagerStressTestRunner extends InstrumentationTestRunn
public int mSoftapIterations = 100;
public int mScanIterations = 100;
public int mReconnectIterations = 100;
- public int mSleepTime = 30 * 1000; // default sleep time is 30 seconds
+ // sleep time before restart wifi, default is set to 2 minutes
+ public int mSleepTime = 2 * 60 * 1000;
public String mReconnectSsid = "securenetdhcp";
public String mReconnectPassword = "androidwifi";
diff --git a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java
index adf1883c8a5e..0580ebcd5a75 100644
--- a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java
+++ b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/ConnectivityManagerTestActivity.java
@@ -62,6 +62,8 @@ public class ConnectivityManagerTestActivity extends Activity {
public static final int WIFI_SCAN_TIMEOUT = 50 * 1000;
public static final int SHORT_TIMEOUT = 5 * 1000;
public static final long LONG_TIMEOUT = 50 * 1000;
+ // 2 minutes timer between wifi stop and start
+ public static final long WIFI_STOP_START_INTERVAL = 2 * 60 * 1000;
public static final int SUCCESS = 0; // for Wifi tethering state change
public static final int FAILURE = 1;
public static final int INIT = -1;
@@ -247,6 +249,8 @@ public class ConnectivityManagerTestActivity extends Activity {
sleep(SHORT_TIMEOUT);
removeConfiguredNetworksAndDisableWifi();
mWifiRegexs = mCM.getTetherableWifiRegexs();
+ // after wifi is shutdown, wait for 2 minute to enable wifi
+ sleep(WIFI_STOP_START_INTERVAL);
}
public List<WifiConfiguration> loadNetworkConfigurations() throws Exception {
diff --git a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/NetworkState.java b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/NetworkState.java
index d586396dc19b..5a4a2d0ba8d3 100644
--- a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/NetworkState.java
+++ b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/NetworkState.java
@@ -77,10 +77,13 @@ public class NetworkState {
mReason = "no state is recorded.";
return false;
} else if (mStateDepository.size() > 1) {
- Log.v(LOG_TAG, "no broadcast is expected, " +
- "instead broadcast is probably received");
- mReason = "no broadcast is expected, instead broadcast is probably received";
- return false;
+ for (int i = 0; i < mStateDepository.size(); i++) {
+ if (mStateDepository.get(i) != mTransitionTarget) {
+ Log.v(LOG_TAG, "state changed.");
+ mReason = "Unexpected state change";
+ return false;
+ }
+ }
} else if (mStateDepository.get(0) != mTransitionTarget) {
Log.v(LOG_TAG, mTransitionTarget + " is expected, but it is " +
mStateDepository.get(0));
diff --git a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/ConnectivityManagerMobileTest.java b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/ConnectivityManagerMobileTest.java
index d9b770a384b5..b1f4bf122a4f 100644
--- a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/ConnectivityManagerMobileTest.java
+++ b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/ConnectivityManagerMobileTest.java
@@ -66,7 +66,7 @@ public class ConnectivityManagerMobileTest
// Each test case will start with cellular connection
if (Settings.System.getInt(getInstrumentation().getContext().getContentResolver(),
Settings.System.AIRPLANE_MODE_ON) == 1) {
- Log.v(LOG_TAG, "airplane is not disabled, disable it.");
+ log("airplane is not disabled, disable it.");
cmActivity.setAirplaneMode(getInstrumentation().getContext(), false);
}
if (!UtilHelper.isWifiOnly()) {
@@ -84,13 +84,13 @@ public class ConnectivityManagerMobileTest
@Override
public void tearDown() throws Exception {
cmActivity.finish();
- Log.v(LOG_TAG, "tear down ConnectivityManagerTestActivity");
+ log("tear down ConnectivityManagerTestActivity");
wl.release();
cmActivity.removeConfiguredNetworksAndDisableWifi();
// if airplane mode is set, disable it.
if (Settings.System.getInt(getInstrumentation().getContext().getContentResolver(),
Settings.System.AIRPLANE_MODE_ON) == 1) {
- Log.v(LOG_TAG, "disable airplane mode if it is enabled");
+ log("disable airplane mode if it is enabled");
cmActivity.setAirplaneMode(getInstrumentation().getContext(), false);
}
super.tearDown();
@@ -104,17 +104,24 @@ public class ConnectivityManagerMobileTest
assertTrue("not connected to cellular network", extraNetInfo.isConnected());
}
+ private void log(String message) {
+ Log.v(LOG_TAG, message);
+ }
+
+ private void sleep(long sleeptime) {
+ try {
+ Thread.sleep(sleeptime);
+ } catch (InterruptedException e) {}
+ }
+
// Test case 1: Test enabling Wifi without associating with any AP, no broadcast on network
// event should be expected.
@LargeTest
public void test3GToWifiNotification() {
// Enable Wi-Fi to avoid initial UNKNOWN state
cmActivity.enableWifi();
- try {
- Thread.sleep(2 * ConnectivityManagerTestActivity.SHORT_TIMEOUT);
- } catch (Exception e) {
- Log.v(LOG_TAG, "exception: " + e.toString());
- }
+ sleep(2 * ConnectivityManagerTestActivity.SHORT_TIMEOUT);
+
// Wi-Fi is disabled
cmActivity.disableWifi();
@@ -123,11 +130,8 @@ public class ConnectivityManagerMobileTest
assertTrue(cmActivity.waitForNetworkState(ConnectivityManager.TYPE_MOBILE,
State.CONNECTED, ConnectivityManagerTestActivity.LONG_TIMEOUT));
// Wait for 10 seconds for broadcasts to be sent out
- try {
- Thread.sleep(10 * 1000);
- } catch (Exception e) {
- fail("thread in sleep is interrupted.");
- }
+ sleep(10 * 1000);
+
// As Wifi stays in DISCONNETED, Mobile statys in CONNECTED,
// the connectivity manager will not broadcast any network connectivity event for Wifi
NetworkInfo networkInfo = cmActivity.mCM.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
@@ -138,22 +142,18 @@ public class ConnectivityManagerMobileTest
NetworkState.DO_NOTHING, State.DISCONNECTED);
// Eanble Wifi without associating with any AP
cmActivity.enableWifi();
- try {
- Thread.sleep(2 * ConnectivityManagerTestActivity.SHORT_TIMEOUT);
- } catch (Exception e) {
- Log.v(LOG_TAG, "exception: " + e.toString());
- }
+ sleep(2 * ConnectivityManagerTestActivity.SHORT_TIMEOUT);
// validate state and broadcast
if (!cmActivity.validateNetworkStates(ConnectivityManager.TYPE_WIFI)) {
- Log.v(LOG_TAG, "the state for WIFI is changed");
- Log.v(LOG_TAG, "reason: " +
+ log("the state for WIFI is changed");
+ log("reason: " +
cmActivity.getTransitionFailureReason(ConnectivityManager.TYPE_WIFI));
assertTrue("state validation fail", false);
}
if (!cmActivity.validateNetworkStates(ConnectivityManager.TYPE_MOBILE)) {
- Log.v(LOG_TAG, "the state for MOBILE is changed");
- Log.v(LOG_TAG, "reason: " +
+ log("the state for MOBILE is changed");
+ log("reason: " +
cmActivity.getTransitionFailureReason(ConnectivityManager.TYPE_MOBILE));
assertTrue("state validation fail", false);
}
@@ -182,7 +182,7 @@ public class ConnectivityManagerMobileTest
assertTrue(cmActivity.waitForWifiState(WifiManager.WIFI_STATE_ENABLED,
ConnectivityManagerTestActivity.LONG_TIMEOUT));
- Log.v(LOG_TAG, "wifi state is enabled");
+ log("wifi state is enabled");
assertTrue(cmActivity.waitForNetworkState(ConnectivityManager.TYPE_WIFI, State.CONNECTED,
ConnectivityManagerTestActivity.LONG_TIMEOUT));
if (!UtilHelper.isWifiOnly()) {
@@ -192,15 +192,15 @@ public class ConnectivityManagerMobileTest
// validate states
if (!cmActivity.validateNetworkStates(ConnectivityManager.TYPE_WIFI)) {
- Log.v(LOG_TAG, "Wifi state transition validation failed.");
- Log.v(LOG_TAG, "reason: " +
+ log("Wifi state transition validation failed.");
+ log("reason: " +
cmActivity.getTransitionFailureReason(ConnectivityManager.TYPE_WIFI));
assertTrue(false);
}
if (!UtilHelper.isWifiOnly()) {
if (!cmActivity.validateNetworkStates(ConnectivityManager.TYPE_MOBILE)) {
- Log.v(LOG_TAG, "Mobile state transition validation failed.");
- Log.v(LOG_TAG, "reason: " +
+ log("Mobile state transition validation failed.");
+ log("reason: " +
cmActivity.getTransitionFailureReason(ConnectivityManager.TYPE_MOBILE));
assertTrue(false);
}
@@ -219,16 +219,11 @@ public class ConnectivityManagerMobileTest
assertTrue(cmActivity.waitForNetworkState(ConnectivityManager.TYPE_WIFI, State.CONNECTED,
ConnectivityManagerTestActivity.LONG_TIMEOUT));
- try {
- Thread.sleep(ConnectivityManagerTestActivity.SHORT_TIMEOUT);
- } catch (Exception e) {
- Log.v(LOG_TAG, "exception: " + e.toString());
- }
-
+ sleep(ConnectivityManagerTestActivity.SHORT_TIMEOUT);
// Disable Wifi
- Log.v(LOG_TAG, "Disable Wifi");
+ log("Disable Wifi");
if (!cmActivity.disableWifi()) {
- Log.v(LOG_TAG, "disable Wifi failed");
+ log("disable Wifi failed");
return;
}
@@ -254,8 +249,10 @@ public class ConnectivityManagerMobileTest
cmActivity.setStateTransitionCriteria(ConnectivityManager.TYPE_WIFI, networkInfo.getState(),
NetworkState.TO_CONNECTION, State.CONNECTED);
+ // wait for 2 minutes before restart wifi
+ sleep(ConnectivityManagerTestActivity.WIFI_STOP_START_INTERVAL);
// Enable Wifi again
- Log.v(LOG_TAG, "Enable Wifi again");
+ log("Enable Wifi again");
cmActivity.enableWifi();
// Wait for Wifi to be connected and mobile to be disconnected
@@ -268,8 +265,8 @@ public class ConnectivityManagerMobileTest
// validate wifi states
if (!cmActivity.validateNetworkStates(ConnectivityManager.TYPE_WIFI)) {
- Log.v(LOG_TAG, "Wifi state transition validation failed.");
- Log.v(LOG_TAG, "reason: " +
+ log("Wifi state transition validation failed.");
+ log("reason: " +
cmActivity.getTransitionFailureReason(ConnectivityManager.TYPE_WIFI));
assertTrue(false);
}
@@ -288,11 +285,7 @@ public class ConnectivityManagerMobileTest
ConnectivityManagerTestActivity.LONG_TIMEOUT));
// Wait for a few seconds to avoid the state that both Mobile and Wifi is connected
- try {
- Thread.sleep(ConnectivityManagerTestActivity.SHORT_TIMEOUT);
- } catch (Exception e) {
- Log.v(LOG_TAG, "exception: " + e.toString());
- }
+ sleep(ConnectivityManagerTestActivity.SHORT_TIMEOUT);
NetworkInfo networkInfo;
if (!UtilHelper.isWifiOnly()) {
@@ -318,15 +311,15 @@ public class ConnectivityManagerMobileTest
// validate states
if (!cmActivity.validateNetworkStates(ConnectivityManager.TYPE_WIFI)) {
- Log.v(LOG_TAG, "Wifi state transition validation failed.");
- Log.v(LOG_TAG, "reason: " +
+ log("Wifi state transition validation failed.");
+ log("reason: " +
cmActivity.getTransitionFailureReason(ConnectivityManager.TYPE_WIFI));
assertTrue(false);
}
if (!UtilHelper.isWifiOnly()) {
if (!cmActivity.validateNetworkStates(ConnectivityManager.TYPE_MOBILE)) {
- Log.v(LOG_TAG, "Mobile state transition validation failed.");
- Log.v(LOG_TAG, "reason: " +
+ log("Mobile state transition validation failed.");
+ log("reason: " +
cmActivity.getTransitionFailureReason(ConnectivityManager.TYPE_MOBILE));
assertTrue(false);
}
@@ -346,19 +339,16 @@ public class ConnectivityManagerMobileTest
assertEquals(State.DISCONNECTED, networkInfo.getState());
// Enable airplane mode
+ log("Enable airplane mode");
cmActivity.setAirplaneMode(getInstrumentation().getContext(), true);
- try {
- Thread.sleep(ConnectivityManagerTestActivity.SHORT_TIMEOUT);
- } catch (Exception e) {
- Log.v(LOG_TAG, "exception: " + e.toString());
- }
+ sleep(ConnectivityManagerTestActivity.SHORT_TIMEOUT);
networkInfo = cmActivity.mCM.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
assertEquals(State.DISCONNECTED, networkInfo.getState());
if (!cmActivity.validateNetworkStates(ConnectivityManager.TYPE_MOBILE)) {
- Log.v(LOG_TAG, "Mobile state transition validation failed.");
- Log.v(LOG_TAG, "reason: " +
+ log("Mobile state transition validation failed.");
+ log("reason: " +
cmActivity.getTransitionFailureReason(ConnectivityManager.TYPE_MOBILE));
assertTrue(false);
}
@@ -381,14 +371,14 @@ public class ConnectivityManagerMobileTest
// Validate the state transition
if (!cmActivity.validateNetworkStates(ConnectivityManager.TYPE_MOBILE)) {
- Log.v(LOG_TAG, "Mobile state transition validation failed.");
- Log.v(LOG_TAG, "reason: " +
+ log("Mobile state transition validation failed.");
+ log("reason: " +
cmActivity.getTransitionFailureReason(ConnectivityManager.TYPE_MOBILE));
assertTrue(false);
}
if (!cmActivity.validateNetworkStates(ConnectivityManager.TYPE_WIFI)) {
- Log.v(LOG_TAG, "Wifi state transition validation failed.");
- Log.v(LOG_TAG, "reason: " +
+ log("Wifi state transition validation failed.");
+ log("reason: " +
cmActivity.getTransitionFailureReason(ConnectivityManager.TYPE_WIFI));
assertTrue(false);
}
@@ -399,6 +389,7 @@ public class ConnectivityManagerMobileTest
public void testDataConnectionOverAMWithWifi() {
assertNotNull("SSID is null", TEST_ACCESS_POINT);
// Eanble airplane mode
+ log("Enable airplane mode");
cmActivity.setAirplaneMode(getInstrumentation().getContext(), true);
NetworkInfo networkInfo;
@@ -423,15 +414,15 @@ public class ConnectivityManagerMobileTest
// validate state and broadcast
if (!cmActivity.validateNetworkStates(ConnectivityManager.TYPE_WIFI)) {
- Log.v(LOG_TAG, "state validate for Wifi failed");
- Log.v(LOG_TAG, "reason: " +
+ log("state validate for Wifi failed");
+ log("reason: " +
cmActivity.getTransitionFailureReason(ConnectivityManager.TYPE_WIFI));
assertTrue("State validation failed", false);
}
if (!UtilHelper.isWifiOnly()) {
if (!cmActivity.validateNetworkStates(ConnectivityManager.TYPE_MOBILE)) {
- Log.v(LOG_TAG, "state validation for Mobile failed");
- Log.v(LOG_TAG, "reason: " +
+ log("state validation for Mobile failed");
+ log("reason: " +
cmActivity.getTransitionFailureReason(ConnectivityManager.TYPE_MOBILE));
assertTrue("state validation failed", false);
}
@@ -454,7 +445,7 @@ public class ConnectivityManagerMobileTest
try {
Thread.sleep(ConnectivityManagerTestActivity.SHORT_TIMEOUT);
} catch (Exception e) {
- Log.v(LOG_TAG, "exception: " + e.toString());
+ log("exception: " + e.toString());
}
// Enable airplane mode without clearing Wifi
@@ -466,7 +457,7 @@ public class ConnectivityManagerMobileTest
try {
Thread.sleep(ConnectivityManagerTestActivity.SHORT_TIMEOUT);
} catch (Exception e) {
- Log.v(LOG_TAG, "exception: " + e.toString());
+ log("exception: " + e.toString());
}
// Prepare for state validation
@@ -487,8 +478,8 @@ public class ConnectivityManagerMobileTest
// validate the state transition
if (!cmActivity.validateNetworkStates(ConnectivityManager.TYPE_WIFI)) {
- Log.v(LOG_TAG, "Wifi state transition validation failed.");
- Log.v(LOG_TAG, "reason: " +
+ log("Wifi state transition validation failed.");
+ log("reason: " +
cmActivity.getTransitionFailureReason(ConnectivityManager.TYPE_WIFI));
assertTrue(false);
}
@@ -511,13 +502,13 @@ public class ConnectivityManagerMobileTest
try {
Thread.sleep(ConnectivityManagerTestActivity.SHORT_TIMEOUT);
} catch (Exception e) {
- Log.v(LOG_TAG, "exception: " + e.toString());
+ log("exception: " + e.toString());
}
// Disconnect from the current AP
- Log.v(LOG_TAG, "disconnect from the AP");
+ log("disconnect from the AP");
if (!cmActivity.disconnectAP()) {
- Log.v(LOG_TAG, "failed to disconnect from " + TEST_ACCESS_POINT);
+ log("failed to disconnect from " + TEST_ACCESS_POINT);
}
// Verify the connectivity state for Wifi is DISCONNECTED
@@ -525,7 +516,7 @@ public class ConnectivityManagerMobileTest
ConnectivityManagerTestActivity.LONG_TIMEOUT));
if (!cmActivity.disableWifi()) {
- Log.v(LOG_TAG, "disable Wifi failed");
+ log("disable Wifi failed");
return;
}
assertTrue(cmActivity.waitForWifiState(WifiManager.WIFI_STATE_DISABLED,
diff --git a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/WifiConnectionTest.java b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/WifiConnectionTest.java
index 22b17597bc24..d33a445e244c 100644
--- a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/WifiConnectionTest.java
+++ b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/WifiConnectionTest.java
@@ -136,7 +136,7 @@ public class WifiConnectionTest
// step 2: verify Wifi state and network state;
assertTrue(mAct.waitForNetworkState(ConnectivityManager.TYPE_WIFI,
- State.CONNECTED, 2 * ConnectivityManagerTestActivity.LONG_TIMEOUT));
+ State.CONNECTED, 6 * ConnectivityManagerTestActivity.LONG_TIMEOUT));
// step 3: verify the current connected network is the given SSID
assertNotNull("Wifi connection returns null", mAct.mWifiManager.getConnectionInfo());
@@ -166,8 +166,9 @@ public class WifiConnectionTest
String ssid = networks.get(i).SSID;
log("-- START Wi-Fi connection test to : " + ssid + " --");
connectToWifi(networks.get(i));
- sleep(2 * ConnectivityManagerTestActivity.SHORT_TIMEOUT,
- "interruped while waiting for wifi disabled.");
+ // wait for 2 minutes between wifi stop and start
+ sleep(ConnectivityManagerTestActivity.WIFI_STOP_START_INTERVAL,
+ "interruped while connected to wifi");
log("-- END Wi-Fi connection test to " + ssid + " -- ");
}
}
diff --git a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/stress/WifiStressTest.java b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/stress/WifiStressTest.java
index 7578e675b4eb..0b32fde76d4b 100644
--- a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/stress/WifiStressTest.java
+++ b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/stress/WifiStressTest.java
@@ -92,6 +92,9 @@ public class WifiStressTest
mPassword = mRunner.mReconnectPassword;
mScanIterations = mRunner.mScanIterations;
mWifiSleepTime = mRunner.mSleepTime;
+ log(String.format("mReconnectIterations(%d), mSsid(%s), mPassword(%s),"
+ + "mScanIterations(%d), mWifiSleepTime(%d)", mReconnectIterations, mSsid,
+ mPassword, mScanIterations, mWifiSleepTime));
mOutputWriter = new BufferedWriter(new FileWriter(new File(
Environment.getExternalStorageDirectory(), OUTPUT_FILE), true));
mAct.turnScreenOn();
@@ -248,6 +251,7 @@ public class WifiStressTest
assertTrue("Wi-Fi is connected, but no data connection.", mAct.pingTest(null));
int i;
+ long sum = 0;
for (i = 0; i < mReconnectIterations; i++) {
// 1. Put device into sleep mode
// 2. Wait for the device to sleep for sometime, verify wi-fi is off and mobile is on.
@@ -284,12 +288,18 @@ public class WifiStressTest
// Turn screen on again
mAct.turnScreenOn();
+ // Measure the time for Wi-Fi to get connected
+ long startTime = System.currentTimeMillis();
assertTrue("Wait for Wi-Fi enable timeout after wake up",
mAct.waitForWifiState(WifiManager.WIFI_STATE_ENABLED,
ConnectivityManagerTestActivity.SHORT_TIMEOUT));
assertTrue("Wait for Wi-Fi connection timeout after wake up",
mAct.waitForNetworkState(ConnectivityManager.TYPE_WIFI, State.CONNECTED,
- ConnectivityManagerTestActivity.LONG_TIMEOUT));
+ 6 * ConnectivityManagerTestActivity.LONG_TIMEOUT));
+ long connectionTime = System.currentTimeMillis() - startTime;
+ sum += connectionTime;
+ log("average reconnection time is: " + sum/(i+1));
+
assertTrue("Reconnect to Wi-Fi network, but no data connection.", mAct.pingTest(null));
}
if (i == mReconnectIterations) {
diff --git a/include/media/AudioTrack.h b/include/media/AudioTrack.h
index f71965ede4e9..cb3d8338bc84 100644
--- a/include/media/AudioTrack.h
+++ b/include/media/AudioTrack.h
@@ -38,7 +38,7 @@ class audio_track_cblk_t;
// ----------------------------------------------------------------------------
-class AudioTrack
+class AudioTrack : virtual public RefBase
{
public:
enum channel_index {
diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp
index a077cbc55f34..158f78503689 100644
--- a/libs/hwui/FontRenderer.cpp
+++ b/libs/hwui/FontRenderer.cpp
@@ -163,7 +163,6 @@ void Font::render(SkPaint* paint, const char* text, uint32_t start, uint32_t len
render(paint, text, start, len, numGlyphs, x, y, FRAMEBUFFER, NULL,
0, 0, NULL);
}
-
}
void Font::measure(SkPaint* paint, const char* text, uint32_t start, uint32_t len,
@@ -615,7 +614,8 @@ void FontRenderer::issueDrawCommand() {
void FontRenderer::appendMeshQuad(float x1, float y1, float z1, float u1, float v1, float x2,
float y2, float z2, float u2, float v2, float x3, float y3, float z3, float u3, float v3,
float x4, float y4, float z4, float u4, float v4) {
- if (x1 > mClip->right || y1 < mClip->top || x2 < mClip->left || y4 > mClip->bottom) {
+ if (mClip &&
+ (x1 > mClip->right || y1 < mClip->top || x2 < mClip->left || y4 > mClip->bottom)) {
return;
}
@@ -723,11 +723,16 @@ FontRenderer::DropShadow FontRenderer::renderDropShadow(SkPaint* paint, const ch
return image;
}
+ mClip = NULL;
+ mBounds = NULL;
+
Rect bounds;
mCurrentFont->measure(paint, text, startIndex, len, numGlyphs, &bounds);
+
uint32_t paddedWidth = (uint32_t) (bounds.right - bounds.left) + 2 * radius;
uint32_t paddedHeight = (uint32_t) (bounds.top - bounds.bottom) + 2 * radius;
uint8_t* dataBuffer = new uint8_t[paddedWidth * paddedHeight];
+
for (uint32_t i = 0; i < paddedWidth * paddedHeight; i++) {
dataBuffer[i] = 0;
}
@@ -765,8 +770,11 @@ bool FontRenderer::renderText(SkPaint* paint, const Rect* clip, const char *text
mDrawn = false;
mBounds = bounds;
mClip = clip;
+
mCurrentFont->render(paint, text, startIndex, len, numGlyphs, x, y);
+
mBounds = NULL;
+ mClip = NULL;
if (mCurrentQuadIndex != 0) {
issueDrawCommand();
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 0b5262dbf4b9..718c1312a874 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -201,14 +201,16 @@ void OpenGLRenderer::interrupt() {
}
void OpenGLRenderer::resume() {
- glViewport(0, 0, mSnapshot->viewport.getWidth(), mSnapshot->viewport.getHeight());
+ sp<Snapshot> snapshot = (mSnapshot != NULL) ? mSnapshot : mFirstSnapshot;
+
+ glViewport(0, 0, snapshot->viewport.getWidth(), snapshot->viewport.getHeight());
glEnable(GL_SCISSOR_TEST);
dirtyClip();
glDisable(GL_DITHER);
- glBindFramebuffer(GL_FRAMEBUFFER, mSnapshot->fbo);
+ glBindFramebuffer(GL_FRAMEBUFFER, snapshot->fbo);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
mCaches.blend = true;
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java
index 3fb2da080954..92ac9eb09766 100755
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java
@@ -39,6 +39,7 @@ import com.android.mediaframeworktest.functional.videoeditor.VideoEditorExportTe
import com.android.mediaframeworktest.functional.videoeditor.VideoEditorPreviewTest;
import junit.framework.TestSuite;
+import android.os.Bundle;
import android.test.InstrumentationTestRunner;
import android.test.InstrumentationTestSuite;
@@ -54,6 +55,7 @@ import android.test.InstrumentationTestSuite;
public class MediaFrameworkTestRunner extends InstrumentationTestRunner {
+ public static int mMinCameraFps = 0;
@Override
public TestSuite getAllTests() {
@@ -87,4 +89,16 @@ public class MediaFrameworkTestRunner extends InstrumentationTestRunner {
public ClassLoader getLoader() {
return MediaFrameworkTestRunner.class.getClassLoader();
}
+
+ @Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+
+ String minCameraFps = (String) icicle.get("min_camera_fps");
+ System.out.print("min_camera_" + minCameraFps);
+
+ if (minCameraFps != null ) {
+ mMinCameraFps = Integer.parseInt(minCameraFps);
+ }
+ }
}
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/mediarecorder/MediaRecorderTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/mediarecorder/MediaRecorderTest.java
index b5c8c8c486f0..0684946617c0 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/mediarecorder/MediaRecorderTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/mediarecorder/MediaRecorderTest.java
@@ -33,6 +33,7 @@ import android.util.Log;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import com.android.mediaframeworktest.MediaProfileReader;
+import com.android.mediaframeworktest.MediaFrameworkTestRunner;
import android.test.suitebuilder.annotation.LargeTest;
import android.test.suitebuilder.annotation.Suppress;
@@ -115,9 +116,16 @@ public class MediaRecorderTest extends ActivityInstrumentationTestCase2<MediaFra
int audioChannels = highQuality? audioCap.mMaxChannels: audioCap.mMinChannels ;
int audioSamplingRate = highQuality? audioCap.mMaxSampleRate: audioCap.mMinSampleRate;
+ //Overide the fps if the min_camera_fps is set
+ if (MediaFrameworkTestRunner.mMinCameraFps != 0 &&
+ MediaFrameworkTestRunner.mMinCameraFps > videoFps){
+ videoFps = MediaFrameworkTestRunner.mMinCameraFps;
+ }
+
if (videoFps < MIN_VIDEO_FPS) {
videoFps = MIN_VIDEO_FPS;
}
+
mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
String filename = ("/sdcard/" + videoEncoder + "_" + audioEncoder + "_" + highQuality + ".3gp");
try {
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/MediaPlayerPerformance.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/MediaPlayerPerformance.java
index 0b887b9c6428..4f6e7d2831f5 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/MediaPlayerPerformance.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/MediaPlayerPerformance.java
@@ -37,11 +37,13 @@ import android.util.Log;
import android.view.SurfaceHolder;
import java.util.List;
+import java.io.BufferedReader;
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.io.Writer;
import java.io.File;
import java.io.FileWriter;
@@ -68,6 +70,8 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med
private static final long MEDIA_STRESS_WAIT_TIME = 5000; //5 seconds
private static final String MEDIA_MEMORY_OUTPUT =
"/sdcard/mediaMemOutput.txt";
+ private static final String MEDIA_PROCMEM_OUTPUT =
+ "/sdcard/mediaProcmemOutput.txt";
private static int mStartMemory = 0;
private static int mEndMemory = 0;
@@ -84,6 +88,9 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med
private static int DECODER_LIMIT = 150;
private static int CAMERA_LIMIT = 80;
+ private Writer mProcMemWriter;
+ private Writer mMemWriter;
+
private static List<VideoEncoderCap> videoEncoders = MediaProfileReader.getVideoEncoders();
Camera mCamera;
@@ -97,12 +104,21 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med
getActivity();
if (MediaFrameworkPerfTestRunner.mGetNativeHeapDump)
MediaTestUtil.getNativeHeapDump(this.getName() + "_before");
+
+ mProcMemWriter = new BufferedWriter(new FileWriter
+ (new File(MEDIA_PROCMEM_OUTPUT), true));
+ mProcMemWriter.write(this.getName() + "\n");
+ mMemWriter = new BufferedWriter(new FileWriter
+ (new File(MEDIA_MEMORY_OUTPUT), true));
+
}
protected void tearDown() throws Exception {
- super.tearDown();
if (MediaFrameworkPerfTestRunner.mGetNativeHeapDump)
MediaTestUtil.getNativeHeapDump(this.getName() + "_after");
+ mProcMemWriter.close();
+ mMemWriter.close();
+ super.tearDown();
}
private void initializeMessageLooper() {
@@ -247,24 +263,39 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med
}
//Write the ps output to the file
- public void getMemoryWriteToLog(Writer output, int writeCount) {
+ public void getMemoryWriteToLog(int writeCount) {
String memusage = null;
try {
if (writeCount == 0) {
mStartMemory = getMediaserverVsize();
- output.write("Start memory : " + mStartMemory + "\n");
+ mMemWriter.write("Start memory : " + mStartMemory + "\n");
}
memusage = captureMediaserverInfo();
- output.write(memusage);
+ mMemWriter.write(memusage);
if (writeCount == NUM_STRESS_LOOP - 1) {
mEndMemory = getMediaserverVsize();
- output.write("End Memory :" + mEndMemory + "\n");
+ mMemWriter.write("End Memory :" + mEndMemory + "\n");
}
} catch (Exception e) {
e.toString();
}
}
+ public void writeProcmemInfo() throws Exception{
+ String cmd = "procmem " + getMediaserverPid();
+ Process p = Runtime.getRuntime().exec(cmd);
+
+ InputStream inStream = p.getInputStream();
+ InputStreamReader inReader = new InputStreamReader(inStream);
+ BufferedReader inBuffer = new BufferedReader(inReader);
+ String s;
+ while ((s = inBuffer.readLine()) != null) {
+ mProcMemWriter.write(s);
+ mProcMemWriter.write("\n");
+ }
+ mProcMemWriter.write("\n\n");
+ }
+
public String captureMediaserverInfo() {
String cm = "ps mediaserver";
String memoryUsage = null;
@@ -306,7 +337,7 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med
return vsizevalue;
}
- public boolean validateMemoryResult(int startPid, int startMemory, Writer output, int limit)
+ public boolean validateMemoryResult(int startPid, int startMemory, int limit)
throws Exception {
// Wait for 10 seconds to make sure the memory settle.
Thread.sleep(10000);
@@ -315,11 +346,11 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med
if (memDiff < 0) {
memDiff = 0;
}
- output.write("The total diff = " + memDiff);
- output.write("\n\n");
+ mMemWriter.write("The total diff = " + memDiff);
+ mMemWriter.write("\n\n");
// mediaserver crash
if (startPid != mEndPid) {
- output.write("mediaserver died. Test failed\n");
+ mMemWriter.write("mediaserver died. Test failed\n");
return false;
}
// memory leak greter than the tolerant
@@ -331,18 +362,16 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med
@LargeTest
public void testH263VideoPlaybackMemoryUsage() throws Exception {
boolean memoryResult = false;
- mStartPid = getMediaserverPid();
- File h263MemoryOut = new File(MEDIA_MEMORY_OUTPUT);
- Writer output = new BufferedWriter(new FileWriter(h263MemoryOut, true));
- output.write("H263 Video Playback Only\n");
+ mStartPid = getMediaserverPid();
+ mMemWriter.write("H263 Video Playback Only\n");
for (int i = 0; i < NUM_STRESS_LOOP; i++) {
mediaStressPlayback(MediaNames.VIDEO_HIGHRES_H263);
- getMemoryWriteToLog(output, i);
+ getMemoryWriteToLog(i);
+ writeProcmemInfo();
}
- output.write("\n");
- memoryResult = validateMemoryResult(mStartPid, mStartMemory, output, DECODER_LIMIT);
- output.close();
+ mMemWriter.write("\n");
+ memoryResult = validateMemoryResult(mStartPid, mStartMemory, DECODER_LIMIT);
assertTrue("H263 playback memory test", memoryResult);
}
@@ -350,18 +379,16 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med
@LargeTest
public void testH264VideoPlaybackMemoryUsage() throws Exception {
boolean memoryResult = false;
- mStartPid = getMediaserverPid();
- File h264MemoryOut = new File(MEDIA_MEMORY_OUTPUT);
- Writer output = new BufferedWriter(new FileWriter(h264MemoryOut, true));
- output.write("H264 Video Playback only\n");
+ mStartPid = getMediaserverPid();
+ mMemWriter.write("H264 Video Playback only\n");
for (int i = 0; i < NUM_STRESS_LOOP; i++) {
mediaStressPlayback(MediaNames.VIDEO_H264_AMR);
- getMemoryWriteToLog(output, i);
+ getMemoryWriteToLog(i);
+ writeProcmemInfo();
}
- output.write("\n");
- memoryResult = validateMemoryResult(mStartPid, mStartMemory, output, DECODER_LIMIT);
- output.close();
+ mMemWriter.write("\n");
+ memoryResult = validateMemoryResult(mStartPid, mStartMemory, DECODER_LIMIT);
assertTrue("H264 playback memory test", memoryResult);
}
@@ -369,21 +396,19 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med
@LargeTest
public void testH263RecordVideoOnlyMemoryUsage() throws Exception {
boolean memoryResult = false;
- mStartPid = getMediaserverPid();
- File videoH263RecordOnlyMemoryOut = new File(MEDIA_MEMORY_OUTPUT);
- Writer output = new BufferedWriter(new FileWriter(videoH263RecordOnlyMemoryOut, true));
- output.write("H263 video record only\n");
+ mStartPid = getMediaserverPid();
+ mMemWriter.write("H263 video record only\n");
int frameRate = MediaProfileReader.getMaxFrameRateForCodec(MediaRecorder.VideoEncoder.H263);
assertTrue("H263 video recording frame rate", frameRate != -1);
for (int i = 0; i < NUM_STRESS_LOOP; i++) {
assertTrue(stressVideoRecord(frameRate, 352, 288, MediaRecorder.VideoEncoder.H263,
MediaRecorder.OutputFormat.MPEG_4, MediaNames.RECORDED_VIDEO_3GP, true));
- getMemoryWriteToLog(output, i);
+ getMemoryWriteToLog(i);
+ writeProcmemInfo();
}
- output.write("\n");
- memoryResult = validateMemoryResult(mStartPid, mStartMemory, output, ENCODER_LIMIT);
- output.close();
+ mMemWriter.write("\n");
+ memoryResult = validateMemoryResult(mStartPid, mStartMemory, ENCODER_LIMIT);
assertTrue("H263 record only memory test", memoryResult);
}
@@ -391,21 +416,19 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med
@LargeTest
public void testMpeg4RecordVideoOnlyMemoryUsage() throws Exception {
boolean memoryResult = false;
- mStartPid = getMediaserverPid();
- File videoMp4RecordOnlyMemoryOut = new File(MEDIA_MEMORY_OUTPUT);
- Writer output = new BufferedWriter(new FileWriter(videoMp4RecordOnlyMemoryOut, true));
- output.write("MPEG4 video record only\n");
+ mStartPid = getMediaserverPid();
+ mMemWriter.write("MPEG4 video record only\n");
int frameRate = MediaProfileReader.getMaxFrameRateForCodec(MediaRecorder.VideoEncoder.MPEG_4_SP);
assertTrue("MPEG4 video recording frame rate", frameRate != -1);
for (int i = 0; i < NUM_STRESS_LOOP; i++) {
assertTrue(stressVideoRecord(frameRate, 352, 288, MediaRecorder.VideoEncoder.MPEG_4_SP,
MediaRecorder.OutputFormat.MPEG_4, MediaNames.RECORDED_VIDEO_3GP, true));
- getMemoryWriteToLog(output, i);
+ getMemoryWriteToLog(i);
+ writeProcmemInfo();
}
- output.write("\n");
- memoryResult = validateMemoryResult(mStartPid, mStartMemory, output, ENCODER_LIMIT);
- output.close();
+ mMemWriter.write("\n");
+ memoryResult = validateMemoryResult(mStartPid, mStartMemory, ENCODER_LIMIT);
assertTrue("mpeg4 record only memory test", memoryResult);
}
@@ -414,21 +437,19 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med
@LargeTest
public void testRecordVideoAudioMemoryUsage() throws Exception {
boolean memoryResult = false;
- mStartPid = getMediaserverPid();
- File videoRecordAudioMemoryOut = new File(MEDIA_MEMORY_OUTPUT);
- Writer output = new BufferedWriter(new FileWriter(videoRecordAudioMemoryOut, true));
+ mStartPid = getMediaserverPid();
int frameRate = MediaProfileReader.getMaxFrameRateForCodec(MediaRecorder.VideoEncoder.H263);
assertTrue("H263 video recording frame rate", frameRate != -1);
- output.write("Audio and h263 video record\n");
+ mMemWriter.write("Audio and h263 video record\n");
for (int i = 0; i < NUM_STRESS_LOOP; i++) {
assertTrue(stressVideoRecord(frameRate, 352, 288, MediaRecorder.VideoEncoder.H263,
MediaRecorder.OutputFormat.MPEG_4, MediaNames.RECORDED_VIDEO_3GP, false));
- getMemoryWriteToLog(output, i);
+ getMemoryWriteToLog(i);
+ writeProcmemInfo();
}
- output.write("\n");
- memoryResult = validateMemoryResult(mStartPid, mStartMemory, output, ENCODER_LIMIT);
- output.close();
+ mMemWriter.write("\n");
+ memoryResult = validateMemoryResult(mStartPid, mStartMemory, ENCODER_LIMIT);
assertTrue("H263 audio video record memory test", memoryResult);
}
@@ -436,18 +457,16 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med
@LargeTest
public void testRecordAudioOnlyMemoryUsage() throws Exception {
boolean memoryResult = false;
- mStartPid = getMediaserverPid();
- File audioOnlyMemoryOut = new File(MEDIA_MEMORY_OUTPUT);
- Writer output = new BufferedWriter(new FileWriter(audioOnlyMemoryOut, true));
- output.write("Audio record only\n");
+ mStartPid = getMediaserverPid();
+ mMemWriter.write("Audio record only\n");
for (int i = 0; i < NUM_STRESS_LOOP; i++) {
stressAudioRecord(MediaNames.RECORDER_OUTPUT);
- getMemoryWriteToLog(output, i);
+ getMemoryWriteToLog(i);
+ writeProcmemInfo();
}
- output.write("\n");
- memoryResult = validateMemoryResult(mStartPid, mStartMemory, output, ENCODER_LIMIT);
- output.close();
+ mMemWriter.write("\n");
+ memoryResult = validateMemoryResult(mStartPid, mStartMemory, ENCODER_LIMIT);
assertTrue("audio record only memory test", memoryResult);
}
@@ -455,18 +474,16 @@ public class MediaPlayerPerformance extends ActivityInstrumentationTestCase2<Med
@LargeTest
public void testCameraPreviewMemoryUsage() throws Exception {
boolean memoryResult = false;
- mStartPid = getMediaserverPid();
- File cameraPreviewMemoryOut = new File(MEDIA_MEMORY_OUTPUT);
- Writer output = new BufferedWriter(new FileWriter(cameraPreviewMemoryOut, true));
- output.write("Camera Preview Only\n");
+ mStartPid = getMediaserverPid();
+ mMemWriter.write("Camera Preview Only\n");
for (int i = 0; i < NUM_STRESS_LOOP; i++) {
stressCameraPreview();
- getMemoryWriteToLog(output, i);
+ getMemoryWriteToLog(i);
+ writeProcmemInfo();
}
- output.write("\n");
- memoryResult = validateMemoryResult(mStartPid, mStartMemory, output, CAMERA_LIMIT);
- output.close();
+ mMemWriter.write("\n");
+ memoryResult = validateMemoryResult(mStartPid, mStartMemory, CAMERA_LIMIT);
assertTrue("camera preview memory test", memoryResult);
}
}
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 72856b8eda24..bc656917ed8a 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -3468,6 +3468,15 @@ public class PhoneWindowManager implements WindowManagerPolicy {
if (localLOGV) Log.v(TAG, "mScreenSaverActivator: not running screen saver when not plugged in");
return;
}
+ // Quick fix for automation tests.
+ // The correct fix is to move this triggering logic to PowerManager, where more complete
+ // information about wakelocks (including StayOnWhilePluggedIn) is available.
+ if (Settings.System.getInt(mContext.getContentResolver(),
+ Settings.System.STAY_ON_WHILE_PLUGGED_IN,
+ BatteryManager.BATTERY_PLUGGED_AC) != 0) {
+ Log.v(TAG, "mScreenSaverActivator: not running screen saver when STAY_ON_WHILE_PLUGGED_IN");
+ return;
+ }
if (localLOGV) Log.v(TAG, "mScreenSaverActivator entering dreamland");
diff --git a/services/java/com/android/server/wm/Session.java b/services/java/com/android/server/wm/Session.java
index ee62a56ddc1f..77575f2f5251 100644
--- a/services/java/com/android/server/wm/Session.java
+++ b/services/java/com/android/server/wm/Session.java
@@ -151,18 +151,22 @@ final class Session extends IWindowSession.Stub
public int relayout(IWindow window, int seq, WindowManager.LayoutParams attrs,
int requestedWidth, int requestedHeight, int viewFlags,
- boolean insetsPending, Rect outFrame, Rect outContentInsets,
+ int flags, Rect outFrame, Rect outContentInsets,
Rect outVisibleInsets, Configuration outConfig, Surface outSurface) {
if (false) Slog.d(WindowManagerService.TAG, ">>>>>> ENTERED relayout from "
+ Binder.getCallingPid());
int res = mService.relayoutWindow(this, window, seq, attrs,
- requestedWidth, requestedHeight, viewFlags, insetsPending,
+ requestedWidth, requestedHeight, viewFlags, flags,
outFrame, outContentInsets, outVisibleInsets, outConfig, outSurface);
if (false) Slog.d(WindowManagerService.TAG, "<<<<<< EXITING relayout to "
+ Binder.getCallingPid());
return res;
}
+ public void performDeferredDestroy(IWindow window) {
+ mService.performDeferredDestroyWindow(this, window);
+ }
+
public boolean outOfMemory(IWindow window) {
return mService.outOfMemoryWindow(this, window);
}
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index ebb13d5c8f61..769e6cf8d971 100644
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -2499,12 +2499,13 @@ public class WindowManagerService extends IWindowManager.Stub
public int relayoutWindow(Session session, IWindow client, int seq,
WindowManager.LayoutParams attrs, int requestedWidth,
- int requestedHeight, int viewVisibility, boolean insetsPending,
+ int requestedHeight, int viewVisibility, int flags,
Rect outFrame, Rect outContentInsets, Rect outVisibleInsets,
Configuration outConfig, Surface outSurface) {
boolean displayed = false;
boolean inTouchMode;
boolean configChanged;
+ boolean surfaceChanged = false;
// if they don't have this permission, mask out the status bar bits
int systemUiVisibility = 0;
@@ -2534,6 +2535,9 @@ public class WindowManagerService extends IWindowManager.Stub
mPolicy.adjustWindowParamsLw(attrs);
}
+ win.mSurfaceDestroyDeferred =
+ (flags&WindowManagerImpl.RELAYOUT_DEFER_SURFACE_DESTROY) != 0;
+
int attrChanges = 0;
int flagChanges = 0;
if (attrs != null) {
@@ -2630,8 +2634,12 @@ public class WindowManagerService extends IWindowManager.Stub
// To change the format, we need to re-build the surface.
win.destroySurfaceLocked();
displayed = true;
+ surfaceChanged = true;
}
try {
+ if (win.mSurface == null) {
+ surfaceChanged = true;
+ }
Surface surface = win.createSurfaceLocked();
if (surface != null) {
outSurface.copyFrom(surface);
@@ -2683,6 +2691,7 @@ public class WindowManagerService extends IWindowManager.Stub
// If we are not currently running the exit animation, we
// need to see about starting one.
if (!win.mExiting || win.mSurfacePendingDestroy) {
+ surfaceChanged = true;
// Try starting an animation; if there isn't one, we
// can destroy the surface right away.
int transit = WindowManagerPolicy.TRANSIT_EXIT;
@@ -2715,10 +2724,10 @@ public class WindowManagerService extends IWindowManager.Stub
if (win.mSurface == null || (win.getAttrs().flags
& WindowManager.LayoutParams.FLAG_KEEP_SURFACE_WHILE_ANIMATING) == 0
|| win.mSurfacePendingDestroy) {
- // We are being called from a local process, which
+ // We could be called from a local process, which
// means outSurface holds its current surface. Ensure the
- // surface object is cleared, but we don't want it actually
- // destroyed at this point.
+ // surface object is cleared, but we don't necessarily want
+ // it actually destroyed at this point.
win.mSurfacePendingDestroy = false;
outSurface.release();
if (DEBUG_VISIBILITY) Slog.i(TAG, "Releasing surface in: " + win);
@@ -2760,7 +2769,7 @@ public class WindowManagerService extends IWindowManager.Stub
}
mLayoutNeeded = true;
- win.mGivenInsetsPending = insetsPending;
+ win.mGivenInsetsPending = (flags&WindowManagerImpl.RELAYOUT_INSETS_PENDING) != 0;
if (assignLayers) {
assignLayersLocked();
}
@@ -2797,8 +2806,25 @@ public class WindowManagerService extends IWindowManager.Stub
Binder.restoreCallingIdentity(origId);
- return (inTouchMode ? WindowManagerImpl.RELAYOUT_IN_TOUCH_MODE : 0)
- | (displayed ? WindowManagerImpl.RELAYOUT_FIRST_TIME : 0);
+ return (inTouchMode ? WindowManagerImpl.RELAYOUT_RES_IN_TOUCH_MODE : 0)
+ | (displayed ? WindowManagerImpl.RELAYOUT_RES_FIRST_TIME : 0)
+ | (surfaceChanged ? WindowManagerImpl.RELAYOUT_RES_SURFACE_CHANGED : 0);
+ }
+
+ public void performDeferredDestroyWindow(Session session, IWindow client) {
+ long origId = Binder.clearCallingIdentity();
+
+ try {
+ synchronized(mWindowMap) {
+ WindowState win = windowForClientLocked(session, client, false);
+ if (win == null) {
+ return;
+ }
+ win.destroyDeferredSurfaceLocked();
+ }
+ } finally {
+ Binder.restoreCallingIdentity(origId);
+ }
}
public boolean outOfMemoryWindow(Session session, IWindow client) {
@@ -3738,7 +3764,7 @@ public class WindowManagerService extends IWindowManager.Stub
return;
}
- // If this is a translucent or wallpaper window, then don't
+ // If this is a translucent window, then don't
// show a starting window -- the current effect (a full-screen
// opaque starting window that fades away to the real contents
// when it is ready) does not work for this.
@@ -3755,7 +3781,16 @@ public class WindowManagerService extends IWindowManager.Stub
}
if (ent.array.getBoolean(
com.android.internal.R.styleable.Window_windowShowWallpaper, false)) {
- return;
+ if (mWallpaperTarget == null) {
+ // If this theme is requesting a wallpaper, and the wallpaper
+ // is not curently visible, then this effectively serves as
+ // an opaque window and our starting window transition animation
+ // can still work. We just need to make sure the starting window
+ // is also showing the wallpaper.
+ windowFlags |= WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
+ } else {
+ return;
+ }
}
}
@@ -7659,7 +7694,8 @@ public class WindowManagerService extends IWindowManager.Stub
// a detached wallpaper animation.
if (nowAnimating) {
if (w.mAnimation != null) {
- if (w.mAnimation.getDetachWallpaper()) {
+ if ((w.mAttrs.flags&FLAG_SHOW_WALLPAPER) != 0
+ && w.mAnimation.getDetachWallpaper()) {
windowDetachedWallpaper = w;
}
if (w.mAnimation.getBackgroundColor() != 0) {
@@ -7679,7 +7715,8 @@ public class WindowManagerService extends IWindowManager.Stub
// displayed behind it.
if (w.mAppToken != null && w.mAppToken.animation != null
&& w.mAppToken.animating) {
- if (w.mAppToken.animation.getDetachWallpaper()) {
+ if ((w.mAttrs.flags&FLAG_SHOW_WALLPAPER) != 0
+ && w.mAppToken.animation.getDetachWallpaper()) {
windowDetachedWallpaper = w;
}
if (w.mAppToken.animation.getBackgroundColor() != 0) {
diff --git a/services/java/com/android/server/wm/WindowState.java b/services/java/com/android/server/wm/WindowState.java
index 23ec2d9f578d..aa7bf2d1b7ce 100644
--- a/services/java/com/android/server/wm/WindowState.java
+++ b/services/java/com/android/server/wm/WindowState.java
@@ -85,6 +85,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
boolean mPolicyVisibilityAfterAnim = true;
boolean mAppFreezing;
Surface mSurface;
+ Surface mPendingDestroySurface;
boolean mReportDestroySurface;
boolean mSurfacePendingDestroy;
boolean mAttachedHidden; // is our parent window hidden?
@@ -121,7 +122,13 @@ final class WindowState implements WindowManagerPolicy.WindowState {
* we must tell them application to resize (and thus redraw itself).
*/
boolean mSurfaceResized;
-
+
+ /**
+ * Set if the client has asked that the destroy of its surface be delayed
+ * until it explicitly says it is okay.
+ */
+ boolean mSurfaceDestroyDeferred;
+
/**
* Insets that determine the actually visible area. These are in the application's
* coordinate space (without compatibility scale applied).
@@ -764,15 +771,32 @@ final class WindowState implements WindowManagerPolicy.WindowState {
Slog.w(WindowManagerService.TAG, "Window " + this + " destroying surface "
+ mSurface + ", session " + mSession, e);
}
- if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) {
- RuntimeException e = null;
- if (!WindowManagerService.HIDE_STACK_CRAWLS) {
- e = new RuntimeException();
- e.fillInStackTrace();
+ if (mSurfaceDestroyDeferred) {
+ if (mSurface != null && mPendingDestroySurface != mSurface) {
+ if (mPendingDestroySurface != null) {
+ if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) {
+ RuntimeException e = null;
+ if (!WindowManagerService.HIDE_STACK_CRAWLS) {
+ e = new RuntimeException();
+ e.fillInStackTrace();
+ }
+ WindowManagerService.logSurface(this, "DESTROY PENDING", e);
+ }
+ mPendingDestroySurface.destroy();
+ }
+ mPendingDestroySurface = mSurface;
}
- WindowManagerService.logSurface(this, "DESTROY", e);
+ } else {
+ if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) {
+ RuntimeException e = null;
+ if (!WindowManagerService.HIDE_STACK_CRAWLS) {
+ e = new RuntimeException();
+ e.fillInStackTrace();
+ }
+ WindowManagerService.logSurface(this, "DESTROY", e);
+ }
+ mSurface.destroy();
}
- mSurface.destroy();
} catch (RuntimeException e) {
Slog.w(WindowManagerService.TAG, "Exception thrown when destroying Window " + this
+ " surface " + mSurface + " session " + mSession
@@ -784,6 +808,28 @@ final class WindowState implements WindowManagerPolicy.WindowState {
}
}
+ void destroyDeferredSurfaceLocked() {
+ try {
+ if (mPendingDestroySurface != null) {
+ if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) {
+ RuntimeException e = null;
+ if (!WindowManagerService.HIDE_STACK_CRAWLS) {
+ e = new RuntimeException();
+ e.fillInStackTrace();
+ }
+ mService.logSurface(this, "DESTROY PENDING", e);
+ }
+ mPendingDestroySurface.destroy();
+ }
+ } catch (RuntimeException e) {
+ Slog.w(WindowManagerService.TAG, "Exception thrown when destroying Window "
+ + this + " surface " + mPendingDestroySurface
+ + " session " + mSession + ": " + e.toString());
+ }
+ mSurfaceDestroyDeferred = false;
+ mPendingDestroySurface = null;
+ }
+
boolean finishDrawingLocked() {
if (mDrawPending) {
if (SHOW_TRANSACTIONS || WindowManagerService.DEBUG_ORIENTATION) Slog.v(
@@ -977,6 +1023,9 @@ final class WindowState implements WindowManagerPolicy.WindowState {
mAnimation.cancel();
mAnimation = null;
}
+ if (mService.mWindowDetachedWallpaper == this) {
+ mService.mWindowDetachedWallpaper = null;
+ }
mAnimLayer = mLayer;
if (mIsImWindow) {
mAnimLayer += mService.mInputMethodAnimLayerAdjustment;
@@ -1415,6 +1464,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
if (WindowManagerService.DEBUG_ADD_REMOVE) Slog.v(WindowManagerService.TAG, "Removing " + this + " from " + mAttachedWindow);
mAttachedWindow.mChildWindows.remove(this);
}
+ destroyDeferredSurfaceLocked();
destroySurfaceLocked();
mSession.windowRemovedLocked();
try {
@@ -1612,6 +1662,10 @@ final class WindowState implements WindowManagerPolicy.WindowState {
pw.print(") "); pw.print(mSurfaceW);
pw.print(" x "); pw.println(mSurfaceH);
}
+ if (mPendingDestroySurface != null) {
+ pw.print(prefix); pw.print("mPendingDestroySurface=");
+ pw.println(mPendingDestroySurface);
+ }
if (dumpAll) {
pw.print(prefix); pw.print("mToken="); pw.println(mToken);
pw.print(prefix); pw.print("mRootToken="); pw.println(mRootToken);
@@ -1640,6 +1694,10 @@ final class WindowState implements WindowManagerPolicy.WindowState {
if (!mRelayoutCalled) {
pw.print(prefix); pw.print("mRelayoutCalled="); pw.println(mRelayoutCalled);
}
+ if (mSurfaceResized || mSurfaceDestroyDeferred) {
+ pw.print(prefix); pw.print("mSurfaceResized="); pw.print(mSurfaceResized);
+ pw.print(" mSurfaceDestroyDeferred="); pw.println(mSurfaceDestroyDeferred);
+ }
if (mXOffset != 0 || mYOffset != 0) {
pw.print(prefix); pw.print("Offsets x="); pw.print(mXOffset);
pw.print(" y="); pw.println(mYOffset);
diff --git a/tests/FrameworkPerf/res/layout/main.xml b/tests/FrameworkPerf/res/layout/main.xml
index 781264881ceb..e00ad924cd36 100644
--- a/tests/FrameworkPerf/res/layout/main.xml
+++ b/tests/FrameworkPerf/res/layout/main.xml
@@ -66,7 +66,24 @@
>
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
+ android:text="Limit by: "
+ />
+ <Spinner android:id="@+id/limitspinner"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:drawSelectorOnTop="true"
+ />
+ </LinearLayout>
+
+ <LinearLayout android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:layout_marginTop="10dp"
+ >
+ <TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Test time (ms): "
+ android:id="@+id/limitlabel"
/>
<EditText android:id="@+id/testtime"
android:layout_width="match_parent"
diff --git a/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java b/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java
index 8ee5978729e8..30a968ffd33d 100644
--- a/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java
+++ b/tests/FrameworkPerf/src/com/android/frameworkperf/FrameworkPerfActivity.java
@@ -50,6 +50,8 @@ public class FrameworkPerfActivity extends Activity
Spinner mFgSpinner;
Spinner mBgSpinner;
+ Spinner mLimitSpinner;
+ TextView mLimitLabel;
TextView mTestTime;
Button mStartButton;
Button mStopButton;
@@ -58,10 +60,12 @@ public class FrameworkPerfActivity extends Activity
PowerManager.WakeLock mPartialWakeLock;
long mMaxRunTime = 5000;
+ boolean mLimitIsIterations;
boolean mStarted;
final String[] mAvailOpLabels;
final String[] mAvailOpDescriptions;
+ final String[] mLimitLabels = { "Time", "Iterations" };
int mFgTestIndex = -1;
int mBgTestIndex = -1;
@@ -169,8 +173,15 @@ public class FrameworkPerfActivity extends Activity
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mBgSpinner.setAdapter(adapter);
mBgSpinner.setOnItemSelectedListener(this);
+ mLimitSpinner = (Spinner) findViewById(R.id.limitspinner);
+ adapter = new ArrayAdapter<String>(this,
+ android.R.layout.simple_spinner_item, mLimitLabels);
+ adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ mLimitSpinner.setAdapter(adapter);
+ mLimitSpinner.setOnItemSelectedListener(this);
mTestTime = (TextView)findViewById(R.id.testtime);
+ mLimitLabel = (TextView)findViewById(R.id.limitlabel);
mStartButton = (Button)findViewById(R.id.start);
mStartButton.setOnClickListener(new View.OnClickListener() {
@@ -196,16 +207,23 @@ public class FrameworkPerfActivity extends Activity
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
- if (parent == mFgSpinner || parent == mBgSpinner) {
+ if (parent == mFgSpinner || parent == mBgSpinner || parent == mLimitSpinner) {
TestService.Op op = TestService.mAvailOps[position];
if (parent == mFgSpinner) {
mFgTestIndex = position;
mFgTest = op;
((TextView)findViewById(R.id.fgtext)).setText(mAvailOpDescriptions[position]);
- } else {
+ } else if (parent == mBgSpinner) {
mBgTestIndex = position;
mBgTest = op;
((TextView)findViewById(R.id.bgtext)).setText(mAvailOpDescriptions[position]);
+ } else if (parent == mLimitSpinner) {
+ mLimitIsIterations = (position != 0);
+ if (mLimitIsIterations) {
+ mLimitLabel.setText("Iterations: ");
+ } else {
+ mLimitLabel.setText("Test time (ms): ");
+ }
}
}
}
@@ -234,7 +252,11 @@ public class FrameworkPerfActivity extends Activity
return;
}
TestArgs args = new TestArgs();
- args.maxTime = mMaxRunTime;
+ if (mLimitIsIterations) {
+ args.maxOps = mMaxRunTime;
+ } else {
+ args.maxTime = mMaxRunTime;
+ }
if (mFgTestIndex == 0 && mBgTestIndex == 0) {
args.combOp = mCurOpIndex;
} else if (mFgTestIndex != 0 && mBgTestIndex != 0) {
@@ -376,6 +398,7 @@ public class FrameworkPerfActivity extends Activity
mTestTime.setEnabled(false);
mFgSpinner.setEnabled(false);
mBgSpinner.setEnabled(false);
+ mLimitSpinner.setEnabled(false);
updateWakeLock();
startService(new Intent(this, SchedulerService.class));
mCurOpIndex = 0;
@@ -397,6 +420,7 @@ public class FrameworkPerfActivity extends Activity
mTestTime.setEnabled(true);
mFgSpinner.setEnabled(true);
mBgSpinner.setEnabled(true);
+ mLimitSpinner.setEnabled(true);
updateWakeLock();
stopService(new Intent(this, SchedulerService.class));
synchronized (mResults) {
diff --git a/tests/FrameworkPerf/src/com/android/frameworkperf/TestArgs.java b/tests/FrameworkPerf/src/com/android/frameworkperf/TestArgs.java
index f2f7c5675bcf..2fe38aaca5d2 100644
--- a/tests/FrameworkPerf/src/com/android/frameworkperf/TestArgs.java
+++ b/tests/FrameworkPerf/src/com/android/frameworkperf/TestArgs.java
@@ -21,6 +21,7 @@ import android.os.Parcelable;
public class TestArgs implements Parcelable {
long maxTime;
+ long maxOps = -1;
int combOp = -1;
int fgOp = -1;
int bgOp = -1;
@@ -30,6 +31,7 @@ public class TestArgs implements Parcelable {
public TestArgs(Parcel source) {
maxTime = source.readLong();
+ maxOps = source.readLong();
combOp = source.readInt();
fgOp = source.readInt();
bgOp = source.readInt();
@@ -43,6 +45,7 @@ public class TestArgs implements Parcelable {
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(maxTime);
+ dest.writeLong(maxOps);
dest.writeInt(combOp);
dest.writeInt(fgOp);
dest.writeInt(bgOp);
diff --git a/tests/FrameworkPerf/src/com/android/frameworkperf/TestService.java b/tests/FrameworkPerf/src/com/android/frameworkperf/TestService.java
index 8cf1ac2932e3..a8c43e993452 100644
--- a/tests/FrameworkPerf/src/com/android/frameworkperf/TestService.java
+++ b/tests/FrameworkPerf/src/com/android/frameworkperf/TestService.java
@@ -224,6 +224,7 @@ public class TestService extends Service {
public class TestRunner {
Handler mHandler;
long mMaxRunTime;
+ long mMaxOps;
Op mForegroundOp;
Op mBackgroundOp;
Runnable mDoneCallback;
@@ -277,6 +278,7 @@ public class TestService extends Service {
public void run(Handler handler, TestArgs args, Runnable doneCallback) {
mHandler = handler;
mMaxRunTime = args.maxTime;
+ mMaxOps = args.maxOps;
if (args.combOp >= 0) {
mForegroundOp = mOpPairs[args.combOp];
mBackgroundOp = mOpPairs[args.combOp+1];
@@ -352,9 +354,18 @@ public class TestService extends Service {
if (!mBackgroundRunning && !mForegroundRunning) {
return false;
}
- long now = SystemClock.uptimeMillis();
- if (now > (mStartTime+mMaxRunTime)) {
- return false;
+ if (mMaxOps > 0) {
+ // iteration-limited case
+ if (mForegroundOps >= mMaxOps) {
+ return false;
+ }
+ mForegroundOps++;
+ } else {
+ // time-limited case
+ long now = SystemClock.uptimeMillis();
+ if (now > (mStartTime+mMaxRunTime)) {
+ return false;
+ }
}
return true;
}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java
index 1d97e1506866..a640a9139be8 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java
@@ -79,12 +79,16 @@ public final class BridgeWindowSession implements IWindowSession {
}
public int relayout(IWindow arg0, int seq, LayoutParams arg1, int arg2, int arg3, int arg4,
- boolean arg4_5, Rect arg5, Rect arg6, Rect arg7, Configuration arg7b, Surface arg8)
+ int arg4_5, Rect arg5, Rect arg6, Rect arg7, Configuration arg7b, Surface arg8)
throws RemoteException {
// pass for now.
return 0;
}
+ public void performDeferredDestroy(IWindow window) {
+ // pass for now.
+ }
+
public boolean outOfMemory(IWindow window) throws RemoteException {
return false;
}