Skip to content

Commit e02c88a

Browse files
author
Dianne Hackborn
committed
Work on process management.
Introduce a new concept of "B" services. All running services are classified as either A or B. B services are later in the LRU list. Their oom_adj is after the home app. This allows us to better pick services to kill based on how long they have running, and should reduce the amount that we end up killing the home app. This temporarly turns on a debug log when the oom_adj of a process is changed. Sorry, I know it is noisy. This is needed to try to track down why some processes are being killed. Also add a flag to the SyncManager's service binding to allow the syncing process to be more aggressively killed if it has done UI. This is to address cases we have seen where sync is causing an 80MB gmail process to be kept around, preventing other process from running. Now what will happen is that the syncing process will aggressively be killed by the system, and can then be restarted in a much lighter-weight state. Do a little tweak in the power manager to allow us to still do smooth brightness changes even when the fancy TV off animation is in use. And get rid of a debug log in the window manager that was accidentally left in. Change-Id: I64a8eeaaa1f096bab29c665fbff804c7f1d029e2
1 parent 678ed0c commit e02c88a

File tree

6 files changed

+102
-81
lines changed

6 files changed

+102
-81
lines changed

core/java/android/content/SyncManager.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,8 @@ private void initializeSyncAdapter(Account account, String authority) {
416416
intent.setComponent(syncAdapterInfo.componentName);
417417
if (!mContext.bindService(intent,
418418
new InitializerServiceConnection(account, authority, mContext, mMainHandler),
419-
Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND)) {
419+
Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND
420+
| Context.BIND_ALLOW_OOM_MANAGEMENT)) {
420421
Log.w(TAG, "initializeSyncAdapter: failed to bind to " + intent);
421422
}
422423
}
@@ -971,7 +972,8 @@ boolean bindToSyncAdapter(RegisteredServicesCache.ServiceInfo info) {
971972
mContext, 0, new Intent(Settings.ACTION_SYNC_SETTINGS), 0));
972973
mBound = true;
973974
final boolean bindResult = mContext.bindService(intent, this,
974-
Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND);
975+
Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND
976+
| Context.BIND_ALLOW_OOM_MANAGEMENT);
975977
if (!bindResult) {
976978
mBound = false;
977979
}

services/java/com/android/server/PowerManagerService.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2198,25 +2198,21 @@ private void finishAnimationLocked(boolean more, int curIntValue) {
21982198
}
21992199

22002200
public void run() {
2201-
if (mAnimateScreenLights) {
2202-
synchronized (mLocks) {
2201+
synchronized (mLocks) {
2202+
// we're turning off
2203+
final boolean turningOff = animating && targetValue == Power.BRIGHTNESS_OFF;
2204+
if (mAnimateScreenLights || !turningOff) {
22032205
long now = SystemClock.uptimeMillis();
22042206
boolean more = mScreenBrightness.stepLocked();
22052207
if (more) {
22062208
mScreenOffHandler.postAtTime(this, now+(1000/60));
22072209
}
2208-
}
2209-
} else {
2210-
synchronized (mLocks) {
2211-
// we're turning off
2212-
final boolean animate = animating && targetValue == Power.BRIGHTNESS_OFF;
2213-
if (animate) {
2214-
// It's pretty scary to hold mLocks for this long, and we should
2215-
// redesign this, but it works for now.
2216-
nativeStartSurfaceFlingerAnimation(
2217-
mScreenOffReason == WindowManagerPolicy.OFF_BECAUSE_OF_PROX_SENSOR
2218-
? 0 : mAnimationSetting);
2219-
}
2210+
} else {
2211+
// It's pretty scary to hold mLocks for this long, and we should
2212+
// redesign this, but it works for now.
2213+
nativeStartSurfaceFlingerAnimation(
2214+
mScreenOffReason == WindowManagerPolicy.OFF_BECAUSE_OF_PROX_SENSOR
2215+
? 0 : mAnimationSetting);
22202216
mScreenBrightness.jumpToTargetLocked();
22212217
}
22222218
}

0 commit comments

Comments
 (0)