Skip to content

Commit 2a6bcda

Browse files
author
Dianne Hackborn
committed
Fix issue #5253941: ICS ignoring provider's android:process flag
Provider was not being removed from the class map because it was using the wrong key. D'oh. Also a little cleanup. Change-Id: I318e8b1a265318ac1474e0a7f14f27f89f357505
1 parent a80599f commit 2a6bcda

2 files changed

Lines changed: 41 additions & 23 deletions

File tree

services/java/com/android/server/am/ActivityManagerService.java

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,8 +1631,8 @@ private final void updateLruProcessInternalLocked(ProcessRecord app,
16311631
}
16321632
if (app.conProviders.size() > 0) {
16331633
for (ContentProviderRecord cpr : app.conProviders.keySet()) {
1634-
if (cpr.app != null && cpr.app.lruSeq != mLruSeq) {
1635-
updateLruProcessInternalLocked(cpr.app, oomAdj,
1634+
if (cpr.proc != null && cpr.proc.lruSeq != mLruSeq) {
1635+
updateLruProcessInternalLocked(cpr.proc, oomAdj,
16361636
updateActivityTime, i+1);
16371637
}
16381638
}
@@ -3373,7 +3373,24 @@ private final boolean forceStopPackageLocked(String name, int uid,
33733373
for (i=0; i<N; i++) {
33743374
bringDownServiceLocked(services.get(i), true);
33753375
}
3376-
3376+
3377+
ArrayList<ContentProviderRecord> providers = new ArrayList<ContentProviderRecord>();
3378+
for (ContentProviderRecord provider : mProvidersByClass.values()) {
3379+
if (provider.info.packageName.equals(name)
3380+
&& (provider.proc == null || evenPersistent || !provider.proc.persistent)) {
3381+
if (!doit) {
3382+
return true;
3383+
}
3384+
didSomething = true;
3385+
providers.add(provider);
3386+
}
3387+
}
3388+
3389+
N = providers.size();
3390+
for (i=0; i<N; i++) {
3391+
removeDyingProviderLocked(null, providers.get(i));
3392+
}
3393+
33773394
if (doit) {
33783395
if (purgeCache) {
33793396
AttributeCache ac = AttributeCache.instance();
@@ -5485,7 +5502,7 @@ private final List<ProviderInfo> generateApplicationProvidersLocked(ProcessRecor
54855502
ComponentName comp = new ComponentName(cpi.packageName, cpi.name);
54865503
ContentProviderRecord cpr = mProvidersByClass.get(comp);
54875504
if (cpr == null) {
5488-
cpr = new ContentProviderRecord(cpi, app.info);
5505+
cpr = new ContentProviderRecord(cpi, app.info, comp);
54895506
mProvidersByClass.put(comp, cpr);
54905507
}
54915508
app.pubProviders.put(cpi.name, cpr);
@@ -5643,25 +5660,25 @@ private final ContentProviderHolder getContentProviderImpl(
56435660
// return it right away.
56445661
final boolean countChanged = incProviderCount(r, cpr);
56455662
if (countChanged) {
5646-
if (cpr.app != null && r.setAdj <= ProcessList.PERCEPTIBLE_APP_ADJ) {
5663+
if (cpr.proc != null && r.setAdj <= ProcessList.PERCEPTIBLE_APP_ADJ) {
56475664
// If this is a perceptible app accessing the provider,
56485665
// make sure to count it as being accessed and thus
56495666
// back up on the LRU list. This is good because
56505667
// content providers are often expensive to start.
5651-
updateLruProcessLocked(cpr.app, false, true);
5668+
updateLruProcessLocked(cpr.proc, false, true);
56525669
}
56535670
}
56545671

5655-
if (cpr.app != null) {
5672+
if (cpr.proc != null) {
56565673
if (false) {
56575674
if (cpr.name.flattenToShortString().equals(
56585675
"com.android.providers.calendar/.CalendarProvider2")) {
56595676
Slog.v(TAG, "****************** KILLING "
56605677
+ cpr.name.flattenToShortString());
5661-
Process.killProcess(cpr.app.pid);
5678+
Process.killProcess(cpr.proc.pid);
56625679
}
56635680
}
5664-
boolean success = updateOomAdjLocked(cpr.app);
5681+
boolean success = updateOomAdjLocked(cpr.proc);
56655682
if (DEBUG_PROVIDER) Slog.i(TAG, "Adjust success: " + success);
56665683
// NOTE: there is still a race here where a signal could be
56675684
// pending on the process even though we managed to update its
@@ -5676,7 +5693,7 @@ private final ContentProviderHolder getContentProviderImpl(
56765693
"Existing provider " + cpr.name.flattenToShortString()
56775694
+ " is crashing; detaching " + r);
56785695
boolean lastRef = decProviderCount(r, cpr);
5679-
appDiedLocked(cpr.app, cpr.app.pid, cpr.app.thread);
5696+
appDiedLocked(cpr.proc, cpr.proc.pid, cpr.proc.thread);
56805697
if (!lastRef) {
56815698
// This wasn't the last ref our process had on
56825699
// the provider... we have now been killed, bail.
@@ -5729,7 +5746,7 @@ private final ContentProviderHolder getContentProviderImpl(
57295746
+ cpi.name);
57305747
return null;
57315748
}
5732-
cpr = new ContentProviderRecord(cpi, ai);
5749+
cpr = new ContentProviderRecord(cpi, ai, comp);
57335750
} catch (RemoteException ex) {
57345751
// pm is in same process, this will never happen.
57355752
}
@@ -5864,7 +5881,7 @@ public void removeContentProvider(IApplicationThread caller, String name) {
58645881
//update content provider record entry info
58655882
ComponentName comp = new ComponentName(cpr.info.packageName, cpr.info.name);
58665883
ContentProviderRecord localCpr = mProvidersByClass.get(comp);
5867-
if (localCpr.app == r) {
5884+
if (localCpr.proc == r) {
58685885
//should not happen. taken care of as a local provider
58695886
Slog.w(TAG, "removeContentProvider called on local provider: "
58705887
+ cpr.info.name + " in process " + r.processName);
@@ -5940,7 +5957,7 @@ public final void publishContentProviders(IApplicationThread caller,
59405957
}
59415958
synchronized (dst) {
59425959
dst.provider = src.provider;
5943-
dst.app = r;
5960+
dst.proc = r;
59445961
dst.notifyAll();
59455962
}
59465963
updateOomAdjLocked(r);
@@ -8706,9 +8723,9 @@ boolean dumpProvidersLocked(FileDescriptor fd, PrintWriter pw, String[] args,
87068723
r.dump(pw, " ");
87078724
} else {
87088725
pw.print(" * "); pw.print(e.getKey().flattenToShortString());
8709-
if (r.app != null) {
8726+
if (r.proc != null) {
87108727
pw.println(":");
8711-
pw.print(" "); pw.println(r.app);
8728+
pw.print(" "); pw.println(r.proc);
87128729
} else {
87138730
pw.println();
87148731
}
@@ -9440,7 +9457,7 @@ private final void removeDyingProviderLocked(ProcessRecord proc,
94409457
cpr.notifyAll();
94419458
}
94429459

9443-
mProvidersByClass.remove(cpr.info.name);
9460+
mProvidersByClass.remove(cpr.name);
94449461
String names[] = cpr.info.authority.split(";");
94459462
for (int j = 0; j < names.length; j++) {
94469463
mProvidersByName.remove(names[j]);
@@ -9454,9 +9471,10 @@ private final void removeDyingProviderLocked(ProcessRecord proc,
94549471
&& capp.pid != MY_PID) {
94559472
Slog.i(TAG, "Kill " + capp.processName
94569473
+ " (pid " + capp.pid + "): provider " + cpr.info.name
9457-
+ " in dying process " + proc.processName);
9474+
+ " in dying process " + (proc != null ? proc.processName : "??"));
94589475
EventLog.writeEvent(EventLogTags.AM_KILL, capp.pid,
9459-
capp.processName, capp.setAdj, "dying provider " + proc.processName);
9476+
capp.processName, capp.setAdj, "dying provider "
9477+
+ cpr.name.toShortString());
94609478
Process.killProcessQuiet(capp.pid);
94619479
}
94629480
}
@@ -9515,7 +9533,7 @@ private final void cleanUpApplicationRecordLocked(ProcessRecord app,
95159533
while (it.hasNext()) {
95169534
ContentProviderRecord cpr = it.next();
95179535
cpr.provider = null;
9518-
cpr.app = null;
9536+
cpr.proc = null;
95199537

95209538
// See if someone is waiting for this provider... in which
95219539
// case we don't remove it, but just let it restart.

services/java/com/android/server/am/ContentProviderRecord.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ class ContentProviderRecord extends ContentProviderHolder {
3232
final ApplicationInfo appInfo;
3333
final ComponentName name;
3434
int externals; // number of non-framework processes supported by this provider
35-
ProcessRecord app; // if non-null, hosting application
35+
ProcessRecord proc; // if non-null, hosting process.
3636
ProcessRecord launchingApp; // if non-null, waiting for this app to be launched.
3737
String stringName;
3838

39-
public ContentProviderRecord(ProviderInfo _info, ApplicationInfo ai) {
39+
public ContentProviderRecord(ProviderInfo _info, ApplicationInfo ai, ComponentName _name) {
4040
super(_info);
4141
uid = ai.uid;
4242
appInfo = ai;
43-
name = new ComponentName(_info.packageName, _info.name);
43+
name = _name;
4444
noReleaseNeeded = uid == 0 || uid == Process.SYSTEM_UID;
4545
}
4646

@@ -61,7 +61,7 @@ void dump(PrintWriter pw, String prefix) {
6161
pw.print(prefix); pw.print("package=");
6262
pw.print(info.applicationInfo.packageName);
6363
pw.print(" process="); pw.println(info.processName);
64-
pw.print(prefix); pw.print("app="); pw.println(app);
64+
pw.print(prefix); pw.print("proc="); pw.println(proc);
6565
if (launchingApp != null) {
6666
pw.print(prefix); pw.print("launchingApp="); pw.println(launchingApp);
6767
}

0 commit comments

Comments
 (0)