diff options
27 files changed, 473 insertions, 202 deletions
diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp index d816e7c..154dbb8 100644 --- a/cmds/bootanimation/BootAnimation.cpp +++ b/cmds/bootanimation/BootAnimation.cpp @@ -42,6 +42,7 @@ #include <surfaceflinger/ISurfaceComposerClient.h> #include <core/SkBitmap.h> +#include <core/SkStream.h> #include <images/SkImageDecoder.h> #include <GLES/gl.h> @@ -150,9 +151,15 @@ status_t BootAnimation::initTexture(void* buffer, size_t len) //StopWatch watch("blah"); SkBitmap bitmap; - SkImageDecoder::DecodeMemory(buffer, len, - &bitmap, SkBitmap::kRGB_565_Config, - SkImageDecoder::kDecodePixels_Mode); + SkMemoryStream stream(buffer, len); + SkImageDecoder* codec = SkImageDecoder::Factory(&stream); + codec->setDitherImage(false); + if (codec) { + codec->decode(&stream, &bitmap, + SkBitmap::kRGB_565_Config, + SkImageDecoder::kDecodePixels_Mode); + delete codec; + } // ensure we can call getPixels(). No need to call unlock, since the // bitmap will go out of scope when we return from this method. diff --git a/core/java/android/animation/LayoutTransition.java b/core/java/android/animation/LayoutTransition.java index f383af9..7f0ea99 100644 --- a/core/java/android/animation/LayoutTransition.java +++ b/core/java/android/animation/LayoutTransition.java @@ -657,6 +657,15 @@ public class LayoutTransition { */ private void setupChangeAnimation(final ViewGroup parent, final int changeReason, Animator baseAnimator, final long duration, final View child) { + + // If we already have a listener for this child, then we've already set up the + // changing animation we need. Multiple calls for a child may occur when several + // add/remove operations are run at once on a container; each one will trigger + // changes for the existing children in the container. + if (layoutChangeListenerMap.get(child) != null) { + return; + } + // Make a copy of the appropriate animation final Animator anim = baseAnimator.clone(); diff --git a/core/java/android/app/WallpaperManager.java b/core/java/android/app/WallpaperManager.java index f81ea81..91398bc 100644 --- a/core/java/android/app/WallpaperManager.java +++ b/core/java/android/app/WallpaperManager.java @@ -212,7 +212,11 @@ public class WallpaperManager { */ mHandler.sendEmptyMessage(MSG_CLEAR_WALLPAPER); } - + + public Handler getHandler() { + return mHandler; + } + public Bitmap peekWallpaperBitmap(Context context, boolean returnDefault) { synchronized (this) { if (mWallpaper != null) { @@ -604,7 +608,7 @@ public class WallpaperManager { // Ignore } } - + /** * Set the position of the current wallpaper within any larger space, when * that wallpaper is visible behind the given window. The X and Y offsets @@ -619,16 +623,23 @@ public class WallpaperManager { * @param yOffset The offset along the Y dimension, from 0 to 1. */ public void setWallpaperOffsets(IBinder windowToken, float xOffset, float yOffset) { - try { - //Log.v(TAG, "Sending new wallpaper offsets from app..."); - ViewRootImpl.getWindowSession(mContext.getMainLooper()).setWallpaperPosition( - windowToken, xOffset, yOffset, mWallpaperXStep, mWallpaperYStep); - //Log.v(TAG, "...app returning after sending offsets!"); - } catch (RemoteException e) { - // Ignore. - } + final IBinder fWindowToken = windowToken; + final float fXOffset = xOffset; + final float fYOffset = yOffset; + sGlobals.getHandler().post(new Runnable() { + public void run() { + try { + //Log.v(TAG, "Sending new wallpaper offsets from app..."); + ViewRootImpl.getWindowSession(mContext.getMainLooper()).setWallpaperPosition( + fWindowToken, fXOffset, fYOffset, mWallpaperXStep, mWallpaperYStep); + //Log.v(TAG, "...app returning after sending offsets!"); + } catch (RemoteException e) { + // Ignore. + } + } + }); } - + /** * For applications that use multiple virtual screens showing a wallpaper, * specify the step size between virtual screens. For example, if the diff --git a/core/java/android/net/NetworkStats.java b/core/java/android/net/NetworkStats.java index 3605652..f6e627c 100644 --- a/core/java/android/net/NetworkStats.java +++ b/core/java/android/net/NetworkStats.java @@ -464,6 +464,19 @@ public class NetworkStats implements Parcelable { * time, and that none of them have disappeared. */ public NetworkStats subtract(NetworkStats value) throws NonMonotonicException { + return subtract(value, false); + } + + /** + * Subtract the given {@link NetworkStats}, effectively leaving the delta + * between two snapshots in time. Assumes that statistics rows collect over + * time, and that none of them have disappeared. + * + * @param clampNonMonotonic When non-monotonic stats are found, just clamp + * to 0 instead of throwing {@link NonMonotonicException}. + */ + public NetworkStats subtract(NetworkStats value, boolean clampNonMonotonic) + throws NonMonotonicException { final long deltaRealtime = this.elapsedRealtime - value.elapsedRealtime; if (deltaRealtime < 0) { throw new NonMonotonicException(this, value); @@ -497,7 +510,15 @@ public class NetworkStats implements Parcelable { if (entry.rxBytes < 0 || entry.rxPackets < 0 || entry.txBytes < 0 || entry.txPackets < 0 || entry.operations < 0) { - throw new NonMonotonicException(this, i, value, j); + if (clampNonMonotonic) { + entry.rxBytes = Math.max(entry.rxBytes, 0); + entry.rxPackets = Math.max(entry.rxPackets, 0); + entry.txBytes = Math.max(entry.txBytes, 0); + entry.txPackets = Math.max(entry.txPackets, 0); + entry.operations = Math.max(entry.operations, 0); + } else { + throw new NonMonotonicException(this, i, value, j); + } } } diff --git a/core/java/android/view/GLES20Canvas.java b/core/java/android/view/GLES20Canvas.java index c934c7b..d948ec2 100644 --- a/core/java/android/view/GLES20Canvas.java +++ b/core/java/android/view/GLES20Canvas.java @@ -315,6 +315,27 @@ class GLES20Canvas extends HardwareCanvas { private static native void nFlushCaches(int level); + /** + * Release all resources associated with the underlying caches. This should + * only be called after a full flushCaches(). + * + * @hide + */ + public static void terminateCaches() { + nTerminateCaches(); + } + + private static native void nTerminateCaches(); + + /** + * @hide + */ + public static void initCaches() { + nInitCaches(); + } + + private static native void nInitCaches(); + /////////////////////////////////////////////////////////////////////////// // Display list /////////////////////////////////////////////////////////////////////////// diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java index c2ac79d..e0167d8 100644 --- a/core/java/android/view/HardwareRenderer.java +++ b/core/java/android/view/HardwareRenderer.java @@ -25,6 +25,7 @@ import android.opengl.GLUtils; import android.os.SystemClock; import android.os.SystemProperties; import android.util.Log; +import com.google.android.gles_jni.EGLImpl; import javax.microedition.khronos.egl.EGL10; import javax.microedition.khronos.egl.EGL11; @@ -344,6 +345,15 @@ public abstract class HardwareRenderer { } /** + * Invoke this method when the system needs to clean up all resources + * associated with hardware rendering. + */ + static void terminate() { + Log.d(LOG_TAG, "Terminating hardware rendering"); + Gl20Renderer.terminate(); + } + + /** * Indicates whether hardware acceleration is currently enabled. * * @return True if hardware acceleration is in use, false otherwise. @@ -651,6 +661,8 @@ public abstract class HardwareRenderer { throw new Surface.OutOfResourcesException("eglMakeCurrent failed " + GLUtils.getEGLErrorString(sEgl.eglGetError())); } + + initCaches(); // If mDirtyRegions is set, this means we have an EGL configuration // with EGL_SWAP_BEHAVIOR_PRESERVED_BIT set @@ -671,6 +683,8 @@ public abstract class HardwareRenderer { return mEglContext.getGL(); } + abstract void initCaches(); + EGLContext createContext(EGL10 egl, EGLDisplay eglDisplay, EGLConfig eglConfig) { int[] attribs = { EGL_CONTEXT_CLIENT_VERSION, mGlVersion, EGL_NONE }; @@ -914,6 +928,11 @@ public abstract class HardwareRenderer { EGL_NONE }; } + + @Override + void initCaches() { + GLES20Canvas.initCaches(); + } @Override boolean canDraw() { @@ -1006,16 +1025,7 @@ public abstract class HardwareRenderer { if (eglContext == null) { return; } else { - synchronized (sPbufferLock) { - // Create a temporary 1x1 pbuffer so we have a context - // to clear our OpenGL objects - if (sPbuffer == null) { - sPbuffer = sEgl.eglCreatePbufferSurface(sEglDisplay, sEglConfig, new int[] { - EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE - }); - } - } - sEgl.eglMakeCurrent(sEglDisplay, sPbuffer, sPbuffer, eglContext); + usePbufferSurface(eglContext); } switch (level) { @@ -1029,5 +1039,46 @@ public abstract class HardwareRenderer { break; } } + + private static void usePbufferSurface(EGLContext eglContext) { + synchronized (sPbufferLock) { + // Create a temporary 1x1 pbuffer so we have a context + // to clear our OpenGL objects + if (sPbuffer == null) { + sPbuffer = sEgl.eglCreatePbufferSurface(sEglDisplay, sEglConfig, new int[] { + EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE + }); + } + } + sEgl.eglMakeCurrent(sEglDisplay, sPbuffer, sPbuffer, eglContext); + } + + static void terminate() { + synchronized (sEglLock) { + if (sEgl == null) return; + + if (EGLImpl.getInitCount(sEglDisplay) == 1) { + EGLContext eglContext = sEglContextStorage.get(); + if (eglContext == null) return; + + usePbufferSurface(eglContext); + GLES20Canvas.terminateCaches(); + + sEgl.eglDestroyContext(sEglDisplay, eglContext); + sEglContextStorage.remove(); + + sEgl.eglDestroySurface(sEglDisplay, sPbuffer); + sEgl.eglMakeCurrent(sEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + + sEgl.eglReleaseThread(); + sEgl.eglTerminate(sEglDisplay); + + sEgl = null; + sEglDisplay = null; + sEglConfig = null; + sPbuffer = null; + } + } + } } } diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index f7078ec..b15b155 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -567,7 +567,7 @@ public final class ViewRootImpl extends Handler implements ViewParent, } } - private void destroyHardwareResources() { + void destroyHardwareResources() { if (mAttachInfo.mHardwareRenderer != null) { if (mAttachInfo.mHardwareRenderer.isEnabled()) { mAttachInfo.mHardwareRenderer.destroyLayers(mView); @@ -880,12 +880,10 @@ public final class ViewRootImpl extends Handler implements ViewParent, || mNewSurfaceNeeded; WindowManager.LayoutParams params = null; - int windowAttributesChanges = 0; if (mWindowAttributesChanged) { mWindowAttributesChanged = false; surfaceChanged = true; params = lp; - windowAttributesChanges = mWindowAttributesChangesFlag; } CompatibilityInfo compatibilityInfo = mCompatibilityInfo.get(); if (compatibilityInfo.supportsScreen() == mLastInCompatMode) { diff --git a/core/java/android/view/WindowManagerImpl.java b/core/java/android/view/WindowManagerImpl.java index 5ef4f3e..d89bc36 100644 --- a/core/java/android/view/WindowManagerImpl.java +++ b/core/java/android/view/WindowManagerImpl.java @@ -16,6 +16,8 @@ package android.view; +import android.app.ActivityManager; +import android.content.ComponentCallbacks2; import android.content.res.CompatibilityInfo; import android.content.res.Configuration; import android.graphics.PixelFormat; @@ -409,7 +411,30 @@ public class WindowManagerImpl implements WindowManager { */ public void trimMemory(int level) { if (HardwareRenderer.isAvailable()) { - HardwareRenderer.trimMemory(level); + switch (level) { + case ComponentCallbacks2.TRIM_MEMORY_COMPLETE: + case ComponentCallbacks2.TRIM_MEMORY_MODERATE: + // On low and medium end gfx devices + if (!ActivityManager.isHighEndGfx(getDefaultDisplay())) { + // Force a full memory flush + HardwareRenderer.trimMemory(ComponentCallbacks2.TRIM_MEMORY_COMPLETE); + // Destroy all hardware surfaces and resources associated to + // known windows + synchronized (this) { + if (mViews == null) return; + int count = mViews.length; + for (int i = 0; i < count; i++) { + mRoots[i].destroyHardwareResources(); + } + } + // Terminate the hardware renderer to free all resources + HardwareRenderer.terminate(); + break; + } + // high end gfx devices fall through to next case + default: + HardwareRenderer.trimMemory(level); + } } } diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 03d6511..7249497 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -2861,8 +2861,8 @@ public class WebView extends AbsoluteLayout } // Used to avoid sending many visible rect messages. - private Rect mLastVisibleRectSent; - private Rect mLastGlobalRect; + private Rect mLastVisibleRectSent = new Rect(); + private Rect mLastGlobalRect = new Rect(); private Rect mVisibleRect = new Rect(); private Rect mGlobalVisibleRect = new Rect(); private Point mScrollOffset = new Point(); @@ -2878,7 +2878,7 @@ public class WebView extends AbsoluteLayout mWebViewCore.sendMessage(EventHub.SET_SCROLL_OFFSET, nativeMoveGeneration(), mSendScrollEvent ? 1 : 0, mScrollOffset); } - mLastVisibleRectSent = mVisibleRect; + mLastVisibleRectSent.set(mVisibleRect); mPrivateHandler.removeMessages(SWITCH_TO_LONGPRESS); } if (getGlobalVisibleRect(mGlobalVisibleRect) @@ -2894,7 +2894,7 @@ public class WebView extends AbsoluteLayout if (!mBlockWebkitViewMessages) { mWebViewCore.sendMessage(EventHub.SET_GLOBAL_BOUNDS, mGlobalVisibleRect); } - mLastGlobalRect = mGlobalVisibleRect; + mLastGlobalRect.set(mGlobalVisibleRect); } return mVisibleRect; } diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java index c1e36ed..73e1273 100644 --- a/core/java/android/widget/ImageView.java +++ b/core/java/android/widget/ImageView.java @@ -1036,6 +1036,7 @@ public class ImageView extends View { } } + @RemotableViewMethod @Override public void setVisibility(int visibility) { super.setVisibility(visibility); diff --git a/core/java/android/widget/PopupWindow.java b/core/java/android/widget/PopupWindow.java index 8ba7bee..5fa4ad0 100644 --- a/core/java/android/widget/PopupWindow.java +++ b/core/java/android/widget/PopupWindow.java @@ -1248,6 +1248,8 @@ public class PopupWindow { */ public void dismiss() { if (isShowing() && mPopupView != null) { + mIsShowing = false; + unregisterForScrollChanged(); try { @@ -1257,7 +1259,6 @@ public class PopupWindow { ((ViewGroup) mPopupView).removeView(mContentView); } mPopupView = null; - mIsShowing = false; if (mOnDismissListener != null) { mOnDismissListener.onDismiss(); diff --git a/core/jni/android_nfc_NdefRecord.cpp b/core/jni/android_nfc_NdefRecord.cpp index e8cc4c6..67907b6 100644 --- a/core/jni/android_nfc_NdefRecord.cpp +++ b/core/jni/android_nfc_NdefRecord.cpp @@ -149,7 +149,7 @@ static jint android_nfc_NdefRecord_parseNdefRecord(JNIEnv *e, jobject o, /* Set flags field */ mFlags = e->GetFieldID(record_cls, "mFlags", "B"); - e->SetIntField(o, mFlags, record.Flags); + e->SetByteField(o, mFlags, record.Flags); ret = 0; diff --git a/core/jni/android_view_GLES20Canvas.cpp b/core/jni/android_view_GLES20Canvas.cpp index e79de2d..4f75fad 100644 --- a/core/jni/android_view_GLES20Canvas.cpp +++ b/core/jni/android_view_GLES20Canvas.cpp @@ -134,6 +134,18 @@ static void android_view_GLES20Canvas_flushCaches(JNIEnv* env, jobject clazz, } } +static void android_view_GLES20Canvas_initCaches(JNIEnv* env, jobject clazz) { + if (Caches::hasInstance()) { + Caches::getInstance().init(); + } +} + +static void android_view_GLES20Canvas_terminateCaches(JNIEnv* env, jobject clazz) { + if (Caches::hasInstance()) { + Caches::getInstance().terminate(); + } +} + // ---------------------------------------------------------------------------- // Constructors // ---------------------------------------------------------------------------- @@ -756,6 +768,8 @@ static JNINativeMethod gMethods[] = { { "nPreserveBackBuffer", "()Z", (void*) android_view_GLES20Canvas_preserveBackBuffer }, { "nDisableVsync", "()V", (void*) android_view_GLES20Canvas_disableVsync }, { "nFlushCaches", "(I)V", (void*) android_view_GLES20Canvas_flushCaches }, + { "nInitCaches", "()V", (void*) android_view_GLES20Canvas_initCaches }, + { "nTerminateCaches", "()V", (void*) android_view_GLES20Canvas_terminateCaches }, { "nCreateRenderer", "()I", (void*) android_view_GLES20Canvas_createRenderer }, { "nDestroyRenderer", "(I)V", (void*) android_view_GLES20Canvas_destroyRenderer }, diff --git a/core/jni/com_google_android_gles_jni_EGLImpl.cpp b/core/jni/com_google_android_gles_jni_EGLImpl.cpp index 02974f9..4fe7600 100644 --- a/core/jni/com_google_android_gles_jni_EGLImpl.cpp +++ b/core/jni/com_google_android_gles_jni_EGLImpl.cpp @@ -24,6 +24,8 @@ #include <EGL/egl.h> #include <GLES/gl.h> +#include <EGL/egl_display.h> + #include <surfaceflinger/Surface.h> #include <SkBitmap.h> #include <SkPixelRef.h> @@ -173,6 +175,16 @@ static jboolean jni_eglQuerySurface(JNIEnv *_env, jobject _this, jobject display return success; } +static jint jni_getInitCount(JNIEnv *_env, jobject _clazz, jobject display) { + EGLDisplay dpy = getDisplay(_env, display); + egl_display_t* eglDisplay = get_display(dpy); + return eglDisplay ? eglDisplay->getRefsCount() : 0; +} + +static jboolean jni_eglReleaseThread(JNIEnv *_env, jobject _this) { + return eglReleaseThread(); +} + static jboolean jni_eglChooseConfig(JNIEnv *_env, jobject _this, jobject display, jintArray attrib_list, jobjectArray configs, jint config_size, jintArray num_config) { if (display == NULL @@ -526,6 +538,8 @@ static JNINativeMethod methods[] = { {"eglInitialize", "(" DISPLAY "[I)Z", (void*)jni_eglInitialize }, {"eglQueryContext", "(" DISPLAY CONTEXT "I[I)Z", (void*)jni_eglQueryContext }, {"eglQuerySurface", "(" DISPLAY SURFACE "I[I)Z", (void*)jni_eglQuerySurface }, +{"eglReleaseThread","()Z", (void*)jni_eglReleaseThread }, +{"getInitCount", "(" DISPLAY ")I", (void*)jni_getInitCount }, {"eglChooseConfig", "(" DISPLAY "[I[" CONFIG "I[I)Z", (void*)jni_eglChooseConfig }, {"_eglCreateContext","(" DISPLAY CONFIG CONTEXT "[I)I", (void*)jni_eglCreateContext }, {"eglGetConfigs", "(" DISPLAY "[" CONFIG "I[I)Z", (void*)jni_eglGetConfigs }, diff --git a/libs/hwui/Caches.cpp b/libs/hwui/Caches.cpp index 75b07de..f293cba 100644 --- a/libs/hwui/Caches.cpp +++ b/libs/hwui/Caches.cpp @@ -46,22 +46,16 @@ namespace uirenderer { // Constructors/destructor /////////////////////////////////////////////////////////////////////////////// -Caches::Caches(): Singleton<Caches>(), blend(false), lastSrcMode(GL_ZERO), - lastDstMode(GL_ZERO), currentProgram(NULL) { +Caches::Caches(): Singleton<Caches>(), mInitialized(false) { GLint maxTextureUnits; glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxTextureUnits); if (maxTextureUnits < REQUIRED_TEXTURE_UNITS_COUNT) { LOGW("At least %d texture units are required!", REQUIRED_TEXTURE_UNITS_COUNT); } - glGenBuffers(1, &meshBuffer); - glBindBuffer(GL_ARRAY_BUFFER, meshBuffer); - glBufferData(GL_ARRAY_BUFFER, sizeof(gMeshVertices), gMeshVertices, GL_STATIC_DRAW); - glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize); - mCurrentBuffer = meshBuffer; - mRegionMesh = NULL; + init(); mDebugLevel = readDebugLevel(); LOGD("Enabling debug mode %d", mDebugLevel); @@ -71,8 +65,40 @@ Caches::Caches(): Singleton<Caches>(), blend(false), lastSrcMode(GL_ZERO), #endif } -Caches::~Caches() { +void Caches::init() { + if (mInitialized) return; + + glGenBuffers(1, &meshBuffer); + glBindBuffer(GL_ARRAY_BUFFER, meshBuffer); + glBufferData(GL_ARRAY_BUFFER, sizeof(gMeshVertices), gMeshVertices, GL_STATIC_DRAW); + + mCurrentBuffer = meshBuffer; + mRegionMesh = NULL; + + blend = false; + lastSrcMode = GL_ZERO; + lastDstMode = GL_ZERO; + currentProgram = NULL; + + mInitialized = true; +} + +void Caches::terminate() { + if (!mInitialized) return; + + glDeleteBuffers(1, &meshBuffer); + mCurrentBuffer = 0; + + glDeleteBuffers(1, &mRegionMeshIndices); delete[] mRegionMesh; + mRegionMesh = NULL; + + fboCache.clear(); + + programCache.clear(); + currentProgram = NULL; + + mInitialized = false; } /////////////////////////////////////////////////////////////////////////////// diff --git a/libs/hwui/Caches.h b/libs/hwui/Caches.h index 9b0d7c6..5e58a9e 100644 --- a/libs/hwui/Caches.h +++ b/libs/hwui/Caches.h @@ -86,7 +86,6 @@ struct CacheLogger { class ANDROID_API Caches: public Singleton<Caches> { Caches(); - ~Caches(); friend class Singleton<Caches>; @@ -109,6 +108,11 @@ public: }; /** + * Initializes the cache. + */ + void init(); + + /** * Flush the cache. * * @param mode Indicates how much of the cache should be flushed @@ -116,6 +120,12 @@ public: void flush(FlushMode mode); /** + * Destroys all resources associated with this cache. This should + * be called after a flush(kFlushMode_Full). + */ + void terminate(); + + /** * Indicates whether the renderer is in debug mode. * This debug mode provides limited information to app developers. */ @@ -194,6 +204,7 @@ public: private: DebugLevel mDebugLevel; + bool mInitialized; }; // class Caches }; // namespace uirenderer diff --git a/opengl/java/android/opengl/EGLLogWrapper.java b/opengl/java/android/opengl/EGLLogWrapper.java index 6c0fdb3..36e88a2 100644 --- a/opengl/java/android/opengl/EGLLogWrapper.java +++ b/opengl/java/android/opengl/EGLLogWrapper.java @@ -314,6 +314,16 @@ class EGLLogWrapper implements EGL11 { checkError(); return result; } + + /** @hide **/ + public boolean eglReleaseThread() { + begin("eglReleaseThread"); + end(); + boolean result = mEgl10.eglReleaseThread(); + returns(result); + checkError(); + return result; + } public boolean eglSwapBuffers(EGLDisplay display, EGLSurface surface) { begin("eglInitialize"); diff --git a/opengl/java/com/google/android/gles_jni/EGLImpl.java b/opengl/java/com/google/android/gles_jni/EGLImpl.java index 51d6ca8..6992019 100644 --- a/opengl/java/com/google/android/gles_jni/EGLImpl.java +++ b/opengl/java/com/google/android/gles_jni/EGLImpl.java @@ -31,6 +31,8 @@ public class EGLImpl implements EGL10 { public native boolean eglInitialize(EGLDisplay display, int[] major_minor); public native boolean eglQueryContext(EGLDisplay display, EGLContext context, int attribute, int[] value); public native boolean eglQuerySurface(EGLDisplay display, EGLSurface surface, int attribute, int[] value); + /** @hide **/ + public native boolean eglReleaseThread(); public native boolean eglChooseConfig(EGLDisplay display, int[] attrib_list, EGLConfig[] configs, int config_size, int[] num_config); public native boolean eglGetConfigAttrib(EGLDisplay display, EGLConfig config, int attribute, int[] value); public native boolean eglGetConfigs(EGLDisplay display, EGLConfig[] configs, int config_size, int[] num_config); @@ -44,6 +46,9 @@ public class EGLImpl implements EGL10 { public native boolean eglCopyBuffers(EGLDisplay display, EGLSurface surface, Object native_pixmap); public native boolean eglWaitGL(); public native boolean eglWaitNative(int engine, Object bindTarget); + + /** @hide **/ + public static native int getInitCount(EGLDisplay display); public EGLContext eglCreateContext(EGLDisplay display, EGLConfig config, EGLContext share_context, int[] attrib_list) { int eglContextId = _eglCreateContext(display, config, share_context, attrib_list); @@ -85,7 +90,7 @@ public class EGLImpl implements EGL10 { eglSurfaceId = _eglCreateWindowSurface(display, config, sur, attrib_list); } else if (native_window instanceof SurfaceTexture) { eglSurfaceId = _eglCreateWindowSurfaceTexture(display, config, - (SurfaceTexture) native_window, attrib_list); + native_window, attrib_list); } else { throw new java.lang.UnsupportedOperationException( "eglCreateWindowSurface() can only be called with an instance of " + diff --git a/opengl/java/javax/microedition/khronos/egl/EGL10.java b/opengl/java/javax/microedition/khronos/egl/EGL10.java index 2ae793a..cf58888 100644 --- a/opengl/java/javax/microedition/khronos/egl/EGL10.java +++ b/opengl/java/javax/microedition/khronos/egl/EGL10.java @@ -114,6 +114,8 @@ public interface EGL10 extends EGL { boolean eglQueryContext(EGLDisplay display, EGLContext context, int attribute, int[] value); String eglQueryString(EGLDisplay display, int name); boolean eglQuerySurface(EGLDisplay display, EGLSurface surface, int attribute, int[] value); + /** @hide **/ + boolean eglReleaseThread(); boolean eglSwapBuffers(EGLDisplay display, EGLSurface surface); boolean eglTerminate(EGLDisplay display); boolean eglWaitGL(); diff --git a/opengl/libs/EGL/egl_display.h b/opengl/libs/EGL/egl_display.h index 1c1092c..e0a367d 100644 --- a/opengl/libs/EGL/egl_display.h +++ b/opengl/libs/EGL/egl_display.h @@ -91,6 +91,8 @@ public: inline bool isValid() const { return magic == '_dpy'; } inline bool isAlive() const { return isValid(); } + inline uint32_t getRefsCount() const { return refs; } + struct strings_t { char const * vendor; char const * version; diff --git a/packages/SystemUI/res/layout/signal_cluster_view.xml b/packages/SystemUI/res/layout/signal_cluster_view.xml index 93ac22e..9be9041 100644 --- a/packages/SystemUI/res/layout/signal_cluster_view.xml +++ b/packages/SystemUI/res/layout/signal_cluster_view.xml @@ -51,7 +51,7 @@ android:visibility="gone" android:id="@+id/spacer" /> - <FrameLayout + <!--<FrameLayout android:id="@+id/wimax_combo" android:layout_height="wrap_content" android:layout_width="wrap_content" @@ -72,6 +72,7 @@ android:layout_gravity="center|bottom" /> </FrameLayout> + --> <FrameLayout android:layout_height="wrap_content" android:layout_width="wrap_content" diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index a0d7b13..fc81f8e 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -257,10 +257,16 @@ <string name="accessibility_wifi_three_bars">Wi-Fi three bars.</string> <!-- Content description of the WIFI signal when it is full for accessibility (not shown on the screen). [CHAR LIMIT=NONE] --> <string name="accessibility_wifi_signal_full">WiFi signal full.</string> + + <!-- Content description of the WiMAX signal when no signal for accessibility (not shown on the screen). [CHAR LIMIT=NONE] --> <string name="accessibility_no_wimax">No WiMAX.</string> + <!-- Content description of the WiMAX signal when it is one bar for accessibility (not shown on the screen). [CHAR LIMIT=NONE] --> <string name="accessibility_wimax_one_bar">WiMAX one bar.</string> + <!-- Content description of the WiMAX signal when it is two bars for accessibility (not shown on the screen). [CHAR LIMIT=NONE] --> <string name="accessibility_wimax_two_bars">WiMAX two bars.</string> + <!-- Content description of the WiMAX signal when it is three bars for accessibility (not shown on the screen). [CHAR LIMIT=NONE] --> <string name="accessibility_wimax_three_bars">WiMAX three bars.</string> + <!-- Content description of the WiMAX signal when it is full for accessibility (not shown on the screen). [CHAR LIMIT=NONE] --> <string name="accessibility_wimax_signal_full">WiMAX signal full.</string> <!-- Content description of the data connection type GPRS for accessibility (not shown on the screen). [CHAR LIMIT=NONE] --> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index b0e6968..51fb262 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -350,11 +350,11 @@ public class PhoneStatusBar extends StatusBar { (SignalClusterView)sb.findViewById(R.id.signal_cluster); mNetworkController.addSignalCluster(signalCluster); signalCluster.setNetworkController(mNetworkController); - final ImageView wimaxRSSI = - (ImageView)sb.findViewById(R.id.wimax_signal); - if (wimaxRSSI != null) { - mNetworkController.addWimaxIconView(wimaxRSSI); - } +// final ImageView wimaxRSSI = +// (ImageView)sb.findViewById(R.id.wimax_signal); +// if (wimaxRSSI != null) { +// mNetworkController.addWimaxIconView(wimaxRSSI); +// } // Recents Panel mRecentTasksLoader = new RecentTasksLoader(context); updateRecentsPanel(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java index f77e93f..55a5b0a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java @@ -111,6 +111,7 @@ public class NetworkController extends BroadcastReceiver { com.android.internal.R.drawable.stat_sys_tether_bluetooth; //wimax + private boolean mWimaxSupported = false; private boolean mIsWimaxEnabled = false; private boolean mWimaxConnected = false; private boolean mWimaxIdle = false; @@ -213,9 +214,9 @@ public class NetworkController extends BroadcastReceiver { filter.addAction(ConnectivityManager.INET_CONDITION_ACTION); filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED); - boolean isWimaxConfigEnabled = mContext.getResources().getBoolean( + mWimaxSupported = mContext.getResources().getBoolean( com.android.internal.R.bool.config_wimaxEnabled); - if(isWimaxConfigEnabled) { + if(mWimaxSupported) { filter.addAction(WimaxManagerConstants.WIMAX_NETWORK_STATE_CHANGED_ACTION); filter.addAction(WimaxManagerConstants.SIGNAL_LEVEL_CHANGED_ACTION); filter.addAction(WimaxManagerConstants.NET_4G_STATE_CHANGED_ACTION); @@ -262,19 +263,36 @@ public class NetworkController extends BroadcastReceiver { public void addSignalCluster(SignalCluster cluster) { mSignalClusters.add(cluster); + refreshSignalCluster(cluster); + } + + public void refreshSignalCluster(SignalCluster cluster) { cluster.setWifiIndicators( mWifiConnected, // only show wifi in the cluster if connected mWifiIconId, mWifiActivityIconId, mContentDescriptionWifi); - cluster.setMobileDataIndicators( - mHasMobileDataFeature, - mShowPhoneRSSIForData ? mPhoneSignalIconId : mDataSignalIconId, - mMobileActivityIconId, - mDataTypeIconId, - mContentDescriptionPhoneSignal, - mContentDescriptionDataType); + if (mIsWimaxEnabled && mWimaxConnected) { + // wimax is special + cluster.setMobileDataIndicators( + true, + mWimaxIconId, + mMobileActivityIconId, + mDataTypeIconId, + mContentDescriptionWimax, + mContentDescriptionDataType); + } else { + // normal mobile data + cluster.setMobileDataIndicators( + mHasMobileDataFeature, + mShowPhoneRSSIForData ? mPhoneSignalIconId : mDataSignalIconId, + mMobileActivityIconId, + mDataTypeIconId, + mContentDescriptionPhoneSignal, + mContentDescriptionDataType); + } + cluster.setIsAirplaneMode(mAirplaneMode); } public void setStackedMode(boolean stacked) { @@ -311,7 +329,7 @@ public class NetworkController extends BroadcastReceiver { } else if (action.equals(WimaxManagerConstants.NET_4G_STATE_CHANGED_ACTION) || action.equals(WimaxManagerConstants.SIGNAL_LEVEL_CHANGED_ACTION) || action.equals(WimaxManagerConstants.WIMAX_NETWORK_STATE_CHANGED_ACTION)) { - updateWimaxState(intent); + updateWimaxState(intent); refreshViews(); } } @@ -466,91 +484,100 @@ public class NetworkController extends BroadcastReceiver { } private final void updateDataNetType() { - switch (mDataNetType) { - case TelephonyManager.NETWORK_TYPE_UNKNOWN: - if (!mShowAtLeastThreeGees) { - mDataIconList = TelephonyIcons.DATA_G[mInetCondition]; - mDataTypeIconId = 0; + if (mIsWimaxEnabled && mWimaxConnected) { + // wimax is a special 4g network not handled by telephony + mDataIconList = TelephonyIcons.DATA_4G[mInetCondition]; + mDataTypeIconId = R.drawable.stat_sys_data_connected_4g; + mContentDescriptionDataType = mContext.getString( + R.string.accessibility_data_connection_4g); + } else { + switch (mDataNetType) { + case TelephonyManager.NETWORK_TYPE_UNKNOWN: + if (!mShowAtLeastThreeGees) { + mDataIconList = TelephonyIcons.DATA_G[mInetCondition]; + mDataTypeIconId = 0; + mContentDescriptionDataType = mContext.getString( + R.string.accessibility_data_connection_gprs); + break; + } else { + // fall through + } + case TelephonyManager.NETWORK_TYPE_EDGE: + if (!mShowAtLeastThreeGees) { + mDataIconList = TelephonyIcons.DATA_E[mInetCondition]; + mDataTypeIconId = R.drawable.stat_sys_data_connected_e; + mContentDescriptionDataType = mContext.getString( + R.string.accessibility_data_connection_edge); + break; + } else { + // fall through + } + case TelephonyManager.NETWORK_TYPE_UMTS: + mDataIconList = TelephonyIcons.DATA_3G[mInetCondition]; + mDataTypeIconId = R.drawable.stat_sys_data_connected_3g; mContentDescriptionDataType = mContext.getString( - R.string.accessibility_data_connection_gprs); + R.string.accessibility_data_connection_3g); break; - } else { - // fall through - } - case TelephonyManager.NETWORK_TYPE_EDGE: - if (!mShowAtLeastThreeGees) { - mDataIconList = TelephonyIcons.DATA_E[mInetCondition]; - mDataTypeIconId = R.drawable.stat_sys_data_connected_e; + case TelephonyManager.NETWORK_TYPE_HSDPA: + case TelephonyManager.NETWORK_TYPE_HSUPA: + case TelephonyManager.NETWORK_TYPE_HSPA: + case TelephonyManager.NETWORK_TYPE_HSPAP: + if (mHspaDataDistinguishable) { + mDataIconList = TelephonyIcons.DATA_H[mInetCondition]; + mDataTypeIconId = R.drawable.stat_sys_data_connected_h; + mContentDescriptionDataType = mContext.getString( + R.string.accessibility_data_connection_3_5g); + } else { + mDataIconList = TelephonyIcons.DATA_3G[mInetCondition]; + mDataTypeIconId = R.drawable.stat_sys_data_connected_3g; + mContentDescriptionDataType = mContext.getString( + R.string.accessibility_data_connection_3g); + } + break; + case TelephonyManager.NETWORK_TYPE_CDMA: + // display 1xRTT for IS95A/B + mDataIconList = TelephonyIcons.DATA_1X[mInetCondition]; + mDataTypeIconId = R.drawable.stat_sys_data_connected_1x; mContentDescriptionDataType = mContext.getString( - R.string.accessibility_data_connection_edge); + R.string.accessibility_data_connection_cdma); break; - } else { - // fall through - } - case TelephonyManager.NETWORK_TYPE_UMTS: - mDataIconList = TelephonyIcons.DATA_3G[mInetCondition]; - mDataTypeIconId = R.drawable.stat_sys_data_connected_3g; - mContentDescriptionDataType = mContext.getString( - R.string.accessibility_data_connection_3g); - break; - case TelephonyManager.NETWORK_TYPE_HSDPA: - case TelephonyManager.NETWORK_TYPE_HSUPA: - case TelephonyManager.NETWORK_TYPE_HSPA: - case TelephonyManager.NETWORK_TYPE_HSPAP: - if (mHspaDataDistinguishable) { - mDataIconList = TelephonyIcons.DATA_H[mInetCondition]; - mDataTypeIconId = R.drawable.stat_sys_data_connected_h; + case TelephonyManager.NETWORK_TYPE_1xRTT: + mDataIconList = TelephonyIcons.DATA_1X[mInetCondition]; + mDataTypeIconId = R.drawable.stat_sys_data_connected_1x; mContentDescriptionDataType = mContext.getString( - R.string.accessibility_data_connection_3_5g); - } else { + R.string.accessibility_data_connection_cdma); + break; + case TelephonyManager.NETWORK_TYPE_EVDO_0: //fall through + case TelephonyManager.NETWORK_TYPE_EVDO_A: + case TelephonyManager.NETWORK_TYPE_EVDO_B: + case TelephonyManager.NETWORK_TYPE_EHRPD: mDataIconList = TelephonyIcons.DATA_3G[mInetCondition]; mDataTypeIconId = R.drawable.stat_sys_data_connected_3g; mContentDescriptionDataType = mContext.getString( R.string.accessibility_data_connection_3g); - } - break; - case TelephonyManager.NETWORK_TYPE_CDMA: - // display 1xRTT for IS95A/B - mDataIconList = TelephonyIcons.DATA_1X[mInetCondition]; - mDataTypeIconId = R.drawable.stat_sys_data_connected_1x; - mContentDescriptionDataType = mContext.getString( - R.string.accessibility_data_connection_cdma); - break; - case TelephonyManager.NETWORK_TYPE_1xRTT: - mDataIconList = TelephonyIcons.DATA_1X[mInetCondition]; - mDataTypeIconId = R.drawable.stat_sys_data_connected_1x; - mContentDescriptionDataType = mContext.getString( - R.string.accessibility_data_connection_cdma); - break; - case TelephonyManager.NETWORK_TYPE_EVDO_0: //fall through - case TelephonyManager.NETWORK_TYPE_EVDO_A: - case TelephonyManager.NETWORK_TYPE_EVDO_B: - case TelephonyManager.NETWORK_TYPE_EHRPD: - mDataIconList = TelephonyIcons.DATA_3G[mInetCondition]; - mDataTypeIconId = R.drawable.stat_sys_data_connected_3g; - mContentDescriptionDataType = mContext.getString( - R.string.accessibility_data_connection_3g); - break; - case TelephonyManager.NETWORK_TYPE_LTE: - mDataIconList = TelephonyIcons.DATA_4G[mInetCondition]; - mDataTypeIconId = R.drawable.stat_sys_data_connected_4g; - mContentDescriptionDataType = mContext.getString( - R.string.accessibility_data_connection_4g); - break; - default: - if (!mShowAtLeastThreeGees) { - mDataIconList = TelephonyIcons.DATA_G[mInetCondition]; - mDataTypeIconId = R.drawable.stat_sys_data_connected_g; - mContentDescriptionDataType = mContext.getString( - R.string.accessibility_data_connection_gprs); - } else { - mDataIconList = TelephonyIcons.DATA_3G[mInetCondition]; - mDataTypeIconId = R.drawable.stat_sys_data_connected_3g; + break; + case TelephonyManager.NETWORK_TYPE_LTE: + mDataIconList = TelephonyIcons.DATA_4G[mInetCondition]; + mDataTypeIconId = R.drawable.stat_sys_data_connected_4g; mContentDescriptionDataType = mContext.getString( - R.string.accessibility_data_connection_3g); - } - break; + R.string.accessibility_data_connection_4g); + break; + default: + if (!mShowAtLeastThreeGees) { + mDataIconList = TelephonyIcons.DATA_G[mInetCondition]; + mDataTypeIconId = R.drawable.stat_sys_data_connected_g; + mContentDescriptionDataType = mContext.getString( + R.string.accessibility_data_connection_gprs); + } else { + mDataIconList = TelephonyIcons.DATA_3G[mInetCondition]; + mDataTypeIconId = R.drawable.stat_sys_data_connected_3g; + mContentDescriptionDataType = mContext.getString( + R.string.accessibility_data_connection_3g); + } + break; + } } + if ((isCdma() && isCdmaEri()) || mPhone.isNetworkRoaming()) { mDataTypeIconId = R.drawable.stat_sys_data_connected_roam; } @@ -763,8 +790,7 @@ public class NetworkController extends BroadcastReceiver { } - // ===== Wimax =================================================================== - + // ===== Wimax =================================================================== private final void updateWimaxState(Intent intent) { final String action = intent.getAction(); boolean wasConnected = mWimaxConnected; @@ -772,42 +798,41 @@ public class NetworkController extends BroadcastReceiver { int wimaxStatus = intent.getIntExtra(WimaxManagerConstants.EXTRA_4G_STATE, WimaxManagerConstants.NET_4G_STATE_UNKNOWN); mIsWimaxEnabled = (wimaxStatus == - WimaxManagerConstants.NET_4G_STATE_ENABLED)? true : false; + WimaxManagerConstants.NET_4G_STATE_ENABLED); } else if (action.equals(WimaxManagerConstants.SIGNAL_LEVEL_CHANGED_ACTION)) { mWimaxSignal = intent.getIntExtra(WimaxManagerConstants.EXTRA_NEW_SIGNAL_LEVEL, 0); } else if (action.equals(WimaxManagerConstants.WIMAX_NETWORK_STATE_CHANGED_ACTION)) { - mWimaxState = intent.getIntExtra(WimaxManagerConstants.EXTRA_WIMAX_STATE, + mWimaxState = intent.getIntExtra(WimaxManagerConstants.EXTRA_WIMAX_STATE, WimaxManagerConstants.NET_4G_STATE_UNKNOWN); mWimaxExtraState = intent.getIntExtra( WimaxManagerConstants.EXTRA_WIMAX_STATE_DETAIL, WimaxManagerConstants.NET_4G_STATE_UNKNOWN); mWimaxConnected = (mWimaxState == - WimaxManagerConstants.WIMAX_STATE_CONNECTED) ? true : false; - mWimaxIdle = (mWimaxExtraState == WimaxManagerConstants.WIMAX_IDLE)? true : false; + WimaxManagerConstants.WIMAX_STATE_CONNECTED); + mWimaxIdle = (mWimaxExtraState == WimaxManagerConstants.WIMAX_IDLE); } + updateDataNetType(); updateWimaxIcons(); } - private void updateWimaxIcons() { - Slog.d(TAG, "in .... updateWimaxIcons function : "+mIsWimaxEnabled); - if (mIsWimaxEnabled) { - if (mWimaxConnected) { - Slog.d(TAG, "in .... updateWimaxIcons function WiMAX COnnected"); - if (mWimaxIdle) - mWimaxIconId = WimaxIcons.WIMAX_IDLE; - else - mWimaxIconId = WimaxIcons.WIMAX_SIGNAL_STRENGTH[mInetCondition][mWimaxSignal]; - mContentDescriptionWimax = mContext.getString( - AccessibilityContentDescriptions.WIMAX_CONNECTION_STRENGTH[mWimaxSignal]); - } else { - Slog.d(TAG, "in .... updateWimaxIcons function WiMAX Disconnected"); - mWimaxIconId = WimaxIcons.WIMAX_DISCONNECTED; - mContentDescriptionWimax = mContext.getString(R.string.accessibility_no_wimax); - } - } else { - Slog.d(TAG, "in .... updateWimaxIcons function wimax icon id 0"); - mWimaxIconId = 0; - } + + private void updateWimaxIcons() { + if (mIsWimaxEnabled) { + if (mWimaxConnected) { + if (mWimaxIdle) + mWimaxIconId = WimaxIcons.WIMAX_IDLE; + else + mWimaxIconId = WimaxIcons.WIMAX_SIGNAL_STRENGTH[mInetCondition][mWimaxSignal]; + mContentDescriptionWimax = mContext.getString( + AccessibilityContentDescriptions.WIMAX_CONNECTION_STRENGTH[mWimaxSignal]); + } else { + mWimaxIconId = WimaxIcons.WIMAX_DISCONNECTED; + mContentDescriptionWimax = mContext.getString(R.string.accessibility_no_wimax); + } + } else { + mWimaxIconId = 0; } + } + // ===== Full or limited Internet connectivity ================================== private void updateConnectivity(Intent intent) { @@ -827,14 +852,14 @@ public class NetworkController extends BroadcastReceiver { mInetCondition = (connectionStatus > INET_CONDITION_THRESHOLD ? 1 : 0); if (info != null && info.getType() == ConnectivityManager.TYPE_BLUETOOTH) { - mBluetoothTethered = info.isConnected() ? true: false; + mBluetoothTethered = info.isConnected(); } else { mBluetoothTethered = false; } // We want to update all the icons, all at once, for any condition change updateDataNetType(); - updateWimaxIcons(); + updateWimaxIcons(); updateDataIcon(); updateTelephonySignalStrength(); updateWifiIcons(); @@ -921,7 +946,7 @@ public class NetworkController extends BroadcastReceiver { combinedSignalIconId = mDataSignalIconId; } - else if (!mDataConnected && !mWifiConnected && !mBluetoothTethered) { + else if (!mDataConnected && !mWifiConnected && !mBluetoothTethered && !mWimaxConnected) { // pretty much totally disconnected label = context.getString(R.string.status_bar_settings_signal_meter_disconnected); @@ -961,23 +986,12 @@ public class NetworkController extends BroadcastReceiver { if (mLastPhoneSignalIconId != mPhoneSignalIconId || mLastDataDirectionOverlayIconId != combinedActivityIconId || mLastWifiIconId != mWifiIconId + || mLastWimaxIconId != mWimaxIconId || mLastDataTypeIconId != mDataTypeIconId) { // NB: the mLast*s will be updated later for (SignalCluster cluster : mSignalClusters) { - cluster.setWifiIndicators( - mWifiConnected, // only show wifi in the cluster if connected - mWifiIconId, - mWifiActivityIconId, - mContentDescriptionWifi); - cluster.setMobileDataIndicators( - mHasMobileDataFeature, - mShowPhoneRSSIForData ? mPhoneSignalIconId : mDataSignalIconId, - mMobileActivityIconId, - mDataTypeIconId, - mContentDescriptionPhoneSignal, - mContentDescriptionDataType); - cluster.setIsAirplaneMode(mAirplaneMode); + refreshSignalCluster(cluster); } } @@ -1152,11 +1166,22 @@ public class NetworkController extends BroadcastReceiver { pw.println(mWifiLevel); pw.print(" mWifiSsid="); pw.println(mWifiSsid); - pw.print(String.format(" mWifiIconId=0x%08x/%s", + pw.println(String.format(" mWifiIconId=0x%08x/%s", mWifiIconId, getResourceName(mWifiIconId))); pw.print(" mWifiActivity="); pw.println(mWifiActivity); + if (mWimaxSupported) { + pw.println(" - wimax ------"); + pw.print(" mIsWimaxEnabled="); pw.println(mIsWimaxEnabled); + pw.print(" mWimaxConnected="); pw.println(mWimaxConnected); + pw.print(" mWimaxIdle="); pw.println(mWimaxIdle); + pw.println(String.format(" mWimaxIconId=0x%08x/%s", + mWimaxIconId, getResourceName(mWimaxIconId))); + pw.println(String.format(" mWimaxSignal=%d", mWimaxSignal)); + pw.println(String.format(" mWimaxState=%d", mWimaxState)); + pw.println(String.format(" mWimaxExtraState=%d", mWimaxExtraState)); + } pw.println(" - Bluetooth ----"); pw.print(" mBtReverseTethered="); @@ -1190,7 +1215,7 @@ public class NetworkController extends BroadcastReceiver { pw.print(" mLastDataTypeIconId=0x"); pw.print(Integer.toHexString(mLastDataTypeIconId)); pw.print("/"); - pw.println(getResourceName(mLastCombinedSignalIconId)); + pw.println(getResourceName(mLastDataTypeIconId)); pw.print(" mLastLabel="); pw.print(mLastLabel); pw.println(""); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/WimaxIcons.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/WimaxIcons.java index 8605489..d3d4338 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/WimaxIcons.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/WimaxIcons.java @@ -1,5 +1,5 @@ /*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,22 +16,13 @@ package com.android.systemui.statusbar.policy;
+import com.android.systemui.statusbar.policy.TelephonyIcons;
import com.android.systemui.R;
class WimaxIcons {
- static final int[][] WIMAX_SIGNAL_STRENGTH = {
- { R.drawable.stat_sys_data_wimax_signal_0,
- R.drawable.stat_sys_data_wimax_signal_1,
- R.drawable.stat_sys_data_wimax_signal_2,
- R.drawable.stat_sys_data_wimax_signal_3 },
- { R.drawable.stat_sys_data_wimax_signal_0_fully,
- R.drawable.stat_sys_data_wimax_signal_1_fully,
- R.drawable.stat_sys_data_wimax_signal_2_fully,
- R.drawable.stat_sys_data_wimax_signal_3_fully }
- };
+ static final int[][] WIMAX_SIGNAL_STRENGTH = TelephonyIcons.DATA_SIGNAL_STRENGTH;
- static final int WIMAX_DISCONNECTED =
- R.drawable.stat_sys_data_wimax_signal_disconnected;
- static final int WIMAX_IDLE = R.drawable.stat_sys_data_wimax_signal_idle;
- static final int WIFI_LEVEL_COUNT = WIMAX_SIGNAL_STRENGTH[0].length;
+ static final int WIMAX_DISCONNECTED = WIMAX_SIGNAL_STRENGTH[0][0];
+
+ static final int WIMAX_IDLE = WIMAX_DISCONNECTED; // XXX: unclear if we need a different icon
}
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java index 4af6112..fc87033 100644 --- a/services/java/com/android/server/ConnectivityService.java +++ b/services/java/com/android/server/ConnectivityService.java @@ -514,7 +514,9 @@ public class ConnectivityService extends IConnectivityManager.Stub { continue; } mCurrentLinkProperties[netType] = null; - if (mNetConfigs[netType].isDefault()) mNetTrackers[netType].reconnect(); + if (mNetTrackers[netType] != null && mNetConfigs[netType].isDefault()) { + mNetTrackers[netType].reconnect(); + } } IBinder b = ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE); diff --git a/services/java/com/android/server/net/NetworkStatsService.java b/services/java/com/android/server/net/NetworkStatsService.java index 77b0d96..6365525 100644 --- a/services/java/com/android/server/net/NetworkStatsService.java +++ b/services/java/com/android/server/net/NetworkStatsService.java @@ -806,9 +806,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub { final NetworkStats networkDevSnapshot; try { // collect any tethering stats - final String[] tetheredIfacePairs = mConnManager.getTetheredIfacePairs(); - final NetworkStats tetherSnapshot = mNetworkManager.getNetworkStatsTethering( - tetheredIfacePairs); + final NetworkStats tetherSnapshot = getNetworkStatsTethering(); // record uid stats, folding in tethering stats uidSnapshot = mNetworkManager.getNetworkStatsUidDetail(UID_ALL); @@ -1505,7 +1503,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub { NetworkStats before, NetworkStats current, boolean collectStale, String type) { if (before != null) { try { - return current.subtract(before); + return current.subtract(before, false); } catch (NonMonotonicException e) { Log.w(TAG, "found non-monotonic values; saving to dropbox"); @@ -1517,8 +1515,13 @@ public class NetworkStatsService extends INetworkStatsService.Stub { builder.append("right=").append(e.right).append('\n'); mDropBox.addText(TAG_NETSTATS_ERROR, builder.toString()); - // return empty delta to avoid recording broken stats - return new NetworkStats(0L, 10); + try { + // return clamped delta to help recover + return current.subtract(before, true); + } catch (NonMonotonicException e1) { + Log.wtf(TAG, "found non-monotonic values; returning empty delta", e1); + return new NetworkStats(0L, 10); + } } } else if (collectStale) { // caller is okay collecting stale stats for first call. @@ -1530,6 +1533,20 @@ public class NetworkStatsService extends INetworkStatsService.Stub { } } + /** + * Return snapshot of current tethering statistics. Will return empty + * {@link NetworkStats} if any problems are encountered. + */ + private NetworkStats getNetworkStatsTethering() throws RemoteException { + try { + final String[] tetheredIfacePairs = mConnManager.getTetheredIfacePairs(); + return mNetworkManager.getNetworkStatsTethering(tetheredIfacePairs); + } catch (IllegalStateException e) { + Log.wtf(TAG, "problem reading network stats", e); + return new NetworkStats(0L, 10); + } + } + private static NetworkStats computeNetworkXtSnapshotFromUid(NetworkStats uidSnapshot) { return uidSnapshot.groupedByIface(); } |