diff options
18 files changed, 448 insertions, 214 deletions
diff --git a/core/java/android/net/MobileDataStateTracker.java b/core/java/android/net/MobileDataStateTracker.java index bcf6239afbca..62bb9657f796 100644 --- a/core/java/android/net/MobileDataStateTracker.java +++ b/core/java/android/net/MobileDataStateTracker.java @@ -56,7 +56,7 @@ import java.io.PrintWriter; public class MobileDataStateTracker implements NetworkStateTracker { private static final String TAG = "MobileDataStateTracker"; - private static final boolean DBG = true; + private static final boolean DBG = false; private static final boolean VDBG = false; private Phone.DataState mMobileDataState; diff --git a/core/java/android/net/ProxyProperties.java b/core/java/android/net/ProxyProperties.java index 44dbec1ba508..cd799da9d7d2 100644 --- a/core/java/android/net/ProxyProperties.java +++ b/core/java/android/net/ProxyProperties.java @@ -137,6 +137,8 @@ public class ProxyProperties implements Parcelable { if (mExclusionList != null) { sb.append(" xl=").append(mExclusionList); } + } else { + sb.append("[ProxyProperties.mHost == null]"); } return sb.toString(); } diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 122a717f7643..47629c4434e8 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -7170,6 +7170,14 @@ public class WebView extends AbsoluteLayout } /** + * Return the overview scale of the WebView + * @return The overview scale. + */ + float getZoomOverviewScale() { + return mZoomManager.getZoomOverviewScale(); + } + + /** * @return TRUE if the WebView can be zoomed in. */ public boolean canZoomIn() { diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java index 48359d44daca..470e843f5868 100644 --- a/core/java/android/webkit/WebViewCore.java +++ b/core/java/android/webkit/WebViewCore.java @@ -2512,10 +2512,13 @@ public final class WebViewCore { // called by JNI private void restoreScale(float scale, float textWrapScale) { if (mBrowserFrame.firstLayoutDone() == false) { - final float defaultScale = mWebView.getDefaultZoomScale(); - mRestoredScale = (scale <= 0.0) ? defaultScale : scale; + // If restored scale and textWrapScale are 0, set them to + // overview and reading level scale respectively. + mRestoredScale = (scale <= 0.0) + ? mWebView.getZoomOverviewScale() : scale; if (mSettings.getUseWideViewPort()) { - mRestoredTextWrapScale = (textWrapScale <= 0.0) ? defaultScale : textWrapScale; + mRestoredTextWrapScale = (textWrapScale <= 0.0) + ? mWebView.getReadingLevelScale() : textWrapScale; } } } diff --git a/core/java/android/webkit/ZoomManager.java b/core/java/android/webkit/ZoomManager.java index 7ca6aeba87fe..7f526e7e7c1b 100644 --- a/core/java/android/webkit/ZoomManager.java +++ b/core/java/android/webkit/ZoomManager.java @@ -1128,12 +1128,6 @@ class ZoomManager { mTextWrapScale = Math.max(mTextWrapScale, overviewScale); } reflowText = exceedsMinScaleIncrement(mTextWrapScale, scale); - } else { - // In case of restored scale, treat defaultScale as overview since - // it usually means the previous scale is not saved. - if (scale == mDefaultScale && settings.getLoadWithOverviewMode()) { - scale = overviewScale; - } } mInitialZoomOverview = settings.getLoadWithOverviewMode() && !exceedsMinScaleIncrement(scale, overviewScale); diff --git a/media/java/android/media/Ringtone.java b/media/java/android/media/Ringtone.java index 0ce35269bf39..f2c1694b62f9 100644 --- a/media/java/android/media/Ringtone.java +++ b/media/java/android/media/Ringtone.java @@ -203,7 +203,22 @@ public class Ringtone { mUri = uri; openMediaPlayer(); } - + + /** @hide */ + public void setWakeMode(Context context, int mode) { + if (mAudio == null) { + try { + openMediaPlayer(); + } catch (Exception ex) { + Log.e(TAG, "setWakeMode() caught ", ex); + mAudio = null; + } + } + if (mAudio != null) { + mAudio.setWakeMode(context, mode); + } + } + /** * Plays the ringtone. */ diff --git a/media/libstagefright/AVIExtractor.cpp b/media/libstagefright/AVIExtractor.cpp index 4e464148b090..d47e5d132578 100644 --- a/media/libstagefright/AVIExtractor.cpp +++ b/media/libstagefright/AVIExtractor.cpp @@ -18,6 +18,7 @@ #define LOG_TAG "AVIExtractor" #include <utils/Log.h> +#include "include/avc_utils.h" #include "include/AVIExtractor.h" #include <binder/ProcessState.h> @@ -362,6 +363,13 @@ static const char *GetMIMETypeForHandler(uint32_t handler) { case FOURCC('X', 'V', 'I', 'X'): return MEDIA_MIMETYPE_VIDEO_MPEG4; + // from http://wiki.multimedia.cx/index.php?title=H264 + case FOURCC('a', 'v', 'c', '1'): + case FOURCC('d', 'a', 'v', 'c'): + case FOURCC('x', '2', '6', '4'): + case FOURCC('v', 's', 's', 'h'): + return MEDIA_MIMETYPE_VIDEO_AVC; + default: return NULL; } @@ -406,6 +414,14 @@ status_t AVIExtractor::parseStreamHeader(off64_t offset, size_t size) { return ERROR_MALFORMED; } + if (mime == NULL) { + LOGW("Unsupported video format '%c%c%c%c'", + (char)(handler >> 24), + (char)((handler >> 16) & 0xff), + (char)((handler >> 8) & 0xff), + (char)(handler & 0xff)); + } + kind = Track::VIDEO; } else if (type == FOURCC('a', 'u', 'd', 's')) { if (mime && strncasecmp(mime, "audio/", 6)) { @@ -473,8 +489,11 @@ status_t AVIExtractor::parseStreamFormat(off64_t offset, size_t size) { track->mMeta->setInt32(kKeyHeight, height); } else { uint32_t format = U16LE_AT(data); + if (format == 0x55) { track->mMeta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_MPEG); + } else { + LOGW("Unsupported audio format = 0x%04x", format); } uint32_t numChannels = U16LE_AT(&data[2]); @@ -646,21 +665,26 @@ status_t AVIExtractor::parseIndex(off64_t offset, size_t size) { AString mime = tmp; - if (!strncasecmp("video/", mime.c_str(), 6) - && track->mThumbnailSampleIndex >= 0) { - int64_t thumbnailTimeUs; - CHECK_EQ((status_t)OK, - getSampleTime(i, track->mThumbnailSampleIndex, - &thumbnailTimeUs)); + if (!strncasecmp("video/", mime.c_str(), 6)) { + if (track->mThumbnailSampleIndex >= 0) { + int64_t thumbnailTimeUs; + CHECK_EQ((status_t)OK, + getSampleTime(i, track->mThumbnailSampleIndex, + &thumbnailTimeUs)); - track->mMeta->setInt64(kKeyThumbnailTime, thumbnailTimeUs); + track->mMeta->setInt64(kKeyThumbnailTime, thumbnailTimeUs); + } + + status_t err = OK; if (!strcasecmp(mime.c_str(), MEDIA_MIMETYPE_VIDEO_MPEG4)) { - status_t err = addMPEG4CodecSpecificData(i); + err = addMPEG4CodecSpecificData(i); + } else if (!strcasecmp(mime.c_str(), MEDIA_MIMETYPE_VIDEO_AVC)) { + err = addH264CodecSpecificData(i); + } - if (err != OK) { - return err; - } + if (err != OK) { + return err; } } @@ -781,6 +805,63 @@ status_t AVIExtractor::addMPEG4CodecSpecificData(size_t trackIndex) { return OK; } +status_t AVIExtractor::addH264CodecSpecificData(size_t trackIndex) { + Track *track = &mTracks.editItemAt(trackIndex); + + off64_t offset; + size_t size; + bool isKey; + int64_t timeUs; + + // Extract codec specific data from the first non-empty sample. + + size_t sampleIndex = 0; + for (;;) { + status_t err = + getSampleInfo( + trackIndex, sampleIndex, &offset, &size, &isKey, &timeUs); + + if (err != OK) { + return err; + } + + if (size > 0) { + break; + } + + ++sampleIndex; + } + + sp<ABuffer> buffer = new ABuffer(size); + ssize_t n = mDataSource->readAt(offset, buffer->data(), buffer->size()); + + if (n < (ssize_t)size) { + return n < 0 ? (status_t)n : ERROR_MALFORMED; + } + + sp<MetaData> meta = MakeAVCCodecSpecificData(buffer); + + if (meta == NULL) { + LOGE("Unable to extract AVC codec specific data"); + return ERROR_MALFORMED; + } + + int32_t width, height; + CHECK(meta->findInt32(kKeyWidth, &width)); + CHECK(meta->findInt32(kKeyHeight, &height)); + + uint32_t type; + const void *csd; + size_t csdSize; + CHECK(meta->findData(kKeyAVCC, &type, &csd, &csdSize)); + + track->mMeta->setInt32(kKeyWidth, width); + track->mMeta->setInt32(kKeyHeight, width); + track->mMeta->setData(kKeyAVCC, type, csd, csdSize); + + return OK; +} + status_t AVIExtractor::getSampleInfo( size_t trackIndex, size_t sampleIndex, off64_t *offset, size_t *size, bool *isKey, diff --git a/media/libstagefright/avc_utils.cpp b/media/libstagefright/avc_utils.cpp index 07aa140929a2..153ee3352c78 100644 --- a/media/libstagefright/avc_utils.cpp +++ b/media/libstagefright/avc_utils.cpp @@ -297,7 +297,7 @@ sp<MetaData> MakeAVCCodecSpecificData(const sp<ABuffer> &accessUnit) { sp<MetaData> meta = new MetaData; meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_VIDEO_AVC); - meta->setData(kKeyAVCC, 0, csd->data(), csd->size()); + meta->setData(kKeyAVCC, kTypeAVCC, csd->data(), csd->size()); meta->setInt32(kKeyWidth, width); meta->setInt32(kKeyHeight, height); diff --git a/media/libstagefright/include/AVIExtractor.h b/media/libstagefright/include/AVIExtractor.h index b5753473804b..75ce68d92d37 100644 --- a/media/libstagefright/include/AVIExtractor.h +++ b/media/libstagefright/include/AVIExtractor.h @@ -101,6 +101,7 @@ private: size_t *sampleIndex) const; status_t addMPEG4CodecSpecificData(size_t trackIndex); + status_t addH264CodecSpecificData(size_t trackIndex); static bool IsCorrectChunkType( ssize_t trackIndex, Track::Kind kind, uint32_t chunkType); diff --git a/opengl/java/android/opengl/Matrix.java b/opengl/java/android/opengl/Matrix.java index 6d80bc60c94a..7c72ae470c52 100644 --- a/opengl/java/android/opengl/Matrix.java +++ b/opengl/java/android/opengl/Matrix.java @@ -39,6 +39,10 @@ package android.opengl; * */ public class Matrix { + + /** Temporary memory for operations that need temporary matrix data. */ + private final static float[] sTemp = new float[32]; + /** * Multiply two 4x4 matrices together and store the result in a third 4x4 * matrix. In matrix notation: result = lhs x rhs. Due to the way @@ -125,95 +129,120 @@ public class Matrix { int mOffset) { // Invert a 4 x 4 matrix using Cramer's Rule - // array of transpose source matrix - float[] src = new float[16]; - // transpose matrix - transposeM(src, 0, m, mOffset); - - // temp array for pairs - float[] tmp = new float[12]; + final float src0 = m[mOffset + 0]; + final float src4 = m[mOffset + 1]; + final float src8 = m[mOffset + 2]; + final float src12 = m[mOffset + 3]; + + final float src1 = m[mOffset + 4]; + final float src5 = m[mOffset + 5]; + final float src9 = m[mOffset + 6]; + final float src13 = m[mOffset + 7]; + + final float src2 = m[mOffset + 8]; + final float src6 = m[mOffset + 9]; + final float src10 = m[mOffset + 10]; + final float src14 = m[mOffset + 11]; + + final float src3 = m[mOffset + 12]; + final float src7 = m[mOffset + 13]; + final float src11 = m[mOffset + 14]; + final float src15 = m[mOffset + 15]; // calculate pairs for first 8 elements (cofactors) - tmp[0] = src[10] * src[15]; - tmp[1] = src[11] * src[14]; - tmp[2] = src[9] * src[15]; - tmp[3] = src[11] * src[13]; - tmp[4] = src[9] * src[14]; - tmp[5] = src[10] * src[13]; - tmp[6] = src[8] * src[15]; - tmp[7] = src[11] * src[12]; - tmp[8] = src[8] * src[14]; - tmp[9] = src[10] * src[12]; - tmp[10] = src[8] * src[13]; - tmp[11] = src[9] * src[12]; - - // Holds the destination matrix while we're building it up. - float[] dst = new float[16]; + final float atmp0 = src10 * src15; + final float atmp1 = src11 * src14; + final float atmp2 = src9 * src15; + final float atmp3 = src11 * src13; + final float atmp4 = src9 * src14; + final float atmp5 = src10 * src13; + final float atmp6 = src8 * src15; + final float atmp7 = src11 * src12; + final float atmp8 = src8 * src14; + final float atmp9 = src10 * src12; + final float atmp10 = src8 * src13; + final float atmp11 = src9 * src12; // calculate first 8 elements (cofactors) - dst[0] = tmp[0] * src[5] + tmp[3] * src[6] + tmp[4] * src[7]; - dst[0] -= tmp[1] * src[5] + tmp[2] * src[6] + tmp[5] * src[7]; - dst[1] = tmp[1] * src[4] + tmp[6] * src[6] + tmp[9] * src[7]; - dst[1] -= tmp[0] * src[4] + tmp[7] * src[6] + tmp[8] * src[7]; - dst[2] = tmp[2] * src[4] + tmp[7] * src[5] + tmp[10] * src[7]; - dst[2] -= tmp[3] * src[4] + tmp[6] * src[5] + tmp[11] * src[7]; - dst[3] = tmp[5] * src[4] + tmp[8] * src[5] + tmp[11] * src[6]; - dst[3] -= tmp[4] * src[4] + tmp[9] * src[5] + tmp[10] * src[6]; - dst[4] = tmp[1] * src[1] + tmp[2] * src[2] + tmp[5] * src[3]; - dst[4] -= tmp[0] * src[1] + tmp[3] * src[2] + tmp[4] * src[3]; - dst[5] = tmp[0] * src[0] + tmp[7] * src[2] + tmp[8] * src[3]; - dst[5] -= tmp[1] * src[0] + tmp[6] * src[2] + tmp[9] * src[3]; - dst[6] = tmp[3] * src[0] + tmp[6] * src[1] + tmp[11] * src[3]; - dst[6] -= tmp[2] * src[0] + tmp[7] * src[1] + tmp[10] * src[3]; - dst[7] = tmp[4] * src[0] + tmp[9] * src[1] + tmp[10] * src[2]; - dst[7] -= tmp[5] * src[0] + tmp[8] * src[1] + tmp[11] * src[2]; + final float dst0 = (atmp0 * src5 + atmp3 * src6 + atmp4 * src7) + - (atmp1 * src5 + atmp2 * src6 + atmp5 * src7); + final float dst1 = (atmp1 * src4 + atmp6 * src6 + atmp9 * src7) + - (atmp0 * src4 + atmp7 * src6 + atmp8 * src7); + final float dst2 = (atmp2 * src4 + atmp7 * src5 + atmp10 * src7) + - (atmp3 * src4 + atmp6 * src5 + atmp11 * src7); + final float dst3 = (atmp5 * src4 + atmp8 * src5 + atmp11 * src6) + - (atmp4 * src4 + atmp9 * src5 + atmp10 * src6); + final float dst4 = (atmp1 * src1 + atmp2 * src2 + atmp5 * src3) + - (atmp0 * src1 + atmp3 * src2 + atmp4 * src3); + final float dst5 = (atmp0 * src0 + atmp7 * src2 + atmp8 * src3) + - (atmp1 * src0 + atmp6 * src2 + atmp9 * src3); + final float dst6 = (atmp3 * src0 + atmp6 * src1 + atmp11 * src3) + - (atmp2 * src0 + atmp7 * src1 + atmp10 * src3); + final float dst7 = (atmp4 * src0 + atmp9 * src1 + atmp10 * src2) + - (atmp5 * src0 + atmp8 * src1 + atmp11 * src2); // calculate pairs for second 8 elements (cofactors) - tmp[0] = src[2] * src[7]; - tmp[1] = src[3] * src[6]; - tmp[2] = src[1] * src[7]; - tmp[3] = src[3] * src[5]; - tmp[4] = src[1] * src[6]; - tmp[5] = src[2] * src[5]; - tmp[6] = src[0] * src[7]; - tmp[7] = src[3] * src[4]; - tmp[8] = src[0] * src[6]; - tmp[9] = src[2] * src[4]; - tmp[10] = src[0] * src[5]; - tmp[11] = src[1] * src[4]; + final float btmp0 = src2 * src7; + final float btmp1 = src3 * src6; + final float btmp2 = src1 * src7; + final float btmp3 = src3 * src5; + final float btmp4 = src1 * src6; + final float btmp5 = src2 * src5; + final float btmp6 = src0 * src7; + final float btmp7 = src3 * src4; + final float btmp8 = src0 * src6; + final float btmp9 = src2 * src4; + final float btmp10 = src0 * src5; + final float btmp11 = src1 * src4; // calculate second 8 elements (cofactors) - dst[8] = tmp[0] * src[13] + tmp[3] * src[14] + tmp[4] * src[15]; - dst[8] -= tmp[1] * src[13] + tmp[2] * src[14] + tmp[5] * src[15]; - dst[9] = tmp[1] * src[12] + tmp[6] * src[14] + tmp[9] * src[15]; - dst[9] -= tmp[0] * src[12] + tmp[7] * src[14] + tmp[8] * src[15]; - dst[10] = tmp[2] * src[12] + tmp[7] * src[13] + tmp[10] * src[15]; - dst[10] -= tmp[3] * src[12] + tmp[6] * src[13] + tmp[11] * src[15]; - dst[11] = tmp[5] * src[12] + tmp[8] * src[13] + tmp[11] * src[14]; - dst[11] -= tmp[4] * src[12] + tmp[9] * src[13] + tmp[10] * src[14]; - dst[12] = tmp[2] * src[10] + tmp[5] * src[11] + tmp[1] * src[9]; - dst[12] -= tmp[4] * src[11] + tmp[0] * src[9] + tmp[3] * src[10]; - dst[13] = tmp[8] * src[11] + tmp[0] * src[8] + tmp[7] * src[10]; - dst[13] -= tmp[6] * src[10] + tmp[9] * src[11] + tmp[1] * src[8]; - dst[14] = tmp[6] * src[9] + tmp[11] * src[11] + tmp[3] * src[8]; - dst[14] -= tmp[10] * src[11] + tmp[2] * src[8] + tmp[7] * src[9]; - dst[15] = tmp[10] * src[10] + tmp[4] * src[8] + tmp[9] * src[9]; - dst[15] -= tmp[8] * src[9] + tmp[11] * src[10] + tmp[5] * src[8]; + final float dst8 = (btmp0 * src13 + btmp3 * src14 + btmp4 * src15) + - (btmp1 * src13 + btmp2 * src14 + btmp5 * src15); + final float dst9 = (btmp1 * src12 + btmp6 * src14 + btmp9 * src15) + - (btmp0 * src12 + btmp7 * src14 + btmp8 * src15); + final float dst10 = (btmp2 * src12 + btmp7 * src13 + btmp10 * src15) + - (btmp3 * src12 + btmp6 * src13 + btmp11 * src15); + final float dst11 = (btmp5 * src12 + btmp8 * src13 + btmp11 * src14) + - (btmp4 * src12 + btmp9 * src13 + btmp10 * src14); + final float dst12 = (btmp2 * src10 + btmp5 * src11 + btmp1 * src9 ) + - (btmp4 * src11 + btmp0 * src9 + btmp3 * src10); + final float dst13 = (btmp8 * src11 + btmp0 * src8 + btmp7 * src10) + - (btmp6 * src10 + btmp9 * src11 + btmp1 * src8 ); + final float dst14 = (btmp6 * src9 + btmp11 * src11 + btmp3 * src8 ) + - (btmp10 * src11 + btmp2 * src8 + btmp7 * src9 ); + final float dst15 = (btmp10 * src10 + btmp4 * src8 + btmp9 * src9 ) + - (btmp8 * src9 + btmp11 * src10 + btmp5 * src8 ); // calculate determinant - float det = - src[0] * dst[0] + src[1] * dst[1] + src[2] * dst[2] + src[3] - * dst[3]; + final float det = + src0 * dst0 + src1 * dst1 + src2 * dst2 + src3 * dst3; if (det == 0.0f) { - + return false; } // calculate matrix inverse - det = 1 / det; - for (int j = 0; j < 16; j++) - mInv[j + mInvOffset] = dst[j] * det; + final float invdet = 1.0f / det; + mInv[ mInvOffset] = dst0 * invdet; + mInv[ 1 + mInvOffset] = dst1 * invdet; + mInv[ 2 + mInvOffset] = dst2 * invdet; + mInv[ 3 + mInvOffset] = dst3 * invdet; + + mInv[ 4 + mInvOffset] = dst4 * invdet; + mInv[ 5 + mInvOffset] = dst5 * invdet; + mInv[ 6 + mInvOffset] = dst6 * invdet; + mInv[ 7 + mInvOffset] = dst7 * invdet; + + mInv[ 8 + mInvOffset] = dst8 * invdet; + mInv[ 9 + mInvOffset] = dst9 * invdet; + mInv[10 + mInvOffset] = dst10 * invdet; + mInv[11 + mInvOffset] = dst11 * invdet; + + mInv[12 + mInvOffset] = dst12 * invdet; + mInv[13 + mInvOffset] = dst13 * invdet; + mInv[14 + mInvOffset] = dst14 * invdet; + mInv[15 + mInvOffset] = dst15 * invdet; return true; } @@ -488,9 +517,10 @@ public class Matrix { public static void rotateM(float[] rm, int rmOffset, float[] m, int mOffset, float a, float x, float y, float z) { - float[] r = new float[16]; - setRotateM(r, 0, a, x, y, z); - multiplyMM(rm, rmOffset, m, mOffset, r, 0); + synchronized(sTemp) { + setRotateM(sTemp, 0, a, x, y, z); + multiplyMM(rm, rmOffset, m, mOffset, sTemp, 0); + } } /** @@ -505,10 +535,11 @@ public class Matrix { */ public static void rotateM(float[] m, int mOffset, float a, float x, float y, float z) { - float[] temp = new float[32]; - setRotateM(temp, 0, a, x, y, z); - multiplyMM(temp, 16, m, mOffset, temp, 0); - System.arraycopy(temp, 16, m, mOffset, 16); + synchronized(sTemp) { + setRotateM(sTemp, 0, a, x, y, z); + multiplyMM(sTemp, 16, m, mOffset, sTemp, 0); + System.arraycopy(sTemp, 16, m, mOffset, 16); + } } /** diff --git a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java index 5d3dee9d1b0c..0f1d6337fde6 100644 --- a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java +++ b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java @@ -1054,6 +1054,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback, final Ringtone sfx = RingtoneManager.getRingtone(mContext, soundUri); if (sfx != null) { sfx.setStreamType(AudioManager.STREAM_SYSTEM); + sfx.setWakeMode(mContext, PowerManager.PARTIAL_WAKE_LOCK); sfx.play(); } else { if (DEBUG) Log.d(TAG, "playSounds: failed to load ringtone from uri: " diff --git a/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java index 465fc2cb8814..d9bd5f2bd3de 100644 --- a/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java +++ b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java @@ -540,7 +540,8 @@ public class LockPatternKeyguardView extends KeyguardViewBase implements Handler mShowLockBeforeUnlock = resources.getBoolean(R.bool.config_enableLockBeforeUnlockScreen); mConfiguration = newConfig; if (DEBUG_CONFIGURATION) Log.v(TAG, "**** re-creating lock screen since config changed"); - updateScreen(mMode, true /* force */); + removeCallbacks(mRecreateRunnable); + post(mRecreateRunnable); } @Override diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java index 1b7271db843b..9a3031dc1d89 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java @@ -2135,6 +2135,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { com.android.internal.R.attr.actionModePopupWindowStyle); mActionModePopup.setLayoutInScreenEnabled(true); mActionModePopup.setLayoutInsetDecor(true); + mActionModePopup.setFocusable(true); mActionModePopup.setWindowLayoutType( WindowManager.LayoutParams.TYPE_APPLICATION); mActionModePopup.setContentView(mActionModeView); diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java index 8b58d42bdd89..2b1638b83b02 100644 --- a/services/java/com/android/server/ConnectivityService.java +++ b/services/java/com/android/server/ConnectivityService.java @@ -97,7 +97,7 @@ import java.util.List; public class ConnectivityService extends IConnectivityManager.Stub { private static final boolean DBG = true; - private static final boolean VDBG = true; + private static final boolean VDBG = false; private static final String TAG = "ConnectivityService"; private static final boolean LOGD_RULES = false; @@ -867,7 +867,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { // javadoc from interface public int startUsingNetworkFeature(int networkType, String feature, IBinder binder) { - if (DBG) { + if (VDBG) { log("startUsingNetworkFeature for net " + networkType + ": " + feature); } enforceChangePermission(); @@ -933,17 +933,19 @@ public class ConnectivityService extends IConnectivityManager.Stub { if (ni.isConnected() == true) { // add the pid-specific dns handleDnsConfigurationChange(usedNetworkType); - if (DBG) log("special network already active"); + if (VDBG) log("special network already active"); return Phone.APN_ALREADY_ACTIVE; } - if (DBG) log("special network already connecting"); + if (VDBG) log("special network already connecting"); return Phone.APN_REQUEST_STARTED; } // check if the radio in play can make another contact // assume if cannot for now - if (DBG) log("reconnecting to special network"); + if (DBG) { + log("startUsingNetworkFeature reconnecting to " + networkType + ": " + feature); + } network.reconnect(); return Phone.APN_REQUEST_STARTED; } else { @@ -985,7 +987,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { return stopUsingNetworkFeature(u, true); } else { // none found! - if (VDBG) log("ignoring stopUsingNetworkFeature - not a live request"); + if (VDBG) log("stopUsingNetworkFeature - not a live request, ignoring"); return 1; } } @@ -999,12 +1001,15 @@ public class ConnectivityService extends IConnectivityManager.Stub { NetworkStateTracker tracker = null; boolean callTeardown = false; // used to carry our decision outside of sync block - if (DBG) { - log("stopUsingNetworkFeature for net " + networkType + - ": " + feature); + if (VDBG) { + log("stopUsingNetworkFeature: net " + networkType + ": " + feature); } if (!ConnectivityManager.isNetworkTypeValid(networkType)) { + if (DBG) { + log("stopUsingNetworkFeature: net " + networkType + ": " + feature + + ", net is invalid"); + } return -1; } @@ -1013,7 +1018,10 @@ public class ConnectivityService extends IConnectivityManager.Stub { synchronized(this) { // check if this process still has an outstanding start request if (!mFeatureUsers.contains(u)) { - if (DBG) log("ignoring - this process has no outstanding requests"); + if (VDBG) { + log("stopUsingNetworkFeature: this process has no outstanding requests" + + ", ignoring"); + } return 1; } u.unlinkDeathRecipient(); @@ -1028,7 +1036,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { if (ignoreDups == false) { for (FeatureUser x : mFeatureUsers) { if (x.isSameUser(u)) { - if (DBG) log("ignoring stopUsingNetworkFeature as dup is found"); + if (VDBG) log("stopUsingNetworkFeature: dup is found, ignoring"); return 1; } } @@ -1039,7 +1047,10 @@ public class ConnectivityService extends IConnectivityManager.Stub { tracker = mNetTrackers[usedNetworkType]; if (tracker == null) { - if (DBG) log("ignoring - no known tracker for net type " + usedNetworkType); + if (DBG) { + log("stopUsingNetworkFeature: net " + networkType + ": " + feature + + " no known tracker for used net type " + usedNetworkType); + } return -1; } if (usedNetworkType != networkType) { @@ -1047,17 +1058,25 @@ public class ConnectivityService extends IConnectivityManager.Stub { mNetRequestersPids[usedNetworkType].remove(currentPid); reassessPidDns(pid, true); if (mNetRequestersPids[usedNetworkType].size() != 0) { - if (DBG) log("not tearing down special network - " + - "others still using it"); + if (VDBG) { + log("stopUsingNetworkFeature: net " + networkType + ": " + feature + + " others still using it"); + } return 1; } callTeardown = true; } else { - if (DBG) log("not a known feature - dropping"); + if (DBG) { + log("stopUsingNetworkFeature: net " + networkType + ": " + feature + + " not a known feature - dropping"); + } } } - if (DBG) log("Doing network teardown"); + if (callTeardown) { + if (DBG) { + log("stopUsingNetworkFeature: teardown net " + networkType + ": " + feature); + } tracker.teardown(); return 1; } else { @@ -1592,7 +1611,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { mInitialBroadcast = new Intent(intent); } intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); - if (DBG) { + if (VDBG) { log("sendStickyBroadcast: action=" + intent.getAction()); } @@ -1604,7 +1623,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { if (delayMs <= 0) { sendStickyBroadcast(intent); } else { - if (DBG) { + if (VDBG) { log("sendStickyBroadcastDelayed: delayMs=" + delayMs + ", action=" + intent.getAction()); } @@ -1779,12 +1798,12 @@ public class ConnectivityService extends IConnectivityManager.Stub { } } if (resetDns) { - if (DBG) log("resetting DNS cache for " + iface); + if (VDBG) log("resetting DNS cache for " + iface); try { mNetd.flushInterfaceDnsCache(iface); } catch (Exception e) { // never crash - catch them all - loge("Exception resetting dns cache: " + e); + if (DBG) loge("Exception resetting dns cache: " + e); } } } @@ -1840,12 +1859,12 @@ public class ConnectivityService extends IConnectivityManager.Stub { // remove the default route unless somebody else has asked for it String ifaceName = newLp.getInterfaceName(); if (TextUtils.isEmpty(ifaceName) == false && mAddedRoutes.contains(r) == false) { - if (DBG) log("Removing " + r + " for interface " + ifaceName); + if (VDBG) log("Removing " + r + " for interface " + ifaceName); try { mNetd.removeRoute(ifaceName, r); } catch (Exception e) { // never crash - catch them all - loge("Exception trying to remove a route: " + e); + if (VDBG) loge("Exception trying to remove a route: " + e); } } } @@ -2059,7 +2078,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { mNetd.setDnsServersForInterface(iface, NetworkUtils.makeStrings(dnses)); mNetd.setDefaultInterfaceForDns(iface); } catch (Exception e) { - loge("exception setting default dns interface: " + e); + if (VDBG) loge("exception setting default dns interface: " + e); } } if (!domains.equals(SystemProperties.get("net.dns.search"))) { @@ -2089,7 +2108,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { mNetd.setDnsServersForInterface(p.getInterfaceName(), NetworkUtils.makeStrings(dnses)); } catch (Exception e) { - loge("exception setting dns servers: " + e); + if (VDBG) loge("exception setting dns servers: " + e); } // set per-pid dns for attached secondary nets List pids = mNetRequestersPids[netType]; @@ -2194,9 +2213,12 @@ public class ConnectivityService extends IConnectivityManager.Stub { int type = info.getType(); NetworkInfo.State state = info.getState(); - if (DBG) log("ConnectivityChange for " + + if (VDBG || (state == NetworkInfo.State.CONNECTED) || + (state == NetworkInfo.State.DISCONNECTED)) { + log("ConnectivityChange for " + info.getTypeName() + ": " + state + "/" + info.getDetailedState()); + } // Connectivity state changed: // [31-13] Reserved for future use @@ -2458,23 +2480,24 @@ public class ConnectivityService extends IConnectivityManager.Stub { } private void handleInetConditionChange(int netType, int condition) { - if (DBG) { - log("Inet connectivity change, net=" + - netType + ", condition=" + condition + - ",mActiveDefaultNetwork=" + mActiveDefaultNetwork); - } if (mActiveDefaultNetwork == -1) { - if (DBG) log("no active default network - aborting"); + if (DBG) log("handleInetConditionChange: no active default network - ignore"); return; } if (mActiveDefaultNetwork != netType) { - if (DBG) log("given net not default - aborting"); + if (DBG) log("handleInetConditionChange: net=" + netType + + " != default=" + mActiveDefaultNetwork + " - ignore"); return; } + if (VDBG) { + log("handleInetConditionChange: net=" + + netType + ", condition=" + condition + + ",mActiveDefaultNetwork=" + mActiveDefaultNetwork); + } mDefaultInetCondition = condition; int delay; if (mInetConditionChangeInFlight == false) { - if (VDBG) log("starting a change hold"); + if (VDBG) log("handleInetConditionChange: starting a change hold"); // setup a new hold to debounce this if (mDefaultInetCondition > 50) { delay = Settings.Secure.getInt(mContext.getContentResolver(), @@ -2487,26 +2510,25 @@ public class ConnectivityService extends IConnectivityManager.Stub { mHandler.sendMessageDelayed(mHandler.obtainMessage(EVENT_INET_CONDITION_HOLD_END, mActiveDefaultNetwork, mDefaultConnectionSequence), delay); } else { - // we've set the new condition, when this hold ends that will get - // picked up - if (VDBG) log("currently in hold - not setting new end evt"); + // we've set the new condition, when this hold ends that will get picked up + if (VDBG) log("handleInetConditionChange: currently in hold - not setting new end evt"); } } private void handleInetConditionHoldEnd(int netType, int sequence) { - if (VDBG) { - log("Inet hold end, net=" + netType + - ", condition =" + mDefaultInetCondition + - ", published condition =" + mDefaultInetConditionPublished); + if (DBG) { + log("handleInetConditionHoldEnd: net=" + netType + + ", condition=" + mDefaultInetCondition + + ", published condition=" + mDefaultInetConditionPublished); } mInetConditionChangeInFlight = false; if (mActiveDefaultNetwork == -1) { - if (DBG) log("no active default network - aborting"); + if (DBG) log("handleInetConditionHoldEnd: no active default network - ignoring"); return; } if (mDefaultConnectionSequence != sequence) { - if (DBG) log("event hold for obsolete network - aborting"); + if (DBG) log("handleInetConditionHoldEnd: event hold for obsolete network - ignoring"); return; } // TODO: Figure out why this optimization sometimes causes a @@ -2518,7 +2540,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { //} NetworkInfo networkInfo = mNetTrackers[mActiveDefaultNetwork].getNetworkInfo(); if (networkInfo.isConnected() == false) { - if (DBG) log("default network not connected - aborting"); + if (DBG) log("handleInetConditionHoldEnd: default network not connected - ignoring"); return; } mDefaultInetConditionPublished = mDefaultInetCondition; diff --git a/services/java/com/android/server/NetworkManagementService.java b/services/java/com/android/server/NetworkManagementService.java index 0cffb15b3758..6fcf3994f5fb 100644 --- a/services/java/com/android/server/NetworkManagementService.java +++ b/services/java/com/android/server/NetworkManagementService.java @@ -560,8 +560,10 @@ public class NetworkManagementService extends INetworkManagementService.Stub + e); } - for (String line : rsp) { - Log.v(TAG, "add route response is " + line); + if (DBG) { + for (String line : rsp) { + Log.v(TAG, "add route response is " + line); + } } } diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java index 0934cd02f8bd..785db9829992 100644 --- a/services/java/com/android/server/PowerManagerService.java +++ b/services/java/com/android/server/PowerManagerService.java @@ -79,6 +79,8 @@ public class PowerManagerService extends IPowerManager.Stub private static final String TAG = "PowerManagerService"; static final String PARTIAL_NAME = "PowerManagerService"; + static final boolean DEBUG_SCREEN_ON = false; + private static final boolean LOG_PARTIAL_WL = false; // Indicates whether touch-down cycles should be logged as part of the @@ -162,6 +164,8 @@ public class PowerManagerService extends IPowerManager.Stub private final int[] mBroadcastQueue = new int[] { -1, -1, -1 }; private final int[] mBroadcastWhy = new int[3]; private boolean mPreparingForScreenOn = false; + private boolean mSkippedScreenOn = false; + private boolean mInitialized = false; private int mPartialCount = 0; private int mPowerState; // mScreenOffReason can be WindowManagerPolicy.OFF_BECAUSE_OF_USER, @@ -557,6 +561,9 @@ public class PowerManagerService extends IPowerManager.Stub nativeInit(); synchronized (mLocks) { updateNativePowerStateLocked(); + // We make sure to start out with the screen on due to user activity. + // (They did just boot their device, after all.) + forceUserActivityLocked(); } } @@ -1123,7 +1130,8 @@ public class PowerManagerService extends IPowerManager.Stub + " " + ((mNextTimeout-now)/1000) + "s from now"); pw.println(" mDimScreen=" + mDimScreen + " mStayOnConditions=" + mStayOnConditions - + " mPreparingForScreenOn=" + mPreparingForScreenOn); + + " mPreparingForScreenOn=" + mPreparingForScreenOn + + " mSkippedScreenOn=" + mSkippedScreenOn); pw.println(" mScreenOffReason=" + mScreenOffReason + " mUserState=" + mUserState); pw.println(" mBroadcastQueue={" + mBroadcastQueue[0] + ',' + mBroadcastQueue[1] @@ -1312,8 +1320,16 @@ public class PowerManagerService extends IPowerManager.Stub } } - private void sendNotificationLocked(boolean on, int why) - { + private void sendNotificationLocked(boolean on, int why) { + if (!mInitialized) { + // No notifications sent until first initialization is done. + // This is so that when we are moving from our initial state + // which looks like the screen was off to it being on, we do not + // go through the process of waiting for the higher-level user + // space to be ready before turning up the display brightness. + // (And also do not send needless broadcasts about the screen.) + return; + } if (!on) { mStillNeedSleepNotification = false; } @@ -1360,7 +1376,9 @@ public class PowerManagerService extends IPowerManager.Stub // The broadcast queue has changed; make sure the screen is on if it // is now possible for it to be. - updateNativePowerStateLocked(); + if (mSkippedScreenOn) { + updateLightsLocked(mPowerState, SCREEN_ON_BIT); + } // Now send the message. if (index >= 0) { @@ -1380,7 +1398,7 @@ public class PowerManagerService extends IPowerManager.Stub synchronized (mLocks) { if (mPreparingForScreenOn) { mPreparingForScreenOn = false; - updateNativePowerStateLocked(); + updateLightsLocked(mPowerState, SCREEN_ON_BIT); EventLog.writeEvent(EventLogTags.POWER_SCREEN_BROADCAST_STOP, 4, mBroadcastWakeLock.mCount); mBroadcastWakeLock.release(); @@ -1453,7 +1471,7 @@ public class PowerManagerService extends IPowerManager.Stub synchronized (mLocks) { EventLog.writeEvent(EventLogTags.POWER_SCREEN_BROADCAST_STOP, 3, mBroadcastWakeLock.mCount); - updateNativePowerStateLocked(); + updateLightsLocked(mPowerState, SCREEN_ON_BIT); mBroadcastWakeLock.release(); } } @@ -1646,6 +1664,11 @@ public class PowerManagerService extends IPowerManager.Stub }; private int setScreenStateLocked(boolean on) { + if (DEBUG_SCREEN_ON) { + RuntimeException e = new RuntimeException("here"); + e.fillInStackTrace(); + Slog.i(TAG, "Set screen state: " + on, e); + } int err = Power.setScreenState(on); if (err == 0) { mLastScreenOnTime = (on ? SystemClock.elapsedRealtime() : 0); @@ -1696,7 +1719,7 @@ public class PowerManagerService extends IPowerManager.Stub } else { newState &= ~BATTERY_LOW_BIT; } - if (newState == mPowerState) { + if (newState == mPowerState && mInitialized) { return; } @@ -1722,10 +1745,7 @@ public class PowerManagerService extends IPowerManager.Stub + " newBatteryLow=" + ((newState & BATTERY_LOW_BIT) != 0)); } - if (mPowerState != newState) { - updateLightsLocked(newState, 0); - mPowerState = (mPowerState & ~LIGHTS_MASK) | (newState & LIGHTS_MASK); - } + final boolean stateChanged = mPowerState != newState; if (oldScreenOn != newScreenOn) { if (newScreenOn) { @@ -1777,10 +1797,24 @@ public class PowerManagerService extends IPowerManager.Stub EventLog.writeEvent(EventLogTags.POWER_SCREEN_STATE, 1, reason, mTotalTouchDownTime, mTouchCycles); if (err == 0) { - mPowerState |= SCREEN_ON_BIT; sendNotificationLocked(true, -1); + // Update the lights *after* taking care of turning the + // screen on, so we do this after our notifications are + // enqueued and thus will delay turning on the screen light + // until the windows are correctly displayed. + if (stateChanged) { + updateLightsLocked(newState, 0); + } + mPowerState |= SCREEN_ON_BIT; } + } else { + // Update the lights *before* taking care of turning the + // screen off, so we can initiate any animations that are desired. + if (stateChanged) { + updateLightsLocked(newState, 0); + } + // cancel light sensor task mHandler.removeCallbacks(mAutoBrightnessTask); mLightSensorPendingDecrease = false; @@ -1803,30 +1837,20 @@ public class PowerManagerService extends IPowerManager.Stub mLastTouchDown = 0; } } + } else if (stateChanged) { + // Screen on/off didn't change, but lights may have. + updateLightsLocked(newState, 0); } - + + mPowerState = (mPowerState & ~LIGHTS_MASK) | (newState & LIGHTS_MASK); + updateNativePowerStateLocked(); + + mInitialized = true; } } - + private void updateNativePowerStateLocked() { - if ((mPowerState & SCREEN_ON_BIT) != 0) { - // Don't turn screen on until we know we are really ready to. - // This is to avoid letting the screen go on before things like the - // lock screen have been displayed. - if (mPreparingForScreenOn) { - // Currently waiting for confirmation from the policy that it - // is okay to turn on the screen. Don't allow the screen to go - // on until that is done. - return; - } - for (int i=0; i<mBroadcastQueue.length; i++) { - if (mBroadcastQueue[i] == 1) { - // A screen on is currently enqueued. - return; - } - } - } nativeSetPowerState( (mPowerState & SCREEN_ON_BIT) != 0, (mPowerState & SCREEN_BRIGHT) == SCREEN_BRIGHT); @@ -1852,8 +1876,43 @@ public class PowerManagerService extends IPowerManager.Stub mBatteryService.getBatteryLevel() <= Power.LOW_BATTERY_THRESHOLD); } + private boolean shouldDeferScreenOnLocked() { + if (mPreparingForScreenOn) { + // Currently waiting for confirmation from the policy that it + // is okay to turn on the screen. Don't allow the screen to go + // on until that is done. + if (DEBUG_SCREEN_ON) Slog.i(TAG, + "updateLights: delaying screen on due to mPreparingForScreenOn"); + return true; + } else { + // If there is a screen-on command in the notification queue, we + // can't turn the screen on until it has been processed (and we + // have set mPreparingForScreenOn) or it has been dropped. + for (int i=0; i<mBroadcastQueue.length; i++) { + if (mBroadcastQueue[i] == 1) { + if (DEBUG_SCREEN_ON) Slog.i(TAG, + "updateLights: delaying screen on due to notification queue"); + return true; + } + } + } + return false; + } + private void updateLightsLocked(int newState, int forceState) { final int oldState = mPowerState; + + // If the screen is not currently on, we will want to delay actually + // turning the lights on if we are still getting the UI put up. + if ((oldState&SCREEN_ON_BIT) == 0 || mSkippedScreenOn) { + // Don't turn screen on until we know we are really ready to. + // This is to avoid letting the screen go on before things like the + // lock screen have been displayed. + if ((mSkippedScreenOn=shouldDeferScreenOnLocked())) { + newState &= ~(SCREEN_ON_BIT|SCREEN_BRIGHT_BIT); + } + } + if ((newState & SCREEN_ON_BIT) != 0) { // Only turn on the buttons or keyboard if the screen is also on. // We should never see the buttons on but not the screen. @@ -1960,6 +2019,13 @@ public class PowerManagerService extends IPowerManager.Stub } mScreenBrightness.setTargetLocked(brightness, steps, INITIAL_SCREEN_BRIGHTNESS, nominalCurrentValue); + if (DEBUG_SCREEN_ON) { + RuntimeException e = new RuntimeException("here"); + e.fillInStackTrace(); + Slog.i(TAG, "Setting screen brightness: " + brightness, e); + mScreenBrightness.setTargetLocked(brightness, steps, + INITIAL_SCREEN_BRIGHTNESS, nominalCurrentValue); + } } if (mSpew) { diff --git a/services/java/com/android/server/TelephonyRegistry.java b/services/java/com/android/server/TelephonyRegistry.java index bc256ed28162..8c8e72500689 100644 --- a/services/java/com/android/server/TelephonyRegistry.java +++ b/services/java/com/android/server/TelephonyRegistry.java @@ -53,6 +53,7 @@ import com.android.server.am.BatteryStatsService; */ class TelephonyRegistry extends ITelephonyRegistry.Stub { private static final String TAG = "TelephonyRegistry"; + private static final boolean DBG = false; private static class Record { String pkgForDebug; @@ -387,9 +388,11 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { if (!checkNotifyPermission("notifyDataConnection()" )) { return; } - Slog.i(TAG, "notifyDataConnection: state=" + state + " isDataConnectivityPossible=" + if (DBG) { + Slog.i(TAG, "notifyDataConnection: state=" + state + " isDataConnectivityPossible=" + isDataConnectivityPossible + " reason='" + reason + "' apn='" + apn + "' apnType=" + apnType + " networkType=" + networkType); + } synchronized (mRecords) { boolean modified = false; if (state == TelephonyManager.DATA_CONNECTED) { @@ -421,8 +424,10 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { modified = true; } if (modified) { - Slog.d(TAG, "onDataConnectionStateChanged(" + mDataConnectionState + if (DBG) { + Slog.d(TAG, "onDataConnectionStateChanged(" + mDataConnectionState + ", " + mDataConnectionNetworkType + ")"); + } for (Record r : mRecords) { if ((r.events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) { try { @@ -639,7 +644,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { } String msg = "Modify Phone State Permission Denial: " + method + " from pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid(); - Slog.w(TAG, msg); + if (DBG) Slog.w(TAG, msg); return false; } diff --git a/services/java/com/android/server/connectivity/Tethering.java b/services/java/com/android/server/connectivity/Tethering.java index 52868242750f..10f6d2ccdc5f 100644 --- a/services/java/com/android/server/connectivity/Tethering.java +++ b/services/java/com/android/server/connectivity/Tethering.java @@ -71,7 +71,8 @@ public class Tethering extends INetworkManagementEventObserver.Stub { private Context mContext; private final static String TAG = "Tethering"; - private final static boolean DEBUG = true; + private final static boolean DBG = true; + private final static boolean VDBG = false; // TODO - remove both of these - should be part of interface inspection/selection stuff private String[] mTetherableUsbRegexs; @@ -178,7 +179,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub { } public void interfaceStatusChanged(String iface, boolean up) { - if (DEBUG) Log.d(TAG, "interfaceStatusChanged " + iface + ", " + up); + if (VDBG) Log.d(TAG, "interfaceStatusChanged " + iface + ", " + up); boolean found = false; boolean usb = false; if (isWifi(iface)) { @@ -203,7 +204,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub { if (isUsb(iface)) { // ignore usb0 down after enabling RNDIS // we will handle disconnect in interfaceRemoved instead - Log.d(TAG, "ignoring interface down for " + iface); + if (VDBG) Log.d(TAG, "ignoring interface down for " + iface); } else if (sm != null) { sm.sendMessage(TetherInterfaceSM.CMD_INTERFACE_DOWN); mIfaces.remove(iface); @@ -213,7 +214,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub { } public void interfaceLinkStateChanged(String iface, boolean up) { - if (DEBUG) Log.d(TAG, "interfaceLinkStateChanged " + iface + ", " + up); + if (VDBG) Log.d(TAG, "interfaceLinkStateChanged " + iface + ", " + up); interfaceStatusChanged(iface, up); } @@ -239,7 +240,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub { } public void interfaceAdded(String iface) { - if (DEBUG) Log.d(TAG, "interfaceAdded " + iface); + if (VDBG) Log.d(TAG, "interfaceAdded " + iface); boolean found = false; boolean usb = false; if (isWifi(iface)) { @@ -253,29 +254,29 @@ public class Tethering extends INetworkManagementEventObserver.Stub { found = true; } if (found == false) { - if (DEBUG) Log.d(TAG, iface + " is not a tetherable iface, ignoring"); + if (VDBG) Log.d(TAG, iface + " is not a tetherable iface, ignoring"); return; } synchronized (mIfaces) { TetherInterfaceSM sm = mIfaces.get(iface); if (sm != null) { - if (DEBUG) Log.d(TAG, "active iface (" + iface + ") reported as added, ignoring"); + if (VDBG) Log.d(TAG, "active iface (" + iface + ") reported as added, ignoring"); return; } sm = new TetherInterfaceSM(iface, mLooper, usb); mIfaces.put(iface, sm); sm.start(); } - if (DEBUG) Log.d(TAG, "interfaceAdded :" + iface); + if (VDBG) Log.d(TAG, "interfaceAdded :" + iface); } public void interfaceRemoved(String iface) { - if (DEBUG) Log.d(TAG, "interfaceRemoved " + iface); + if (VDBG) Log.d(TAG, "interfaceRemoved " + iface); synchronized (mIfaces) { TetherInterfaceSM sm = mIfaces.get(iface); if (sm == null) { - if (DEBUG) { + if (VDBG) { Log.e(TAG, "attempting to remove unknown iface (" + iface + "), ignoring"); } return; @@ -288,7 +289,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub { public void limitReached(String limitName, String iface) {} public int tether(String iface) { - Log.d(TAG, "Tethering " + iface); + if (DBG) Log.d(TAG, "Tethering " + iface); TetherInterfaceSM sm = null; synchronized (mIfaces) { sm = mIfaces.get(iface); @@ -306,7 +307,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub { } public int untether(String iface) { - Log.d(TAG, "Untethering " + iface); + if (DBG) Log.d(TAG, "Untethering " + iface); TetherInterfaceSM sm = null; synchronized (mIfaces) { sm = mIfaces.get(iface); @@ -383,7 +384,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub { broadcast.putStringArrayListExtra(ConnectivityManager.EXTRA_ERRORED_TETHER, erroredList); mContext.sendStickyBroadcast(broadcast); - if (DEBUG) { + if (VDBG) { Log.d(TAG, "sendTetherStateChangedBroadcast " + availableList.size() + ", " + activeList.size() + ", " + erroredList.size()); } @@ -468,14 +469,14 @@ public class Tethering extends INetworkManagementEventObserver.Stub { mUsbTetherRequested = false; } } else if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) { - if (DEBUG) Log.d(TAG, "Tethering got CONNECTIVITY_ACTION"); + if (VDBG) Log.d(TAG, "Tethering got CONNECTIVITY_ACTION"); mTetherMasterSM.sendMessage(TetherMasterSM.CMD_UPSTREAM_CHANGED); } } } private void tetherUsb(boolean enable) { - if (DEBUG) Log.d(TAG, "tetherUsb " + enable); + if (VDBG) Log.d(TAG, "tetherUsb " + enable); String[] ifaces = new String[0]; try { @@ -497,7 +498,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub { // configured when we start tethering and unconfig'd on error or conclusion private boolean configureUsbIface(boolean enabled) { - if (DEBUG) Log.d(TAG, "configureUsbIface(" + enabled + ")"); + if (VDBG) Log.d(TAG, "configureUsbIface(" + enabled + ")"); // toggle the USB interfaces String[] ifaces = new String[0]; @@ -547,7 +548,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub { } public int setUsbTethering(boolean enable) { - if (DEBUG) Log.d(TAG, "setUsbTethering(" + enable + ")"); + if (VDBG) Log.d(TAG, "setUsbTethering(" + enable + ")"); UsbManager usbManager = (UsbManager)mContext.getSystemService(Context.USB_SERVICE); synchronized (this) { @@ -808,7 +809,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub { @Override public boolean processMessage(Message message) { - if (DEBUG) Log.d(TAG, "InitialState.processMessage what=" + message.what); + if (VDBG) Log.d(TAG, "InitialState.processMessage what=" + message.what); boolean retValue = true; switch (message.what) { case CMD_TETHER_REQUESTED: @@ -849,7 +850,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub { } @Override public boolean processMessage(Message message) { - if (DEBUG) Log.d(TAG, "StartingState.processMessage what=" + message.what); + if (VDBG) Log.d(TAG, "StartingState.processMessage what=" + message.what); boolean retValue = true; switch (message.what) { // maybe a parent class? @@ -897,14 +898,14 @@ public class Tethering extends INetworkManagementEventObserver.Stub { transitionTo(mInitialState); return; } - if (DEBUG) Log.d(TAG, "Tethered " + mIfaceName); + if (DBG) Log.d(TAG, "Tethered " + mIfaceName); setAvailable(false); setTethered(true); sendTetherStateChangedBroadcast(); } @Override public boolean processMessage(Message message) { - if (DEBUG) Log.d(TAG, "TetheredState.processMessage what=" + message.what); + if (VDBG) Log.d(TAG, "TetheredState.processMessage what=" + message.what); boolean retValue = true; boolean error = false; switch (message.what) { @@ -944,14 +945,14 @@ public class Tethering extends INetworkManagementEventObserver.Stub { } else if (message.what == CMD_INTERFACE_DOWN) { transitionTo(mUnavailableState); } - if (DEBUG) Log.d(TAG, "Untethered " + mIfaceName); + if (DBG) Log.d(TAG, "Untethered " + mIfaceName); break; case CMD_TETHER_CONNECTION_CHANGED: String newUpstreamIfaceName = (String)(message.obj); if ((mMyUpstreamIfaceName == null && newUpstreamIfaceName == null) || (mMyUpstreamIfaceName != null && mMyUpstreamIfaceName.equals(newUpstreamIfaceName))) { - if (DEBUG) Log.d(TAG, "Connection changed noop - dropping"); + if (VDBG) Log.d(TAG, "Connection changed noop - dropping"); break; } if (mMyUpstreamIfaceName != null) { @@ -1018,7 +1019,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub { ConnectivityManager.TETHER_ERROR_MASTER_ERROR); break; } - if (DEBUG) Log.d(TAG, "Tether lost upstream connection " + mIfaceName); + if (VDBG) Log.d(TAG, "Tether lost upstream connection " + mIfaceName); sendTetherStateChangedBroadcast(); if (mUsb) { if (!Tethering.this.configureUsbIface(false)) { @@ -1248,7 +1249,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub { } } - if (DEBUG) { + if (VDBG) { Log.d(TAG, "chooseUpstreamType(" + tryCell + "), preferredApn =" + mPreferredUpstreamMobileApn + ", got type=" + upType); } @@ -1280,7 +1281,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub { } protected void notifyTetheredOfNewUpstreamIface(String ifaceName) { - if (DEBUG) Log.d(TAG, "notifying tethered with iface =" + ifaceName); + if (VDBG) Log.d(TAG, "notifying tethered with iface =" + ifaceName); mUpstreamIfaceName = ifaceName; for (Object o : mNotifyList) { TetherInterfaceSM sm = (TetherInterfaceSM)o; @@ -1296,19 +1297,19 @@ public class Tethering extends INetworkManagementEventObserver.Stub { } @Override public boolean processMessage(Message message) { - if (DEBUG) Log.d(TAG, "MasterInitialState.processMessage what=" + message.what); + if (VDBG) Log.d(TAG, "MasterInitialState.processMessage what=" + message.what); boolean retValue = true; switch (message.what) { case CMD_TETHER_MODE_REQUESTED: checkDunRequired(); TetherInterfaceSM who = (TetherInterfaceSM)message.obj; - if (DEBUG) Log.d(TAG, "Tether Mode requested by " + who.toString()); + if (VDBG) Log.d(TAG, "Tether Mode requested by " + who.toString()); mNotifyList.add(who); transitionTo(mTetherModeAliveState); break; case CMD_TETHER_MODE_UNREQUESTED: who = (TetherInterfaceSM)message.obj; - if (DEBUG) Log.d(TAG, "Tether Mode unrequested by " + who.toString()); + if (VDBG) Log.d(TAG, "Tether Mode unrequested by " + who.toString()); int index = mNotifyList.indexOf(who); if (index != -1) { mNotifyList.remove(who); @@ -1339,7 +1340,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub { } @Override public boolean processMessage(Message message) { - if (DEBUG) Log.d(TAG, "TetherModeAliveState.processMessage what=" + message.what); + if (VDBG) Log.d(TAG, "TetherModeAliveState.processMessage what=" + message.what); boolean retValue = true; switch (message.what) { case CMD_TETHER_MODE_REQUESTED: @@ -1368,7 +1369,7 @@ public class Tethering extends INetworkManagementEventObserver.Stub { // make sure we're still using a requested connection - may have found // wifi or something since then. if (mCurrentConnectionSequence == message.arg1) { - if (DEBUG) { + if (VDBG) { Log.d(TAG, "renewing mobile connection - requeuing for another " + CELL_CONNECTION_RENEW_MS + "ms"); } |