summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2012-09-09 18:19:50 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-09-09 18:19:50 -0700
commit01a7c79dda60c572af0db5820a66680d0faf95cf (patch)
tree77d3eec6928a22d9c68c6ce976c171d55880f7ae
parent3e6d426d8d28e172af6b62c7b9e4b70c25c5facb (diff)
parent2d1b37819112274f538d1886c379ff337eb0d9ed (diff)
downloadframeworks_base-01a7c79dda60c572af0db5820a66680d0faf95cf.zip
frameworks_base-01a7c79dda60c572af0db5820a66680d0faf95cf.tar.gz
frameworks_base-01a7c79dda60c572af0db5820a66680d0faf95cf.tar.bz2
Merge "Various fixes." into jb-mr1-dev
-rw-r--r--services/java/com/android/server/am/ActiveServices.java8
-rw-r--r--services/java/com/android/server/am/ActivityManagerService.java24
-rw-r--r--services/java/com/android/server/am/ActivityRecord.java6
-rwxr-xr-xservices/java/com/android/server/am/ActivityStack.java65
-rw-r--r--services/java/com/android/server/am/ProviderMap.java60
5 files changed, 94 insertions, 69 deletions
diff --git a/services/java/com/android/server/am/ActiveServices.java b/services/java/com/android/server/am/ActiveServices.java
index 7144808..2975880 100644
--- a/services/java/com/android/server/am/ActiveServices.java
+++ b/services/java/com/android/server/am/ActiveServices.java
@@ -1551,8 +1551,12 @@ public class ActiveServices {
}
}
} else {
- didSomething = collectForceStopServicesLocked(name, userId, evenPersistent,
- doit, mServiceMap.mServicesByNamePerUser.get(userId), services);
+ HashMap<ComponentName, ServiceRecord> items
+ = mServiceMap.mServicesByNamePerUser.get(userId);
+ if (items != null) {
+ didSomething = collectForceStopServicesLocked(name, userId, evenPersistent,
+ doit, items, services);
+ }
}
int N = services.size();
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index ca45946..0b2d769 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -546,7 +546,7 @@ public final class ActivityManagerService extends ActivityManagerNative
*/
final ArrayList mCancelledThumbnails = new ArrayList();
- final ProviderMap mProviderMap = new ProviderMap();
+ final ProviderMap mProviderMap;
/**
* List of content providers who have clients waiting for them. The
@@ -1511,6 +1511,7 @@ public final class ActivityManagerService extends ActivityManagerNative
mBroadcastQueues[1] = mBgBroadcastQueue;
mServices = new ActiveServices(this);
+ mProviderMap = new ProviderMap(this);
File dataDir = Environment.getDataDirectory();
File systemDir = new File(dataDir, "system");
@@ -1792,7 +1793,7 @@ public final class ActivityManagerService extends ActivityManagerNative
// Also don't let it kick out the first few "real" hidden processes.
skipTop = ProcessList.MIN_HIDDEN_APPS;
}
-
+
while (i >= 0) {
ProcessRecord p = mLruProcesses.get(i);
// If this app shouldn't be in front of the first N background
@@ -2680,7 +2681,7 @@ public final class ActivityManagerService extends ActivityManagerNative
}
final long origId = Binder.clearCallingIdentity();
boolean res = mMainStack.requestFinishActivityLocked(token, resultCode,
- resultData, "app-request");
+ resultData, "app-request", true);
Binder.restoreCallingIdentity(origId);
return res;
}
@@ -2710,7 +2711,7 @@ public final class ActivityManagerService extends ActivityManagerNative
int index = mMainStack.indexOfTokenLocked(r.appToken);
if (index >= 0) {
mMainStack.finishActivityLocked(r, index, Activity.RESULT_CANCELED,
- null, "finish-heavy");
+ null, "finish-heavy", true);
}
}
}
@@ -3627,7 +3628,7 @@ public final class ActivityManagerService extends ActivityManagerNative
ActivityRecord r = (ActivityRecord)mMainStack.mHistory.get(i);
if ((r.info.flags&ActivityInfo.FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS) != 0) {
r.stack.finishActivityLocked(r, i,
- Activity.RESULT_CANCELED, null, "close-sys");
+ Activity.RESULT_CANCELED, null, "close-sys", true);
}
}
@@ -6972,7 +6973,7 @@ public final class ActivityManagerService extends ActivityManagerNative
if (count > 1) {
final long origId = Binder.clearCallingIdentity();
mMainStack.finishActivityLocked((ActivityRecord)mMainStack.mHistory.get(count-1),
- count-1, Activity.RESULT_CANCELED, null, "unhandled-back");
+ count-1, Activity.RESULT_CANCELED, null, "unhandled-back", true);
Binder.restoreCallingIdentity(origId);
}
}
@@ -7891,7 +7892,8 @@ public final class ActivityManagerService extends ActivityManagerNative
if (r.app == app) {
Slog.w(TAG, " Force finishing activity "
+ r.intent.getComponent().flattenToShortString());
- r.stack.finishActivityLocked(r, i, Activity.RESULT_CANCELED, null, "crashed");
+ r.stack.finishActivityLocked(r, i, Activity.RESULT_CANCELED,
+ null, "crashed", false);
}
}
if (!app.persistent) {
@@ -7926,7 +7928,7 @@ public final class ActivityManagerService extends ActivityManagerNative
+ r.intent.getComponent().flattenToShortString());
int index = mMainStack.indexOfActivityLocked(r);
r.stack.finishActivityLocked(r, index,
- Activity.RESULT_CANCELED, null, "crashed");
+ Activity.RESULT_CANCELED, null, "crashed", false);
// Also terminate any activities below it that aren't yet
// stopped, to avoid a situation where one will get
// re-start our crashing activity once it gets resumed again.
@@ -7940,7 +7942,7 @@ public final class ActivityManagerService extends ActivityManagerNative
Slog.w(TAG, " Force finishing activity "
+ r.intent.getComponent().flattenToShortString());
r.stack.finishActivityLocked(r, index,
- Activity.RESULT_CANCELED, null, "crashed");
+ Activity.RESULT_CANCELED, null, "crashed", false);
}
}
}
@@ -12305,7 +12307,7 @@ public final class ActivityManagerService extends ActivityManagerNative
for (int i = start; i > finishTo; i--) {
ActivityRecord r = history.get(i);
mMainStack.requestFinishActivityLocked(r.appToken, resultCode, resultData,
- "navigate-up");
+ "navigate-up", true);
// Only return the supplied result for the first activity finished
resultCode = Activity.RESULT_CANCELED;
resultData = null;
@@ -12331,7 +12333,7 @@ public final class ActivityManagerService extends ActivityManagerNative
foundParentInTask = false;
}
mMainStack.requestFinishActivityLocked(parent.appToken, resultCode,
- resultData, "navigate-up");
+ resultData, "navigate-up", true);
}
}
Binder.restoreCallingIdentity(origId);
diff --git a/services/java/com/android/server/am/ActivityRecord.java b/services/java/com/android/server/am/ActivityRecord.java
index c70650d..009fb5d 100644
--- a/services/java/com/android/server/am/ActivityRecord.java
+++ b/services/java/com/android/server/am/ActivityRecord.java
@@ -333,7 +333,6 @@ final class ActivityRecord {
state = ActivityState.INITIALIZING;
frontOfTask = false;
launchFailed = false;
- haveState = false;
stopped = false;
delayedResume = false;
finishing = false;
@@ -347,6 +346,11 @@ final class ActivityRecord {
idle = false;
hasBeenLaunched = false;
+ // This starts out true, since the initial state of an activity
+ // is that we have everything, and we shouldn't never consider it
+ // lacking in state to be removed if it dies.
+ haveState = true;
+
if (aInfo != null) {
if (aInfo.targetActivity == null
|| aInfo.launchMode == ActivityInfo.LAUNCH_MULTIPLE
diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java
index 895b52a..bc835b6 100755
--- a/services/java/com/android/server/am/ActivityStack.java
+++ b/services/java/com/android/server/am/ActivityStack.java
@@ -725,7 +725,7 @@ final class ActivityStack {
+ ", giving up", e);
mService.appDiedLocked(app, app.pid, app.thread);
requestFinishActivityLocked(r.appToken, Activity.RESULT_CANCELED, null,
- "2nd-crash");
+ "2nd-crash", false);
return false;
}
@@ -1092,7 +1092,7 @@ final class ActivityStack {
if (prev != null) {
if (prev.finishing) {
if (DEBUG_PAUSE) Slog.v(TAG, "Executing finish of activity: " + prev);
- prev = finishCurrentActivityLocked(prev, FINISH_AFTER_VISIBLE);
+ prev = finishCurrentActivityLocked(prev, FINISH_AFTER_VISIBLE, false);
} else if (prev.app != null) {
if (DEBUG_PAUSE) Slog.v(TAG, "Enqueueing pending stop: " + prev);
if (prev.waitingVisible) {
@@ -1504,7 +1504,7 @@ final class ActivityStack {
Slog.d(TAG, "no-history finish of " + last + " on new resume");
}
requestFinishActivityLocked(last.appToken, Activity.RESULT_CANCELED, null,
- "no-history");
+ "no-history", false);
}
}
@@ -1726,7 +1726,7 @@ final class ActivityStack {
// activity and try the next one.
Slog.w(TAG, "Exception thrown during resume of " + next, e);
requestFinishActivityLocked(next.appToken, Activity.RESULT_CANCELED, null,
- "resume-exception");
+ "resume-exception", true);
return true;
}
@@ -2080,7 +2080,7 @@ final class ActivityStack {
continue;
}
if (finishActivityLocked(p, srcPos,
- Activity.RESULT_CANCELED, null, "reset")) {
+ Activity.RESULT_CANCELED, null, "reset", false)) {
replyChainEnd--;
srcPos--;
}
@@ -2143,7 +2143,7 @@ final class ActivityStack {
continue;
}
if (finishActivityLocked(p, srcPos,
- Activity.RESULT_CANCELED, null, "reset")) {
+ Activity.RESULT_CANCELED, null, "reset", false)) {
taskTopI--;
lastReparentPos--;
replyChainEnd--;
@@ -2200,7 +2200,7 @@ final class ActivityStack {
}
if (p.intent.getComponent().equals(target.intent.getComponent())) {
if (finishActivityLocked(p, j,
- Activity.RESULT_CANCELED, null, "replace")) {
+ Activity.RESULT_CANCELED, null, "replace", false)) {
taskTopI--;
lastReparentPos--;
}
@@ -2270,7 +2270,7 @@ final class ActivityStack {
continue;
}
if (finishActivityLocked(r, i, Activity.RESULT_CANCELED,
- null, "clear")) {
+ null, "clear", false)) {
i--;
}
}
@@ -2284,7 +2284,7 @@ final class ActivityStack {
int index = indexOfTokenLocked(ret.appToken);
if (index >= 0) {
finishActivityLocked(ret, index, Activity.RESULT_CANCELED,
- null, "clear");
+ null, "clear", false);
}
return null;
}
@@ -2313,7 +2313,7 @@ final class ActivityStack {
continue;
}
if (!finishActivityLocked(r, i, Activity.RESULT_CANCELED,
- null, "clear")) {
+ null, "clear", false)) {
i++;
}
}
@@ -2579,6 +2579,7 @@ final class ActivityStack {
mDismissKeyguardOnNextActivity = false;
mService.mWindowManager.dismissKeyguard();
}
+ Slog.i(TAG, "DONE STARTING!");
return err;
}
@@ -3319,7 +3320,7 @@ final class ActivityStack {
Slog.d(TAG, "no-history finish of " + r);
}
requestFinishActivityLocked(r.appToken, Activity.RESULT_CANCELED, null,
- "no-history");
+ "no-history", false);
} else {
if (DEBUG_STATES) Slog.d(TAG, "Not finishing noHistory " + r
+ " on stop because we're just sleeping");
@@ -3531,7 +3532,7 @@ final class ActivityStack {
ActivityRecord r = (ActivityRecord)stops.get(i);
synchronized (mService) {
if (r.finishing) {
- finishCurrentActivityLocked(r, FINISH_IMMEDIATELY);
+ finishCurrentActivityLocked(r, FINISH_IMMEDIATELY, false);
} else {
stopActivityLocked(r);
}
@@ -3585,7 +3586,7 @@ final class ActivityStack {
* some reason it is being left as-is.
*/
final boolean requestFinishActivityLocked(IBinder token, int resultCode,
- Intent resultData, String reason) {
+ Intent resultData, String reason, boolean oomAdj) {
int index = indexOfTokenLocked(token);
if (DEBUG_RESULTS || DEBUG_STATES) Slog.v(
TAG, "Finishing activity @" + index + ": token=" + token
@@ -3596,7 +3597,7 @@ final class ActivityStack {
}
ActivityRecord r = mHistory.get(index);
- finishActivityLocked(r, index, resultCode, resultData, reason);
+ finishActivityLocked(r, index, resultCode, resultData, reason, oomAdj);
return true;
}
@@ -3613,10 +3614,11 @@ final class ActivityStack {
if ((r.resultWho == null && resultWho == null) ||
(r.resultWho != null && r.resultWho.equals(resultWho))) {
finishActivityLocked(r, i,
- Activity.RESULT_CANCELED, null, "request-sub");
+ Activity.RESULT_CANCELED, null, "request-sub", false);
}
}
}
+ mService.updateOomAdjLocked();
}
final boolean finishActivityAffinityLocked(IBinder token) {
@@ -3639,7 +3641,8 @@ final class ActivityStack {
if (cur.taskAffinity != null && !cur.taskAffinity.equals(r.taskAffinity)) {
break;
}
- finishActivityLocked(cur, index, Activity.RESULT_CANCELED, null, "request-affinity");
+ finishActivityLocked(cur, index, Activity.RESULT_CANCELED, null,
+ "request-affinity", true);
index--;
}
return true;
@@ -3677,16 +3680,16 @@ final class ActivityStack {
* list, or false if it is still in the list and will be removed later.
*/
final boolean finishActivityLocked(ActivityRecord r, int index,
- int resultCode, Intent resultData, String reason) {
- return finishActivityLocked(r, index, resultCode, resultData, reason, false);
+ int resultCode, Intent resultData, String reason, boolean oomAdj) {
+ return finishActivityLocked(r, index, resultCode, resultData, reason, false, oomAdj);
}
/**
* @return Returns true if this activity has been removed from the history
* list, or false if it is still in the list and will be removed later.
*/
- final boolean finishActivityLocked(ActivityRecord r, int index,
- int resultCode, Intent resultData, String reason, boolean immediate) {
+ final boolean finishActivityLocked(ActivityRecord r, int index, int resultCode,
+ Intent resultData, String reason, boolean immediate, boolean oomAdj) {
if (r.finishing) {
Slog.w(TAG, "Duplicate finish request for " + r);
return false;
@@ -3730,7 +3733,7 @@ final class ActivityStack {
if (immediate) {
return finishCurrentActivityLocked(r, index,
- FINISH_IMMEDIATELY) == null;
+ FINISH_IMMEDIATELY, oomAdj) == null;
} else if (mResumedActivity == r) {
boolean endTask = index <= 0
|| (mHistory.get(index-1)).task != r.task;
@@ -3754,7 +3757,7 @@ final class ActivityStack {
// it is done pausing; else we can just directly finish it here.
if (DEBUG_PAUSE) Slog.v(TAG, "Finish not pausing: " + r);
return finishCurrentActivityLocked(r, index,
- FINISH_AFTER_PAUSE) == null;
+ FINISH_AFTER_PAUSE, oomAdj) == null;
} else {
if (DEBUG_PAUSE) Slog.v(TAG, "Finish waiting for pause of: " + r);
}
@@ -3767,17 +3770,17 @@ final class ActivityStack {
private static final int FINISH_AFTER_VISIBLE = 2;
private final ActivityRecord finishCurrentActivityLocked(ActivityRecord r,
- int mode) {
+ int mode, boolean oomAdj) {
final int index = indexOfActivityLocked(r);
if (index < 0) {
return null;
}
- return finishCurrentActivityLocked(r, index, mode);
+ return finishCurrentActivityLocked(r, index, mode, oomAdj);
}
private final ActivityRecord finishCurrentActivityLocked(ActivityRecord r,
- int index, int mode) {
+ int index, int mode, boolean oomAdj) {
// First things first: if this activity is currently visible,
// and the resumed activity is not yet visible, then hold off on
// finishing until the resumed one becomes visible.
@@ -3796,7 +3799,9 @@ final class ActivityStack {
if (DEBUG_STATES) Slog.v(TAG, "Moving to STOPPING: " + r
+ " (finish requested)");
r.state = ActivityState.STOPPING;
- mService.updateOomAdjLocked();
+ if (oomAdj) {
+ mService.updateOomAdjLocked();
+ }
return r;
}
@@ -3816,7 +3821,8 @@ final class ActivityStack {
|| prevState == ActivityState.INITIALIZING) {
// If this activity is already stopped, we can just finish
// it right now.
- boolean activityRemoved = destroyActivityLocked(r, true, true, "finish-imm");
+ boolean activityRemoved = destroyActivityLocked(r, true,
+ oomAdj, "finish-imm");
if (activityRemoved) {
resumeTopActivityLocked(null);
}
@@ -4008,9 +4014,8 @@ final class ActivityStack {
ActivityManagerService.CANCEL_HEAVY_NOTIFICATION_MSG);
}
if (r.app.activities.size() == 0) {
- // No longer have activities, so update location in
- // LRU list.
- mService.updateLruProcessLocked(r.app, oomAdj, false);
+ // No longer have activities, so update oom adj.
+ mService.updateOomAdjLocked();
}
}
diff --git a/services/java/com/android/server/am/ProviderMap.java b/services/java/com/android/server/am/ProviderMap.java
index 2d7167b..9dbf5f5 100644
--- a/services/java/com/android/server/am/ProviderMap.java
+++ b/services/java/com/android/server/am/ProviderMap.java
@@ -18,7 +18,6 @@ package com.android.server.am;
import android.content.ComponentName;
import android.os.Binder;
-import android.os.Process;
import android.os.RemoteException;
import android.os.UserHandle;
import android.util.Slog;
@@ -31,8 +30,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
/**
* Keeps track of content providers by authority (name) and class. It separates the mapping by
@@ -44,6 +41,8 @@ public class ProviderMap {
private static final boolean DBG = false;
+ private final ActivityManagerService mAm;
+
private final HashMap<String, ContentProviderRecord> mSingletonByName
= new HashMap<String, ContentProviderRecord>();
private final HashMap<ComponentName, ContentProviderRecord> mSingletonByClass
@@ -54,6 +53,10 @@ public class ProviderMap {
private final SparseArray<HashMap<ComponentName, ContentProviderRecord>> mProvidersByClassPerUser
= new SparseArray<HashMap<ComponentName, ContentProviderRecord>>();
+ ProviderMap(ActivityManagerService am) {
+ mAm = am;
+ }
+
ContentProviderRecord getProviderByName(String name) {
return getProviderByName(name, -1);
}
@@ -217,8 +220,12 @@ public class ProviderMap {
}
}
} else {
- didSomething |= collectForceStopProvidersLocked(name, appId, doit, evenPersistent,
- userId, getProvidersByClass(userId), result);
+ HashMap<ComponentName, ContentProviderRecord> items
+ = getProvidersByClass(userId);
+ if (items != null) {
+ didSomething |= collectForceStopProvidersLocked(name, appId, doit,
+ evenPersistent, userId, items, result);
+ }
}
return didSomething;
}
@@ -279,30 +286,33 @@ public class ProviderMap {
protected boolean dumpProvider(FileDescriptor fd, PrintWriter pw, String name, String[] args,
int opti, boolean dumpAll) {
+ ArrayList<ContentProviderRecord> allProviders = new ArrayList<ContentProviderRecord>();
ArrayList<ContentProviderRecord> providers = new ArrayList<ContentProviderRecord>();
- if ("all".equals(name)) {
- synchronized (this) {
- for (ContentProviderRecord r1 : getProvidersByClass(-1).values()) {
- providers.add(r1);
- }
+ synchronized (mAm) {
+ allProviders.addAll(mSingletonByClass.values());
+ for (int i=0; i<mProvidersByClassPerUser.size(); i++) {
+ allProviders.addAll(mProvidersByClassPerUser.valueAt(i).values());
}
- } else {
- ComponentName componentName = name != null
- ? ComponentName.unflattenFromString(name) : null;
- int objectId = 0;
- if (componentName == null) {
- // Not a '/' separated full component name; maybe an object ID?
- try {
- objectId = Integer.parseInt(name, 16);
- name = null;
- componentName = null;
- } catch (RuntimeException e) {
+
+ if ("all".equals(name)) {
+ providers.addAll(allProviders);
+ } else {
+ ComponentName componentName = name != null
+ ? ComponentName.unflattenFromString(name) : null;
+ int objectId = 0;
+ if (componentName == null) {
+ // Not a '/' separated full component name; maybe an object ID?
+ try {
+ objectId = Integer.parseInt(name, 16);
+ name = null;
+ componentName = null;
+ } catch (RuntimeException e) {
+ }
}
- }
- synchronized (this) {
- for (ContentProviderRecord r1 : getProvidersByClass(-1).values()) {
+ for (int i=0; i<allProviders.size(); i++) {
+ ContentProviderRecord r1 = allProviders.get(i);
if (componentName != null) {
if (r1.name.equals(componentName)) {
providers.add(r1);
@@ -340,7 +350,7 @@ public class ProviderMap {
private void dumpProvider(String prefix, FileDescriptor fd, PrintWriter pw,
final ContentProviderRecord r, String[] args, boolean dumpAll) {
String innerPrefix = prefix + " ";
- synchronized (this) {
+ synchronized (mAm) {
pw.print(prefix); pw.print("PROVIDER ");
pw.print(r);
pw.print(" pid=");