From c1c49c024f990bf54b2a7d16fdf5110263693aea Mon Sep 17 00:00:00 2001 From: Dan Egnor Date: Fri, 30 Oct 2009 17:35:39 -0700 Subject: [PATCH 1/9] Use setRepeating() rather than setInexactRepeating() for backup scheduling, and add some random fuzz to the scheduling times, to make sure we aren't creating hour-aligned server load spikes. See bug 2226553 for details & Dr. No information. --- .../com/android/server/BackupManagerService.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java index 82a7c1c6d90ec..754e6e578b538 100644 --- a/services/java/com/android/server/BackupManagerService.java +++ b/services/java/com/android/server/BackupManagerService.java @@ -76,6 +76,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Random; class BackupManagerService extends IBackupManager.Stub { private static final String TAG = "BackupManagerService"; @@ -85,6 +86,9 @@ class BackupManagerService extends IBackupManager.Stub { // trigger an immediate pass. private static final long BACKUP_INTERVAL = AlarmManager.INTERVAL_HOUR; + // Random variation in backup scheduling time to avoid server load spikes + private static final int FUZZ_MILLIS = 5 * 60 * 1000; + // The amount of time between the initial provisioning of the device and // the first backup pass. private static final long FIRST_BACKUP_INTERVAL = 12 * AlarmManager.INTERVAL_HOUR; @@ -1949,9 +1953,15 @@ class BackupManagerService extends IBackupManager.Stub { } private void startBackupAlarmsLocked(long delayBeforeFirstBackup) { - long when = System.currentTimeMillis() + delayBeforeFirstBackup; - mAlarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, when, - BACKUP_INTERVAL, mRunBackupIntent); + // We used to use setInexactRepeating(), but that may be linked to + // backups running at :00 more often than not, creating load spikes. + // Schedule at an exact time for now, and also add a bit of "fuzz". + + Random random = new Random(); + long when = System.currentTimeMillis() + delayBeforeFirstBackup + + random.nextInt(FUZZ_MILLIS); + mAlarmManager.setRepeating(AlarmManager.RTC_WAKEUP, when, + BACKUP_INTERVAL + random.nextInt(FUZZ_MILLIS), mRunBackupIntent); mNextBackupPass = when; } From 553399518f39cd9f31f2bb6f502866c3c9d6d1a5 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Sun, 1 Nov 2009 21:16:59 -0800 Subject: [PATCH 2/9] Fix issue #2226370: Resource versions match with equality Also fixed turned-around increment of version number for resources. :( Change-Id: I604137272da984bcd69cee4f174e6b7f2c786e46 --- core/java/android/content/res/Resources.java | 2 +- include/utils/ResourceTypes.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java index 00ab7de101783..1c0ed3671d37d 100644 --- a/core/java/android/content/res/Resources.java +++ b/core/java/android/content/res/Resources.java @@ -54,7 +54,7 @@ public class Resources { // Use the current SDK version code. If we are a development build, // also allow the previous SDK version + 1. private static final int sSdkVersion = Build.VERSION.SDK_INT - + ("REL".equals(Build.VERSION.CODENAME) ? 1 : 0); + + ("REL".equals(Build.VERSION.CODENAME) ? 0 : 1); private static final Object mSync = new Object(); private static Resources mSystem = null; diff --git a/include/utils/ResourceTypes.h b/include/utils/ResourceTypes.h index 17ccad6f987b1..49145e8efd53b 100644 --- a/include/utils/ResourceTypes.h +++ b/include/utils/ResourceTypes.h @@ -1272,7 +1272,7 @@ struct ResTable_config if (version || o.version) { if ((sdkVersion != o.sdkVersion) && requested->sdkVersion) { - return (sdkVersion); + return (sdkVersion > o.sdkVersion); } if ((minorVersion != o.minorVersion) && @@ -1384,7 +1384,7 @@ struct ResTable_config } if (version != 0) { if (settings.sdkVersion != 0 && sdkVersion != 0 - && sdkVersion != settings.sdkVersion) { + && sdkVersion > settings.sdkVersion) { return false; } if (settings.minorVersion != 0 && minorVersion != 0 From 0bca68cfff161abbc992fec82dc7c88079dd1a36 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Fri, 30 Oct 2009 11:09:39 -0700 Subject: [PATCH 3/9] Fix issue 197683: English IME key-press latency is noticeably higher on passion than sholes. Part 2. Reduce sleep time in AudioFlinger mixer thread when no data has been written to output to speed up startup time when exiting standby. The rest of the modifications for this issues is in kernel driver: commit 0dbb0ee136ed8de757df1ae26d84556c1751deae for buffer size modification from 8192 to 4800 bytes. Another kernel improvement that is not submitted yes will reduce delay when audio output is exiting standby. --- libs/audioflinger/AudioFlinger.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libs/audioflinger/AudioFlinger.cpp b/libs/audioflinger/AudioFlinger.cpp index 0960c81e108ea..9c0c8508606ba 100644 --- a/libs/audioflinger/AudioFlinger.cpp +++ b/libs/audioflinger/AudioFlinger.cpp @@ -1162,7 +1162,7 @@ AudioFlinger::MixerThread::~MixerThread() bool AudioFlinger::MixerThread::threadLoop() { - uint32_t sleepTime = 0; + uint32_t sleepTime = 1000; uint32_t maxBufferRecoveryInUsecs = getMaxBufferRecoveryInUsecs(); int16_t* curBuf = mMixBuffer; Vector< sp > tracksToRemove; @@ -1224,6 +1224,7 @@ bool AudioFlinger::MixerThread::threadLoop() } standbyTime = systemTime() + kStandbyTimeInNsecs; + sleepTime = 1000; continue; } } @@ -1591,7 +1592,7 @@ AudioFlinger::DirectOutputThread::~DirectOutputThread() bool AudioFlinger::DirectOutputThread::threadLoop() { - uint32_t sleepTime = 0; + uint32_t sleepTime = 1000; uint32_t maxBufferRecoveryInUsecs = getMaxBufferRecoveryInUsecs(); sp trackToRemove; sp activeTrack; @@ -1643,6 +1644,7 @@ bool AudioFlinger::DirectOutputThread::threadLoop() } standbyTime = systemTime() + kStandbyTimeInNsecs; + sleepTime = 1000; continue; } } @@ -1879,7 +1881,7 @@ AudioFlinger::DuplicatingThread::~DuplicatingThread() bool AudioFlinger::DuplicatingThread::threadLoop() { - uint32_t sleepTime = 0; + uint32_t sleepTime = 1000; uint32_t maxBufferRecoveryInUsecs = getMaxBufferRecoveryInUsecs(); int16_t* curBuf = mMixBuffer; Vector< sp > tracksToRemove; @@ -1940,6 +1942,7 @@ bool AudioFlinger::DuplicatingThread::threadLoop() } standbyTime = systemTime() + kStandbyTimeInNsecs; + sleepTime = 1000; continue; } } From f1d14f6a33bc6086db52a77b6a1217452b7eac90 Mon Sep 17 00:00:00 2001 From: Mike Lockwood Date: Mon, 2 Nov 2009 11:56:04 -0500 Subject: [PATCH 4/9] Do not advance mLastEventTime when enabling or disabling user activity. Fixes a race condition between the keyguard and power key that sometimes resulted in the power key failing to turn off the screen. Fixes bug b/2212852 (Power button does not put phone to sleep) Change-Id: I92498c5fddf2bfc32b105ea1a7ea14a06d83888e Signed-off-by: Mike Lockwood --- services/java/com/android/server/PowerManagerService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java index 190ba5e075075..f68bcbbcb7346 100644 --- a/services/java/com/android/server/PowerManagerService.java +++ b/services/java/com/android/server/PowerManagerService.java @@ -2079,7 +2079,6 @@ class PowerManagerService extends IPowerManager.Stub public void enableUserActivity(boolean enabled) { synchronized (mLocks) { mUserActivityAllowed = enabled; - mLastEventTime = SystemClock.uptimeMillis(); // we might need to pass this in } } From f22a0975c442f1f216f16db3ddb27015d72c6532 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Mon, 2 Nov 2009 05:31:33 -0800 Subject: [PATCH 5/9] Fix 2194140: [Passion] Support Audience chip. Added new input device DEVICE_IN_BACK_MIC. Added new audio source AUDIO_SOURCE_CAMCORDER. --- include/media/AudioSystem.h | 3 ++- include/media/mediarecorder.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h index a7c8a0a7bd2f1..e0661778c3e3e 100644 --- a/include/media/AudioSystem.h +++ b/include/media/AudioSystem.h @@ -257,11 +257,12 @@ public: DEVICE_IN_WIRED_HEADSET = 0x100000, DEVICE_IN_AUX_DIGITAL = 0x200000, DEVICE_IN_VOICE_CALL = 0x400000, + DEVICE_IN_BACK_MIC = 0x800000, DEVICE_IN_DEFAULT = 0x80000000, DEVICE_IN_ALL = (DEVICE_IN_COMMUNICATION | DEVICE_IN_AMBIENT | DEVICE_IN_BUILTIN_MIC | DEVICE_IN_BLUETOOTH_SCO_HEADSET | DEVICE_IN_WIRED_HEADSET | DEVICE_IN_AUX_DIGITAL | - DEVICE_IN_VOICE_CALL| DEVICE_IN_DEFAULT) + DEVICE_IN_VOICE_CALL | DEVICE_IN_BACK_MIC | DEVICE_IN_DEFAULT) }; // device connection states used for setDeviceConnectionState() diff --git a/include/media/mediarecorder.h b/include/media/mediarecorder.h index 13316a9339d30..d8ab63d6092f4 100644 --- a/include/media/mediarecorder.h +++ b/include/media/mediarecorder.h @@ -41,7 +41,8 @@ enum audio_source { AUDIO_SOURCE_VOICE_UPLINK = 2, AUDIO_SOURCE_VOICE_DOWNLINK = 3, AUDIO_SOURCE_VOICE_CALL = 4, - AUDIO_SOURCE_MAX = AUDIO_SOURCE_VOICE_CALL, + AUDIO_SOURCE_CAMCORDER = 5, + AUDIO_SOURCE_MAX = AUDIO_SOURCE_CAMCORDER, AUDIO_SOURCE_LIST_END // must be last - used to validate audio source type }; From 952211b4ae8fa8cd626ae5a077b87924f35e0081 Mon Sep 17 00:00:00 2001 From: Mike Lockwood Date: Mon, 2 Nov 2009 14:17:57 -0500 Subject: [PATCH 6/9] Fix problem with proximity sensor not reawaking screen if the values change too quickly. The logic that disables user activity while turning off the screen should not affect proximity sensor. Fixes bug b/2228734 (in-call, prox sensor gets confused) Change-Id: Ieca126e6f79bf7baa5741981aea72d306ba03edc Signed-off-by: Mike Lockwood --- services/java/com/android/server/PowerManagerService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java index f68bcbbcb7346..8a7c28fc1fc17 100644 --- a/services/java/com/android/server/PowerManagerService.java +++ b/services/java/com/android/server/PowerManagerService.java @@ -1803,6 +1803,8 @@ class PowerManagerService extends IPowerManager.Stub } private void forceUserActivityLocked() { + // cancel animation so userActivity will succeed + mScreenBrightness.animating = false; boolean savedActivityAllowed = mUserActivityAllowed; mUserActivityAllowed = true; userActivity(SystemClock.uptimeMillis(), false); From 0d7dc3b800d0489c43ad9071615b2b4ebec80443 Mon Sep 17 00:00:00 2001 From: Joe Onorato Date: Mon, 2 Nov 2009 16:20:44 -0500 Subject: [PATCH 7/9] Fix notification bar performance. Bug 2195678 We had all this stuff there to keep the notification view around so it doesn't need to be reconstructed each time, and we weren't using it. This fixes that, and it looks much better now. --- .../android/server/status/StatusBarService.java | 14 +++++++++----- .../android/server/status/TrackingPatternView.java | 2 -- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/services/java/com/android/server/status/StatusBarService.java b/services/java/com/android/server/status/StatusBarService.java index 59e9832c18fe6..8dded1a8a6e84 100644 --- a/services/java/com/android/server/status/StatusBarService.java +++ b/services/java/com/android/server/status/StatusBarService.java @@ -950,7 +950,8 @@ public class StatusBarService extends IStatusBar.Stub panelSlightlyVisible(true); updateExpandedViewPos(EXPANDED_LEAVE_ALONE); - mExpandedDialog.show(); + mExpandedParams.flags &= ~WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; + mExpandedDialog.getWindow().setAttributes(mExpandedParams); mExpandedView.requestFocus(View.FOCUS_FORWARD); mTrackingView.setVisibility(View.VISIBLE); @@ -1027,7 +1028,8 @@ public class StatusBarService extends IStatusBar.Stub } mExpandedVisible = false; panelSlightlyVisible(false); - mExpandedDialog.hide(); + mExpandedParams.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; + mExpandedDialog.getWindow().setAttributes(mExpandedParams); mTrackingView.setVisibility(View.GONE); if ((mDisabled & StatusBarManager.DISABLE_NOTIFICATION_ICONS) == 0) { @@ -1056,6 +1058,7 @@ public class StatusBarService extends IStatusBar.Stub else if (mAnimY < mStatusBarView.getHeight()) { if (SPEW) Log.d(TAG, "Animation completed to collapsed state."); mAnimating = false; + updateExpandedViewPos(0); performCollapse(); } else { @@ -1508,17 +1511,19 @@ public class StatusBarService extends IStatusBar.Stub } } + final int disph = mDisplay.getHeight(); lp = mExpandedDialog.getWindow().getAttributes(); lp.width = ViewGroup.LayoutParams.FILL_PARENT; lp.height = ViewGroup.LayoutParams.WRAP_CONTENT; lp.x = 0; - lp.y = 0; + mTrackingPosition = lp.y = -disph; // sufficiently large negative lp.type = WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL; lp.flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM - | WindowManager.LayoutParams.FLAG_DITHER; + | WindowManager.LayoutParams.FLAG_DITHER + | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; lp.format = pixelFormat; lp.gravity = Gravity.TOP | Gravity.FILL_HORIZONTAL; lp.setTitle("StatusBarExpanded"); @@ -1531,7 +1536,6 @@ public class StatusBarService extends IStatusBar.Stub new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); mExpandedDialog.show(); - mExpandedDialog.hide(); FrameLayout hack = (FrameLayout)mExpandedView.getParent(); hack.setForeground(null); } diff --git a/services/java/com/android/server/status/TrackingPatternView.java b/services/java/com/android/server/status/TrackingPatternView.java index 0ae9984cb348c..4cb8eff5043a7 100644 --- a/services/java/com/android/server/status/TrackingPatternView.java +++ b/services/java/com/android/server/status/TrackingPatternView.java @@ -55,8 +55,6 @@ public class TrackingPatternView extends View { final int textureWidth = mTextureWidth; final int textureHeight = mTextureHeight; - Log.d("TrackingPatternView", "width=" + width + " textureWidth=" + textureWidth); - int x = 0; int y; From 758613de2829f92122d3b684733a5fe815e488c1 Mon Sep 17 00:00:00 2001 From: Marco Nelissen Date: Mon, 2 Nov 2009 13:52:11 -0800 Subject: [PATCH 8/9] Make sure the visualization stops immediately when sound stops, instead of continuing for a fraction of a second. --- media/libmediaplayerservice/MediaPlayerService.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp index 9d2c779e70e30..0b75a2bf75f34 100644 --- a/media/libmediaplayerservice/MediaPlayerService.cpp +++ b/media/libmediaplayerservice/MediaPlayerService.cpp @@ -1509,6 +1509,7 @@ void MediaPlayerService::AudioOutput::pause() { LOGV("pause"); if (mTrack) mTrack->pause(); + lastWriteTime = 0; } void MediaPlayerService::AudioOutput::close() From b7a6c4340a35b7cc4ceeeccf6cc01ed82c99a8ba Mon Sep 17 00:00:00 2001 From: Jason Sams Date: Mon, 2 Nov 2009 14:25:10 -0800 Subject: [PATCH 9/9] Fix some leaks. This fixes the major malloc memory leak in allApps. Still tracking some much more minor issues. --- libs/rs/rsAllocation.cpp | 2 ++ libs/rs/rsContext.cpp | 3 +++ libs/rs/rsObjectBase.cpp | 1 + libs/rs/rsSimpleMesh.cpp | 2 ++ libs/rs/rsType.cpp | 1 + 5 files changed, 9 insertions(+) diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp index b7d1297feddf1..2cbfe17d40a9d 100644 --- a/libs/rs/rsAllocation.cpp +++ b/libs/rs/rsAllocation.cpp @@ -52,6 +52,8 @@ Allocation::Allocation(Context *rsc, const Type *type) : ObjectBase(rsc) Allocation::~Allocation() { + free(mPtr); + mPtr = NULL; } void Allocation::setCpuWritable(bool) diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp index eb388af500344..961ec0b2709cb 100644 --- a/libs/rs/rsContext.cpp +++ b/libs/rs/rsContext.cpp @@ -350,6 +350,7 @@ void * Context::threadProc(void *vrsc) rsc->deinitEGL(); pthread_mutex_unlock(&gInitMutex); + rsc->mObjDestroy.mNeedToEmpty = true; rsc->objDestroyOOBRun(); LOGV("RS Thread exited"); return NULL; @@ -421,6 +422,7 @@ Context::~Context() mIO.shutdown(); int status = pthread_join(mThreadId, &res); + mObjDestroy.mNeedToEmpty = true; objDestroyOOBRun(); // Global structure cleanup. @@ -431,6 +433,7 @@ Context::~Context() if (!gThreadTLSKeyCount) { pthread_key_delete(gThreadTLSKey); } + mDev = NULL; } pthread_mutex_unlock(&gInitMutex); diff --git a/libs/rs/rsObjectBase.cpp b/libs/rs/rsObjectBase.cpp index 0008ea47c222b..1b442ba39a7e0 100644 --- a/libs/rs/rsObjectBase.cpp +++ b/libs/rs/rsObjectBase.cpp @@ -39,6 +39,7 @@ ObjectBase::~ObjectBase() rsAssert(!mUserRefCount); rsAssert(!mSysRefCount); remove(); + delete[] mName; } void ObjectBase::dumpLOGV(const char *op) const diff --git a/libs/rs/rsSimpleMesh.cpp b/libs/rs/rsSimpleMesh.cpp index b082fd7db26b9..434a35ffb3b0c 100644 --- a/libs/rs/rsSimpleMesh.cpp +++ b/libs/rs/rsSimpleMesh.cpp @@ -99,6 +99,8 @@ SimpleMeshContext::SimpleMeshContext() SimpleMeshContext::~SimpleMeshContext() { + delete[] mVertexTypes; + delete[] mVertexBuffers; } diff --git a/libs/rs/rsType.cpp b/libs/rs/rsType.cpp index ddaa2f0e14262..0eb41119daab5 100644 --- a/libs/rs/rsType.cpp +++ b/libs/rs/rsType.cpp @@ -57,6 +57,7 @@ TypeState::TypeState() TypeState::~TypeState() { + delete[] mLODs; } size_t Type::getOffsetForFace(uint32_t face) const