summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2009-09-01 19:54:29 -0700
committerDianne Hackborn <hackbod@google.com>2009-09-06 21:15:41 -0700
commita1e989b5755ea171ebe6875994d9174deee4399a (patch)
treefaf1e8694283ece60a86ca2c61aa8c4b78483d7b /services
parent6e4b7d66998b9ec9255767f6070a2f94d83944a5 (diff)
downloadframeworks_base-a1e989b5755ea171ebe6875994d9174deee4399a.zip
frameworks_base-a1e989b5755ea171ebe6875994d9174deee4399a.tar.gz
frameworks_base-a1e989b5755ea171ebe6875994d9174deee4399a.tar.bz2
Fix bug where we wouldn't release remote provider references.
The check for whether the release call is coming from another process was very broken, and just happened to work by chance. It also never worked for apps that had code running in two different processes, with one process using a provider in another of its processes. Also a little cleanup and debugging logs for provider management, and removal of that increasingly annoying log about services being stopped. Change-Id: Ibc298e674db7d35c4b6499fb32e30929a141b670
Diffstat (limited to 'services')
-rw-r--r--services/java/com/android/server/am/ActivityManagerService.java48
1 files changed, 27 insertions, 21 deletions
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 9554a22..badfa30 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -136,6 +136,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
static final boolean DEBUG_SERVICE = localLOGV || false;
static final boolean DEBUG_VISBILITY = localLOGV || false;
static final boolean DEBUG_PROCESSES = localLOGV || false;
+ static final boolean DEBUG_PROVIDER = localLOGV || false;
static final boolean DEBUG_USER_LEAVING = localLOGV || false;
static final boolean DEBUG_RESULTS = localLOGV || false;
static final boolean DEBUG_BACKUP = localLOGV || true;
@@ -7411,9 +7412,13 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
final long origId = Binder.clearCallingIdentity();
- // In this case the provider is a single instance, so we can
+ // In this case the provider instance already exists, so we can
// return it right away.
if (r != null) {
+ if (DEBUG_PROVIDER) Log.v(TAG,
+ "Adding provider requested by "
+ + r.processName + " from process "
+ + cpr.info.processName);
r.conProviders.add(cpr);
cpr.clients.add(r);
} else {
@@ -7471,10 +7476,10 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
return cpr;
}
- if (false) {
- RuntimeException e = new RuntimeException("foo");
- //Log.w(TAG, "LAUNCHING REMOTE PROVIDER (myuid " + r.info.uid
- // + " pruid " + ai.uid + "): " + cpi.className, e);
+ if (DEBUG_PROVIDER) {
+ RuntimeException e = new RuntimeException("here");
+ Log.w(TAG, "LAUNCHING REMOTE PROVIDER (myuid " + r.info.uid
+ + " pruid " + cpr.appInfo.uid + "): " + cpr.info.name, e);
}
// This is single process, and our app is now connecting to it.
@@ -7486,14 +7491,6 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
if (mLaunchingProviders.get(i) == cpr) {
break;
}
- if (false) {
- final ContentProviderRecord rec =
- (ContentProviderRecord)mLaunchingProviders.get(i);
- if (rec.info.name.equals(cpr.info.name)) {
- cpr = rec;
- break;
- }
- }
}
// If the provider is not already being launched, then get it
@@ -7524,6 +7521,10 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
mProvidersByName.put(name, cpr);
if (r != null) {
+ if (DEBUG_PROVIDER) Log.v(TAG,
+ "Adding provider requested by "
+ + r.processName + " from process "
+ + cpr.info.processName);
r.conProviders.add(cpr);
cpr.clients.add(r);
} else {
@@ -7578,8 +7579,9 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
synchronized (this) {
ContentProviderRecord cpr = (ContentProviderRecord)mProvidersByName.get(name);
if(cpr == null) {
- //remove from mProvidersByClass
- if(localLOGV) Log.v(TAG, name+" content provider not found in providers list");
+ // remove from mProvidersByClass
+ if (DEBUG_PROVIDER) Log.v(TAG, name +
+ " provider not found in providers list");
return;
}
final ProcessRecord r = getRecordForAppLocked(caller);
@@ -7589,12 +7591,15 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
" when removing content provider " + name);
}
//update content provider record entry info
- ContentProviderRecord localCpr = (ContentProviderRecord) mProvidersByClass.get(cpr.info.name);
- if(localLOGV) Log.v(TAG, "Removing content provider requested by "+
- r.info.processName+" from process "+localCpr.appInfo.processName);
- if(localCpr.appInfo.processName == r.info.processName) {
+ ContentProviderRecord localCpr = (ContentProviderRecord)
+ mProvidersByClass.get(cpr.info.name);
+ if (DEBUG_PROVIDER) Log.v(TAG, "Removing provider requested by "
+ + r.info.processName + " from process "
+ + localCpr.appInfo.processName);
+ if (localCpr.app == r) {
//should not happen. taken care of as a local provider
- if(localLOGV) Log.v(TAG, "local provider doing nothing Ignoring other names");
+ Log.w(TAG, "removeContentProvider called on local provider: "
+ + cpr.info.name + " in process " + r.processName);
return;
} else {
localCpr.clients.remove(r);
@@ -10511,7 +10516,8 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
r.app.services.remove(r);
if (r.app.thread != null) {
try {
- Log.i(TAG, "Stopping service: " + r.shortName);
+ if (DEBUG_SERVICE) Log.v(TAG,
+ "Stopping service: " + r.shortName);
bumpServiceExecutingLocked(r);
mStoppingServices.add(r);
updateOomAdjLocked(r.app);